Spidermonkey is a C library for executing Javascript from inside of your application. Although fast an reliable, new versions tend to break compatibility. I just updated my computer from 1.7 to 1.8.5. During that upgrade, here are a few of the problems that I faced:
1) JS_GetStringBytes() has been retired
JS_GetStringBytes() returned a pointer to the private character array of the JSString. I can understand why the API designers wouldn't want to give out a pointer to private data. It has been replaced by JS_EncodeString() which requires a corresponding JS_free() call.
2) JS_AddRoot() and JS_RemoveRoot() have been retired
Instead of a single generic function, there are now specific functions for each scenario. All of my JS_AddRoot() calls got turned to JS_AddObjectRoot() calls.
3) When defining a class, the SET method was changed from type JS_PropertyStub to JS_StrictPropertyStub
This required changing my definitions to JS_StrictPropertyStub or updaring my SET function to the new arguments.
4) Function pointers are now of type JSNative
This required a bunch of casts. Before, I could pass in the function pointer. Now, the DefineFunction function requires the pointer to be of type JSNative. A Simple change.
After making all of those changes, my program compiles, but it doesn't run. It SEGFAULTs on JS_NewObject(). I tried different variations of the call. I recompiled Spidermonkey in debug mode but I don't get any more info. I still get the following stack trace in GDB:
#0 0x00007ffff617eedc in ?? () from /usr/lib64/libmozjs185.so.1.0
#1 0x00007ffff617b0dd in JS_NewObject () from /usr/lib64/libmozjs185.so.1.0
I have decided to revert back to version 1.7.0 for now. This in itself is problematic since I upgraded everything on the system, not just Spidermonkey. Policykit requires 1.8.5, so I have to uninstall policykit. A bunch of apps used policykit, so I had to recompile without policykit support (yay Gentoo). I revered my svn commit and I was up and running. I make a branch out of the 1.8.5 changes to see what I can do to get it to run in the future.
No comments:
Post a Comment
Note: Only a member of this blog may post a comment.