From b5313189058a15cf3a30709875fd4ced1d3a6927 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Sun, 28 Oct 2012 15:37:55 +0000 Subject: fix obtaining the "this" object --- javascript/jsapi.h | 18 ++++++++++++------ javascript/jsapi/binding.h | 3 +++ 2 files changed, 15 insertions(+), 6 deletions(-) (limited to 'javascript') diff --git a/javascript/jsapi.h b/javascript/jsapi.h index 93c0effdd..e7c10c139 100644 --- a/javascript/jsapi.h +++ b/javascript/jsapi.h @@ -29,19 +29,17 @@ #include "mozjs/jsapi.h" #endif -#include "render/html_internal.h" - #if JS_VERSION <= 180 #include -/* *CAUTION* these macros introduce and use jsthis and jsrval +/* *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 *jsthis, argc, vp, jsval *jsrval) + jsapi_native_##name(cx, JSObject *jsapi_this, argc, vp, jsval *jsapi_rval) /* five parameter function descriptor */ #define JSAPI_FS(name, nargs, flags) \ @@ -51,14 +49,17 @@ #define JSAPI_FS_END JS_FS_END /* return value */ -#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsrval) +#define JSAPI_RVAL(cx, vp) JS_RVAL(cx, jsapi_rval) /* return value setter */ -#define JSAPI_SET_RVAL(cx, vp, v) JS_SET_RVAL(cx, jsrval, v) +#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) @@ -93,8 +94,10 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx, outchar = JS_GetStringBytes(injsstring); \ outlen = strlen(outchar) + #else /* #if JS_VERSION <= 180 */ + /* three parameter jsapi native call */ #define JSAPI_NATIVE(name, cx, argc, vp) jsapi_native_##name(cx, argc, vp) @@ -114,6 +117,9 @@ JS_NewCompartmentAndGlobalObject(JSContext *cx, /* arguments */ #define JSAPI_ARGV(cx, vp) JS_ARGV(cx,vp) +/* The object instance in a native call */ +#define JSAPI_THIS_OBJECT(cx,vp) JS_THIS_OBJECT(cx,vp) + /* proprty native calls */ #define JSAPI_PROPERTYGET(name, cx, obj, vp) \ jsapi_property_##name##_get(cx, obj, jsid id, vp) diff --git a/javascript/jsapi/binding.h b/javascript/jsapi/binding.h index b565136af..7ead6f6cb 100644 --- a/javascript/jsapi/binding.h +++ b/javascript/jsapi/binding.h @@ -23,6 +23,9 @@ #ifndef _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_ #define _NETSURF_JAVASCRIPT_JSAPI_BINDING_H_ + +#include "render/html_internal.h" + JSObject *jsapi_InitClass_Window(JSContext *cx, JSObject *parent); /** Create a new javascript window object -- cgit v1.2.3