spidermonkey

How to pass arguments to a script through the SpiderMonkey command-line?

早过忘川 提交于 2020-01-06 08:01:15
问题 I am using SpiderMonkey 1.8.5 on Debian. I am starting a script through the command-line using js -f <myScript> I'd like to pass some arguments to my script, but I don't know how to do that. It's supposedto be possible since the documentation tells you about a special object gathring all parameters provided to a script. I tried the following: js -f <myScript> <1stArg> But SpiderMonkey consider both parameters as different scripts to execute and thus sends en error saying the '<1stArg>' file

Garbage collector issues on spidermonkey… JS_AnchorPtr()?

安稳与你 提交于 2019-12-31 02:44:07
问题 I've rolled my own javascript server side language called bondi. Just recently upgraded to the new spider monkey. Now that JS enter local roots and leave local roots function is gone/useless from the 1.8.5 api, is it enough to just use anchor pointer( JS_AnchorPtr(varname) ) at the end of your function calls to make sure the compiler isn't removing references to keep the garbage collector happy? I've been testing it by removing all my references to JS_EnterLocalRootScope (see here) / Leave

Best way to get spidermonkey js on Ubuntu?

妖精的绣舞 提交于 2019-12-30 01:52:06
问题 I need to install the Spidermonkey JS engine on my work machine. The project I'm working on has a jslint script that requires Spidermonkey or a similar js binary. I've tried compiling Spidermonkey from source and gotten stuck in dependency hell. I tried installing the rhino package from the ubuntu repositories, and that turned out to be slow and broken. This morning, I successfully compiled Google's V8 engine and built v8jslint following the instructions here: http://blog.stevenreid.co.uk

Is Javascript substring virtual?

坚强是说给别人听的谎言 提交于 2019-12-29 05:09:34
问题 If we have a huge string, named str1 , say 5 million characters long, and then str2 = str1.substr(5555, 100) so that str2 is 100 characters long and is a substring of str1 starting at 5555 (or any other randomly selected position). How JavaScript stores str2 internally? Is the string contents copied or the new string is sort of virtual and only a reference to the original string and values for position and size are stored? I know this is implementation dependent, ECMAScript standard (probably

Is Javascript substring virtual?

老子叫甜甜 提交于 2019-12-29 05:08:28
问题 If we have a huge string, named str1 , say 5 million characters long, and then str2 = str1.substr(5555, 100) so that str2 is 100 characters long and is a substring of str1 starting at 5555 (or any other randomly selected position). How JavaScript stores str2 internally? Is the string contents copied or the new string is sort of virtual and only a reference to the original string and values for position and size are stored? I know this is implementation dependent, ECMAScript standard (probably

SpiderMonkey Build Configure Error “configure: error: Your C and C++ compilers are different…”

烈酒焚心 提交于 2019-12-25 14:23:26
问题 Command: mozjs-38.0.0/js/src/build_DBG.OBJ$ ../configure --enable-debug --disable-optimize Output: ... configure:3223: checking for windres configure: error: Your C and C++ compilers are different. You need to use the same compiler. The gcc and g++ version is 4.9.3.Clang version is 3.6.0-2. How to solve this issue? Thanks! 回答1: Resolved by link "/usr/bin/c++" from "/etc/alternatives/c++" to the currently used g++. 来源: https://stackoverflow.com/questions/35043415/spidermonkey-build-configure

SpiderMonkey variables list

自古美人都是妖i 提交于 2019-12-24 17:24:42
问题 I have a QT application in which I want to embed SpiderMonkey. With it I want to parse javascript segment (not execute it) and retrieve all the variables, functions, objects, arrays, etc. in some kind of a structured tree or just list them... Is that possible? I've looked through the documentation, but could not find anything. Or perhaps someone can point me to another parser if I can't do that with SpiderMonkey? 回答1: If you must do this with a SpiderMonkey embedding, you can use the JS

How to load remote javascript into a SpiderMonkey context?

若如初见. 提交于 2019-12-24 08:25:37
问题 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? 回答1: hope the following example helps: >>> import urllib2 >>> import spidermonkey >>> js = spidermonkey.Runtime() >>> js_ctx = js.new_context() >>> script = urllib2.urlopen('http://etherhack.co.uk/hashing/whirlpool/js/whirlpool.js').read() >>> js_ctx.eval_script(script) >>> js_ctx.eval_script('var s = "abc"') >>> js_ctx.eval_script(

Spidermonkey and Garbage Collection

爱⌒轻易说出口 提交于 2019-12-23 20:14:58
问题 I am embedding Spidermonkey in my C++ application. I need to implementing some custom Javascript functions in native C++ that pass around a jsval. I need to guard the jsval against accidental garbage collection. Is it proper for me to do this: (1) In an init routine: static jsval vp; // a STATIC variable, value unknown JSBool init((JSContext *cx, uintN argc, jsval *vp) { JS_AddValueRoot(cx, &vp); } (2) In one c++ function implementing the Javascript function setter(): JSBool setter(JSContext

How to detect from nodejs which JavaScript engine it is running on?

懵懂的女人 提交于 2019-12-23 10:14:24
问题 There are now several forks of nodejs and some of them support JavaScript engines other than Google's V8 engine. For my node code to see which JS engine it is running under, what is currently the best way? The engines I am aware of are: Google's V8 - The only engine supported by the official node.js and the iojs fork. One of the engines supported by JXcore . Mozilla's SpiderMonkey - One of the engines supported by JXcore . Microsoft's ChakraCore - The engine supported by Microsoft 's port of