-
Notifications
You must be signed in to change notification settings - Fork 156
Migrating to v25
Changes needed to migrate to SpiderMonkey v25 from v23
SpiderMonkey uses static_assert
in some header files. So projects that use SpiderMonkey like JS Bindings needs to update its compiler to a C++11 compiler.
JS_Init()
needs to be called at the very beginning.
Also, it is strongly recommended, in your JS setup function, to take inspiration from the example code in js/src/gdb/gdb-tests.cpp
JS_SetProperty
and JS_GetProperty
no longer work with jsval
objects. Instead now receives JS::RootedValue
objects.
// Old Way
jsval someJSval = OBJECT_TO_JSVAL(someObject);
JS_SetProperty(cx, object, "cp", &someJSval);
JS_GetProperty(cx, object, "cp", &someJSval);
// New Way
JS::RootedValue someJSval(_cx);
someJSval = OBJECT_TO_JSVAL(someObject);
JS_SetProperty(cx, object, "cp", someJSval);
JS_GetProperty(cx, object, "cp", &someJSval);
// Old Way
JS_NewGlobalObject(cx, &global_class, NULL);
// New Way
JS_NewGlobalObject(cx, &global_class, NULL, JS::DontFireOnNewGlobalHook /* or JS::FireOnNewGlobalHook */);
// Old Way
JS_GetGlobalObject(cx);
// New Way
JS_GetGlobalForCompartmentOrNull(cx, js::GetContextCompartment(cx));
//or
JS_GetGlobalForObject(cx, jsobject_ptr); // if you have a current object
For more explanations see this [page: https://developer.mozilla.org/en-US/docs/Mozilla/Projects/SpiderMonkey/JSAPI_reference/JS_GetGlobalObject
Although it is not up to date as JS_GetGlobalForCompartmentOrNull
has replaced JS_GetGlobalForScopeChain
...
// Old Way
JS_SetVersion(_cx, JSVERSION_LATEST);
// New Way
#include "jsfriendapi.h"
...
JSCompartment *compartment = js::GetContextCompartment(cx);
if(compartment != NULL)
JS_SetVersionForCompartment(compartment, JSVERSION_LATEST);
else
// well, don't know what to do here...
Also, it must be called from within a
// Old Way
clazz =
{
getClassName().c_str(),
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_PropertyStub,
JS_PropertyStub,
JS_StrictPropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
NULL,
JSCLASS_NO_OPTIONAL_MEMBERS
};
// New Way: JS_DeletePropertyStub instead of JS_PropertyStub because the 4th member is a JS_DeletePropertyOp
clazz =
{
getClassName().c_str(),
JSCLASS_HAS_PRIVATE,
JS_PropertyStub,
JS_DeletePropertyStub,
JS_PropertyStub,
JS_StrictPropertyStub,
JS_EnumerateStub,
JS_ResolveStub,
JS_ConvertStub,
NULL,
JSCLASS_NO_OPTIONAL_MEMBERS
};
// Old Way
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::Value& val = args[0];
// New way
JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
JS::MutableHandleValue mhval = args[0];
const JS::Value& cval = args[0].get();
JS::Value& val = *args[0].address();
Adds build-ios, build-osx, build-android and build-win32 scripts
- Build scripts: https://github.com/ricardoquesada/Spidermonkey/commit/5db23ae289282ba06371e7108a8a4791074c7045
Adds iOS options
-
configure.in, aclocal.m4, ios.m4: https://github.com/ricardoquesada/Spidermonkey/commit/2659a53f386b387bca6e56ba61606fbf3c81bb82
-
configure https://github.com/ricardoquesada/Spidermonkey/commit/4823e237abead7ff83d6af4d29393c814c2131ff
Needed to compile Android
- Android.mk: https://github.com/ricardoquesada/Spidermonkey/commit/047d305ceddc22938dbe446826fc8cbd869c6a31
https://github.com/ricardoquesada/Spidermonkey/commit/0e492ed44a628df4688d642b06244807b159eaec
https://github.com/ricardoquesada/Spidermonkey/commit/729cde6171ad84c7679b28f29ed4d2957e215e2f https://github.com/ricardoquesada/Spidermonkey/commit/33a2f81c7f3ab35cce10435063161b84890b663c
Disables ARM assembly optimizations when using clang
- NumericConversions.h: https://github.com/ricardoquesada/Spidermonkey/commit/b31d6a15d3cc15e504504d6e34f667a6fea75175
Disables "DEBUG" class id in order to have ABI compatibility between DEBUG and RELEASE builds
- jspubtd.h: https://github.com/ricardoquesada/Spidermonkey/commit/0316846baedce757f5c4f54d8930ee24aa1ffdfd
https://github.com/ricardoquesada/Spidermonkey/commit/333f7ffd9674b9c114a0724f97a8567cc7c4eb07
https://github.com/ricardoquesada/Spidermonkey/commit/35f74c893133cd674a425e2ebbd204ee63c64824