Mercurial > pymonkey
changeset 140:ce8099238c01
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).
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 24 Aug 2009 21:53:39 -0700 |
parents | d08cb5a06c66 |
children | 96dc1beefc00 |
files | docs/src/pymonkey.txt src/context.cpp tests/test_pymonkey.py |
diffstat | 3 files changed, 7 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- 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', '<string>', 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', - ... '<string>', 1) + >>> script = cx.compile_script('5 * Math', '<string>', 1) >>> cx.execute_script(obj, script) nan
--- 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) {
--- 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, '<string>', 1) + script = cx.compile_script(code, '<string>', 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', '<string>', 1) + script = cx.compile_script('foo', '<string>', 1) self.assertTrue(len(buffer(script)) > 0) def testCompileScriptWorks(self):