# HG changeset patch # User Atul Varma # Date 1251176019 25200 # Node ID ce8099238c01a283468d2d3959736e43ef8766e4 # Parent d08cb5a06c6647166850907cb953439547adbeca As per a discussion with jorendorff, it looks like we can pass NULL to compile_script(), since we're not using object principals (and instead just using an object capability model for now). diff -r d08cb5a06c66 -r ce8099238c01 docs/src/pymonkey.txt --- a/docs/src/pymonkey.txt Mon Aug 24 11:39:58 2009 -0700 +++ b/docs/src/pymonkey.txt Mon Aug 24 21:53:39 2009 -0700 @@ -184,7 +184,7 @@ >>> cx.evaluate_script(obj, '5 * Math', '', 1) nan - .. method:: compile_script(obj, code, filename, lineno) + .. method:: compile_script(code, filename, lineno) Compiles the given string of code and returns a :class:`Script` instance that can be executed via :meth:`execute_script()`. @@ -192,10 +192,6 @@ `filename` and `lineno` are used just as in :meth:`evaluate_script()`. - `obj` is defined in the SpiderMonkey documentation to be - the "object with which the script is associated", though it's - unclear what its actual role is. - .. method:: execute_script(globalobj, script) Executes the code in the given :class:`Script` object, using @@ -206,8 +202,7 @@ >>> cx = pymonkey.Runtime().new_context() >>> obj = cx.new_object() >>> cx.init_standard_classes(obj) - >>> script = cx.compile_script(cx.new_object(), '5 * Math', - ... '', 1) + >>> script = cx.compile_script('5 * Math', '', 1) >>> cx.execute_script(obj, script) nan diff -r d08cb5a06c66 -r ce8099238c01 src/context.cpp --- a/src/context.cpp Mon Aug 24 11:39:58 2009 -0700 +++ b/src/context.cpp Mon Aug 24 21:53:39 2009 -0700 @@ -315,22 +315,19 @@ PYM_compileScript(PYM_JSContextObject *self, PyObject *args) { PYM_SANITY_CHECK(self->runtime); - PYM_JSObject *object; char *source = NULL; int sourceLen; const char *filename; int lineNo; - if (!PyArg_ParseTuple(args, "O!es#si", &PYM_JSObjectType, &object, - "utf-16", &source, &sourceLen, &filename, &lineNo)) + if (!PyArg_ParseTuple(args, "es#si", "utf-16", &source, &sourceLen, + &filename, &lineNo)) return NULL; PYM_UTF16String str(source, sourceLen); - PYM_ENSURE_RUNTIME_MATCH(self->runtime, object->runtime); - JSScript *script; - script = JS_CompileUCScript(self->cx, object->obj, str.jsbuffer, + script = JS_CompileUCScript(self->cx, NULL, str.jsbuffer, str.jslen, filename, lineNo); if (script == NULL) { diff -r d08cb5a06c66 -r ce8099238c01 tests/test_pymonkey.py --- a/tests/test_pymonkey.py Mon Aug 24 11:39:58 2009 -0700 +++ b/tests/test_pymonkey.py Mon Aug 24 21:53:39 2009 -0700 @@ -20,7 +20,7 @@ cx = rt.new_context() obj = cx.new_object() cx.init_standard_classes(obj) - script = cx.compile_script(obj, code, '', 1) + script = cx.compile_script(code, '', 1) return cx.execute_script(obj, script) def _evalJsWrappedPyFunc(self, func, code): @@ -52,7 +52,7 @@ rt = pymonkey.Runtime() cx = rt.new_context() obj = cx.new_object() - script = cx.compile_script(obj, 'foo', '', 1) + script = cx.compile_script('foo', '', 1) self.assertTrue(len(buffer(script)) > 0) def testCompileScriptWorks(self):