spidermonkey

MongoDB SpiderMonkey doesn't understand UTF-8

喜你入骨 提交于 2019-12-18 15:52:39
问题 If I add non-ASCII characters to MongoDB database then all db.find() fail telling "non ascii character detected". It's problem of SpiderMonkey, I have to rebuild it with UTF-8 support. I've tried to do it like in http://www.mongodb.org/display/DOCS/Building+Spider+Monkey but it doesn't work (SpiderMonkey is not installed after I've completed all steps). I've got Ubuntu 11.04. Does anybody have instruction how to make it work there? Working instruction how to make work MongoDB with Google V8

Javascript var vs let (de)optimization/slowdown issue in v8 and SpiderMonkey

早过忘川 提交于 2019-12-18 03:47:33
问题 During JavaScript code refactoring in my project I've found that some of my loops slowed down drastically. Searching for root cause I've found this SO question stating slowdown is caused by let statement inside for loop and closure creation. To my surprise moving let and closure out of the for loop didn't help, and even using var instead of let for loop variable also does not help because slowdown is caused by let placed after the for loop. By removing extra details I've obtained this code

Click on a javascript link within python?

与世无争的帅哥 提交于 2019-12-17 10:31:41
问题 I am navigating a site using python's mechanize module and having trouble clicking on a javascript link for next page. I did a bit of reading and people suggested I need python-spidermonkey and DOMforms. I managed to get them installed by I am not sure of the syntax to actually click on the link. I can identify the code on the page as: <a href="javascript:__doPostBack('ctl00$MainContent$gvSearchResults','Page$2')">2</a> Does anyone know how to click on it? or if perhaps there's another tool.

How does setInterval and setTimeout work?

懵懂的女人 提交于 2019-12-17 10:25:49
问题 I was in an awkward situation , I am working with pure JavaScript for almost 3 years, and I know that JavaScript is single-threaded language, and that you can simulate asynchronous execution using setInterval and setTimeout functions, but when I thought about how they can work I couldn't clearly understand it. So how these functions affect execution context? I suppose that in specific time runs only one part of the code and after it switches to another part. If so, then would a lot of

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

◇◆丶佛笑我妖孽 提交于 2019-12-17 06:38:51
问题 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. 回答1: If it would be possible at all, it would be very dependent on the javascript engine. The more modern javascript engine compile their code using a just in time compiler and messing with their internal variables would be

Preventing Garbage Collection in the Spidermonkey Javascript Engine

无人久伴 提交于 2019-12-12 03:34:27
问题 According the Spidermonkey's User Guide https://developer.mozilla.org/En/SpiderMonkey/JSAPI_User_Guide ... a jsval by itself does not protect its referent from the garbage collector... My understanding of this statement is that if we create a JSString by, say, JS_NewStringCopyZ(), the value returned can be gc'ed at anytime. e.g. JSString *str=JS_NewStringCopyZ(cx, "hello world"); JS_GC(cx); //..now my "hello world" JSString is gone So how do we prevent the str above from being gc'ed? I notice

apply function in JavaScript

拟墨画扇 提交于 2019-12-10 14:52:03
问题 I'm learning JavaScript and I'm currently trying to figure out why (in Spidermonkey) [].concat.apply([1], [[2]]) returns the expected [1, 2] , but Array.concat.apply([1], [[2]]) returns [2] instead of [1, 2] . Could someone provide a good explanation? 回答1: [].concat is Array.prototype.concat . Array.concat is a Firefox-only static method that concatenates one or more arrays and ignores its this argument. 来源: https://stackoverflow.com/questions/8669527/apply-function-in-javascript

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

﹥>﹥吖頭↗ 提交于 2019-12-10 12:23:19
问题 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); // js_id has JavaScript type int c_id; JS_ValueToInt32(cx, js_id, &c_id); // Now, c_id contains the actual value } // of obj.id, as a C native type 回答1: JS_GetProperty() 来源: https://stackoverflow.com/questions/107317/how-do-i-get-the-value-of-a-jsobject

javascript - catch SyntaxError and run alternate function

本秂侑毒 提交于 2019-12-10 01:14:01
问题 I'm trying to build something on javascript that I can have an input that can be everything like string, xml, javascript and (non-javascript string without quotes) as follows: //strings eval("'hello I am a string'"); /* note the following proper quote marks */ //xml eval(<p>Hello I am a XML doc</p>); //javascript eval("var hello = 2+2;"); So this first 3 are working well since they are simple javascript native formats but when I try use this inside javascript //plain-text without quotes eval(