spidermonkey

How do I get the value of a JSObject property from C?

In SpiderMonkey, how do I get the value of a property of a JSObject from within my C code? static JSBool JSD_getter(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) { jsval js_id; JS_GetProperty(cx, obj, "id", // js_id has JavaScript type int c_id; JS_ValueToInt32(cx, js_id, // Now, c_id contains th...

Embedding JavaScript engine into .NET (C#)

Hi, just wondering if anyone has ever tried embedding and actually integrating any js engine into the .net environment. I could find and actually use (after a LOT of pain and effort, since it's pretty outdated and not quite finished) spidermonkey-dotnet project. Anyone with experience in this area? Engines like SquirrelFish, V8.. Not t...

How can I get the full backtrace in spidermonkey (JSAPI) from my reportError function

I'm embedding javascript in my app using spidermonkey and I have a function called reportError that receives a JSErrorReport. It seems simple to grab the current line of the error, but is it possible to get the entire call path to display a full backtrace? ...

How to Implement Closures Using SpiderMonkey API?

I've been working with the SpiderMonkey C API and would like to implement a closure in C using their API. The one I would like to implement is fairly complex, but I can't even figure out how to do a simple one such as: function x() { var i = 0; return function() { i++; print(i); }; } var y = x(); y(); //1 y(); //2 y(); //3 I w...

How can I get the memory address of a JavaScript variable?

Is it possible to find the memory address of a JavaScript variable? The JavaScript code is part of (embedded into) a normal application where JavaScript is used as a front end to C++ and does not run on the browser. The JavaScript implementation used is SpiderMonkey. ...

Prerequisites on installing Spidermonkey

Considering there is no Mozilla related engines installed on a linux machine. What are the specific libraries or engines needed to successfully install Spidermonkey? ...

jsprf.c:644: error: incompatible types in assignment

Hey guys, Can you help me with this error I encountered while building Spidermonkey in PPC? make -f Makefile.ref cat: ../../dist/Linux_All_DBG.OBJ/nspr/Version: No such file or directory cd editline; make -f Makefile.ref all make[1]: Entering directory `/units/ spidermonkey-1.8-next-wip/src/editline' make[1]: Nothing to be don...

Spidermonkey pointing to a NSPR/DIST directory, HELP!

Hey guys, I've been trying to cross-compile Spidermonkey and I am stuck with the problem wherein prtypes.h(NSPR) is unrecognizable. I alread triedy modifying Makefile.ref/config.mk/jsconfig.mk to point to a desired NSPR/DIS directory. I must have missed some basic steps because it still won't make things work. Do you have any ideas on h...

Parse Javascript to instrument code

Hi, i need to split a javascript file into single instructions. For example: a = 2; foo() function bar() { b = 5; print("spam"); } has to be separated into three instructions. (assignment, function call and function definition). Basically i need to instrument the code, injecting code between these instructions to perform che...

SpiderMonkey vs JavaScriptCore vs ?

I have a C++ desktop application (written in wxWidgets) and I want to add support for some scripting language. Scripting would mostly be used for run-time conversions of strings, numbers and dates by user supplied JavaScript code. I'd like to use JavaScript because it is widely used and everyone is familiar with the syntax. Googling ...

JSON serialization in Spidermonkey

I'm using python-spidermonkey to run JavaScript code. In order to pass objects (instead of just strings) to Python, I'm thinking of returning a JSON string. This seems like a common issue, so I wonder whether there are any facilities for this built into either Spidermonkey or python-spidermonkey. (I do know about uneval but that is not...

file I/O in Spidermonkey

Thanks to python-spidermonkey, using JavaScript code from Python is really easy. However, instead of using Python to read JS code from a file and passing the string to Spidermonkey, is there a way to read the file from within Spidermonkey (or pass the filepath as an argument, as in Rhino)? ...

lvalue return expressions in Spidermonkey Javascript

Here's an interesting question that could provide useful input into the Spidermonkey flavor of Javascript (used in Firefox & other programs)... The original was in a post on mozilla.dev.tech.js-engine but i'll quote here as well: Newsgroups: mozilla.dev.tech.js-engine From: Brendan Eich <[email protected]> Date: Fri, 7 Aug 2009 12...

Command Line JavaScript Input Arguments Issues While Minifying JavaScript in Gedit.

Hello, I want to minify my JavaScript files immediately in Gedit. I tried do it via external tools option with jsmin.js script. I have SpiderMonkey engine installed. I stored jsmin.js file at /home/mushex/use/js/jsmin.js and created a new js file named jsmin-low.js in the same directory with content #!/usr/bin/js load('/home/mushex/us...

Spidermonkey shell. How to change encoding of source code?

If I enter print("®".length) in smjs, it prints 2. If I enter javascript:alert("®".length) in my firefox as well as opera, it prints 1. Rhino prints 1 too. Is it possible to tell smjs that I want to treat such characters as single character? Os: linux(Ubuntu 9.04), locale: UTF-8. ...

How to load remote javascript into a SpiderMonkey context?

I have a server which will be serving up javascript files, I need to grab it and execute some of it's functions using SpiderMonkey in python. How can I do this? ...

Confusing operation of JavaScript `var` keyword

I’ve run into a very strange (to me) problem with the var keyword. I’ve reduced it to a fairly minimal test case, and found it’s exhibited in Node.js (thus, V8 and Chrome), Safari 4’s inspector (thus, Nitro), and FireBug (obviously, SpiderMonkey). I was originally preparing a bug report, but since it’s so widely displayed, I’m going to a...

DOM to use with SpiderMonkey?

I'm trying to use the GoogleMaps javascript library from inside of SpiderMonkey using the pythong wrapper, but I can't because of the lack of a DOM. Is there some way I can integrate a DOM into this so that I can get this to work? ...

Is it possible to increase the recursion limit in SpiderMonkey?

I'm currently working on problems in Project Euler with JavaScript. For the most part I've been using for loops to iterate through the problems but wanted to use recursive functions. However, it seems that all of the JavaScript engines have limits to the amount of recursion they can handle. I compiled/installed SpiderMonkey to try and r...

Python, mongo + spider monkey

Ok, so this isn't exactly a question that I expect a full answer for but here goes... I am currently using a python driver to fire data at a mongo instance and all it well in the world. Now I want to be able to pull data from mongo and evaluate each record in the collection. Now I need to pass in to this evaluation a script that will lo...