mirror of
https://github.com/netsurf-browser/netsurf
synced 2025-01-23 02:42:11 +03:00
make compatability macros for garbage collection
This commit is contained in:
parent
55c6841eca
commit
06b08d3af0
@ -29,7 +29,9 @@
|
||||
#include "mozjs/jsapi.h"
|
||||
#endif
|
||||
|
||||
#if JS_VERSION <= 180
|
||||
#if JS_VERSION < 180
|
||||
|
||||
/************************** Spidermonkey 1.7.0 **************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
@ -99,13 +101,112 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
|
||||
|
||||
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS NULL
|
||||
|
||||
/* GC marking */
|
||||
#define JSAPI_JSCLASS_MARK_IS_TRACE 0
|
||||
|
||||
#define JSAPI_JSCLASS_MARKOP(x) (x)
|
||||
|
||||
#define JSAPI_MARKOP(name) uint32_t name(JSContext cx, JSObject *obj, void *arg)
|
||||
|
||||
#define JSAPI_MARKCX cx
|
||||
|
||||
#define JSAPI_GCMARK(thing) JS_MarkGCThing(cx, thing, "object", arg)
|
||||
|
||||
|
||||
|
||||
#else /*************** #if JS_VERSION <= 180 *****************/
|
||||
#elif JS_VERSION == 180
|
||||
|
||||
/************************** Spidermonkey 1.8.0 **************************/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
/* *CAUTION* these macros introduce and use jsapi_this and jsapi_rval
|
||||
* parameters, native function code should not conflict with these
|
||||
*/
|
||||
|
||||
/* five parameter jsapi native call */
|
||||
#define JSAPI_NATIVE(name, cx, argc, vp) \
|
||||
jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval)
|
||||
|
||||
/* five parameter function descriptor */
|
||||
#define JSAPI_FS(name, nargs, flags) \
|
||||
JS_FS(#name, jsapi_native_##name, nargs, flags, 0)
|
||||
|
||||
/* function descriptor end */
|
||||
#define JSAPI_FS_END JS_FS_END
|
||||
|
||||
/* return value */
|
||||
#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsapi_rval)
|
||||
|
||||
/* return value setter */
|
||||
#define JSAPI_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsapi_rval, v)
|
||||
|
||||
/* arguments */
|
||||
#define JSAPI_ARGV(cx, vp) (vp)
|
||||
|
||||
/* The object instance in a native call */
|
||||
#define JSAPI_THIS_OBJECT(cx,vp) jsapi_this
|
||||
|
||||
/* proprty native calls */
|
||||
#define JSAPI_PROPERTYGET(name, cx, obj, vp) \
|
||||
jsapi_property_##name##_get(cx, obj, jsval id, vp)
|
||||
#define JSAPI_PROPERTYSET(name, cx, obj, vp) \
|
||||
jsapi_property_##name##_set(cx, obj, jsval id, vp)
|
||||
|
||||
/* property specifier */
|
||||
#define JSAPI_PS(name, tinyid, flags) \
|
||||
{ #name , tinyid , flags , jsapi_property_##name##_get , jsapi_property_##name##_set }
|
||||
|
||||
#define JSAPI_PS_RO(name, tinyid, flags) \
|
||||
{ #name , tinyid , flags | JSPROP_READONLY, jsapi_property_##name##_get , NULL }
|
||||
|
||||
#define JSAPI_PS_END { NULL, 0, 0, NULL, NULL }
|
||||
|
||||
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 JS_StrictPropertyStub JS_PropertyStub
|
||||
|
||||
#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
|
||||
|
||||
/* 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);
|
||||
|
||||
|
||||
#else /* #if JS_VERSION == 180 */
|
||||
|
||||
/************************** Spidermonkey 1.8.5 **************************/
|
||||
|
||||
/* three parameter jsapi native call */
|
||||
#define JSAPI_NATIVE(name, cx, argc, vp) jsapi_native_##name(cx, argc, vp)
|
||||
@ -166,6 +267,23 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx,
|
||||
|
||||
#define JSAPI_CLASS_NO_INTERNAL_MEMBERS JSCLASS_NO_INTERNAL_MEMBERS
|
||||
|
||||
/* 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);
|
||||
|
||||
#endif
|
||||
|
||||
#define JSLOG(args...) LOG((args))
|
||||
|
@ -173,7 +173,6 @@ operation write %{
|
||||
/* in dom Document */
|
||||
operation createTextNode %{
|
||||
dom_string *data_dom;
|
||||
dom_element *element;
|
||||
dom_exception exc;
|
||||
dom_text *text;
|
||||
|
||||
|
@ -41,16 +41,16 @@ binding window {
|
||||
api mark %{
|
||||
if (private != NULL) {
|
||||
if (private->document != NULL) {
|
||||
JS_CallTracer(trc, private->document, JSTRACE_OBJECT);
|
||||
JSAPI_GCMARK(private->document);
|
||||
}
|
||||
if (private->navigator != NULL) {
|
||||
JS_CallTracer(trc, private->navigator, JSTRACE_OBJECT);
|
||||
JSAPI_GCMARK(private->navigator);
|
||||
}
|
||||
if (private->console != NULL) {
|
||||
JS_CallTracer(trc, private->console, JSTRACE_OBJECT);
|
||||
JSAPI_GCMARK(private->console);
|
||||
}
|
||||
if (private->location != NULL) {
|
||||
JS_CallTracer(trc, private->location, JSTRACE_OBJECT);
|
||||
JSAPI_GCMARK(private->location);
|
||||
}
|
||||
}
|
||||
%}
|
||||
|
Loading…
Reference in New Issue
Block a user