FreeWRL / FreeX3D 4.3.0
system_js.h
1/*
2
3
4FreeWRL support library.
5Internal header: Javascript engine dependencies.
6
7*/
8
9/****************************************************************************
10 This file is part of the FreeWRL/FreeX3D Distribution.
11
12 Copyright 2009 CRC Canada. (http://www.crc.gc.ca)
13
14 FreeWRL/FreeX3D is free software: you can redistribute it and/or modify
15 it under the terms of the GNU Lesser Public License as published by
16 the Free Software Foundation, either version 3 of the License, or
17 (at your option) any later version.
18
19 FreeWRL/FreeX3D is distributed in the hope that it will be useful,
20 but WITHOUT ANY WARRANTY; without even the implied warranty of
21 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 GNU General Public License for more details.
23
24 You should have received a copy of the GNU General Public License
25 along with FreeWRL/FreeX3D. If not, see <http://www.gnu.org/licenses/>.
26****************************************************************************/
27
28
29#ifndef __LIBFREEWRL_SYSTEM_JS_H__
30#define __LIBFREEWRL_SYSTEM_JS_H__
31
32
33/*
34 spidermonkey is built with the following flags on Mac:
35
36-Wall -Wno-format -no-cpp-precomp -fno-common -DJS_THREADSAFE -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DDARWIN -UDEBUG -DNDEBUG -UDEBUG_root -DJS_THREADSAFE -DEDITLINE
37
38*/
39
40#define JS_HAS_FILE_OBJECT 1 /* workaround warning=>error */
41
42#if defined(IPHONE) || defined(_ANDROID) || defined(NO_JAVASCRIPT)
43typedef int JSContext;
44typedef int JSObject;
45typedef int JSScript;
46typedef int jsval;
47typedef int jsid;
48typedef int JSType;
49typedef int JSClass;
50typedef int JSFunctionSpec;
51typedef int JSPropertySpec;
52typedef int JSBool;
53typedef int uintN;
54typedef int JSErrorReport;
55
56
57
58/* int jsrrunScript(JSContext *_context, JSObject *_globalObj, char *script, jsval *rval); */
59#else
60
61#ifdef MOZILLA_JS_UNSTABLE_INCLUDES
62# include "../unstable/jsapi.h" /* JS compiler */
63# include "../unstable/jsdbgapi.h" /* JS debugger */
64#else
65#undef DEBUG
66//#define DEBUG 1 //challenge it with lots of ASSERTS, just for cleaning up code correctness, not production
67# include <jsapi.h> /* JS compiler */
68# include <jsdbgapi.h> /* JS debugger */
69#endif
70int JS_SetPrivateFw(JSContext *cx, JSObject* obj, void *data);
71JSObject* JS_NewGlobalObjectFw(JSContext *cx, JSClass *clasp); //, JSPrincipals *princ);
72void * JS_GetPrivateFw(JSContext *cx,JSObject*_obj);
73JSObject* JS_GetParentFw(JSContext *cx, JSObject *me);
74JSObject * JS_ConstructObjectWithArgumentsFw(JSContext *cx, JSClass *clasp, JSObject *parent, unsigned argc, jsval *argv);
75JSObject * JS_ConstructObjectFw(JSContext *cx, JSClass *clasp, void *whatever, JSObject *parent);
76JSObject * JS_GetPrototypeFw(JSContext *cx, JSObject * obj);
77JSClass * JS_GetClassFw(JSContext *cx, JSObject * obj);
78#if JS_VERSION >= 185
79#define JSSCRIPT JSObject
80#if JS_VERSION == 185
81#define JSSCRIPT2 JSObject
82#endif
83#if JS_VERSION == 186
84// spidermonkey 17 -last C interface version- is 186
85// https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/Releases/17
86// could alternatively define in preprocessor parameters MOZ_CUSTOM_STDINT_H and jsapi will define, tried but didn't build
87// instead for debugging / tinkering we will define here
88#define uintN unsigned
89#define intN int
90#define jsint int32_t
91#define jsuint uint32_t
92#define int32 int32_t
93#define jsdouble double
94
95#define JS_FinalizeStub NULL
96#define JSSCRIPT2 JSScript
97#define JS_GET_CLASS JS_GetClassFw
98JSBool JS_NewNumberValue(JSContext *cx, jsdouble d, jsval *rval);
99#define JSVAL_IS_OBJECT(retval) JSVAL_IS_OBJECT_OR_NULL_IMPL(retval)
100
101#endif
102#else
103#define JSSCRIPT JSScript
104#define JSSCRIPT2 JSObject
105#endif
106
107
108#define JS_GET_PROPERTY_STUB JS_PropertyStub
109/* #define JS_GET_PROPERTY_STUB js_GetPropertyDebug */
110
111#define JS_SET_PROPERTY_STUB1 js_SetPropertyDebug1
112
113/* #define JS_SET_PROPERTY_STUB2 js_SetPropertyDebug2 */
114#if JS_VERSION < 185
115# define JS_SET_PROPERTY_STUB2 JS_PropertyStub
116#else
117# define JS_SET_PROPERTY_STUB2 JS_StrictPropertyStub
118#endif
119
120#define JS_SET_PROPERTY_STUB3 js_SetPropertyDebug3
121#define JS_SET_PROPERTY_STUB4 js_SetPropertyDebug4
122#define JS_SET_PROPERTY_STUB5 js_SetPropertyDebug5
123#define JS_SET_PROPERTY_STUB6 js_SetPropertyDebug6
124#define JS_SET_PROPERTY_STUB7 js_SetPropertyDebug7
125#define JS_SET_PROPERTY_STUB8 js_SetPropertyDebug8
126#define JS_SET_PROPERTY_CHECK js_SetPropertyCheck
127
128
129#endif /* IPHONE */
130
131#endif /* __LIBFREEWRL_SYSTEM_JS_H__ */