2012-06-11 02:17:30 +04:00
|
|
|
/*
|
|
|
|
* Copyright 2012 Vincent Sanders <vince@netsurf-browser.org>
|
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** \file
|
2012-10-26 15:36:14 +04:00
|
|
|
* spidermonkey jsapi compatability glue.
|
2012-06-11 02:17:30 +04:00
|
|
|
*/
|
|
|
|
|
2012-06-19 13:35:51 +04:00
|
|
|
#ifndef _NETSURF_JAVASCRIPT_JSAPI_H_
|
|
|
|
#define _NETSURF_JAVASCRIPT_JSAPI_H_
|
2012-06-11 02:17:30 +04:00
|
|
|
|
2012-06-28 03:17:18 +04:00
|
|
|
#ifdef WITH_MOZJS
|
|
|
|
#include "js/jsapi.h"
|
|
|
|
#else
|
|
|
|
#include "mozjs/jsapi.h"
|
|
|
|
#endif
|
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
#if JS_VERSION < 180
|
|
|
|
|
|
|
|
/************************** Spidermonkey 1.7.0 **************************/
|
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-11-08 05:02:14 +04:00
|
|
|
# ifndef JSVERSION_LATEST
|
|
|
|
# define JSVERSION_LATEST JS_VERSION
|
|
|
|
# endif
|
2012-11-08 04:40:21 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* *CAUTION* these native function macros introduce and use jsapi_this
|
|
|
|
* and jsapi_rval variables, native function code should not conflict
|
|
|
|
* with these
|
|
|
|
*/
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native function definition with five parameters */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC(name, cx, argc, vp) \
|
|
|
|
jsapi_func_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
|
2012-11-17 15:19:31 +04:00
|
|
|
|
2012-11-22 18:00:13 +04:00
|
|
|
/* native function return value - No macro available */
|
|
|
|
#define JSAPI_FUNC_RVAL(cx, vp) (jsapi_rval)
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-22 18:00:13 +04:00
|
|
|
/* native function return value setter - No macro available */
|
|
|
|
#define JSAPI_FUNC_SET_RVAL(cx, vp, v) (*jsapi_rval = (v))
|
2012-11-08 04:40:21 +04:00
|
|
|
|
|
|
|
/* arguments */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC_ARGV(cx, vp) (vp)
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-08 21:22:29 +04:00
|
|
|
/* check if a jsval is an object */
|
|
|
|
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native function specifier with five parameters and no JS_FS macro */
|
|
|
|
#define JSAPI_FS(name, nargs, flags) \
|
2012-11-22 18:00:13 +04:00
|
|
|
{ #name, jsapi_func_##name, nargs, flags, 0 }
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native function specifier list end */
|
|
|
|
#define JSAPI_FS_END { NULL, NULL, 0, 0, 0 }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* native proprty definition */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
|
2012-11-23 17:48:11 +04:00
|
|
|
jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
|
2012-11-23 17:48:11 +04:00
|
|
|
jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-22 18:00:13 +04:00
|
|
|
/* native property return value */
|
|
|
|
#define JSAPI_PROP_RVAL(cx, vp) (vp)
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native property getter return value */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_SET_RVAL(cx, vp, v) (*(vp) = (v))
|
2012-11-17 15:19:31 +04:00
|
|
|
|
2012-11-23 17:48:11 +04:00
|
|
|
/* native property ID value as a jsval */
|
|
|
|
#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native property specifier */
|
2012-11-20 23:17:54 +04:00
|
|
|
#define JSAPI_PS(name, fnname, tinyid, flags) \
|
|
|
|
{ name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native property specifier with no setter */
|
2012-11-20 23:17:54 +04:00
|
|
|
#define JSAPI_PS_RO(name, fnname, tinyid, flags) \
|
|
|
|
{ name , tinyid , flags | JSPROP_READONLY, jsapi_property_##fnname##_get , NULL }
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* native property specifier list end */
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
#define JS_StrictPropertyStub JS_PropertyStub
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* The object instance in a native call */
|
|
|
|
/* "this" JSObject getter */
|
|
|
|
JSObject * js_ComputeThis(JSContext *cx, JSObject *thisp, void *argv);
|
|
|
|
#define JSAPI_THIS_OBJECT(cx, vp) \
|
|
|
|
js_ComputeThis(cx, JSVAL_TO_OBJECT(vp[-1]), vp)
|
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
static inline JSObject *
|
|
|
|
JS_NewCompartmentAndGlobalObject(JSContext *cx,
|
|
|
|
JSClass *jsclass,
|
|
|
|
JSPrincipals *principals)
|
|
|
|
{
|
|
|
|
JSObject *global;
|
|
|
|
global = JS_NewObject(cx, jsclass, NULL, NULL);
|
|
|
|
if (global == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return global;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define JSString_to_char(injsstring, outchar, outlen) \
|
|
|
|
outchar = JS_GetStringBytes(injsstring); \
|
|
|
|
outlen = strlen(outchar)
|
|
|
|
|
|
|
|
/* string type cast */
|
|
|
|
#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str))
|
|
|
|
|
|
|
|
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* Garbage Collector */
|
|
|
|
|
|
|
|
/* macros for GC marking */
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
|
|
|
|
|
|
|
|
#define JSAPI_JSCLASS_MARKOP(x) (x)
|
|
|
|
|
2012-11-09 03:28:04 +04:00
|
|
|
#define JSAPI_MARKOP(name) uint32_t name(JSContext *cx, JSObject *obj, void *arg)
|
2012-11-08 04:40:21 +04:00
|
|
|
|
|
|
|
#define JSAPI_MARKCX cx
|
|
|
|
|
|
|
|
#define JSAPI_GCMARK(thing) JS_MarkGCThing(cx, thing, "object", arg)
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* Macros for manipulating GC root */
|
2012-11-08 04:40:21 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
|
|
|
|
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
|
2012-11-08 04:40:21 +04:00
|
|
|
|
|
|
|
#elif JS_VERSION == 180
|
|
|
|
|
|
|
|
/************************** Spidermonkey 1.8.0 **************************/
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
#include <string.h>
|
|
|
|
|
2012-10-28 19:37:55 +04:00
|
|
|
/* *CAUTION* these macros introduce and use jsapi_this and jsapi_rval
|
2012-06-30 20:38:12 +04:00
|
|
|
* parameters, native function code should not conflict with these
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* five parameter jsapi native call */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC(name, cx, argc, vp) \
|
|
|
|
jsapi_func_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* five parameter function descriptor */
|
|
|
|
#define JSAPI_FS(name, nargs, flags) \
|
2012-11-22 18:00:13 +04:00
|
|
|
JS_FS(#name, jsapi_func_##name, nargs, flags, 0)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* function descriptor end */
|
|
|
|
#define JSAPI_FS_END JS_FS_END
|
|
|
|
|
|
|
|
/* return value */
|
2012-10-28 19:37:55 +04:00
|
|
|
#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsapi_rval)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* return value setter */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsapi_rval, v)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* arguments */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC_ARGV(cx, vp) (vp)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-11-08 21:22:29 +04:00
|
|
|
/* check if a jsval is an object */
|
|
|
|
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
|
|
|
|
|
2012-10-28 19:37:55 +04:00
|
|
|
/* The object instance in a native call */
|
|
|
|
#define JSAPI_THIS_OBJECT(cx,vp) jsapi_this
|
|
|
|
|
2012-11-23 17:48:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
/* proprty native calls */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
|
2012-11-23 17:48:11 +04:00
|
|
|
jsapi_property_##name##_get(cx, obj, jsval jsapi_id, vp)
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
|
2012-11-23 17:48:11 +04:00
|
|
|
jsapi_property_##name##_set(cx, obj, jsval jsapi_id, vp)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-11-22 18:00:13 +04:00
|
|
|
/* native property return value */
|
|
|
|
#define JSAPI_PROP_RVAL JS_RVAL
|
|
|
|
|
|
|
|
/* native property return value setter */
|
|
|
|
#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
|
|
|
|
|
2012-11-23 17:48:11 +04:00
|
|
|
/* native property ID value as a jsval */
|
|
|
|
#define JSAPI_PROP_IDVAL(cx, vp) (*(vp) = jsapi_id)
|
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
/* property specifier */
|
2012-11-20 23:17:54 +04:00
|
|
|
#define JSAPI_PS(name, fnname, tinyid, flags) \
|
|
|
|
{ name , tinyid , flags , jsapi_property_##fnname##_get , jsapi_property_##fnname##_set }
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-11-20 23:17:54 +04:00
|
|
|
#define JSAPI_PS_RO(name, fnname, tinyid, flags) \
|
|
|
|
{ name , tinyid , flags | JSPROP_READONLY, jsapi_property_##fnname##_get , NULL }
|
2012-08-17 14:52:59 +04:00
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
|
|
|
|
|
2012-11-23 17:48:11 +04:00
|
|
|
|
|
|
|
|
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
static inline JSObject *
|
|
|
|
JS_NewCompartmentAndGlobalObject(JSContext *cx,
|
|
|
|
JSClass *jsclass,
|
2012-06-26 22:55:57 +04:00
|
|
|
JSPrincipals *principals)
|
|
|
|
{
|
|
|
|
JSObject *global;
|
|
|
|
global = JS_NewObject(cx, jsclass, NULL, NULL);
|
|
|
|
if (global == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return global;
|
|
|
|
}
|
|
|
|
|
|
|
|
#define JS_StrictPropertyStub JS_PropertyStub
|
|
|
|
|
2012-06-28 03:39:18 +04:00
|
|
|
#define JSString_to_char(injsstring, outchar, outlen) \
|
2012-07-06 23:00:32 +04:00
|
|
|
outchar = JS_GetStringBytes(injsstring); \
|
|
|
|
outlen = strlen(outchar)
|
2012-06-28 03:39:18 +04:00
|
|
|
|
2012-11-03 21:37:59 +04:00
|
|
|
/* string type cast */
|
|
|
|
#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str))
|
2012-10-28 19:37:55 +04:00
|
|
|
|
2012-11-06 22:47:26 +04:00
|
|
|
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
|
2012-11-06 22:35:59 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* Garbage Collector */
|
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
/* GC marking */
|
|
|
|
#ifdef JSCLASS_MARK_IS_TRACE
|
2012-11-17 15:19:31 +04:00
|
|
|
/* mark function pointer requires casting */
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_JSCLASS_MARK_IS_TRACE JSCLASS_MARK_IS_TRACE
|
|
|
|
#define JSAPI_JSCLASS_MARKOP(x) ((JSMarkOp)x)
|
|
|
|
#else
|
2012-11-17 15:19:31 +04:00
|
|
|
/* mark function pointer does not require casting */
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
|
|
|
|
#define JSAPI_JSCLASS_MARKOP(x) (x)
|
|
|
|
#endif
|
2012-11-06 22:35:59 +04:00
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_MARKOP(name) JSBool name(JSTracer *trc, JSObject *obj)
|
2012-11-06 22:35:59 +04:00
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_MARKCX trc->context
|
2012-11-06 22:35:59 +04:00
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
|
2012-11-06 22:35:59 +04:00
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* Macros for manipulating GC root */
|
|
|
|
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddRoot(cx, obj)
|
|
|
|
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveRoot(cx, obj)
|
|
|
|
|
2012-11-06 22:35:59 +04:00
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
#else /* #if JS_VERSION == 180 */
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
/************************** Spidermonkey 1.8.5 **************************/
|
2012-10-28 19:37:55 +04:00
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
/* three parameter jsapi native call */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC(name, cx, argc, vp) jsapi_func_##name(cx, argc, vp)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* three parameter function descriptor */
|
|
|
|
#define JSAPI_FS(name, nargs, flags) \
|
2012-11-22 18:00:13 +04:00
|
|
|
JS_FS(#name, jsapi_func_##name, nargs, flags)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* function descriptor end */
|
|
|
|
#define JSAPI_FS_END JS_FS_END
|
|
|
|
|
|
|
|
/* return value */
|
|
|
|
#define JSAPI_RVAL JS_RVAL
|
|
|
|
|
|
|
|
/* return value setter */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC_SET_RVAL JS_SET_RVAL
|
2012-06-30 20:38:12 +04:00
|
|
|
|
|
|
|
/* arguments */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_FUNC_ARGV(cx, vp) JS_ARGV(cx,vp)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-11-08 21:22:29 +04:00
|
|
|
/* check if a jsval is an object */
|
|
|
|
#define JSAPI_JSVAL_IS_OBJECT(v) JSVAL_IS_OBJECT(v)
|
|
|
|
/* The docuemntation says this is obsolete and should be
|
|
|
|
* ((JSVAL_IS_NULL(v)) || (JSVAL_IS_PRIMITIVE(v)))
|
|
|
|
* which doesnt work
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2012-10-28 19:37:55 +04:00
|
|
|
/* The object instance in a native call */
|
|
|
|
#define JSAPI_THIS_OBJECT(cx,vp) JS_THIS_OBJECT(cx,vp)
|
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
/* proprty native calls */
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_GETTER(name, cx, obj, vp) \
|
2012-11-23 17:48:11 +04:00
|
|
|
jsapi_property_##name##_get(cx, obj, jsid jsapi_id, vp)
|
2012-11-22 18:00:13 +04:00
|
|
|
#define JSAPI_PROP_SETTER(name, cx, obj, vp) \
|
2012-11-23 17:48:11 +04:00
|
|
|
jsapi_property_##name##_set(cx, obj, jsid jsapi_id, JSBool strict, vp)
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-11-22 18:00:13 +04:00
|
|
|
/* native property return value */
|
|
|
|
#define JSAPI_PROP_RVAL JS_RVAL
|
|
|
|
|
|
|
|
/* native property getter return value */
|
|
|
|
#define JSAPI_PROP_SET_RVAL JS_SET_RVAL
|
|
|
|
|
2012-11-23 17:48:11 +04:00
|
|
|
/* native property ID value as a jsval */
|
|
|
|
#define JSAPI_PROP_IDVAL(cx, vp) JS_IdToValue(cx, jsapi_id, vp)
|
|
|
|
|
2012-06-30 20:38:12 +04:00
|
|
|
/* property specifier */
|
2012-11-20 23:17:54 +04:00
|
|
|
#define JSAPI_PS(name, fnname, tinyid, flags) { \
|
|
|
|
name, \
|
|
|
|
tinyid, \
|
|
|
|
flags, \
|
|
|
|
jsapi_property_##fnname##_get, \
|
|
|
|
jsapi_property_##fnname##_set \
|
2012-06-30 20:38:12 +04:00
|
|
|
}
|
|
|
|
|
2012-11-20 23:17:54 +04:00
|
|
|
#define JSAPI_PS_RO(name, fnname, tinyid, flags) { \
|
|
|
|
name, \
|
|
|
|
tinyid, \
|
2012-08-17 14:52:59 +04:00
|
|
|
flags | JSPROP_READONLY, \
|
2012-11-20 23:17:54 +04:00
|
|
|
jsapi_property_##fnname##_get, \
|
2012-08-17 14:52:59 +04:00
|
|
|
NULL \
|
|
|
|
}
|
|
|
|
|
|
|
|
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
|
2012-06-30 20:38:12 +04:00
|
|
|
|
2012-06-28 03:39:18 +04:00
|
|
|
|
|
|
|
#define JSString_to_char(injsstring, outchar, outlen) \
|
|
|
|
outlen = JS_GetStringLength(injsstring); \
|
|
|
|
outchar = alloca(sizeof(char)*(outlen+1)); \
|
|
|
|
JS_EncodeStringToBuffer(injsstring, outchar, outlen); \
|
|
|
|
outchar[outlen] = '\0'
|
|
|
|
|
2012-11-03 21:37:59 +04:00
|
|
|
/* string type cast */
|
|
|
|
#define JSAPI_STRING_TO_JSVAL(str) ((str == NULL)?JSVAL_NULL:STRING_TO_JSVAL(str))
|
2012-06-28 03:39:18 +04:00
|
|
|
|
2012-11-06 22:35:59 +04:00
|
|
|
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS JSCLASS_NO_INTERNAL_MEMBERS
|
|
|
|
|
2012-11-08 04:40:21 +04:00
|
|
|
/* GC marking */
|
|
|
|
#ifdef JSCLASS_MARK_IS_TRACE
|
|
|
|
/* mark requires casting */
|
|
|
|
#define JSAPI_JSCLASS_MARK_IS_TRACE JSCLASS_MARK_IS_TRACE
|
|
|
|
#define JSAPI_JSCLASS_MARKOP(x) ((JSMarkOp)x)
|
|
|
|
#else
|
|
|
|
/* mark does not require casting */
|
|
|
|
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
|
|
|
|
#define JSAPI_JSCLASS_MARKOP(x) (x)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define JSAPI_MARKOP(name) JSBool name(JSTracer *trc, JSObject *obj)
|
|
|
|
|
|
|
|
#define JSAPI_MARKCX trc->context
|
|
|
|
|
|
|
|
#define JSAPI_GCMARK(thing) JS_CallTracer(trc, thing, JSTRACE_OBJECT);
|
|
|
|
|
2012-11-17 15:19:31 +04:00
|
|
|
/* Macros for manipulating GC root */
|
|
|
|
#define JSAPI_ADD_OBJECT_ROOT(cx, obj) JS_AddObjectRoot(cx, obj)
|
|
|
|
#define JSAPI_REMOVE_OBJECT_ROOT(cx, obj) JS_RemoveObjectRoot(cx, obj)
|
|
|
|
|
2012-06-26 22:55:57 +04:00
|
|
|
#endif
|
|
|
|
|
2012-11-06 22:08:39 +04:00
|
|
|
#define JSLOG(args...) LOG((args))
|
2012-08-06 02:42:30 +04:00
|
|
|
|
2012-06-11 02:17:30 +04:00
|
|
|
#endif
|