diff --git a/MANIFEST.in b/MANIFEST.in index 109a7a8..789c7d8 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -5,6 +5,5 @@ include ez_setup.py include go include go.comm include setup.py -include spidermonkey/*.* -include spidermonkey/libjs/*.* +recursive-include spidermonkey * include tests/*.py diff --git a/README.md b/README.md index 6fea2fb..0491fe8 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,11 @@ Execute arbitrary JavaScript code from Python. Allows you to reference arbitrary Python objects and functions in the JavaScript VM +Having issues? +============== + +The project support site can be found at [lighthouseapp.com][lh]. + Requirements ============ @@ -23,9 +28,7 @@ otherwise. Gentoo: -XXX: Can anyone verify this package name? - - $ sudo emerge pkgconfig + $ sudo emerge dev-util/pkgconfig Python Development Files ------------------------ @@ -64,7 +67,7 @@ Debian/Ubuntu: Gentoo: - $ sudo emerge nspr + $ sudo emerge dev-libs/nspr Alternatively you can build from [source][nspr]. If you choose this route make sure that the nspr-config command is on your $PATH when running the install @@ -91,7 +94,7 @@ Debian/Ubuntu: Gentoo: - $ sudo emerge xulrunner + $ sudo emerge net-libs/xulrunner As with [nspr][nspr], you can also build [xulrunner][xulrunner] from source. And as with [nspr][nspr] you need to make sure hat `$PATH` and `$PKG_CONFIG_PATH` are properly set when building the module. @@ -114,12 +117,6 @@ command with the following: $ python setup.py --system-library build -Having Issues? -============== - -Add issues to the Lighthouse project [here][lh]. - - Examples ======== @@ -138,7 +135,8 @@ Basics >>> fruit = Orange() >>> cx.add_global("apple", fruit) >>> cx.execute('"Show me the " + apple.is_ripe("raisin");') - Show me the ripe raisin + u'Show me the ripe raisin' + Playing with Classes -------------------- @@ -152,13 +150,14 @@ Playing with Classes ... >>> rt = spidermonkey.Runtime() >>> cx = rt.new_context() - >>> cx.add_global(Monkey) + >>> cx.add_global("Monkey", Monkey) >>> monkey = cx.execute('var x = new Monkey(); x.baz = "schmammo"; x;') >>> monkey.baz - 'schmammo' + u'schmammo' >>> monkey.__class__.__name__ 'Monkey' + JavaScript Functions -------------------- @@ -167,7 +166,29 @@ JavaScript Functions >>> cx = rt.new_context() >>> func = cx.execute('function(val) {return "whoosh: " + val;}') >>> func("zipper!"); - 'whoosh: zipper!' + u'whoosh: zipper!' + + +Filtering access to Python +-------------------------- + + >>> import spidermonkey + >>> rt = spidermonkey.Runtime() + >>> def checker(obj, name): + ... return not name.startswith("_") + ... + >>> cx = rt.new_context(access=checker) + >>> # Alternatively: + >>> cx.set_access() #doctest: +ELLIPSIS + + >>> cx.set_access(checker) #doctest: +ELLIPSIS + + >>> cx.add_global("fish", {"gold": "gone", "_old_lady": "huzza"}) + >>> cx.execute('fish["_old_lady"];') + Traceback (most recent call last): + ... + JSError: Error executing JavaScript. + Previous Authors ================ diff --git a/THANKS b/THANKS index e9ea8a5..e630ff8 100644 --- a/THANKS +++ b/THANKS @@ -15,6 +15,7 @@ sk89q spahl * Heads up on the signal hack and fix for a compiler warning. * Bug #16 integer property lookup failure report and fix. + * Bug #17 add_property segfault when value is null. Mike West * Reported bug in Context.max_time @@ -24,3 +25,17 @@ Mike West Riccardo Pelizzi * Bug report for global handlers and "function foo() {}" syntax. +Keiji Costantini + * Bug report on the memory limit test. + +Richard Boulton + * Initial patch for filtering Python access. + +marc + * Report on Context turnover causing segfaults. + +Scott T Silliman + * Provided Gentoo package names. + +Roberto De Almeida + * Pointer on MANIFEST.in diff --git a/extra/nspr.pc b/extra/nspr.pc new file mode 100644 index 0000000..2dac9ba --- /dev/null +++ b/extra/nspr.pc @@ -0,0 +1,12 @@ +prefix=/usr/local/ +exec_prefix=${prefix} +libdir=${exec_prefix}/lib +includedir=${prefix}/include + +Name: nspr +Description: nspr library +Version: 4.8.6 +Requires: +Conflicts: +Libs: -L${libdir} -lplds4 -lplc4 -lnspr4 +Cflags: -I${includedir}/nspr diff --git a/old-sm/jsapi.pxi b/old-sm/jsapi.pxi deleted file mode 100644 index 6d6bd55..0000000 --- a/old-sm/jsapi.pxi +++ /dev/null @@ -1,448 +0,0 @@ - - -ctypedef int uint8 -ctypedef int uint16 -ctypedef int uint32 -ctypedef int uintN -ctypedef int size_t - -ctypedef char jschar -ctypedef double jsdouble -ctypedef int jsid -ctypedef int jsint -ctypedef int jsuint -IF UNAME_MACHINE == "x86_64" or UNAME_MACHINE == "amd64": - ctypedef long jsval -ELSE: - ctypedef int jsval -ctypedef int JSBool - -cdef extern from "stdio.h": - cdef int printf(char* format, ...) - -cdef extern from "string.h": - cdef char* strcpy(char* restrict, char* restrict) - cdef void* memcpy(void* dest, void* src, size_t num) - -cdef extern from "stdlib.h": - cdef void* malloc(size_t size) - cdef void free(void* mem) - -cdef extern from "Python.h": - cdef struct PyObject - cdef void Py_DECREF(PyObject* o) - cdef PyObject* PyString_FromStringAndSize(char* buf, size_t length) - cdef int PyString_AsStringAndSize(PyObject* str, char** buf, int* length) - -cdef extern from "jsapi.h": - cdef struct JSClass - cdef struct JSContext - cdef struct JSErrorReport - cdef struct JSFunction - cdef struct JSFunctionSpec - cdef struct JSString - cdef struct JSObject - cdef struct JSObjectOps - cdef struct JSRuntime - cdef struct JSPropertySpec - cdef struct JSXDRState - - cdef enum: - JS_TRUE - JS_FALSE - JSVAL_VOID - JSVAL_INT - JSPROP_ENUMERATE - JSPROP_READONLY - JS_CLASS_NO_INSTANCE - JSCLASS_HAS_PRIVATE - - cdef enum JSType: - JSTYPE_VOID - JSTYPE_OBJECT - JSTYPE_FUNCTION - JSTYPE_STRING - JSTYPE_NUMBER - JSTYPE_BOOLEAN - JSTYPE_LIMIT - - cdef enum JSAccessMode: - JSACC_PROTO = 0 - JSACC_PARENT = 1 - JSACC_IMPORT = 2 - JSACC_WATCH = 3 - JSACC_READ = 4 - JSACC_WRITE = 8 - JSACC_LIMIT - - ctypedef JSBool (*JSPropertyOp) (JSContext* cx, JSObject* obj, jsval id, jsval* vp) - ctypedef JSBool (*JSEnumerateOp) (JSContext* cx, JSObject* obj) - ctypedef JSBool (*JSResolveOp) (JSContext* cx, JSObject* obj, jsval id) - ctypedef JSBool (*JSConvertOp) (JSContext* cx, JSObject* obj, JSType type, jsval* vp) - ctypedef void (*JSFinalizeOp) (JSContext* cx, JSObject* obj) - ctypedef JSObjectOps* (*JSGetObjectOps) (JSContext* cx, JSClass* clasp) - ctypedef JSBool (*JSCheckAccessOp) (JSContext* cx, JSObject* obj, jsval id, JSAccessMode mode, jsval* vp) - ctypedef JSBool (*JSXDRObjectOp) (JSXDRState* xdr, JSObject** objp) - ctypedef JSBool (*JSHasInstanceOp) (JSContext* cx, JSObject* obj, jsval v, JSBool* bp) - ctypedef uint32 (*JSMarkOp) (JSContext* cx, JSObject* obj, void* arg) - ctypedef JSBool (*JSNative) (JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval) - ctypedef void (*JSErrorReporter) (JSContext* cx, char* message, JSErrorReport* report) - - cdef struct JSClass: - char *name - uint32 flags - - # Mandatory non-null function pointer members. - JSPropertyOp addProperty - JSPropertyOp delProperty - JSPropertyOp getProperty - JSPropertyOp setProperty - JSEnumerateOp enumerate - JSResolveOp resolve - JSConvertOp convert - JSFinalizeOp finalize - - # Optionally non-null members start here. - JSGetObjectOps getObjectOps - JSCheckAccessOp checkAccess - JSNative call - JSNative construct - JSXDRObjectOp xdrObject - JSHasInstanceOp hasInstance - JSMarkOp mark - void* reserveSlots - - cdef struct JSErrorReport: - char* filename - uintN lineno - char* linebuf - char* tokenptr - jschar* uclinebuf - jschar* uctokenptr - uintN flags - uintN errorNumber - jschar* ucmessage - jschar** messageArgs - - cdef struct JSFunctionSpec: - char *name - JSNative call - uint8 nargs - uint8 flags - uint16 extra # number of arg slots for local GC roots - - cdef struct JSIdArray: - jsint length - jsid vector[1] # actually, length jsid words - - cdef JSBool JSVAL_IS_BOOLEAN(jsval v) - cdef JSBool JSVAL_IS_DOUBLE(jsval v) - cdef JSBool JSVAL_IS_GCTHING(jsval v) - cdef JSBool JSVAL_IS_INT(jsval v) - cdef JSBool JSVAL_IS_NULL(jsval v) - cdef JSBool JSVAL_IS_NUMBER(jsval v) - cdef JSBool JSVAL_IS_OBJECT(jsval v) - cdef JSBool JSVAL_IS_PRIMITIVE(jsval v) - cdef JSBool JSVAL_IS_STRING(jsval v) - cdef JSBool JSVAL_IS_VOID(jsval v) - - cdef JSBool JSVAL_TO_BOOLEAN(jsval v) - cdef jsdouble* JSVAL_TO_DOUBLE(jsval v) - cdef void* JSVAL_TO_GCTHING(jsval v) - cdef int JSVAL_TO_INT(jsval v) - cdef JSObject* JSVAL_TO_OBJECT(jsval v) - cdef JSString* JSVAL_TO_STRING(jsval v) - cdef void* JSVAL_TO_PRIVATE(jsval v) - cdef JSString* JSVAL_TO_STRING(jsval v) - - cdef jsval BOOLEAN_TO_JSVAL(JSBool b) - cdef jsval DOUBLE_TO_JSVAL(jsdouble* dp) - cdef jsval INT_TO_JSVAL(int i) - cdef jsval OBJECT_TO_JSVAL(JSObject* obj) - cdef jsval PRIVATE_TO_JSVAL(void* p) - cdef jsval STRING_TO_JSVAL(JSString* str) - - cdef int JSVAL_TAG(jsval v) - cdef void JSVAL_SETTAG(jsval v, int t) - cdef void JSVAL_CLRTAG(jsval v) - - # Runtime Functions - cdef JSRuntime* JS_NewRuntime(uint32 maxbytes) - cdef void JS_DestroyRuntime(JSRuntime* rt) - cdef JSContext* JS_ContextIterator(JSRuntime* rt, JSContext** iterp) - - # Context Functions - cdef JSContext* JS_NewContext(JSRuntime* rt, size_t stackChunkSize) - cdef void JS_DestroyContext(JSContext* cx) - cdef JSRuntime* JS_GetRuntime(JSContext* cx) - cdef JSObject* JS_GetGlobalObject(JSContext* cx) - cdef void* JS_GetContextPrivate(JSContext* cx) - cdef void JS_SetContextPrivate(JSContext* cx, void* data) - - # Type Functions - cdef JSType JS_TypeOfValue(JSContext* cx, jsval v) - - # Class Functions - cdef JSBool JS_InitStandardClasses(JSContext* cx, JSObject* obj) - cdef JSObject* JS_GetClassObject(JSClass* klass) - - cdef JSObject* JS_InitClass( - JSContext* cx, - JSObject* obj, - JSObject* parent_proto, - JSClass* clasp, - JSNative constructor, - uintN nargs, - JSPropertySpec* ps, - JSFunctionSpec* fs, - JSPropertySpec* static_ps, - JSFunctionSpec* static_fs - ) - - cdef JSBool JS_PropertyStub(JSContext* cx, JSObject* obj, jsval id, jsval* vp) - cdef JSBool JS_EnumerateStub(JSContext* cx, JSObject* obj) - cdef JSBool JS_ResolveStub(JSContext* cx, JSObject* obj, jsval id) - cdef JSBool JS_ConvertStub(JSContext* cx, JSObject* obj, JSType type, jsval* vp) - cdef void JS_FinalizeStub(JSContext* cx, JSObject* obj) - - # Object Functions - # Create an object as a property of another object. - cdef JSObject* JS_DefineObject( - JSContext* cx, - JSObject* obj, - char* name, - JSClass* clasp, - JSObject* proto, - uintN attrs - ) - - # Create an object - cdef JSObject* JS_NewObject( - JSContext* cx, - JSClass* clasp, - JSObject* proto, - JSObject* parent - ) - - cdef JSClass* JS_GetClass(JSContext* cx, JSObject* obj) - cdef JSObject* JS_GetPrototype(JSContext* cx, JSObject* obj) - cdef JSIdArray* JS_Enumerate(JSContext* cx, JSObject* obj) - cdef void* JS_GetPrivate(JSContext* cx, JSObject* obj) - cdef JSBool JS_SetPrivate(JSContext* cx, JSObject* obj, void* data) - - # Property Methods - cdef JSBool JS_GetUCProperty(JSContext* cx, JSObject* obj, jschar* name, size_t slen, jsval* vp) - cdef JSBool JS_SetUCProperty(JSContext* cx, JSObject* obj, jschar* name, size_t slen, jsval* vp) - cdef JSBool JS_DeleteUCProperty2(JSContext* cx, JSObject* obj, jschar* name, size_t slen, jsval* vp) - - cdef JSBool JS_DefineUCProperty( - JSContext* cx, - JSObject* obj, - jschar* name, - size_t slen, - jsval value, - JSPropertyOp getter, - JSPropertyOp setter, - uintN attrs - ) - - # Array Functions - cdef JSBool JS_IsArrayObject(JSContext* cx, JSObject* obj) - cdef JSObject* JS_NewArrayObject(JSContext* cx, jsint length, jsval* vector) - cdef JSBool JS_GetArrayLength(JSContext* cx, JSObject* obj, jsuint* lengthp) - cdef JSBool JS_GetElement(JSContext* cx, JSObject* obj, jsint index, jsval* vp) - cdef JSBool JS_SetElement(JSContext* cx, JSObject* obj, jsint index, jsval* vp) - - cdef JSBool JS_DefineElement( - JSContext* cx, - JSObject* obj, - jsint index, - jsval value, - JSPropertyOp getter, - JSPropertyOp setter, - uintN attrs - ) - - # Function Functions - cdef char* JS_GetFunctionName(JSFunction* fun) - cdef JSBool JS_ObjectIsFunction(JSContext* cx, JSObject* obj) - cdef JSObject* JS_GetFunctionObject(JSFunction* fun) - cdef JSFunction* JS_ValueToFunction(JSContext* cx, jsval v) - - # Not necessarily specific to functions, but used for the undocumented - # reserved slots. - JSBool JS_GetReservedSlot(JSContext* cx, JSObject* obj, uint32 index, jsval* vp) - JSBool JS_SetReservedSlot(JSContext* cx, JSObject* obj, uint32 index, jsval v) - - # Set a list of functions on an object - cdef JSBool JS_DefineFunctions(JSContext* cx, JSObject* obj, JSFunctionSpec* fs) - - # Create a function property - cdef JSFunction* JS_DefineUCFunction( - JSContext* cx, - JSObject* obj, - char* name, - JSNative call, - uintN nargs, - uintN attrs - ) - - # Create an anonymous function - cdef JSFunction* JS_NewFunction( - JSContext* cx, - JSNative call, - uintN nargs, - uintN flags, - JSObject* parent, - char* name - ) - - # Call a named function - cdef JSBool JS_CallFunctionName( - JSContext* cx, - JSObject* obj, - char* name, - uintN argc, - jsval* argv, - jsval* rval - ) except * - - # Call a function by jsval reference - cdef JSBool JS_CallFunctionValue( - JSContext* cx, - JSObject* obj, - jsval fun, - uintN argc, - jsval* argv, - jsval* rval - ) except * - - # String Functions - cdef JSString* JS_NewUCStringCopyN(JSContext* cx, jschar* s, size_t n) - cdef char* JS_GetStringBytes(JSString* str) - cdef jschar* JS_GetStringChars(JSString* str) - cdef size_t JS_GetStringLength(JSString* str) - - # Double Functions - cdef JSBool JS_NewNumberValue(JSContext* cx, jsdouble d, jsval* rval) - - # IdArray Functions - cdef JSBool JS_IdToValue(JSContext* cx, jsid id, jsval* vp) - cdef void JS_DestroyIdArray(JSContext* cx, JSIdArray* ida) - - # Memory Functions - cdef void JS_GC(JSContext *cx) - cdef void JS_MaybeGC(JSContext* cx) - cdef void JS_free(JSContext* cx, void* p) - cdef JSBool JS_AddRoot(JSContext* cx, void* rp) - cdef JSBool JS_AddNamedRoot(JSContext* cx, void* rp, char* name) - cdef JSBool JS_RemoveRoot(JSContext* cx, void* rp) - - # Error Reporting - cdef JSBool JS_IsExceptionPending(JSContext* cx) - cdef JSBool JS_GetPendingException(JSContext* cx, jsval* vp) - cdef void JS_SetPendingException(JSContext* cx, jsval v) - cdef void JS_ClearPendingException(JSContext* cx) - - cdef JSErrorReporter JS_SetErrorReporter(JSContext* cx, JSErrorReporter er) - cdef void JS_ReportError(JSContext* cx, char* format, ...) - - # Main Entry Functions - cdef JSBool JS_EvaluateUCScript( - JSContext* cx, - JSObject* obj, - jschar* bytes, - uintN length, - char* filename, - uintN lineno, - jsval* rval - ) - -cdef extern from "jshelpers.c": - cdef JSClass js_global_class - cdef JSObject* js_make_global_object(JSContext *cx) - - cdef void js_context_attach(JSContext* cx, PyObject* obj) - cdef JSBool js_context_has_data(JSContext* cx) - cdef object js_context_fetch(JSContext* cx) - cdef object js_context_destroy(JSContext* cx) - - cdef void js_object_attach(JSContext* cx, JSObject* js_obj, PyObject* obj) - cdef JSBool js_object_has_data(JSContext* cx, JSObject* js_obj) - cdef object js_object_fetch(JSContext* cx, JSObject* js_obj) - cdef object js_object_destroy(JSContext* cx, JSObject* js_obj) - - cdef void js_function_attach(JSContext* cx, JSObject* js_obj, PyObject* obj) - cdef JSBool js_function_has_data(JSContext* cx, JSObject* js_obj) - cdef object js_function_fetch(JSContext* cx, JSObject* js_obj) - cdef object js_function_destroy(JSContext* cx, JSObject* js_obj) - - cdef JSString* py2js_jsstring_c(JSContext* cx, PyObject* str) - cdef PyObject* js2py_jsstring_c(JSString* str) - -cdef void* xmalloc(size_t size) except NULL: - cdef void* mem - mem = malloc(size) - if mem == 0: - raise MemoryError() - return mem - -cdef class PyJSString: - cdef JSString* data - - cdef jschar* chars(PyJSString self): - return JS_GetStringChars(self.data) - - cdef size_t length(PyJSString self): - return JS_GetStringLength(self.data) - -cdef PyJSString py2js_jsstring(JSContext* cx, object str): - cdef PyJSString ret - cdef JSString* js_str - js_str = py2js_jsstring_c(cx, str) - if js_str == NULL: - raise UnicodeError("Failed to encode Python string as UTF-16") - ret = PyJSString() - ret.data = js_str - return ret - -cdef object js2py_jsstring(JSString* str): - cdef PyObject* ret - cdef object var - if str == NULL: - raise TypeError("Unable to convert a NULL JSString.") - ret = js2py_jsstring_c(str) - if ret != NULL: - var = ret - return var - -# JavaScript -> Python -cdef class Context -cdef class Function -cdef class GC -cdef class Runtime -cdef class Value - -# Python -> JavaScript -cdef class ClassAdapter -cdef class ObjectAdapter -cdef class FunctionAdapter - -def test_utf_16_round_trip(Context cx, data): - cdef PyJSString conv - conv = py2js_jsstring(cx.cx, data) - return js2py_jsstring(conv.data) - -import inspect -import sys -import traceback -import types - -class JSError(Exception): - def __init__(self, mesg): - self.mesg = mesg - def __str__(self): - return repr(self) - def __repr__(self): - return self.mesg - diff --git a/old-sm/jsarray.pxi b/old-sm/jsarray.pxi deleted file mode 100644 index be56d4b..0000000 --- a/old-sm/jsarray.pxi +++ /dev/null @@ -1,43 +0,0 @@ - -def js_is_array(Context cx, jsval v): - cdef JSObject* obj - if not JSVAL_IS_OBJECT(v): - return False - obj = JSVAL_TO_OBJECT(v) - return JS_IsArrayObject(cx.cx, obj) - -def py_is_array(Context cx, object py_obj): - return isinstance(py_obj, (types.ListType, types.TupleType)) - -cdef object js2py_array(Context cx, jsval v): - cdef jsuint nr_elems - cdef jsval elem - cdef JSObject *jsobj - cdef int i - cdef list ret - - jsobj = JSVAL_TO_OBJECT(v) - JS_GetArrayLength(cx.cx, jsobj, &nr_elems) - ret = [None] * nr_elems - - for i from 0 <= i < nr_elems: - if not JS_GetElement(cx.cx, jsobj, i, &elem): - raise JSError("Failed to convert JavaScript array to Python.") - ret[i] = js2py(cx, elem) - - return ret - -cdef jsval py2js_array(Context cx, list py_obj, JSObject* parent): - cdef int nr_elems, i - cdef JSObject* ret - cdef jsval elem - - nr_elems = len(py_obj) - ret = JS_NewArrayObject(cx.cx, 0, NULL) - - for i from 0 <= i < nr_elems: - elem = py2js(cx, py_obj[i], parent) - if not JS_SetElement(cx.cx, ret, i, &elem): - raise JSError("Failed to convert Python sequence type to JavaScript.") - - return OBJECT_TO_JSVAL(ret) \ No newline at end of file diff --git a/old-sm/jsbool.pxi b/old-sm/jsbool.pxi deleted file mode 100644 index 569e782..0000000 --- a/old-sm/jsbool.pxi +++ /dev/null @@ -1,17 +0,0 @@ -def js_is_bool(Context cx, jsval jsv): - return JSVAL_IS_BOOLEAN(jsv) - -def py_is_bool(Context cx, object py_obj): - return isinstance(py_obj, types.BooleanType) - -cdef object js2py_bool(Context cx, jsval jsv): - if JSVAL_TO_BOOLEAN(jsv): - return True - else: - return False - -cdef jsval py2js_bool(Context cx, object py_obj, JSObject* parent): - if py_obj: - return BOOLEAN_TO_JSVAL(JS_TRUE) - else: - return BOOLEAN_TO_JSVAL(JS_FALSE) diff --git a/old-sm/jsclass.pxi b/old-sm/jsclass.pxi deleted file mode 100644 index 60fea74..0000000 --- a/old-sm/jsclass.pxi +++ /dev/null @@ -1,236 +0,0 @@ - -cdef JSBool __constructor_callback__(JSContext* cx, JSObject* js_obj, uintN argc, jsval* argv, jsval* rval): - cdef Context pycx - cdef ClassAdapter adapter - cdef ObjectAdapter oa - cdef JSObject* proto - cdef int i - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - proto = JS_GetPrototype(cx, js_obj) - if proto == NULL: - raise JSError("Object has no prototype.") - - if not js_object_has_data(cx, proto): - raise JSError("Unknown constructor callback.") - - pycx = js_context_fetch(cx) - adapter = js_object_fetch(cx, proto) - - args = [] - for i from 0 <= i < argc: - args.append(js2py(pycx, argv[i])) - - if hasattr(adapter.py_class, unicode("__jsinit__")): - py_rval = adapter.py_class.__jsinit__(pycx, *args) - else: - py_rval = adapter.py_class(*args) - - rval[0] = py2js(pycx, py_rval, NULL) - - # Register after conversion so we don't keep it around - # if conversion fails. - if JSVAL_IS_OBJECT(rval[0]): - oa = ObjectAdapter(pycx, adapter, None, py_rval) - oa.js_obj = js_obj - js_object_attach(cx, js_obj, oa) - - return JS_TRUE - except: - return report_python_error(cx) - -cdef JSBool __resolve_global_callback__(JSContext* cx, JSObject* js_obj, jsval jsv): - cdef Context pycx - cdef ObjectAdapter adapter - cdef object py_obj - cdef object key - cdef int i - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - pycx = js_context_fetch(cx) - key = js2py(pycx, jsv) - - if not js_object_has_data(cx, js_obj): - return JS_TRUE; - - adapter = js_object_fetch(cx, js_obj) - py_obj = adapter.py_obj - - if isinstance(key, types.UnicodeType) and hasattr(py_obj, key): - pycx.bind(key, getattr(py_obj, key)) - - return JS_TRUE - except: - traceback.print_exc() - return report_python_error(cx) - -cdef JSBool __get_property_callback__(JSContext* cx, JSObject* js_obj, jsval jsv, jsval* rval): - cdef Context pycx - cdef ObjectAdapter adapter - cdef object py_obj - cdef object key - cdef object attr - - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - pycx = js_context_fetch(cx) - key = js2py(pycx, jsv) - - if not js_object_has_data(cx, js_obj): - return JS_TRUE - - adapter = js_object_fetch(cx, js_obj) - py_obj = adapter.py_obj - - if isinstance(key, (types.IntType, types.LongType)): - try: - attr = py_obj[key] - except: - pass - else: - rval[0] = py2js(pycx, attr, NULL) - elif isinstance(key, types.UnicodeType): - if key[:1] != unicode("_"): - try: - attr = getattr(py_obj, key) - except: - pass - else: - rval[0] = py2js(pycx, attr, js_obj) - elif key is None: - rval[0] = JSVAL_VOID - else: - raise AssertionError("Invalid key: %r" % key) - - return JS_TRUE - except: - traceback.print_exc() - return report_python_error(cx) - -cdef JSBool __set_property_callback__(JSContext* cx, JSObject* js_obj, jsval jsv, jsval rval[0]): - cdef Context pycx - cdef ObjectAdapter adapter - cdef object py_obj - cdef object key - cdef object val - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - pycx = js_context_fetch(cx) - key = js2py(pycx, jsv) - value = js2py(pycx, rval[0]) - - if not js_object_has_data(cx, js_obj): - return JS_TRUE - - adapter = js_object_fetch(cx, js_obj) - py_obj = adapter.py_obj - - if isinstance(key, (types.IntType, types.LongType)): - py_obj[key] = value - elif isinstance(key, types.UnicodeType): - if key[:1] != unicode("_") and hasattr(py_obj, key): - attr = getattr(py_obj, key) - if not callable(attr): - setattr(py_obj, key, value) - else: - raise AssertionError("Invalid key: %r" % key) - - return JS_TRUE - except: - traceback.print_exc() - return report_python_error(cx) - - -cdef void __finalize_callback__(JSContext* cx, JSObject* js_obj): - cdef Context pycx - cdef ObjectAdapter py_obj - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - if not js_object_has_data(cx, js_obj): - raise JSError("Unknown JSObject.") - - pycx = js_context_fetch(cx) - py_obj = js_object_destroy(cx, js_obj) - except: - report_python_error(cx) - -def js_classname(obj): - if inspect.isclass(obj): - return obj.__name__ - else: - return obj.__class__.__name__ - -cdef class ClassAdapter: - cdef Context cx - cdef ObjectAdapter parent - cdef JSClass* js_class - cdef object py_class - - def __cinit__(ClassAdapter self, Context cx, ObjectAdapter parent, py_class, bind_constructor, is_global, flags): - cdef JSObject* proto - - self.cx = cx - self.parent = parent - self.py_class = py_class - - if hasattr(py_class, "__jsname__"): - name = py_class.__jsname__ - else: - name = js_classname(py_class) - - self.js_class = xmalloc(sizeof(JSClass)) - self.js_class.name = xmalloc((len(name) + 1) * sizeof(char)) - strcpy(self.js_class.name, name) - - self.js_class.flags = flags | JSCLASS_HAS_PRIVATE - self.js_class.addProperty = JS_PropertyStub - self.js_class.delProperty = JS_PropertyStub - self.js_class.getProperty = __get_property_callback__ - self.js_class.setProperty = __set_property_callback__ - self.js_class.enumerate = JS_EnumerateStub - self.js_class.convert = JS_ConvertStub - self.js_class.finalize = __finalize_callback__ - self.js_class.getObjectOps = NULL - self.js_class.checkAccess = NULL - self.js_class.call = NULL - self.js_class.construct = NULL - self.js_class.xdrObject = NULL - self.js_class.hasInstance = NULL - self.js_class.mark = NULL - self.js_class.reserveSlots = NULL - - if is_global: - self.js_class.resolve = __resolve_global_callback__ - else: - self.js_class.resolve = JS_ResolveStub - - if bind_constructor: - proto = JS_InitClass(self.cx.cx, parent.js_obj, NULL, self.js_class, - __constructor_callback__, 0, NULL, NULL, NULL, NULL) - if proto == NULL: - raise JSError("Failed to bind Python adapter class.") - js_object_attach(cx.cx, proto, self) - - def __repr__(self): - return "" % self.py_class - - def __dealloc__(self): - if self.js_class: - if self.js_class.name: - free(self.js_class.name) - free(self.js_class) diff --git a/old-sm/jscontext.pxi b/old-sm/jscontext.pxi deleted file mode 100644 index 717ef87..0000000 --- a/old-sm/jscontext.pxi +++ /dev/null @@ -1,128 +0,0 @@ - -class JSRootObject(object): - pass - -cdef class Context: - cdef JSContext* cx - cdef Runtime rt - cdef ObjectAdapter root - cdef GC gc - cdef object reg - cdef object classes - cdef object error - - def __cinit__(self, Runtime rt, root): - self.rt = rt - - STACK_CHUNK_SIZE = 8192 - - self.cx = JS_NewContext(rt.rt, STACK_CHUNK_SIZE) - if self.cx == NULL: - raise JSError("Failed to create Context") - - def __init__(Context self, Runtime rt, root): - cdef ClassAdapter ca - cdef JSObject* js_obj - cdef PyObject* py_obj - - self.gc = GC(self) - self.reg = {} - self.classes = {} - self.error = None - - js_context_attach(self.cx, self) - - if not root: - root = JSRootObject() - - ca = self.install_class(root.__class__, False, True) - js_obj = JS_NewObject(self.cx, ca.js_class, NULL, NULL) - if js_obj == NULL: - raise JSError("Failed to create root object.") - self.root = ObjectAdapter(self, ca, None, root) - self.root.js_obj = js_obj - js_object_attach(self.cx, self.root.js_obj, self.root) - - if not JS_InitStandardClasses(self.cx, js_obj): - raise JSError("Failed to initialize standard classes.") - - JS_SetErrorReporter(self.cx, __report_error_callback__) - - def __dealloc__(self): - JS_DestroyContext(self.cx) - - def install_class(self, py_class, bind_constructor=True, is_global=False, flags=0): - """\ - Install a Python class into the JavaScript runtime. - """ - if not inspect.isclass(py_class): - raise TypeError("Unable to install %r as a class." % py_class) - if not isinstance(flags, (types.IntType, types.LongType)): - raise TypeError("Flags is not an integer.") - - if py_class in self.classes: - return self.classes[py_class] - - ca = ClassAdapter(self, self.root, py_class, bind_constructor, is_global, flags) - self.classes[py_class] = ca - return ca - - def bind(Context self, name, obj): - """\ - Attach a Python object to the JavaScript runtime. - - You should be able to attach most types of Python objects - including builtin types, object instances, functions etc. About - the only thing you can't bind is a Python class which should - be isntalled into the JavaScript environment using - Context.install_class - - This call will bind the provided object `obj` to the JS root. The - Python value is also referenced to keep it from being garbage - collected. - """ - cdef ClassAdapter ca - cdef jsval jsv - cdef PyJSString js_str - - js_str = py2js_jsstring(self.cx, name) - - ca = self.install_class(obj.__class__) - jsv = py2js(self, obj, self.root.js_obj) - if not JS_DefineUCProperty(self.cx, self.root.js_obj, js_str.chars(), js_str.length(), jsv, - __get_property_callback__, __set_property_callback__, 0): - raise JSError("Failed to bind Python object to the global object.") - - def unbind(Context self, name): - cdef jsval rval - cdef PyJSString js_str - - js_str = py2js_jsstring(self.cx, name) - - ret = self.execute(name + unicode(";")) # yeah yeah, I know. - if not JS_DeleteUCProperty2(self.cx, self.root.js_obj, js_str.chars(), js_str.length(), &rval): - raise JSError("Failed to unbind property: %s" % name) - # This always returns True for some reason - #return js2py(self, rval) - return ret - - def execute(Context self, script): - """\ - Execute JavaScript source code. - """ - cdef jsval rval - cdef PyJSString js_str - - js_str = py2js_jsstring(self.cx, script) - - try: - if not JS_EvaluateUCScript(self.cx, self.root.js_obj, js_str.chars(), js_str.length(), "Python", 0, &rval): - raise JSError(self.error) - return js2py(self, rval) - finally: - self.gc.run_maybe() - - def set_error(self, mesg): - self.error = mesg - - diff --git a/old-sm/jsdouble.pxi b/old-sm/jsdouble.pxi deleted file mode 100644 index d578481..0000000 --- a/old-sm/jsdouble.pxi +++ /dev/null @@ -1,15 +0,0 @@ - -def js_is_double(Context cx, jsval jsv): - return JSVAL_IS_DOUBLE(jsv) - -def py_is_double(Context cx, object py_obj): - return isinstance(py_obj, types.FloatType) - -cdef object js2py_double(Context cx, jsval jsv): - return JSVAL_TO_DOUBLE(jsv)[0] - -cdef jsval py2js_double(Context cx, double py_obj, JSObject* parent): - cdef jsval ret - if not JS_NewNumberValue(cx.cx, py_obj, &ret): - raise JSError("Failed to convert double.") - return ret diff --git a/old-sm/jserror.pxi b/old-sm/jserror.pxi deleted file mode 100644 index 06177d5..0000000 --- a/old-sm/jserror.pxi +++ /dev/null @@ -1,30 +0,0 @@ - - -cdef JSBool report_python_error(JSContext* cx): - tb = traceback.format_exc() - JS_ReportError(cx, tb) - return JS_FALSE - -cdef void __report_error_callback__(JSContext* cx, char* message, JSErrorReport* report): - cdef Context pycx - - try: - if not js_context_has_data(cx): - sys.stderr.write("Attempting to report error for an unknown JSContext.\n") - return - pycx = js_context_fetch(cx) - - filename = "Unknown" - lineno = "Unknown" - msg = "Unknown" - - if report != NULL: - if report.filename != NULL: - filename = report.filename - lineno = report.lineno - if message != NULL: - msg = message - - pycx.set_error("%s(%d): %s" % (filename, lineno, message)) - except: - traceback.print_exc() diff --git a/old-sm/jsfunction.pxi b/old-sm/jsfunction.pxi deleted file mode 100644 index 5ff9771..0000000 --- a/old-sm/jsfunction.pxi +++ /dev/null @@ -1,164 +0,0 @@ - -cdef class Function: - cdef Context cx - cdef jsval func - - def __init__(Function self, Context cx): - self.cx = cx - - def __call__(Function self, *args): - cdef jsval* argv - cdef jsval rval - cdef jsval jsarg - - nr_args = len(args) - argv = xmalloc(sizeof(jsval) * nr_args) - try: - for i from 0 <= i < nr_args: - arg = args[i] - jsarg = py2js(self.cx, arg, NULL) - argv[i] = jsarg - - if not JS_CallFunctionValue(self.cx.cx, self.cx.root.js_obj, self.func, nr_args, argv, &rval): - raise JSError(self.cx.error) - finally: - free(argv) - - retval = js2py(self.cx, rval) - self.cx.gc.run_maybe() - - return retval - - def __dealloc__(Function self): - JS_RemoveRoot(self.cx.cx, &self.func) - - -cdef class FunctionAdapter: - cdef Context cx - cdef JSObject* js_obj - cdef object py_obj - - def __cinit__(FunctionAdapter self, Context cx, object obj): - self.cx = cx - self.py_obj = obj - - def __repr__(self): - return "" % self.py_obj - - -cdef JSBool __bound_method_callback__(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval): - cdef Context pycx - cdef ObjectAdapter oa - cdef JSFunction* jsfunc - cdef int i - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - pycx = js_context_fetch(cx) - - if not js_object_has_data(cx, obj): - return JS_FALSE - - oa = js_object_fetch(cx, obj) - - jsfunc = JS_ValueToFunction(cx, argv[-2]) - method_name = JS_GetFunctionName(jsfunc) - method = getattr(oa.py_obj, method_name) - - args = [None] * argc - for i from 0 <= i < argc: - args[i] = js2py(pycx, argv[i]) - - py_rval = method(*args) - rval[0] = py2js(pycx, py_rval, obj) - - return JS_TRUE - except: - return report_python_error(cx) - -cdef JSBool __function_callback__(JSContext* cx, JSObject* obj, uintN argc, jsval* argv, jsval* rval): - cdef Context pycx - cdef FunctionAdapter fa - cdef JSFunction* jsfunc - cdef JSObject* jsobj - cdef int i - - try: - if not js_context_has_data(cx): - raise JSError("Unknown JSContext object.") - - pycx = js_context_fetch(cx) - jsfunc = JS_ValueToFunction(cx, argv[-2]) - jsobj = JS_GetFunctionObject(jsfunc) - - if not js_function_has_data(cx, jsobj): - raise JSError("Function call back without attached functor.") - - fa = js_function_fetch(cx, jsobj) - - args = [None] * argc - for i from 0 <= i < argc: - args[i] = js2py(pycx, argv[i]) - - py_rval = fa.py_obj(*args) - rval[0] = py2js(pycx, py_rval, obj) - - return JS_TRUE - except: - return report_python_error(cx) - -def js_is_function(Context cx, jsval jsv): - return JS_TypeOfValue(cx.cx, jsv) == JSTYPE_FUNCTION - -def py_is_function(Context cx, object py_obj): - return isinstance(py_obj, (types.FunctionType, types.LambdaType)) - -def py_is_bound_method(Context cx, object py_obj): - return isinstance(py_obj, types.MethodType) - -cdef object js2py_function(Context cx, jsval jsv): - cdef Function ret - ret = Function(cx) - ret.func = jsv - JS_AddRoot(cx.cx, &ret.func) - return ret - -cdef jsval py2js_bound_method(Context cx, object py_obj, JSObject* parent): - cdef FunctionAdapter fa - cdef JSFunction* func - cdef JSObject* obj - - if hasattr(py_obj, "func_name"): - name = py_obj.func_name - elif hasattr(py_obj, "im_fun") and hasattr(py_obj.im_fun, "func_name"): - name = py_obj.im_fun.func_name - else: - raise JSError("Failed to find function name.") - - func = JS_NewFunction(cx.cx, __bound_method_callback__, 0, 0, NULL, name) - obj = JS_GetFunctionObject(func) - return OBJECT_TO_JSVAL(obj) - -cdef jsval py2js_function(Context cx, object py_obj, JSObject* parent): - cdef FunctionAdapter fa - cdef JSFunction* func - cdef JSObject* obj - cdef jsval slot - - if hasattr(py_obj, "func_name"): - name = py_obj.func_name - elif hasattr(py_obj, "im_fun") and hasattr(py_obj.im_fun, "func_name"): - name = py_obj.im_fun.func_name - else: - raise JSError("Failed to find function name.") - - func = JS_NewFunction(cx.cx, __function_callback__, 0, 0, NULL, name) - fa = FunctionAdapter(cx, py_obj) - fa.js_obj = JS_GetFunctionObject(func) - - js_function_attach(cx.cx, fa.js_obj, fa) - - return OBJECT_TO_JSVAL(fa.js_obj) - \ No newline at end of file diff --git a/old-sm/jsgc.pxi b/old-sm/jsgc.pxi deleted file mode 100644 index 4ed1b52..0000000 --- a/old-sm/jsgc.pxi +++ /dev/null @@ -1,24 +0,0 @@ - -cdef class GC: - cdef Context cx - - def __cinit__(GC self, Context cx): - self.cx = cx - - cdef void run(GC self): - JS_GC(self.cx.cx) - - cdef void run_maybe(GC self): - JS_MaybeGC(self.cx.cx) - - cdef void add_root(GC self, void* rp): - if not JS_AddRoot(self.cx.cx, rp): - raise JSError("Failed to add a GC root") - - cdef void add_named_root(GC self, void* rp, char* name): - if not JS_AddNamedRoot(self.cx.cx, rp, name): - raise JSError("Failed to add a named GC root: %s" % name) - - cdef void rem_root(GC self, void* rp): - if not JS_RemoveRoot(self.cx.cx, rp): - raise JSError("Failed to remove GC root") diff --git a/old-sm/jshash.pxi b/old-sm/jshash.pxi deleted file mode 100644 index 308d550..0000000 --- a/old-sm/jshash.pxi +++ /dev/null @@ -1,67 +0,0 @@ - -def js_is_hash(Context cx, jsval v): - return JSVAL_IS_OBJECT(v) - -def py_is_hash(Context cx, object py_obj): - return isinstance(py_obj, (types.DictionaryType, types.DictType)) - -cdef object js2py_hash(Context cx, jsval v): - cdef JSObject* hash - cdef JSObject *obj - cdef JSIdArray *props - cdef jsval jskey - cdef jsval jsv - cdef int i - cdef dict ret - cdef PyJSString js_str - - hash = JSVAL_TO_OBJECT(v) - - props = JS_Enumerate(cx.cx, hash) - if props == NULL: - raise JSError("Failed to enumerate hash properties.") - - ret = {} - - try: - for i from 0 <= i < props.length: - if not JS_IdToValue(cx.cx, (props.vector)[i], &jskey): - raise JSError("Failed to convert dict to JavaScript.") - - if js_is_string(cx, jskey): - key = js2py_string(cx, jskey) - js_str = py2js_jsstring(cx.cx, key) - - if not JS_GetUCProperty(cx.cx, hash, js_str.chars(), js_str.length(), &jsv): - raise JSError("Faield to retrieve textual hash property.") - elif js_is_int(cx, jskey): - key = js2py_int(cx, jskey) - if not JS_GetElement(cx.cx, hash, key, &jsv): - raise JSError("Failed to retrive numeric hash property.") - else: - raise AssertionError("Invalid JavaScript property.") - - ret[key] = js2py(cx, jsv) - finally: - JS_DestroyIdArray(cx.cx, props) - - return ret - - -cdef jsval py2js_hash(Context cx, dict py_obj, JSObject* parent): - cdef JSObject* obj - cdef jsval elem - cdef PyJSString js_str - - obj = JS_NewObject(cx.cx, NULL, NULL, parent) - if obj == NULL: - raise JSError("Failed to create new JavaScript object for dict instance.") - - for k, v in py_obj.iteritems(): - js_str = py2js_jsstring(cx.cx, k) - elem = py2js(cx, v, obj) - - if not JS_SetUCProperty(cx.cx, obj, js_str.chars(), js_str.length(), &elem): - raise JSError("Failed to set JavaScript property for dict instance.") - - return OBJECT_TO_JSVAL(obj) diff --git a/old-sm/jshelpers.c b/old-sm/jshelpers.c deleted file mode 100644 index cc85bdd..0000000 --- a/old-sm/jshelpers.c +++ /dev/null @@ -1,198 +0,0 @@ -JSString* py2js_jsstring_c(JSContext* cx, PyObject* str) -{ - PyObject* encoded = NULL; - char* bytes; - Py_ssize_t len; - - if(!PyUnicode_Check(str)) - { - return NULL; - } - - encoded = PyUnicode_AsEncodedString(str, "utf-16", "strict"); - if(encoded == NULL) - { - return NULL; - } - - if(PyString_AsStringAndSize(encoded, &bytes, &len) < 0) - { - return NULL; - } - - if(len < 4) - { - return NULL; - } - - // No idea why python adds FFFE to encoded UTF-16 data. - return JS_NewUCStringCopyN(cx, bytes+2, (len/2)-1); -} - -PyObject* js2py_jsstring_c(JSString* str) -{ - jschar* bytes; - size_t len; - - if(str == NULL) - { - return NULL; - } - - len = JS_GetStringLength(str); - bytes = JS_GetStringChars(str); - - return PyUnicode_Decode((const char*) bytes, (size_t) (len * 2), "utf-16", "strict"); -} - -void -js_context_attach(JSContext* cx, PyObject* obj) -{ - Py_XINCREF(obj); - JS_SetContextPrivate(cx, (void*) obj); -} - -JSBool -js_context_has_data(JSContext* cx) -{ - if(JS_GetContextPrivate(cx) == NULL) - { - return JS_FALSE; - } - - return JS_TRUE; -} - -PyObject* -js_context_fetch(JSContext* cx) -{ - PyObject* obj = (PyObject*) JS_GetContextPrivate(cx); - Py_XINCREF(obj); - return obj; -} - -PyObject* -js_context_destroy(JSContext* cx) -{ - PyObject* ret = (PyObject*) JS_GetContextPrivate(cx); - return ret; -} - -void -js_object_attach(JSContext* cx, JSObject* js_obj, PyObject* py_obj) -{ - Py_XINCREF(py_obj); - JS_SetPrivate(cx, js_obj, (void*) py_obj); -} - -JSBool -js_object_has_data(JSContext* cx, JSObject* js_obj) -{ - JSClass* class = JS_GetClass(cx, js_obj); - - if(class == NULL) - { - return JS_FALSE; - } - - if(!(class->flags & JSCLASS_HAS_PRIVATE)) - { - return JS_FALSE; - } - - if(JS_GetPrivate(cx, js_obj) == NULL) - { - return JS_FALSE; - } - - return JS_TRUE; -} - -PyObject* -js_object_fetch(JSContext* cx, JSObject* js_obj) -{ - PyObject* py_obj = (PyObject*) JS_GetPrivate(cx, js_obj); - Py_XINCREF(py_obj); - return py_obj; -} - -PyObject* -js_object_destroy(JSContext* cx, JSObject* js_obj) -{ - return (PyObject*) JS_GetPrivate(cx, js_obj); -} - -void -js_function_attach(JSContext* cx, JSObject* js_obj, PyObject* py_obj) -{ - Py_XINCREF(py_obj); - jsval slot = PRIVATE_TO_JSVAL(py_obj); - JS_SetReservedSlot(cx, js_obj, 0, slot); -} - -JSBool -js_function_has_data(JSContext* cx, JSObject* js_obj) -{ - jsval slot; - if(JS_GetReservedSlot(cx, js_obj, 0, &slot) != JS_TRUE) - { - return JS_FALSE; - } - - void* data = JSVAL_TO_PRIVATE(slot); - - if(data == NULL) - { - return JS_FALSE; - } - - return JS_TRUE; -} - -PyObject* -js_function_fetch(JSContext* cx, JSObject* js_obj) -{ - jsval slot; - if(JS_GetReservedSlot(cx, js_obj, 0, &slot) != JS_TRUE) - { - return JS_FALSE; - } - - PyObject* py_obj = (PyObject*) JSVAL_TO_PRIVATE(slot); - Py_XINCREF(py_obj); - return py_obj; -} - -PyObject* -js_function_destroy(JSContext* cx, JSObject* js_obj) -{ - jsval slot; - if(JS_GetReservedSlot(cx, js_obj, 0, &slot) != JS_TRUE) - { - return JS_FALSE; - } - - PyObject* py_obj = (PyObject*) JSVAL_TO_PRIVATE(slot); - return py_obj; -} - -static JSClass js_global_class = -{ - "RootObjectClass", - JSCLASS_GLOBAL_FLAGS, - JS_PropertyStub, - JS_PropertyStub, - JS_PropertyStub, - JS_PropertyStub, - JS_EnumerateStub, - JS_ResolveStub, - JS_ConvertStub, - JS_FinalizeStub, - JSCLASS_NO_OPTIONAL_MEMBERS -}; - -JSObject * -js_make_global_object(JSContext *cx) -{ - return JS_NewObject(cx, &js_global_class, NULL, NULL); -} diff --git a/old-sm/jsint.pxi b/old-sm/jsint.pxi deleted file mode 100644 index fdc6b8f..0000000 --- a/old-sm/jsint.pxi +++ /dev/null @@ -1,13 +0,0 @@ - -def js_is_int(Context cx, jsval jsv): - return JSVAL_IS_INT(jsv) - -def py_is_int(Context cx, object py_obj): - return isinstance(py_obj, (types.IntType, types.LongType)) - -cdef object js2py_int(Context cx, jsval jsv): - return JSVAL_TO_INT(jsv) - -cdef jsval py2js_int(Context cx, jsint py_obj, JSObject* parent): - return INT_TO_JSVAL(py_obj) - diff --git a/old-sm/jsobject.pxi b/old-sm/jsobject.pxi deleted file mode 100644 index f1d8c76..0000000 --- a/old-sm/jsobject.pxi +++ /dev/null @@ -1,61 +0,0 @@ - -cdef class ObjectAdapter: - cdef Context cx - cdef ClassAdapter cl_adapter - cdef ObjectAdapter parent - cdef JSObject* js_obj - cdef object py_obj - - def __cinit__(ObjectAdapter self, Context cx, ClassAdapter adapter, ObjectAdapter parent, object obj): - self.cx = cx - self.cl_adapter = adapter - self.parent = parent - self.js_obj = NULL - self.py_obj = obj - - def __repr__(self): - return "" % self.py_obj - -def js_is_object(Context cx, jsval jsv): - if not JSVAL_IS_OBJECT(jsv): - return False - if not js_object_has_data(cx.cx, JSVAL_TO_OBJECT(jsv)): - return False - return True - -def py_is_object(Context cx, object py_obj): - return not isinstance(py_obj, types.TypeType) - -cdef object js2py_object(Context cx, jsval jsv): - cdef ClassAdapter ca - cdef ObjectAdapter oa - cdef FunctionAdapter fa - - tmp = js_object_fetch(cx.cx, JSVAL_TO_OBJECT(jsv)) - if isinstance(tmp, ClassAdapter): - ca = tmp - return ca.py_obj - elif isinstance(tmp, ObjectAdapter): - oa = tmp - return oa.py_obj - elif isinstance(tmp, FunctionAdapter): - fa = tmp - return fa.py_obj - else: - raise JSError("Failed to unwrap Python object.") - -cdef jsval py2js_object(Context cx, object py_obj, JSObject* parent): - cdef ClassAdapter ca - cdef ObjectAdapter oa - cdef JSObject* js_obj - cdef jsval rval - - ca = cx.install_class(py_obj.__class__) - js_obj = JS_NewObject(cx.cx, ca.js_class, NULL, NULL) - if js_obj == NULL: - raise JSError("Failed to create object.") - oa = ObjectAdapter(cx, ca, None, py_obj) - oa.js_obj = js_obj - js_object_attach(cx.cx, oa.js_obj, oa) - - return OBJECT_TO_JSVAL(js_obj) diff --git a/old-sm/jsruntime.pxi b/old-sm/jsruntime.pxi deleted file mode 100644 index ab0ee53..0000000 --- a/old-sm/jsruntime.pxi +++ /dev/null @@ -1,15 +0,0 @@ - -cdef class Runtime: - cdef JSRuntime* rt - - def __cinit__(self): - self.rt = JS_NewRuntime(1000000) - if self.rt == NULL: - raise JSError("Failed to create JavaScript Runtime.") - - def __dealloc__(self): - JS_DestroyRuntime(self.rt) - - def create_context(self, root=None): - cx = Context(self, root) - return cx diff --git a/old-sm/jsstring.pxi b/old-sm/jsstring.pxi deleted file mode 100644 index b06f303..0000000 --- a/old-sm/jsstring.pxi +++ /dev/null @@ -1,20 +0,0 @@ - - - -def js_is_string(Context cx, jsval jsv): - return JSVAL_IS_STRING(jsv) - -def py_is_string(Context cx, object py_obj): - if isinstance(py_obj, types.StringTypes): - if not isinstance(py_obj, types.UnicodeType): - raise UnicodeError("Non unicode strings not allowed in spidermonkey.") - return True - return False - -cdef jsval py2js_string(Context cx, object py_obj, JSObject* parent): - cdef PyJSString js_str - js_str = py2js_jsstring(cx.cx, py_obj) - return STRING_TO_JSVAL(js_str.data) - -cdef object js2py_string(Context cx, jsval jsv): - return js2py_jsstring(JSVAL_TO_STRING(jsv)) diff --git a/old-sm/jsvalue.pxi b/old-sm/jsvalue.pxi deleted file mode 100644 index 9dfb346..0000000 --- a/old-sm/jsvalue.pxi +++ /dev/null @@ -1,57 +0,0 @@ - -cdef jsval py2js(Context cx, object py_obj, JSObject* parent) except 0: - if py_is_void(cx, py_obj): - return py2js_void(cx, py_obj, parent) - elif py_is_bool(cx, py_obj): - return py2js_bool(cx, py_obj, parent) - elif py_is_int(cx, py_obj): - return py2js_int(cx, py_obj, parent) - elif py_is_double(cx, py_obj): - return py2js_double(cx, py_obj, parent) - elif py_is_string(cx, py_obj): - return py2js_string(cx, py_obj, parent) - elif py_is_array(cx, py_obj): - return py2js_array(cx, py_obj, parent) - elif py_is_hash(cx, py_obj): - return py2js_hash(cx, py_obj, parent) - elif py_is_bound_method(cx, py_obj): - return py2js_bound_method(cx, py_obj, parent) - elif py_is_function(cx, py_obj): - return py2js_function(cx, py_obj, parent) - elif py_is_object(cx, py_obj): - return py2js_object(cx, py_obj, parent) - #elif py_is_class(cx, py_obj): - # return py2js_class(cx, py_obj, parent) - else: - raise TypeError("Unable to convert Python value to JavaScript: %r" % py_obj) - -cdef object js2py(Context cx, jsval jsv): - if js_is_void(cx, jsv): - return js2py_void(cx, jsv) - elif js_is_bool(cx, jsv): - return js2py_bool(cx, jsv) - elif js_is_int(cx, jsv): - return js2py_int(cx, jsv) - elif js_is_double(cx, jsv): - return js2py_double(cx, jsv) - elif js_is_string(cx, jsv): - return js2py_string(cx, jsv) - elif js_is_array(cx, jsv): - return js2py_array(cx, jsv) - elif js_is_function(cx, jsv): - return js2py_function(cx, jsv) - elif js_is_object(cx, jsv): - return js2py_object(cx, jsv) - elif js_is_hash(cx, jsv): - return js2py_hash(cx, jsv) - else: - raise TypeError("Unable to convert JavaScript value to Python: %r" % jsv) - -cdef class Value: - cdef jsval jsv - -cdef Value js_create_value(jsval jsv): - cdef Value v - v = Value() - v.jsv = jsv - return v diff --git a/old-sm/jsvoid.pxi b/old-sm/jsvoid.pxi deleted file mode 100644 index cae7374..0000000 --- a/old-sm/jsvoid.pxi +++ /dev/null @@ -1,12 +0,0 @@ - -def js_is_void(Context cx, jsval jsv): - return JSVAL_IS_VOID(jsv) or jsv == 0 - -def py_is_void(Context cx, object py_obj): - return isinstance(py_obj, (types.NoneType)) - -cdef object js2py_void(Context cx, jsval jsv): - return None - -cdef jsval py2js_void(Context cx, object py_obj, JSObject* parent): - return JSVAL_VOID diff --git a/old-sm/spidermonkey.c b/old-sm/spidermonkey.c deleted file mode 100644 index 69d402d..0000000 --- a/old-sm/spidermonkey.c +++ /dev/null @@ -1,8164 +0,0 @@ -/* Generated by Pyrex 0.9.8.5 on Fri Feb 27 17:51:12 2009 */ - -#define PY_SSIZE_T_CLEAN -#include "Python.h" -#include "structmember.h" -#ifndef PY_LONG_LONG - #define PY_LONG_LONG LONG_LONG -#endif -#if PY_VERSION_HEX < 0x02050000 - typedef int Py_ssize_t; - #define PY_SSIZE_T_MAX INT_MAX - #define PY_SSIZE_T_MIN INT_MIN - #define PyInt_FromSsize_t(z) PyInt_FromLong(z) - #define PyInt_AsSsize_t(o) PyInt_AsLong(o) -#endif -#if !defined(WIN32) && !defined(MS_WINDOWS) - #ifndef __stdcall - #define __stdcall - #endif - #ifndef __cdecl - #define __cdecl - #endif -#endif -#ifdef __cplusplus -#define __PYX_EXTERN_C extern "C" -#else -#define __PYX_EXTERN_C extern -#endif -#include -#include "stdio.h" -#include "string.h" -#include "stdlib.h" -#include "jsapi.h" -#include "jshelpers.c" - - -typedef struct {PyObject **p; int i; char *s; long n;} __Pyx_StringTabEntry; /*proto*/ - -static PyObject *__pyx_m; -static PyObject *__pyx_b; -static int __pyx_lineno; -static char *__pyx_filename; -static char **__pyx_f; - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb); /*proto*/ - -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name); /*proto*/ - -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name); /*proto*/ - -static void __Pyx_WriteUnraisable(char *name); /*proto*/ - -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type); /*proto*/ - -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb); /*proto*/ - -static int __Pyx_GetStarArgs(PyObject **args, PyObject **kwds, char *kwd_list[], Py_ssize_t nargs, PyObject **args2, PyObject **kwds2, char rqd_kwds[]); /*proto*/ - -static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v); /*proto*/ - -static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i); /*proto*/ - -static PyObject *__Pyx_UnpackItem(PyObject *); /*proto*/ -static int __Pyx_EndUnpack(PyObject *); /*proto*/ - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/ - -static int __Pyx_SetVtable(PyObject *dict, void *vtable); /*proto*/ - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list); /*proto*/ - -static PyObject *__Pyx_CreateClass(PyObject *bases, PyObject *dict, PyObject *name, char *modname); /*proto*/ - -static void __Pyx_AddTraceback(char *funcname); /*proto*/ - -/* Declarations from spidermonkey */ - - -/* Declarations from implementation of spidermonkey */ - -typedef int __pyx_t_12spidermonkey_uint8; - -typedef int __pyx_t_12spidermonkey_uint16; - -typedef int __pyx_t_12spidermonkey_uint32; - -typedef int __pyx_t_12spidermonkey_uintN; - -typedef int __pyx_t_12spidermonkey_size_t; - -typedef char __pyx_t_12spidermonkey_jschar; - -typedef double __pyx_t_12spidermonkey_jsdouble; - -typedef int __pyx_t_12spidermonkey_jsid; - -typedef int __pyx_t_12spidermonkey_jsint; - -typedef int __pyx_t_12spidermonkey_jsuint; - -typedef int __pyx_t_12spidermonkey_jsval; - -typedef int __pyx_t_12spidermonkey_JSBool; - -struct __pyx_obj_12spidermonkey_PyJSString { - PyObject_HEAD - struct __pyx_vtabstruct_12spidermonkey_PyJSString *__pyx_vtab; - struct JSString *data; -}; - -struct __pyx_obj_12spidermonkey_GC { - PyObject_HEAD - struct __pyx_vtabstruct_12spidermonkey_GC *__pyx_vtab; - struct __pyx_obj_12spidermonkey_Context *cx; -}; - -struct __pyx_obj_12spidermonkey_Runtime { - PyObject_HEAD - struct JSRuntime *rt; -}; - -struct __pyx_obj_12spidermonkey_Context { - PyObject_HEAD - struct JSContext *cx; - struct __pyx_obj_12spidermonkey_Runtime *rt; - struct __pyx_obj_12spidermonkey_ObjectAdapter *root; - struct __pyx_obj_12spidermonkey_GC *gc; - PyObject *reg; - PyObject *classes; - PyObject *error; -}; - -struct __pyx_obj_12spidermonkey_ClassAdapter { - PyObject_HEAD - struct __pyx_obj_12spidermonkey_Context *cx; - struct __pyx_obj_12spidermonkey_ObjectAdapter *parent; - struct JSClass *js_class; - PyObject *py_class; -}; - -struct __pyx_obj_12spidermonkey_ObjectAdapter { - PyObject_HEAD - struct __pyx_obj_12spidermonkey_Context *cx; - struct __pyx_obj_12spidermonkey_ClassAdapter *cl_adapter; - struct __pyx_obj_12spidermonkey_ObjectAdapter *parent; - struct JSObject *js_obj; - PyObject *py_obj; -}; - -struct __pyx_obj_12spidermonkey_Function { - PyObject_HEAD - struct __pyx_obj_12spidermonkey_Context *cx; - __pyx_t_12spidermonkey_jsval func; -}; - -struct __pyx_obj_12spidermonkey_FunctionAdapter { - PyObject_HEAD - struct __pyx_obj_12spidermonkey_Context *cx; - struct JSObject *js_obj; - PyObject *py_obj; -}; - -struct __pyx_obj_12spidermonkey_Value { - PyObject_HEAD - __pyx_t_12spidermonkey_jsval jsv; -}; - - -struct __pyx_vtabstruct_12spidermonkey_PyJSString { - __pyx_t_12spidermonkey_jschar *(*chars)(struct __pyx_obj_12spidermonkey_PyJSString *); - __pyx_t_12spidermonkey_size_t (*length)(struct __pyx_obj_12spidermonkey_PyJSString *); -}; -static struct __pyx_vtabstruct_12spidermonkey_PyJSString *__pyx_vtabptr_12spidermonkey_PyJSString; - - - - -struct __pyx_vtabstruct_12spidermonkey_GC { - void (*run)(struct __pyx_obj_12spidermonkey_GC *); - void (*run_maybe)(struct __pyx_obj_12spidermonkey_GC *); - void (*add_root)(struct __pyx_obj_12spidermonkey_GC *,void *); - void (*add_named_root)(struct __pyx_obj_12spidermonkey_GC *,void *,char *); - void (*rem_root)(struct __pyx_obj_12spidermonkey_GC *,void *); -}; -static struct __pyx_vtabstruct_12spidermonkey_GC *__pyx_vtabptr_12spidermonkey_GC; - - - - - - -static PyTypeObject *__pyx_ptype_12spidermonkey_PyJSString = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_Context = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_Function = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_GC = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_Runtime = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_Value = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_ClassAdapter = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_ObjectAdapter = 0; -static PyTypeObject *__pyx_ptype_12spidermonkey_FunctionAdapter = 0; -static void *__pyx_f_12spidermonkey_xmalloc(__pyx_t_12spidermonkey_size_t); /*proto*/ -static struct __pyx_obj_12spidermonkey_PyJSString *__pyx_f_12spidermonkey_py2js_jsstring(struct JSContext *,PyObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_jsstring(struct JSString *); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey_report_python_error(struct JSContext *); /*proto*/ -static void __pyx_f_12spidermonkey___report_error_callback__(struct JSContext *,char *,struct JSErrorReport *); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___constructor_callback__(struct JSContext *,struct JSObject *,__pyx_t_12spidermonkey_uintN,__pyx_t_12spidermonkey_jsval *,__pyx_t_12spidermonkey_jsval *); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___resolve_global_callback__(struct JSContext *,struct JSObject *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___get_property_callback__(struct JSContext *,struct JSObject *,__pyx_t_12spidermonkey_jsval,__pyx_t_12spidermonkey_jsval *); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___set_property_callback__(struct JSContext *,struct JSObject *,__pyx_t_12spidermonkey_jsval,__pyx_t_12spidermonkey_jsval *); /*proto*/ -static void __pyx_f_12spidermonkey___finalize_callback__(struct JSContext *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_object(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_object(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___bound_method_callback__(struct JSContext *,struct JSObject *,__pyx_t_12spidermonkey_uintN,__pyx_t_12spidermonkey_jsval *,__pyx_t_12spidermonkey_jsval *); /*proto*/ -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___function_callback__(struct JSContext *,struct JSObject *,__pyx_t_12spidermonkey_uintN,__pyx_t_12spidermonkey_jsval *,__pyx_t_12spidermonkey_jsval *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_function(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_bound_method(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_function(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_array(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_array(struct __pyx_obj_12spidermonkey_Context *,PyListObject *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_bool(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_bool(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_double(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_double(struct __pyx_obj_12spidermonkey_Context *,double,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_hash(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_hash(struct __pyx_obj_12spidermonkey_Context *,PyDictObject *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_int(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_int(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsint,struct JSObject *); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_string(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_string(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py_void(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_void(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js(struct __pyx_obj_12spidermonkey_Context *,PyObject *,struct JSObject *); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js2py(struct __pyx_obj_12spidermonkey_Context *,__pyx_t_12spidermonkey_jsval); /*proto*/ -static struct __pyx_obj_12spidermonkey_Value *__pyx_f_12spidermonkey_js_create_value(__pyx_t_12spidermonkey_jsval); /*proto*/ - -static char __pyx_k1[] = "Failed to encode Python string as UTF-16"; -static char __pyx_k2[] = "Unable to convert a NULL JSString."; -static char __pyx_k3[] = "mesg"; -static char __pyx_k4[] = "traceback"; -static char __pyx_k5[] = "format_exc"; -static char __pyx_k6[] = "sys"; -static char __pyx_k7[] = "stderr"; -static char __pyx_k8[] = "write"; -static char __pyx_k9[] = "Attempting to report error for an unknown JSContext.\n"; -static char __pyx_k10[] = "Unknown"; -static char __pyx_k11[] = "set_error"; -static char __pyx_k12[] = "%s(%d): %s"; -static char __pyx_k13[] = "print_exc"; -static char __pyx_k14[] = "JSError"; -static char __pyx_k15[] = "Failed to add a GC root"; -static char __pyx_k16[] = "Failed to add a named GC root: %s"; -static char __pyx_k17[] = "Failed to remove GC root"; -static char __pyx_k18[] = "Failed to create JavaScript Runtime."; -static char __pyx_k19[] = "Failed to create Context"; -static char __pyx_k20[] = "JSRootObject"; -static char __pyx_k21[] = "install_class"; -static char __pyx_k22[] = "__class__"; -static char __pyx_k23[] = "Failed to create root object."; -static char __pyx_k24[] = "Failed to initialize standard classes."; -static char __pyx_k25[] = "inspect"; -static char __pyx_k26[] = "isclass"; -static char __pyx_k27[] = "Unable to install %r as a class."; -static char __pyx_k28[] = "types"; -static char __pyx_k29[] = "IntType"; -static char __pyx_k30[] = "LongType"; -static char __pyx_k31[] = "Flags is not an integer."; -static char __pyx_k32[] = "Failed to bind Python object to the global object."; -static char __pyx_k33[] = "execute"; -static char __pyx_k34[] = "unicode"; -static char __pyx_k35[] = ";"; -static char __pyx_k36[] = "Failed to unbind property: %s"; -static char __pyx_k37[] = "Python"; -static char __pyx_k38[] = "Unknown JSContext object."; -static char __pyx_k39[] = "Object has no prototype."; -static char __pyx_k40[] = "Unknown constructor callback."; -static char __pyx_k41[] = "append"; -static char __pyx_k42[] = "__jsinit__"; -static char __pyx_k43[] = "UnicodeType"; -static char __pyx_k44[] = "bind"; -static char __pyx_k45[] = "_"; -static char __pyx_k46[] = "Invalid key: %r"; -static char __pyx_k47[] = "callable"; -static char __pyx_k48[] = "Unknown JSObject."; -static char __pyx_k49[] = "__name__"; -static char __pyx_k50[] = "__jsname__"; -static char __pyx_k51[] = "js_classname"; -static char __pyx_k52[] = "Failed to bind Python adapter class."; -static char __pyx_k53[] = ""; -static char __pyx_k54[] = ""; -static char __pyx_k55[] = "TypeType"; -static char __pyx_k56[] = "py_obj"; -static char __pyx_k57[] = "Failed to unwrap Python object."; -static char __pyx_k58[] = "Failed to create object."; -static char __pyx_k59[] = ""; -static char __pyx_k60[] = "Function call back without attached functor."; -static char __pyx_k61[] = "FunctionType"; -static char __pyx_k62[] = "LambdaType"; -static char __pyx_k63[] = "MethodType"; -static char __pyx_k64[] = "func_name"; -static char __pyx_k65[] = "im_fun"; -static char __pyx_k66[] = "Failed to find function name."; -static char __pyx_k67[] = "ListType"; -static char __pyx_k68[] = "TupleType"; -static char __pyx_k69[] = "Failed to convert JavaScript array to Python."; -static char __pyx_k70[] = "Failed to convert Python sequence type to JavaScript."; -static char __pyx_k71[] = "BooleanType"; -static char __pyx_k72[] = "FloatType"; -static char __pyx_k73[] = "Failed to convert double."; -static char __pyx_k74[] = "DictionaryType"; -static char __pyx_k75[] = "DictType"; -static char __pyx_k76[] = "Failed to enumerate hash properties."; -static char __pyx_k77[] = "Failed to convert dict to JavaScript."; -static char __pyx_k78[] = "js_is_string"; -static char __pyx_k79[] = "Faield to retrieve textual hash property."; -static char __pyx_k80[] = "js_is_int"; -static char __pyx_k81[] = "Failed to retrive numeric hash property."; -static char __pyx_k82[] = "Invalid JavaScript property."; -static char __pyx_k83[] = "Failed to create new JavaScript object for dict instance."; -static char __pyx_k84[] = "iteritems"; -static char __pyx_k85[] = "Failed to set JavaScript property for dict instance."; -static char __pyx_k86[] = "StringTypes"; -static char __pyx_k87[] = "Non unicode strings not allowed in spidermonkey."; -static char __pyx_k88[] = "NoneType"; -static char __pyx_k89[] = "py_is_void"; -static char __pyx_k90[] = "py_is_bool"; -static char __pyx_k91[] = "py_is_int"; -static char __pyx_k92[] = "py_is_double"; -static char __pyx_k93[] = "py_is_string"; -static char __pyx_k94[] = "py_is_array"; -static char __pyx_k95[] = "py_is_hash"; -static char __pyx_k96[] = "py_is_bound_method"; -static char __pyx_k97[] = "py_is_function"; -static char __pyx_k98[] = "py_is_object"; -static char __pyx_k99[] = "Unable to convert Python value to JavaScript: %r"; -static char __pyx_k100[] = "js_is_void"; -static char __pyx_k101[] = "js_is_bool"; -static char __pyx_k102[] = "js_is_double"; -static char __pyx_k103[] = "js_is_array"; -static char __pyx_k104[] = "js_is_function"; -static char __pyx_k105[] = "js_is_object"; -static char __pyx_k106[] = "js_is_hash"; -static char __pyx_k107[] = "Unable to convert JavaScript value to Python: %r"; -static char __pyx_k108[] = "__init__"; -static char __pyx_k109[] = "__str__"; -static char __pyx_k110[] = "__repr__"; -static char __pyx_k111[] = "object"; - -static PyObject *__pyx_n_BooleanType; -static PyObject *__pyx_n_DictType; -static PyObject *__pyx_n_DictionaryType; -static PyObject *__pyx_n_FloatType; -static PyObject *__pyx_n_FunctionType; -static PyObject *__pyx_n_IntType; -static PyObject *__pyx_n_JSError; -static PyObject *__pyx_n_JSRootObject; -static PyObject *__pyx_n_LambdaType; -static PyObject *__pyx_n_ListType; -static PyObject *__pyx_n_LongType; -static PyObject *__pyx_n_MethodType; -static PyObject *__pyx_n_NoneType; -static PyObject *__pyx_n_StringTypes; -static PyObject *__pyx_n_TupleType; -static PyObject *__pyx_n_TypeType; -static PyObject *__pyx_n_UnicodeType; -static PyObject *__pyx_n_Unknown; -static PyObject *__pyx_n__; -static PyObject *__pyx_n___class__; -static PyObject *__pyx_n___init__; -static PyObject *__pyx_n___jsinit__; -static PyObject *__pyx_n___jsname__; -static PyObject *__pyx_n___name__; -static PyObject *__pyx_n___repr__; -static PyObject *__pyx_n___str__; -static PyObject *__pyx_n_append; -static PyObject *__pyx_n_bind; -static PyObject *__pyx_n_callable; -static PyObject *__pyx_n_execute; -static PyObject *__pyx_n_format_exc; -static PyObject *__pyx_n_func_name; -static PyObject *__pyx_n_im_fun; -static PyObject *__pyx_n_inspect; -static PyObject *__pyx_n_install_class; -static PyObject *__pyx_n_isclass; -static PyObject *__pyx_n_iteritems; -static PyObject *__pyx_n_js_classname; -static PyObject *__pyx_n_js_is_array; -static PyObject *__pyx_n_js_is_bool; -static PyObject *__pyx_n_js_is_double; -static PyObject *__pyx_n_js_is_function; -static PyObject *__pyx_n_js_is_hash; -static PyObject *__pyx_n_js_is_int; -static PyObject *__pyx_n_js_is_object; -static PyObject *__pyx_n_js_is_string; -static PyObject *__pyx_n_js_is_void; -static PyObject *__pyx_n_mesg; -static PyObject *__pyx_n_object; -static PyObject *__pyx_n_print_exc; -static PyObject *__pyx_n_py_is_array; -static PyObject *__pyx_n_py_is_bool; -static PyObject *__pyx_n_py_is_bound_method; -static PyObject *__pyx_n_py_is_double; -static PyObject *__pyx_n_py_is_function; -static PyObject *__pyx_n_py_is_hash; -static PyObject *__pyx_n_py_is_int; -static PyObject *__pyx_n_py_is_object; -static PyObject *__pyx_n_py_is_string; -static PyObject *__pyx_n_py_is_void; -static PyObject *__pyx_n_py_obj; -static PyObject *__pyx_n_set_error; -static PyObject *__pyx_n_stderr; -static PyObject *__pyx_n_sys; -static PyObject *__pyx_n_traceback; -static PyObject *__pyx_n_types; -static PyObject *__pyx_n_unicode; -static PyObject *__pyx_n_write; - -static PyObject *__pyx_k1p; -static PyObject *__pyx_k2p; -static PyObject *__pyx_k9p; -static PyObject *__pyx_k12p; -static PyObject *__pyx_k15p; -static PyObject *__pyx_k16p; -static PyObject *__pyx_k17p; -static PyObject *__pyx_k18p; -static PyObject *__pyx_k19p; -static PyObject *__pyx_k23p; -static PyObject *__pyx_k24p; -static PyObject *__pyx_k27p; -static PyObject *__pyx_k31p; -static PyObject *__pyx_k32p; -static PyObject *__pyx_k35p; -static PyObject *__pyx_k36p; -static PyObject *__pyx_k38p; -static PyObject *__pyx_k39p; -static PyObject *__pyx_k40p; -static PyObject *__pyx_k46p; -static PyObject *__pyx_k48p; -static PyObject *__pyx_k52p; -static PyObject *__pyx_k53p; -static PyObject *__pyx_k54p; -static PyObject *__pyx_k57p; -static PyObject *__pyx_k58p; -static PyObject *__pyx_k59p; -static PyObject *__pyx_k60p; -static PyObject *__pyx_k66p; -static PyObject *__pyx_k69p; -static PyObject *__pyx_k70p; -static PyObject *__pyx_k73p; -static PyObject *__pyx_k76p; -static PyObject *__pyx_k77p; -static PyObject *__pyx_k79p; -static PyObject *__pyx_k81p; -static PyObject *__pyx_k82p; -static PyObject *__pyx_k83p; -static PyObject *__pyx_k85p; -static PyObject *__pyx_k87p; -static PyObject *__pyx_k99p; -static PyObject *__pyx_k107p; - -static __Pyx_StringTabEntry __pyx_string_tab[] = { - {&__pyx_n_BooleanType, 1, __pyx_k71, sizeof(__pyx_k71)}, - {&__pyx_n_DictType, 1, __pyx_k75, sizeof(__pyx_k75)}, - {&__pyx_n_DictionaryType, 1, __pyx_k74, sizeof(__pyx_k74)}, - {&__pyx_n_FloatType, 1, __pyx_k72, sizeof(__pyx_k72)}, - {&__pyx_n_FunctionType, 1, __pyx_k61, sizeof(__pyx_k61)}, - {&__pyx_n_IntType, 1, __pyx_k29, sizeof(__pyx_k29)}, - {&__pyx_n_JSError, 1, __pyx_k14, sizeof(__pyx_k14)}, - {&__pyx_n_JSRootObject, 1, __pyx_k20, sizeof(__pyx_k20)}, - {&__pyx_n_LambdaType, 1, __pyx_k62, sizeof(__pyx_k62)}, - {&__pyx_n_ListType, 1, __pyx_k67, sizeof(__pyx_k67)}, - {&__pyx_n_LongType, 1, __pyx_k30, sizeof(__pyx_k30)}, - {&__pyx_n_MethodType, 1, __pyx_k63, sizeof(__pyx_k63)}, - {&__pyx_n_NoneType, 1, __pyx_k88, sizeof(__pyx_k88)}, - {&__pyx_n_StringTypes, 1, __pyx_k86, sizeof(__pyx_k86)}, - {&__pyx_n_TupleType, 1, __pyx_k68, sizeof(__pyx_k68)}, - {&__pyx_n_TypeType, 1, __pyx_k55, sizeof(__pyx_k55)}, - {&__pyx_n_UnicodeType, 1, __pyx_k43, sizeof(__pyx_k43)}, - {&__pyx_n_Unknown, 1, __pyx_k10, sizeof(__pyx_k10)}, - {&__pyx_n__, 1, __pyx_k45, sizeof(__pyx_k45)}, - {&__pyx_n___class__, 1, __pyx_k22, sizeof(__pyx_k22)}, - {&__pyx_n___init__, 1, __pyx_k108, sizeof(__pyx_k108)}, - {&__pyx_n___jsinit__, 1, __pyx_k42, sizeof(__pyx_k42)}, - {&__pyx_n___jsname__, 1, __pyx_k50, sizeof(__pyx_k50)}, - {&__pyx_n___name__, 1, __pyx_k49, sizeof(__pyx_k49)}, - {&__pyx_n___repr__, 1, __pyx_k110, sizeof(__pyx_k110)}, - {&__pyx_n___str__, 1, __pyx_k109, sizeof(__pyx_k109)}, - {&__pyx_n_append, 1, __pyx_k41, sizeof(__pyx_k41)}, - {&__pyx_n_bind, 1, __pyx_k44, sizeof(__pyx_k44)}, - {&__pyx_n_callable, 1, __pyx_k47, sizeof(__pyx_k47)}, - {&__pyx_n_execute, 1, __pyx_k33, sizeof(__pyx_k33)}, - {&__pyx_n_format_exc, 1, __pyx_k5, sizeof(__pyx_k5)}, - {&__pyx_n_func_name, 1, __pyx_k64, sizeof(__pyx_k64)}, - {&__pyx_n_im_fun, 1, __pyx_k65, sizeof(__pyx_k65)}, - {&__pyx_n_inspect, 1, __pyx_k25, sizeof(__pyx_k25)}, - {&__pyx_n_install_class, 1, __pyx_k21, sizeof(__pyx_k21)}, - {&__pyx_n_isclass, 1, __pyx_k26, sizeof(__pyx_k26)}, - {&__pyx_n_iteritems, 1, __pyx_k84, sizeof(__pyx_k84)}, - {&__pyx_n_js_classname, 1, __pyx_k51, sizeof(__pyx_k51)}, - {&__pyx_n_js_is_array, 1, __pyx_k103, sizeof(__pyx_k103)}, - {&__pyx_n_js_is_bool, 1, __pyx_k101, sizeof(__pyx_k101)}, - {&__pyx_n_js_is_double, 1, __pyx_k102, sizeof(__pyx_k102)}, - {&__pyx_n_js_is_function, 1, __pyx_k104, sizeof(__pyx_k104)}, - {&__pyx_n_js_is_hash, 1, __pyx_k106, sizeof(__pyx_k106)}, - {&__pyx_n_js_is_int, 1, __pyx_k80, sizeof(__pyx_k80)}, - {&__pyx_n_js_is_object, 1, __pyx_k105, sizeof(__pyx_k105)}, - {&__pyx_n_js_is_string, 1, __pyx_k78, sizeof(__pyx_k78)}, - {&__pyx_n_js_is_void, 1, __pyx_k100, sizeof(__pyx_k100)}, - {&__pyx_n_mesg, 1, __pyx_k3, sizeof(__pyx_k3)}, - {&__pyx_n_object, 1, __pyx_k111, sizeof(__pyx_k111)}, - {&__pyx_n_print_exc, 1, __pyx_k13, sizeof(__pyx_k13)}, - {&__pyx_n_py_is_array, 1, __pyx_k94, sizeof(__pyx_k94)}, - {&__pyx_n_py_is_bool, 1, __pyx_k90, sizeof(__pyx_k90)}, - {&__pyx_n_py_is_bound_method, 1, __pyx_k96, sizeof(__pyx_k96)}, - {&__pyx_n_py_is_double, 1, __pyx_k92, sizeof(__pyx_k92)}, - {&__pyx_n_py_is_function, 1, __pyx_k97, sizeof(__pyx_k97)}, - {&__pyx_n_py_is_hash, 1, __pyx_k95, sizeof(__pyx_k95)}, - {&__pyx_n_py_is_int, 1, __pyx_k91, sizeof(__pyx_k91)}, - {&__pyx_n_py_is_object, 1, __pyx_k98, sizeof(__pyx_k98)}, - {&__pyx_n_py_is_string, 1, __pyx_k93, sizeof(__pyx_k93)}, - {&__pyx_n_py_is_void, 1, __pyx_k89, sizeof(__pyx_k89)}, - {&__pyx_n_py_obj, 1, __pyx_k56, sizeof(__pyx_k56)}, - {&__pyx_n_set_error, 1, __pyx_k11, sizeof(__pyx_k11)}, - {&__pyx_n_stderr, 1, __pyx_k7, sizeof(__pyx_k7)}, - {&__pyx_n_sys, 1, __pyx_k6, sizeof(__pyx_k6)}, - {&__pyx_n_traceback, 1, __pyx_k4, sizeof(__pyx_k4)}, - {&__pyx_n_types, 1, __pyx_k28, sizeof(__pyx_k28)}, - {&__pyx_n_unicode, 1, __pyx_k34, sizeof(__pyx_k34)}, - {&__pyx_n_write, 1, __pyx_k8, sizeof(__pyx_k8)}, - {&__pyx_k1p, 0, __pyx_k1, sizeof(__pyx_k1)}, - {&__pyx_k2p, 0, __pyx_k2, sizeof(__pyx_k2)}, - {&__pyx_k9p, 0, __pyx_k9, sizeof(__pyx_k9)}, - {&__pyx_k12p, 0, __pyx_k12, sizeof(__pyx_k12)}, - {&__pyx_k15p, 0, __pyx_k15, sizeof(__pyx_k15)}, - {&__pyx_k16p, 0, __pyx_k16, sizeof(__pyx_k16)}, - {&__pyx_k17p, 0, __pyx_k17, sizeof(__pyx_k17)}, - {&__pyx_k18p, 0, __pyx_k18, sizeof(__pyx_k18)}, - {&__pyx_k19p, 0, __pyx_k19, sizeof(__pyx_k19)}, - {&__pyx_k23p, 0, __pyx_k23, sizeof(__pyx_k23)}, - {&__pyx_k24p, 0, __pyx_k24, sizeof(__pyx_k24)}, - {&__pyx_k27p, 0, __pyx_k27, sizeof(__pyx_k27)}, - {&__pyx_k31p, 0, __pyx_k31, sizeof(__pyx_k31)}, - {&__pyx_k32p, 0, __pyx_k32, sizeof(__pyx_k32)}, - {&__pyx_k35p, 0, __pyx_k35, sizeof(__pyx_k35)}, - {&__pyx_k36p, 0, __pyx_k36, sizeof(__pyx_k36)}, - {&__pyx_k38p, 0, __pyx_k38, sizeof(__pyx_k38)}, - {&__pyx_k39p, 0, __pyx_k39, sizeof(__pyx_k39)}, - {&__pyx_k40p, 0, __pyx_k40, sizeof(__pyx_k40)}, - {&__pyx_k46p, 0, __pyx_k46, sizeof(__pyx_k46)}, - {&__pyx_k48p, 0, __pyx_k48, sizeof(__pyx_k48)}, - {&__pyx_k52p, 0, __pyx_k52, sizeof(__pyx_k52)}, - {&__pyx_k53p, 0, __pyx_k53, sizeof(__pyx_k53)}, - {&__pyx_k54p, 0, __pyx_k54, sizeof(__pyx_k54)}, - {&__pyx_k57p, 0, __pyx_k57, sizeof(__pyx_k57)}, - {&__pyx_k58p, 0, __pyx_k58, sizeof(__pyx_k58)}, - {&__pyx_k59p, 0, __pyx_k59, sizeof(__pyx_k59)}, - {&__pyx_k60p, 0, __pyx_k60, sizeof(__pyx_k60)}, - {&__pyx_k66p, 0, __pyx_k66, sizeof(__pyx_k66)}, - {&__pyx_k69p, 0, __pyx_k69, sizeof(__pyx_k69)}, - {&__pyx_k70p, 0, __pyx_k70, sizeof(__pyx_k70)}, - {&__pyx_k73p, 0, __pyx_k73, sizeof(__pyx_k73)}, - {&__pyx_k76p, 0, __pyx_k76, sizeof(__pyx_k76)}, - {&__pyx_k77p, 0, __pyx_k77, sizeof(__pyx_k77)}, - {&__pyx_k79p, 0, __pyx_k79, sizeof(__pyx_k79)}, - {&__pyx_k81p, 0, __pyx_k81, sizeof(__pyx_k81)}, - {&__pyx_k82p, 0, __pyx_k82, sizeof(__pyx_k82)}, - {&__pyx_k83p, 0, __pyx_k83, sizeof(__pyx_k83)}, - {&__pyx_k85p, 0, __pyx_k85, sizeof(__pyx_k85)}, - {&__pyx_k87p, 0, __pyx_k87, sizeof(__pyx_k87)}, - {&__pyx_k99p, 0, __pyx_k99, sizeof(__pyx_k99)}, - {&__pyx_k107p, 0, __pyx_k107, sizeof(__pyx_k107)}, - {0, 0, 0, 0} -}; - -static PyObject *__pyx_d1; -static PyObject *__pyx_d2; -static PyObject *__pyx_d3; -static PyObject *__pyx_d4; - - -/* Implementation of spidermonkey */ - -static void *__pyx_f_12spidermonkey_xmalloc(__pyx_t_12spidermonkey_size_t __pyx_v_size) { - void *__pyx_v_mem; - void *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":385 */ - __pyx_v_mem = malloc(__pyx_v_size); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":386 */ - __pyx_1 = (((int)__pyx_v_mem) == 0); - if (__pyx_1) { - __pyx_2 = PyObject_CallObject(PyExc_MemoryError, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 387; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":388 */ - __pyx_r = __pyx_v_mem; - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.xmalloc"); - __pyx_r = NULL; - __pyx_L0:; - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jschar *__pyx_f_12spidermonkey_10PyJSString_chars(struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_self) { - __pyx_t_12spidermonkey_jschar *__pyx_r; - Py_INCREF(__pyx_v_self); - __pyx_r = JS_GetStringChars(__pyx_v_self->data); - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_size_t __pyx_f_12spidermonkey_10PyJSString_length(struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_self) { - __pyx_t_12spidermonkey_size_t __pyx_r; - Py_INCREF(__pyx_v_self); - __pyx_r = JS_GetStringLength(__pyx_v_self->data); - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static struct __pyx_obj_12spidermonkey_PyJSString *__pyx_f_12spidermonkey_py2js_jsstring(struct JSContext *__pyx_v_cx,PyObject *__pyx_v_str) { - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_ret; - struct JSString *__pyx_v_js_str; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - Py_INCREF(__pyx_v_str); - __pyx_v_ret = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":402 */ - __pyx_v_js_str = py2js_jsstring_c(__pyx_v_cx,((struct PyObject *)__pyx_v_str)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":403 */ - __pyx_1 = (__pyx_v_js_str == NULL); - if (__pyx_1) { - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;} - Py_INCREF(__pyx_k1p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k1p); - __pyx_3 = PyObject_CallObject(PyExc_UnicodeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 404; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":405 */ - __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_PyJSString), 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_ret)); - __pyx_v_ret = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":406 */ - __pyx_v_ret->data = __pyx_v_js_str; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":407 */ - Py_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - __pyx_r = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.py2js_jsstring"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ret); - Py_DECREF(__pyx_v_str); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_jsstring(struct JSString *__pyx_v_str) { - struct PyObject *__pyx_v_ret; - PyObject *__pyx_v_var; - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - __pyx_v_var = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":412 */ - __pyx_1 = (__pyx_v_str == NULL); - if (__pyx_1) { - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; goto __pyx_L1;} - Py_INCREF(__pyx_k2p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k2p); - __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[0]; __pyx_lineno = 413; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":414 */ - __pyx_v_ret = js2py_jsstring_c(__pyx_v_str); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":415 */ - __pyx_1 = (__pyx_v_ret != NULL); - if (__pyx_1) { - Py_INCREF(((PyObject *)__pyx_v_ret)); - Py_DECREF(__pyx_v_var); - __pyx_v_var = ((PyObject *)__pyx_v_ret); - goto __pyx_L3; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":417 */ - Py_INCREF(__pyx_v_var); - __pyx_r = __pyx_v_var; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.js2py_jsstring"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_var); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_test_utf_16_round_trip(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_test_utf_16_round_trip(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_data = 0; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_conv; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","data",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_data)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_data); - __pyx_v_conv = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 431; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":433 */ - __pyx_1 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(__pyx_v_cx->cx,__pyx_v_data)); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 433; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_conv)); - __pyx_v_conv = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_1); - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":434 */ - __pyx_1 = __pyx_f_12spidermonkey_js2py_jsstring(__pyx_v_conv->data); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.test_utf_16_round_trip"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_conv); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_data); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7JSError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_12spidermonkey_7JSError___init__ = {"__init__", (PyCFunction)__pyx_f_12spidermonkey_7JSError___init__, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_f_12spidermonkey_7JSError___init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_self = 0; - PyObject *__pyx_v_mesg = 0; - PyObject *__pyx_r; - static char *__pyx_argnames[] = {"self","mesg",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_self, &__pyx_v_mesg)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_mesg); - if (PyObject_SetAttr(__pyx_v_self, __pyx_n_mesg, __pyx_v_mesg) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 443; goto __pyx_L1;} - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("spidermonkey.JSError.__init__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_mesg); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7JSError___str__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_12spidermonkey_7JSError___str__ = {"__str__", (PyCFunction)__pyx_f_12spidermonkey_7JSError___str__, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_f_12spidermonkey_7JSError___str__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_self = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"self",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_self)) return 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = PyObject_Repr(__pyx_v_self); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 445; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.JSError.__str__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7JSError___repr__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyMethodDef __pyx_mdef_12spidermonkey_7JSError___repr__ = {"__repr__", (PyCFunction)__pyx_f_12spidermonkey_7JSError___repr__, METH_VARARGS|METH_KEYWORDS, 0}; -static PyObject *__pyx_f_12spidermonkey_7JSError___repr__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_self = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"self",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_self)) return 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_mesg); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 447; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.JSError.__repr__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey_report_python_error(struct JSContext *__pyx_v_cx) { - PyObject *__pyx_v_tb; - __pyx_t_12spidermonkey_JSBool __pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - char *__pyx_3; - __pyx_v_tb = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":4 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_traceback); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 4; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_format_exc); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 4; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 4; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_v_tb); - __pyx_v_tb = __pyx_1; - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":5 */ - __pyx_3 = PyString_AsString(__pyx_v_tb); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 5; goto __pyx_L1;} - JS_ReportError(__pyx_v_cx,__pyx_3); - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":6 */ - __pyx_r = JS_FALSE; - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_WriteUnraisable("spidermonkey.report_python_error"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_tb); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey___report_error_callback__(struct JSContext *__pyx_v_cx,char *__pyx_v_message,struct JSErrorReport *__pyx_v_report) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - PyObject *__pyx_v_filename; - PyObject *__pyx_v_lineno; - PyObject *__pyx_v_msg; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - PyObject *__pyx_6 = 0; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_filename = Py_None; Py_INCREF(Py_None); - __pyx_v_lineno = Py_None; Py_INCREF(Py_None); - __pyx_v_msg = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":11 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":12 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":13 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_sys); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; goto __pyx_L2;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_stderr); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_write); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; goto __pyx_L2;} - Py_INCREF(__pyx_k9p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k9p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 13; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":14 */ - goto __pyx_L0; - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":15 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":17 */ - Py_INCREF(__pyx_n_Unknown); - Py_DECREF(__pyx_v_filename); - __pyx_v_filename = __pyx_n_Unknown; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":18 */ - Py_INCREF(__pyx_n_Unknown); - Py_DECREF(__pyx_v_lineno); - __pyx_v_lineno = __pyx_n_Unknown; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":19 */ - Py_INCREF(__pyx_n_Unknown); - Py_DECREF(__pyx_v_msg); - __pyx_v_msg = __pyx_n_Unknown; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":21 */ - __pyx_1 = (__pyx_v_report != NULL); - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":22 */ - __pyx_1 = (__pyx_v_report->filename != NULL); - if (__pyx_1) { - __pyx_3 = PyString_FromString(__pyx_v_report->filename); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 23; goto __pyx_L2;} - Py_DECREF(__pyx_v_filename); - __pyx_v_filename = __pyx_3; - __pyx_3 = 0; - goto __pyx_L6; - } - __pyx_L6:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":24 */ - __pyx_4 = PyInt_FromLong(__pyx_v_report->lineno); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 24; goto __pyx_L2;} - Py_DECREF(__pyx_v_lineno); - __pyx_v_lineno = __pyx_4; - __pyx_4 = 0; - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":25 */ - __pyx_1 = (__pyx_v_message != NULL); - if (__pyx_1) { - __pyx_2 = PyString_FromString(__pyx_v_message); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 26; goto __pyx_L2;} - Py_DECREF(__pyx_v_msg); - __pyx_v_msg = __pyx_2; - __pyx_2 = 0; - goto __pyx_L7; - } - __pyx_L7:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":28 */ - __pyx_3 = PyObject_GetAttr(((PyObject *)__pyx_v_pycx), __pyx_n_set_error); if (!__pyx_3) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L2;} - __pyx_4 = PyString_FromString(__pyx_v_message); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L2;} - __pyx_2 = PyTuple_New(3); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L2;} - Py_INCREF(__pyx_v_filename); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_filename); - Py_INCREF(__pyx_v_lineno); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_lineno); - PyTuple_SET_ITEM(__pyx_2, 2, __pyx_4); - __pyx_4 = 0; - __pyx_4 = PyNumber_Remainder(__pyx_k12p, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L2;} - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); - __pyx_4 = 0; - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 28; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jserror.pxi":29 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__report_error_callback__"); - if (__Pyx_GetException(&__pyx_3, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 29; goto __pyx_L1;} - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_traceback); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_print_exc); if (!__pyx_6) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(__pyx_6); __pyx_6 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_6); - __Pyx_WriteUnraisable("spidermonkey.__report_error_callback__"); - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_filename); - Py_DECREF(__pyx_v_lineno); - Py_DECREF(__pyx_v_msg); -} - -static int __pyx_f_12spidermonkey_2GC___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_2GC___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - int __pyx_r; - static char *__pyx_argnames[] = {"cx",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_cx)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 5; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_GC *)__pyx_v_self)->cx)); - ((struct __pyx_obj_12spidermonkey_GC *)__pyx_v_self)->cx = __pyx_v_cx; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("spidermonkey.GC.__cinit__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey_2GC_run(struct __pyx_obj_12spidermonkey_GC *__pyx_v_self) { - Py_INCREF(__pyx_v_self); - JS_GC(__pyx_v_self->cx->cx); - - Py_DECREF(__pyx_v_self); -} - -static void __pyx_f_12spidermonkey_2GC_run_maybe(struct __pyx_obj_12spidermonkey_GC *__pyx_v_self) { - Py_INCREF(__pyx_v_self); - JS_MaybeGC(__pyx_v_self->cx->cx); - - Py_DECREF(__pyx_v_self); -} - -static void __pyx_f_12spidermonkey_2GC_add_root(struct __pyx_obj_12spidermonkey_GC *__pyx_v_self,void *__pyx_v_rp) { - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = (!JS_AddRoot(__pyx_v_self->cx->cx,__pyx_v_rp)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; goto __pyx_L1;} - Py_INCREF(__pyx_k15p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k15p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 16; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.GC.add_root"); - __pyx_L0:; - Py_DECREF(__pyx_v_self); -} - -static void __pyx_f_12spidermonkey_2GC_add_named_root(struct __pyx_obj_12spidermonkey_GC *__pyx_v_self,void *__pyx_v_rp,char *__pyx_v_name) { - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = (!JS_AddNamedRoot(__pyx_v_self->cx->cx,__pyx_v_rp,__pyx_v_name)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} - __pyx_3 = PyString_FromString(__pyx_v_name); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} - __pyx_4 = PyNumber_Remainder(__pyx_k16p, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); - __pyx_4 = 0; - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 20; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.GC.add_named_root"); - __pyx_L0:; - Py_DECREF(__pyx_v_self); -} - -static void __pyx_f_12spidermonkey_2GC_rem_root(struct __pyx_obj_12spidermonkey_GC *__pyx_v_self,void *__pyx_v_rp) { - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = (!JS_RemoveRoot(__pyx_v_self->cx->cx,__pyx_v_rp)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 24; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 24; goto __pyx_L1;} - Py_INCREF(__pyx_k17p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k17p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 24; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[2]; __pyx_lineno = 24; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.GC.rem_root"); - __pyx_L0:; - Py_DECREF(__pyx_v_self); -} - -static int __pyx_f_12spidermonkey_7Runtime___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_7Runtime___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - int __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - static char *__pyx_argnames[] = {0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) return -1; - Py_INCREF(__pyx_v_self); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsruntime.pxi":6 */ - ((struct __pyx_obj_12spidermonkey_Runtime *)__pyx_v_self)->rt = JS_NewRuntime(1000000); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsruntime.pxi":7 */ - __pyx_1 = (((struct __pyx_obj_12spidermonkey_Runtime *)__pyx_v_self)->rt == NULL); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; goto __pyx_L1;} - Py_INCREF(__pyx_k18p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k18p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[3]; __pyx_lineno = 8; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey.Runtime.__cinit__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey_7Runtime___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_f_12spidermonkey_7Runtime___dealloc__(PyObject *__pyx_v_self) { - Py_INCREF(__pyx_v_self); - JS_DestroyRuntime(((struct __pyx_obj_12spidermonkey_Runtime *)__pyx_v_self)->rt); - - Py_DECREF(__pyx_v_self); -} - -static PyObject *__pyx_f_12spidermonkey_7Runtime_create_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_7Runtime_create_context(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_root = 0; - PyObject *__pyx_v_cx; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - static char *__pyx_argnames[] = {"root",0}; - __pyx_v_root = __pyx_d1; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "|O", __pyx_argnames, &__pyx_v_root)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_root); - __pyx_v_cx = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsruntime.pxi":14 */ - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 14; goto __pyx_L1;} - Py_INCREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); - Py_INCREF(__pyx_v_root); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_v_root); - __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_Context), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 14; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_v_cx); - __pyx_v_cx = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsruntime.pxi":15 */ - Py_INCREF(__pyx_v_cx); - __pyx_r = __pyx_v_cx; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.Runtime.create_context"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_root); - return __pyx_r; -} - -static int __pyx_f_12spidermonkey_7Context___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_7Context___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Runtime *__pyx_v_rt = 0; - PyObject *__pyx_v_root = 0; - PyObject *__pyx_v_STACK_CHUNK_SIZE; - int __pyx_r; - PyObject *__pyx_1 = 0; - __pyx_t_12spidermonkey_size_t __pyx_2; - int __pyx_3; - PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - static char *__pyx_argnames[] = {"rt","root",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_rt, &__pyx_v_root)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_rt); - Py_INCREF(__pyx_v_root); - __pyx_v_STACK_CHUNK_SIZE = Py_None; Py_INCREF(Py_None); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rt), __pyx_ptype_12spidermonkey_Runtime, 1, "rt")) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 14; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":15 */ - Py_INCREF(((PyObject *)__pyx_v_rt)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->rt)); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->rt = __pyx_v_rt; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":17 */ - __pyx_1 = PyInt_FromLong(8192); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 17; goto __pyx_L1;} - Py_DECREF(__pyx_v_STACK_CHUNK_SIZE); - __pyx_v_STACK_CHUNK_SIZE = __pyx_1; - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":19 */ - __pyx_2 = PyInt_AsLong(__pyx_v_STACK_CHUNK_SIZE); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 19; goto __pyx_L1;} - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx = JS_NewContext(__pyx_v_rt->rt,__pyx_2); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":20 */ - __pyx_3 = (((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx == NULL); - if (__pyx_3) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; goto __pyx_L1;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; goto __pyx_L1;} - Py_INCREF(__pyx_k19p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k19p); - __pyx_5 = PyObject_CallObject(__pyx_1, __pyx_4); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - __Pyx_Raise(__pyx_5, 0, 0); - Py_DECREF(__pyx_5); __pyx_5 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 21; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); - __Pyx_AddTraceback("spidermonkey.Context.__cinit__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_STACK_CHUNK_SIZE); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_rt); - Py_DECREF(__pyx_v_root); - return __pyx_r; -} - -static int __pyx_f_12spidermonkey_7Context___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_7Context___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Runtime *__pyx_v_rt = 0; - PyObject *__pyx_v_root = 0; - struct __pyx_obj_12spidermonkey_ClassAdapter *__pyx_v_ca; - struct JSObject *__pyx_v_js_obj; - int __pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - int __pyx_4; - PyObject *__pyx_5 = 0; - static char *__pyx_argnames[] = {"rt","root",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_rt, &__pyx_v_root)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_rt); - Py_INCREF(__pyx_v_root); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_rt), __pyx_ptype_12spidermonkey_Runtime, 1, "rt")) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 23; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":28 */ - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; goto __pyx_L1;} - Py_INCREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); - __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_GC), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 28; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->gc)); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->gc = ((struct __pyx_obj_12spidermonkey_GC *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":29 */ - __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->reg); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->reg = __pyx_1; - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":30 */ - __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 30; goto __pyx_L1;} - Py_DECREF(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->classes); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->classes = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":31 */ - Py_INCREF(Py_None); - Py_DECREF(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->error); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->error = Py_None; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":33 */ - js_context_attach(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,((struct PyObject *)__pyx_v_self)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":35 */ - __pyx_3 = PyObject_IsTrue(__pyx_v_root); if (__pyx_3 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_4 = (!__pyx_3); - if (__pyx_4) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSRootObject); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; goto __pyx_L1;} - __pyx_2 = PyObject_CallObject(__pyx_1, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 36; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_v_root); - __pyx_v_root = __pyx_2; - __pyx_2 = 0; - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":38 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_install_class); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_v_root, __pyx_n___class__); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; goto __pyx_L1;} - __pyx_5 = PyTuple_New(3); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_2); - Py_INCREF(Py_False); - PyTuple_SET_ITEM(__pyx_5, 1, Py_False); - Py_INCREF(Py_True); - PyTuple_SET_ITEM(__pyx_5, 2, Py_True); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_ClassAdapter)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 38; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_ca)); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":39 */ - __pyx_v_js_obj = JS_NewObject(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,__pyx_v_ca->js_class,NULL,NULL); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":40 */ - __pyx_3 = (__pyx_v_js_obj == NULL); - if (__pyx_3) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; goto __pyx_L1;} - Py_INCREF(__pyx_k23p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k23p); - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_5); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 41; goto __pyx_L1;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":42 */ - __pyx_1 = PyTuple_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; goto __pyx_L1;} - Py_INCREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); - Py_INCREF(((PyObject *)__pyx_v_ca)); - PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_ca)); - Py_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_1, 2, Py_None); - Py_INCREF(__pyx_v_root); - PyTuple_SET_ITEM(__pyx_1, 3, __pyx_v_root); - __pyx_5 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_ObjectAdapter), __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 42; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root)); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_5); - __pyx_5 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":43 */ - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root->js_obj = __pyx_v_js_obj; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":44 */ - js_object_attach(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root->js_obj,((struct PyObject *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":46 */ - __pyx_4 = (!JS_InitStandardClasses(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,__pyx_v_js_obj)); - if (__pyx_4) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; goto __pyx_L1;} - Py_INCREF(__pyx_k24p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k24p); - __pyx_5 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_5) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_5, 0, 0); - Py_DECREF(__pyx_5); __pyx_5 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 47; goto __pyx_L1;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":49 */ - JS_SetErrorReporter(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,__pyx_f_12spidermonkey___report_error_callback__); - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_5); - __Pyx_AddTraceback("spidermonkey.Context.__init__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_ca); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_rt); - Py_DECREF(__pyx_v_root); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey_7Context___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_f_12spidermonkey_7Context___dealloc__(PyObject *__pyx_v_self) { - Py_INCREF(__pyx_v_self); - JS_DestroyContext(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx); - - Py_DECREF(__pyx_v_self); -} - -static PyObject *__pyx_f_12spidermonkey_7Context_install_class(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_12spidermonkey_7Context_install_class[] = " Install a Python class into the JavaScript runtime.\n "; -static PyObject *__pyx_f_12spidermonkey_7Context_install_class(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_py_class = 0; - PyObject *__pyx_v_bind_constructor = 0; - PyObject *__pyx_v_is_global = 0; - PyObject *__pyx_v_flags = 0; - PyObject *__pyx_v_ca; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - int __pyx_5; - static char *__pyx_argnames[] = {"py_class","bind_constructor","is_global","flags",0}; - __pyx_v_bind_constructor = __pyx_d2; - __pyx_v_is_global = __pyx_d3; - __pyx_v_flags = __pyx_d4; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O|OOO", __pyx_argnames, &__pyx_v_py_class, &__pyx_v_bind_constructor, &__pyx_v_is_global, &__pyx_v_flags)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_py_class); - Py_INCREF(__pyx_v_bind_constructor); - Py_INCREF(__pyx_v_is_global); - Py_INCREF(__pyx_v_flags); - __pyx_v_ca = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":58 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_inspect); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_isclass); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; goto __pyx_L1;} - Py_INCREF(__pyx_v_py_class); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_py_class); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 58; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = (!__pyx_4); - if (__pyx_5) { - __pyx_2 = PyNumber_Remainder(__pyx_k27p, __pyx_v_py_class); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; goto __pyx_L1;} - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - __pyx_2 = 0; - __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 59; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":60 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; goto __pyx_L1;} - __pyx_1 = PyObject_GetAttr(__pyx_2, __pyx_n_IntType); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_3, __pyx_n_LongType); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_1 = 0; - __pyx_2 = 0; - __pyx_4 = PyObject_IsInstance(__pyx_v_flags,__pyx_3); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = (!__pyx_4); - if (__pyx_5) { - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; goto __pyx_L1;} - Py_INCREF(__pyx_k31p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k31p); - __pyx_2 = PyObject_CallObject(PyExc_TypeError, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 61; goto __pyx_L1;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":63 */ - __pyx_4 = PySequence_Contains(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->classes, __pyx_v_py_class); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 63; goto __pyx_L1;} - if (__pyx_4) { - __pyx_3 = PyObject_GetItem(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->classes, __pyx_v_py_class); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 64; goto __pyx_L1;} - __pyx_r = __pyx_3; - __pyx_3 = 0; - goto __pyx_L0; - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":66 */ - __pyx_1 = PyTuple_New(6); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; goto __pyx_L1;} - Py_INCREF(__pyx_v_self); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_self); - Py_INCREF(((PyObject *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root)); - PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root)); - Py_INCREF(__pyx_v_py_class); - PyTuple_SET_ITEM(__pyx_1, 2, __pyx_v_py_class); - Py_INCREF(__pyx_v_bind_constructor); - PyTuple_SET_ITEM(__pyx_1, 3, __pyx_v_bind_constructor); - Py_INCREF(__pyx_v_is_global); - PyTuple_SET_ITEM(__pyx_1, 4, __pyx_v_is_global); - Py_INCREF(__pyx_v_flags); - PyTuple_SET_ITEM(__pyx_1, 5, __pyx_v_flags); - __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_ClassAdapter), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 66; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_v_ca); - __pyx_v_ca = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":67 */ - if (PyObject_SetItem(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->classes, __pyx_v_py_class, __pyx_v_ca) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 67; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":68 */ - Py_INCREF(__pyx_v_ca); - __pyx_r = __pyx_v_ca; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.Context.install_class"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ca); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_py_class); - Py_DECREF(__pyx_v_bind_constructor); - Py_DECREF(__pyx_v_is_global); - Py_DECREF(__pyx_v_flags); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7Context_bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_12spidermonkey_7Context_bind[] = " Attach a Python object to the JavaScript runtime.\n \n You should be able to attach most types of Python objects\n including builtin types, object instances, functions etc. About\n the only thing you can\'t bind is a Python class which should\n be isntalled into the JavaScript environment using\n Context.install_class\n \n This call will bind the provided object `obj` to the JS root. The\n Python value is also referenced to keep it from being garbage\n collected.\n "; -static PyObject *__pyx_f_12spidermonkey_7Context_bind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_name = 0; - PyObject *__pyx_v_obj = 0; - struct __pyx_obj_12spidermonkey_ClassAdapter *__pyx_v_ca; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_js_str; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - __pyx_t_12spidermonkey_jsval __pyx_4; - int __pyx_5; - static char *__pyx_argnames[] = {"name","obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_name, &__pyx_v_obj)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_name); - Py_INCREF(__pyx_v_obj); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":88 */ - __pyx_1 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,__pyx_v_name)); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 88; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_js_str)); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_1); - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":90 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_install_class); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_v_obj, __pyx_n___class__); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_ClassAdapter)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 90; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_ca)); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":91 */ - __pyx_4 = __pyx_f_12spidermonkey_py2js(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self),__pyx_v_obj,((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root->js_obj); if (__pyx_4 == 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 91; goto __pyx_L1;} - __pyx_v_jsv = __pyx_4; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":92 */ - __pyx_5 = (!JS_DefineUCProperty(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root->js_obj,((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->chars(__pyx_v_js_str),((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->length(__pyx_v_js_str),__pyx_v_jsv,__pyx_f_12spidermonkey___get_property_callback__,__pyx_f_12spidermonkey___set_property_callback__,0)); - if (__pyx_5) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 94; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 94; goto __pyx_L1;} - Py_INCREF(__pyx_k32p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k32p); - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 94; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 94; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.Context.bind"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ca); - Py_DECREF(__pyx_v_js_str); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_name); - Py_DECREF(__pyx_v_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7Context_unbind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_7Context_unbind(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_name = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_rval; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_js_str; - PyObject *__pyx_v_ret; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - int __pyx_5; - static char *__pyx_argnames[] = {"name",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_name)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_name); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - __pyx_v_ret = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":100 */ - __pyx_1 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,__pyx_v_name)); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 100; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_js_str)); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_1); - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":102 */ - __pyx_1 = PyObject_GetAttr(__pyx_v_self, __pyx_n_execute); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - Py_INCREF(__pyx_k35p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k35p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_2 = PyNumber_Add(__pyx_v_name, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); - __pyx_2 = 0; - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 102; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_v_ret); - __pyx_v_ret = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":103 */ - __pyx_5 = (!JS_DeleteUCProperty2(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root->js_obj,((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->chars(__pyx_v_js_str),((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->length(__pyx_v_js_str),(&__pyx_v_rval))); - if (__pyx_5) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 104; goto __pyx_L1;} - __pyx_1 = PyNumber_Remainder(__pyx_k36p, __pyx_v_name); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 104; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 104; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_1); - __pyx_1 = 0; - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 104; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 104; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":107 */ - Py_INCREF(__pyx_v_ret); - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey.Context.unbind"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_js_str); - Py_DECREF(__pyx_v_ret); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_name); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7Context_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static char __pyx_doc_12spidermonkey_7Context_execute[] = " Execute JavaScript source code.\n "; -static PyObject *__pyx_f_12spidermonkey_7Context_execute(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_script = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_rval; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_js_str; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - int __pyx_2; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - static char *__pyx_argnames[] = {"script",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_script)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_script); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":116 */ - __pyx_1 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,__pyx_v_script)); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 116; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_js_str)); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_1); - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":118 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":119 */ - __pyx_2 = (!JS_EvaluateUCScript(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->cx,((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->root->js_obj,((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->chars(__pyx_v_js_str),((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->length(__pyx_v_js_str),__pyx_k37,0,(&__pyx_v_rval))); - if (__pyx_2) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 120; goto __pyx_L3;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 120; goto __pyx_L3;} - Py_INCREF(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->error); - PyTuple_SET_ITEM(__pyx_3, 0, ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->error); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 120; goto __pyx_L3;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[4]; __pyx_lineno = 120; goto __pyx_L3;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":121 */ - __pyx_1 = __pyx_f_12spidermonkey_js2py(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self),__pyx_v_rval); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 121; goto __pyx_L3;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L2; - } - /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_why = 0; goto __pyx_L4; - __pyx_L2: __pyx_why = 3; goto __pyx_L4; - __pyx_L3: { - __pyx_why = 4; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_1); __pyx_1 = 0; - PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L4; - } - __pyx_L4:; - ((struct __pyx_vtabstruct_12spidermonkey_GC *)((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->gc->__pyx_vtab)->run_maybe(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->gc); - switch (__pyx_why) { - case 3: goto __pyx_L0; - case 4: { - PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1; - } - } - } - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey.Context.execute"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_js_str); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_script); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_7Context_set_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_7Context_set_error(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_mesg = 0; - PyObject *__pyx_r; - static char *__pyx_argnames[] = {"mesg",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_mesg)) return 0; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_mesg); - Py_INCREF(__pyx_v_mesg); - Py_DECREF(((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->error); - ((struct __pyx_obj_12spidermonkey_Context *)__pyx_v_self)->error = __pyx_v_mesg; - - __pyx_r = Py_None; Py_INCREF(Py_None); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_mesg); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___constructor_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_js_obj,__pyx_t_12spidermonkey_uintN __pyx_v_argc,__pyx_t_12spidermonkey_jsval *__pyx_v_argv,__pyx_t_12spidermonkey_jsval *__pyx_v_rval) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_ClassAdapter *__pyx_v_adapter; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_oa; - struct JSObject *__pyx_v_proto; - int __pyx_v_i; - PyObject *__pyx_v_args; - PyObject *__pyx_v_py_rval; - __pyx_t_12spidermonkey_JSBool __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - __pyx_t_12spidermonkey_jsval __pyx_6; - __pyx_t_12spidermonkey_JSBool __pyx_7; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_args = Py_None; Py_INCREF(Py_None); - __pyx_v_py_rval = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":9 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":10 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 11; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 11; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 11; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 11; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":13 */ - __pyx_v_proto = JS_GetPrototype(__pyx_v_cx,__pyx_v_js_obj); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":14 */ - __pyx_1 = (__pyx_v_proto == NULL); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; goto __pyx_L2;} - Py_INCREF(__pyx_k39p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k39p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 15; goto __pyx_L2;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":17 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx,__pyx_v_proto)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L2;} - Py_INCREF(__pyx_k40p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k40p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 18; goto __pyx_L2;} - goto __pyx_L6; - } - __pyx_L6:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":20 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 20; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 20; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":21 */ - __pyx_3 = js_object_fetch(__pyx_v_cx,__pyx_v_proto); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 21; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_12spidermonkey_ClassAdapter)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 21; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_adapter)); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_3); - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":23 */ - __pyx_4 = PyList_New(0); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 23; goto __pyx_L2;} - Py_DECREF(__pyx_v_args); - __pyx_v_args = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":24 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_argc; ++__pyx_v_i) { - __pyx_2 = PyObject_GetAttr(__pyx_v_args, __pyx_n_append); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 25; goto __pyx_L2;} - __pyx_3 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,(__pyx_v_argv[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 25; goto __pyx_L2;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 25; goto __pyx_L2;} - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); - __pyx_3 = 0; - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 25; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":27 */ - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 27; goto __pyx_L2;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 27; goto __pyx_L2;} - Py_INCREF(__pyx_n___jsinit__); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n___jsinit__); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 27; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_1 = PyObject_HasAttr(__pyx_v_adapter->py_class,__pyx_3); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 27; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_adapter->py_class, __pyx_n___jsinit__); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; goto __pyx_L2;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; goto __pyx_L2;} - Py_INCREF(((PyObject *)__pyx_v_pycx)); - PyTuple_SET_ITEM(__pyx_4, 0, ((PyObject *)__pyx_v_pycx)); - __pyx_3 = PySequence_Tuple(__pyx_v_args); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; goto __pyx_L2;} - __pyx_5 = PyNumber_Add(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 28; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(__pyx_v_py_rval); - __pyx_v_py_rval = __pyx_4; - __pyx_4 = 0; - goto __pyx_L9; - } - /*else*/ { - __pyx_3 = PySequence_Tuple(__pyx_v_args); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 30; goto __pyx_L2;} - __pyx_2 = PyObject_CallObject(__pyx_v_adapter->py_class, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 30; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_v_py_rval); - __pyx_v_py_rval = __pyx_2; - __pyx_2 = 0; - } - __pyx_L9:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":32 */ - __pyx_6 = __pyx_f_12spidermonkey_py2js(__pyx_v_pycx,__pyx_v_py_rval,NULL); if (__pyx_6 == 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 32; goto __pyx_L2;} - (__pyx_v_rval[0]) = __pyx_6; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":36 */ - __pyx_7 = JSVAL_IS_OBJECT((__pyx_v_rval[0])); - if (__pyx_7) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":37 */ - __pyx_5 = PyTuple_New(4); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 37; goto __pyx_L2;} - Py_INCREF(((PyObject *)__pyx_v_pycx)); - PyTuple_SET_ITEM(__pyx_5, 0, ((PyObject *)__pyx_v_pycx)); - Py_INCREF(((PyObject *)__pyx_v_adapter)); - PyTuple_SET_ITEM(__pyx_5, 1, ((PyObject *)__pyx_v_adapter)); - Py_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_5, 2, Py_None); - Py_INCREF(__pyx_v_py_rval); - PyTuple_SET_ITEM(__pyx_5, 3, __pyx_v_py_rval); - __pyx_4 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_ObjectAdapter), __pyx_5); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 37; goto __pyx_L2;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(((PyObject *)__pyx_v_oa)); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_4); - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":38 */ - __pyx_v_oa->js_obj = __pyx_v_js_obj; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":39 */ - js_object_attach(__pyx_v_cx,__pyx_v_js_obj,((struct PyObject *)__pyx_v_oa)); - goto __pyx_L10; - } - __pyx_L10:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":41 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_5); __pyx_5 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":42 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__constructor_callback__"); - if (__Pyx_GetException(&__pyx_3, &__pyx_2, &__pyx_5) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 42; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - goto __pyx_L0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); - __Pyx_WriteUnraisable("spidermonkey.__constructor_callback__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_adapter); - Py_DECREF(__pyx_v_oa); - Py_DECREF(__pyx_v_args); - Py_DECREF(__pyx_v_py_rval); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___resolve_global_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_js_obj,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_adapter; - PyObject *__pyx_v_py_obj; - PyObject *__pyx_v_key; - __pyx_t_12spidermonkey_JSBool __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - PyObject *__pyx_6 = 0; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_py_obj = Py_None; Py_INCREF(Py_None); - __pyx_v_key = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":52 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":53 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 54; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 54; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 54; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 54; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":56 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 56; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":57 */ - __pyx_3 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 57; goto __pyx_L2;} - Py_DECREF(__pyx_v_key); - __pyx_v_key = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":59 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx,__pyx_v_js_obj)); - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":60 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":62 */ - __pyx_4 = js_object_fetch(__pyx_v_cx,__pyx_v_js_obj); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 62; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_12spidermonkey_ObjectAdapter)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 62; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_adapter)); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_4); - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":63 */ - Py_INCREF(__pyx_v_adapter->py_obj); - Py_DECREF(__pyx_v_py_obj); - __pyx_v_py_obj = __pyx_v_adapter->py_obj; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":65 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; goto __pyx_L2;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_UnicodeType); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyObject_IsInstance(__pyx_v_key,__pyx_3); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_1) { - __pyx_1 = PyObject_HasAttr(__pyx_v_py_obj,__pyx_v_key); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 65; goto __pyx_L2;} - } - if (__pyx_1) { - __pyx_4 = PyObject_GetAttr(((PyObject *)__pyx_v_pycx), __pyx_n_bind); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 66; goto __pyx_L2;} - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj,__pyx_v_key); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 66; goto __pyx_L2;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 66; goto __pyx_L2;} - Py_INCREF(__pyx_v_key); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_key); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 66; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - goto __pyx_L6; - } - __pyx_L6:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":68 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":69 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__resolve_global_callback__"); - if (__Pyx_GetException(&__pyx_4, &__pyx_3, &__pyx_2) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 69; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":70 */ - __pyx_5 = __Pyx_GetName(__pyx_m, __pyx_n_traceback); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 70; goto __pyx_L1;} - __pyx_6 = PyObject_GetAttr(__pyx_5, __pyx_n_print_exc); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 70; goto __pyx_L1;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_5 = PyObject_CallObject(__pyx_6, 0); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 70; goto __pyx_L1;} - Py_DECREF(__pyx_6); __pyx_6 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":71 */ - __pyx_r = __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - goto __pyx_L0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_6); - __Pyx_WriteUnraisable("spidermonkey.__resolve_global_callback__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_adapter); - Py_DECREF(__pyx_v_py_obj); - Py_DECREF(__pyx_v_key); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___get_property_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_js_obj,__pyx_t_12spidermonkey_jsval __pyx_v_jsv,__pyx_t_12spidermonkey_jsval *__pyx_v_rval) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_adapter; - PyObject *__pyx_v_py_obj; - PyObject *__pyx_v_key; - PyObject *__pyx_v_attr; - __pyx_t_12spidermonkey_JSBool __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_t_12spidermonkey_jsval __pyx_5; - PyObject *__pyx_6 = 0; - PyObject *__pyx_7 = 0; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_py_obj = Py_None; Py_INCREF(Py_None); - __pyx_v_key = Py_None; Py_INCREF(Py_None); - __pyx_v_attr = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":81 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":82 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 83; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 83; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 83; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 83; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":85 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 85; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 85; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":86 */ - __pyx_3 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 86; goto __pyx_L2;} - Py_DECREF(__pyx_v_key); - __pyx_v_key = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":88 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx,__pyx_v_js_obj)); - if (__pyx_1) { - __pyx_r = JS_TRUE; - goto __pyx_L0; - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":91 */ - __pyx_4 = js_object_fetch(__pyx_v_cx,__pyx_v_js_obj); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 91; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_4, __pyx_ptype_12spidermonkey_ObjectAdapter)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 91; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_adapter)); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_4); - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":92 */ - Py_INCREF(__pyx_v_adapter->py_obj); - Py_DECREF(__pyx_v_py_obj); - __pyx_v_py_obj = __pyx_v_adapter->py_obj; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":94 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 94; goto __pyx_L2;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_IntType); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 94; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 94; goto __pyx_L2;} - __pyx_2 = PyObject_GetAttr(__pyx_4, __pyx_n_LongType); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 94; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_4 = PyTuple_New(2); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 94; goto __pyx_L2;} - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_3); - PyTuple_SET_ITEM(__pyx_4, 1, __pyx_2); - __pyx_3 = 0; - __pyx_2 = 0; - __pyx_1 = PyObject_IsInstance(__pyx_v_key,__pyx_4); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 94; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (__pyx_1) { - /*try:*/ { - __pyx_3 = PyObject_GetItem(__pyx_v_py_obj, __pyx_v_key); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 96; goto __pyx_L7;} - Py_DECREF(__pyx_v_attr); - __pyx_v_attr = __pyx_3; - __pyx_3 = 0; - } - /*else:*/ { - __pyx_5 = __pyx_f_12spidermonkey_py2js(__pyx_v_pycx,__pyx_v_attr,NULL); if (__pyx_5 == 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 100; goto __pyx_L2;} - (__pyx_v_rval[0]) = __pyx_5; - } - goto __pyx_L8; - __pyx_L7:; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":97 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__get_property_callback__"); - if (__Pyx_GetException(&__pyx_2, &__pyx_4, &__pyx_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 97; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - goto __pyx_L8; - } - __pyx_L8:; - goto __pyx_L6; - } - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 101; goto __pyx_L2;} - __pyx_4 = PyObject_GetAttr(__pyx_2, __pyx_n_UnicodeType); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 101; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyObject_IsInstance(__pyx_v_key,__pyx_4); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 101; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (__pyx_1) { - __pyx_3 = PySequence_GetSlice(__pyx_v_key, 0, 1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; goto __pyx_L2;} - __pyx_2 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; goto __pyx_L2;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; goto __pyx_L2;} - Py_INCREF(__pyx_n__); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_n__); - __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_4); if (!__pyx_6) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyObject_Cmp(__pyx_3, __pyx_6, &__pyx_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 102; goto __pyx_L2;} - __pyx_1 = __pyx_1 != 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_6); __pyx_6 = 0; - if (__pyx_1) { - /*try:*/ { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj,__pyx_v_key); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 104; goto __pyx_L10;} - Py_DECREF(__pyx_v_attr); - __pyx_v_attr = __pyx_2; - __pyx_2 = 0; - } - /*else:*/ { - __pyx_5 = __pyx_f_12spidermonkey_py2js(__pyx_v_pycx,__pyx_v_attr,__pyx_v_js_obj); if (__pyx_5 == 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 108; goto __pyx_L2;} - (__pyx_v_rval[0]) = __pyx_5; - } - goto __pyx_L11; - __pyx_L10:; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_6); __pyx_6 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":105 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__get_property_callback__"); - if (__Pyx_GetException(&__pyx_4, &__pyx_3, &__pyx_6) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 105; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_6); __pyx_6 = 0; - goto __pyx_L11; - } - __pyx_L11:; - goto __pyx_L9; - } - __pyx_L9:; - goto __pyx_L6; - } - __pyx_1 = __pyx_v_key == Py_None; - if (__pyx_1) { - (__pyx_v_rval[0]) = JSVAL_VOID; - goto __pyx_L6; - } - /*else*/ { - __pyx_2 = PyNumber_Remainder(__pyx_k46p, __pyx_v_key); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 112; goto __pyx_L2;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 112; goto __pyx_L2;} - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_2); - __pyx_2 = 0; - __pyx_3 = PyObject_CallObject(PyExc_AssertionError, __pyx_4); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 112; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 112; goto __pyx_L2;} - } - __pyx_L6:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":114 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_6); __pyx_6 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":115 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__get_property_callback__"); - if (__Pyx_GetException(&__pyx_6, &__pyx_2, &__pyx_4) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 115; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":116 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_traceback); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 116; goto __pyx_L1;} - __pyx_7 = PyObject_GetAttr(__pyx_3, __pyx_n_print_exc); if (!__pyx_7) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 116; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_3 = PyObject_CallObject(__pyx_7, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 116; goto __pyx_L1;} - Py_DECREF(__pyx_7); __pyx_7 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":117 */ - __pyx_r = __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_6); __pyx_6 = 0; - goto __pyx_L0; - Py_DECREF(__pyx_6); __pyx_6 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_6); - Py_XDECREF(__pyx_7); - __Pyx_WriteUnraisable("spidermonkey.__get_property_callback__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_adapter); - Py_DECREF(__pyx_v_py_obj); - Py_DECREF(__pyx_v_key); - Py_DECREF(__pyx_v_attr); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___set_property_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_js_obj,__pyx_t_12spidermonkey_jsval __pyx_v_jsv,__pyx_t_12spidermonkey_jsval *__pyx_v_rval) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_adapter; - PyObject *__pyx_v_py_obj; - PyObject *__pyx_v_key; - PyObject *__pyx_v_value; - PyObject *__pyx_v_attr; - __pyx_t_12spidermonkey_JSBool __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - PyObject *__pyx_5 = 0; - int __pyx_6; - int __pyx_7; - PyObject *__pyx_8 = 0; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_py_obj = Py_None; Py_INCREF(Py_None); - __pyx_v_key = Py_None; Py_INCREF(Py_None); - __pyx_v_value = Py_None; Py_INCREF(Py_None); - __pyx_v_attr = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":126 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":127 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 128; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 128; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 128; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 128; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":130 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 130; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 130; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":131 */ - __pyx_3 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 131; goto __pyx_L2;} - Py_DECREF(__pyx_v_key); - __pyx_v_key = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":132 */ - __pyx_4 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,(__pyx_v_rval[0])); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 132; goto __pyx_L2;} - Py_DECREF(__pyx_v_value); - __pyx_v_value = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":134 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx,__pyx_v_js_obj)); - if (__pyx_1) { - __pyx_r = JS_TRUE; - goto __pyx_L0; - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":137 */ - __pyx_2 = js_object_fetch(__pyx_v_cx,__pyx_v_js_obj); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 137; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_ObjectAdapter)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 137; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_adapter)); - __pyx_v_adapter = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":138 */ - Py_INCREF(__pyx_v_adapter->py_obj); - Py_DECREF(__pyx_v_py_obj); - __pyx_v_py_obj = __pyx_v_adapter->py_obj; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":140 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L2;} - __pyx_4 = PyObject_GetAttr(__pyx_3, __pyx_n_IntType); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L2;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_LongType); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L2;} - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_4); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3); - __pyx_4 = 0; - __pyx_3 = 0; - __pyx_1 = PyObject_IsInstance(__pyx_v_key,__pyx_2); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 140; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_1) { - if (PyObject_SetItem(__pyx_v_py_obj, __pyx_v_key, __pyx_v_value) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 141; goto __pyx_L2;} - goto __pyx_L6; - } - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L2;} - __pyx_3 = PyObject_GetAttr(__pyx_4, __pyx_n_UnicodeType); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - __pyx_1 = PyObject_IsInstance(__pyx_v_key,__pyx_3); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 142; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_1) { - __pyx_2 = PySequence_GetSlice(__pyx_v_key, 0, 1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 143; goto __pyx_L2;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_unicode); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 143; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 143; goto __pyx_L2;} - Py_INCREF(__pyx_n__); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_n__); - __pyx_5 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 143; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (PyObject_Cmp(__pyx_2, __pyx_5, &__pyx_1) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 143; goto __pyx_L2;} - __pyx_1 = __pyx_1 != 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - if (__pyx_1) { - __pyx_1 = PyObject_HasAttr(__pyx_v_py_obj,__pyx_v_key); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 143; goto __pyx_L2;} - } - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":144 */ - __pyx_4 = PyObject_GetAttr(__pyx_v_py_obj,__pyx_v_key); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 144; goto __pyx_L2;} - Py_DECREF(__pyx_v_attr); - __pyx_v_attr = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":145 */ - __pyx_3 = __Pyx_GetName(__pyx_b, __pyx_n_callable); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 145; goto __pyx_L2;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 145; goto __pyx_L2;} - Py_INCREF(__pyx_v_attr); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_v_attr); - __pyx_5 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_5) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 145; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyObject_IsTrue(__pyx_5); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 145; goto __pyx_L2;} - Py_DECREF(__pyx_5); __pyx_5 = 0; - __pyx_6 = (!__pyx_1); - if (__pyx_6) { - __pyx_7 = PyObject_SetAttr(__pyx_v_py_obj,__pyx_v_key,__pyx_v_value); if (__pyx_7 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 146; goto __pyx_L2;} - goto __pyx_L8; - } - __pyx_L8:; - goto __pyx_L7; - } - __pyx_L7:; - goto __pyx_L6; - } - /*else*/ { - __pyx_4 = PyNumber_Remainder(__pyx_k46p, __pyx_v_key); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; goto __pyx_L2;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); - __pyx_4 = 0; - __pyx_2 = PyObject_CallObject(PyExc_AssertionError, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 148; goto __pyx_L2;} - } - __pyx_L6:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":150 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_5); __pyx_5 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":151 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__set_property_callback__"); - if (__Pyx_GetException(&__pyx_5, &__pyx_4, &__pyx_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 151; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":152 */ - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_traceback); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; goto __pyx_L1;} - __pyx_8 = PyObject_GetAttr(__pyx_2, __pyx_n_print_exc); if (!__pyx_8) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_8, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 152; goto __pyx_L1;} - Py_DECREF(__pyx_8); __pyx_8 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":153 */ - __pyx_r = __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - goto __pyx_L0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_8); - __Pyx_WriteUnraisable("spidermonkey.__set_property_callback__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_adapter); - Py_DECREF(__pyx_v_py_obj); - Py_DECREF(__pyx_v_key); - Py_DECREF(__pyx_v_value); - Py_DECREF(__pyx_v_attr); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey___finalize_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_js_obj) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_py_obj; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_py_obj = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":160 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":161 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 162; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 162; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 162; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 162; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":164 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx,__pyx_v_js_obj)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 165; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 165; goto __pyx_L2;} - Py_INCREF(__pyx_k48p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k48p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 165; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 165; goto __pyx_L2;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":167 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 167; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":168 */ - __pyx_3 = js_object_destroy(__pyx_v_cx,__pyx_v_js_obj); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_12spidermonkey_ObjectAdapter)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 168; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_py_obj)); - __pyx_v_py_obj = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_3); - __pyx_3 = 0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":169 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__finalize_callback__"); - if (__Pyx_GetException(&__pyx_4, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 169; goto __pyx_L1;} - __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.__finalize_callback__"); - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_py_obj); -} - -static PyObject *__pyx_f_12spidermonkey_js_classname(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_classname(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - static char *__pyx_argnames[] = {"obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_obj)) return 0; - Py_INCREF(__pyx_v_obj); - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_inspect); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_isclass); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; goto __pyx_L1;} - Py_INCREF(__pyx_v_obj); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_v_obj); - __pyx_3 = PyObject_CallObject(__pyx_2, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 173; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_2 = PyObject_GetAttr(__pyx_v_obj, __pyx_n___name__); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 174; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - /*else*/ { - __pyx_1 = PyObject_GetAttr(__pyx_v_obj, __pyx_n___class__); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n___name__); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 176; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_r = __pyx_3; - __pyx_3 = 0; - goto __pyx_L0; - } - __pyx_L2:; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.js_classname"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_obj); - return __pyx_r; -} - -static int __pyx_f_12spidermonkey_12ClassAdapter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_12ClassAdapter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_parent = 0; - PyObject *__pyx_v_py_class = 0; - PyObject *__pyx_v_bind_constructor = 0; - PyObject *__pyx_v_is_global = 0; - PyObject *__pyx_v_flags = 0; - struct JSObject *__pyx_v_proto; - PyObject *__pyx_v_name; - int __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - void *__pyx_5; - Py_ssize_t __pyx_6; - char *__pyx_7; - __pyx_t_12spidermonkey_uint32 __pyx_8; - static char *__pyx_argnames[] = {"cx","parent","py_class","bind_constructor","is_global","flags",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOOOO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_parent, &__pyx_v_py_class, &__pyx_v_bind_constructor, &__pyx_v_is_global, &__pyx_v_flags)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_parent); - Py_INCREF(__pyx_v_py_class); - Py_INCREF(__pyx_v_bind_constructor); - Py_INCREF(__pyx_v_is_global); - Py_INCREF(__pyx_v_flags); - __pyx_v_name = Py_None; Py_INCREF(Py_None); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; goto __pyx_L1;} - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_12spidermonkey_ObjectAdapter, 1, "parent")) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 184; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":187 */ - Py_INCREF(((PyObject *)__pyx_v_cx)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->cx)); - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->cx = __pyx_v_cx; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":188 */ - Py_INCREF(((PyObject *)__pyx_v_parent)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->parent)); - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->parent = __pyx_v_parent; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":189 */ - Py_INCREF(__pyx_v_py_class); - Py_DECREF(((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->py_class); - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->py_class = __pyx_v_py_class; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":191 */ - __pyx_1 = PyObject_HasAttr(__pyx_v_py_class,__pyx_n___jsname__); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 191; goto __pyx_L1;} - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_class, __pyx_n___jsname__); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 192; goto __pyx_L1;} - Py_DECREF(__pyx_v_name); - __pyx_v_name = __pyx_2; - __pyx_2 = 0; - goto __pyx_L2; - } - /*else*/ { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_js_classname); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; goto __pyx_L1;} - Py_INCREF(__pyx_v_py_class); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_v_py_class); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 194; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_v_name); - __pyx_v_name = __pyx_4; - __pyx_4 = 0; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":196 */ - __pyx_5 = __pyx_f_12spidermonkey_xmalloc((sizeof(struct JSClass))); if (__pyx_5 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 196; goto __pyx_L1;} - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class = ((struct JSClass *)__pyx_5); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":197 */ - __pyx_6 = PyObject_Length(__pyx_v_name); if (__pyx_6 == -1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 197; goto __pyx_L1;} - __pyx_5 = __pyx_f_12spidermonkey_xmalloc(((__pyx_6 + 1) * (sizeof(char)))); if (__pyx_5 == NULL) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 197; goto __pyx_L1;} - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->name = ((char *)__pyx_5); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":198 */ - __pyx_7 = PyString_AsString(__pyx_v_name); if (!__pyx_7) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 198; goto __pyx_L1;} - strcpy(((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->name,__pyx_7); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":200 */ - __pyx_2 = PyInt_FromLong(JSCLASS_HAS_PRIVATE); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 200; goto __pyx_L1;} - __pyx_3 = PyNumber_Or(__pyx_v_flags, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 200; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_8 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 200; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->flags = __pyx_8; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":201 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->addProperty = JS_PropertyStub; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":202 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->delProperty = JS_PropertyStub; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":203 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->getProperty = __pyx_f_12spidermonkey___get_property_callback__; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":204 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->setProperty = __pyx_f_12spidermonkey___set_property_callback__; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":205 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->enumerate = JS_EnumerateStub; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":206 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->convert = JS_ConvertStub; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":207 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->finalize = __pyx_f_12spidermonkey___finalize_callback__; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":208 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->getObjectOps = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":209 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->checkAccess = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":210 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->call = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":211 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->construct = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":212 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->xdrObject = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":213 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->hasInstance = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":214 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->mark = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":215 */ - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->reserveSlots = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":217 */ - __pyx_1 = PyObject_IsTrue(__pyx_v_is_global); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 217; goto __pyx_L1;} - if (__pyx_1) { - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->resolve = __pyx_f_12spidermonkey___resolve_global_callback__; - goto __pyx_L3; - } - /*else*/ { - ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->resolve = JS_ResolveStub; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":222 */ - __pyx_1 = PyObject_IsTrue(__pyx_v_bind_constructor); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 222; goto __pyx_L1;} - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":223 */ - __pyx_v_proto = JS_InitClass(((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->cx->cx,__pyx_v_parent->js_obj,NULL,((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class,__pyx_f_12spidermonkey___constructor_callback__,0,NULL,NULL,NULL,NULL); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":225 */ - __pyx_1 = (__pyx_v_proto == NULL); - if (__pyx_1) { - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_4) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 226; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 226; goto __pyx_L1;} - Py_INCREF(__pyx_k52p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k52p); - __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 226; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[5]; __pyx_lineno = 226; goto __pyx_L1;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":227 */ - js_object_attach(__pyx_v_cx->cx,__pyx_v_proto,((struct PyObject *)__pyx_v_self)); - goto __pyx_L4; - } - __pyx_L4:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey.ClassAdapter.__cinit__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_name); - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_parent); - Py_DECREF(__pyx_v_py_class); - Py_DECREF(__pyx_v_bind_constructor); - Py_DECREF(__pyx_v_is_global); - Py_DECREF(__pyx_v_flags); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_12ClassAdapter___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_12ClassAdapter___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = PyNumber_Remainder(__pyx_k53p, ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->py_class); if (!__pyx_1) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 230; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.ClassAdapter.__repr__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey_12ClassAdapter___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_f_12spidermonkey_12ClassAdapter___dealloc__(PyObject *__pyx_v_self) { - int __pyx_1; - Py_INCREF(__pyx_v_self); - __pyx_1 = (((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class != 0); - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":234 */ - __pyx_1 = (((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->name != 0); - if (__pyx_1) { - free(((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class->name); - goto __pyx_L3; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsclass.pxi":236 */ - free(((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_self)->js_class); - goto __pyx_L2; - } - __pyx_L2:; - - Py_DECREF(__pyx_v_self); -} - -static int __pyx_f_12spidermonkey_13ObjectAdapter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_13ObjectAdapter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - struct __pyx_obj_12spidermonkey_ClassAdapter *__pyx_v_adapter = 0; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_parent = 0; - PyObject *__pyx_v_obj = 0; - int __pyx_r; - static char *__pyx_argnames[] = {"cx","adapter","parent","obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OOOO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_adapter, &__pyx_v_parent, &__pyx_v_obj)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_adapter); - Py_INCREF(__pyx_v_parent); - Py_INCREF(__pyx_v_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 9; goto __pyx_L1;} - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_adapter), __pyx_ptype_12spidermonkey_ClassAdapter, 1, "adapter")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 9; goto __pyx_L1;} - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_parent), __pyx_ptype_12spidermonkey_ObjectAdapter, 1, "parent")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 9; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":10 */ - Py_INCREF(((PyObject *)__pyx_v_cx)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->cx)); - ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->cx = __pyx_v_cx; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":11 */ - Py_INCREF(((PyObject *)__pyx_v_adapter)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->cl_adapter)); - ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->cl_adapter = __pyx_v_adapter; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":12 */ - Py_INCREF(((PyObject *)__pyx_v_parent)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->parent)); - ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->parent = __pyx_v_parent; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":13 */ - ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->js_obj = NULL; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":14 */ - Py_INCREF(__pyx_v_obj); - Py_DECREF(((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->py_obj); - ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->py_obj = __pyx_v_obj; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("spidermonkey.ObjectAdapter.__cinit__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_adapter); - Py_DECREF(__pyx_v_parent); - Py_DECREF(__pyx_v_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_13ObjectAdapter___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_13ObjectAdapter___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = PyNumber_Remainder(__pyx_k54p, ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_self)->py_obj); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 17; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.ObjectAdapter.__repr__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - int __pyx_1; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 19; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":20 */ - __pyx_1 = (!JSVAL_IS_OBJECT(__pyx_v_jsv)); - if (__pyx_1) { - Py_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":22 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx->cx,JSVAL_TO_OBJECT(__pyx_v_jsv))); - if (__pyx_1) { - Py_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - goto __pyx_L3; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":24 */ - Py_INCREF(Py_True); - __pyx_r = Py_True; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("spidermonkey.js_is_object"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_object(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 27; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_TypeType); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 27; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 27; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyInt_FromLong((!__pyx_3)); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 27; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.py_is_object"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_object(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - struct __pyx_obj_12spidermonkey_ClassAdapter *__pyx_v_ca; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_oa; - struct __pyx_obj_12spidermonkey_FunctionAdapter *__pyx_v_fa; - PyObject *__pyx_v_tmp; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - int __pyx_2; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - Py_INCREF(__pyx_v_cx); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_fa = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_tmp = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":34 */ - __pyx_1 = js_object_fetch(__pyx_v_cx->cx,JSVAL_TO_OBJECT(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 34; goto __pyx_L1;} - Py_DECREF(__pyx_v_tmp); - __pyx_v_tmp = __pyx_1; - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":35 */ - __pyx_2 = PyObject_IsInstance(__pyx_v_tmp,((PyObject *)__pyx_ptype_12spidermonkey_ClassAdapter)); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 35; goto __pyx_L1;} - if (__pyx_2) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":36 */ - if (!__Pyx_TypeTest(__pyx_v_tmp, __pyx_ptype_12spidermonkey_ClassAdapter)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 36; goto __pyx_L1;} - Py_INCREF(__pyx_v_tmp); - Py_DECREF(((PyObject *)__pyx_v_ca)); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_v_tmp); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":37 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_ca), __pyx_n_py_obj); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 37; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_2 = PyObject_IsInstance(__pyx_v_tmp,((PyObject *)__pyx_ptype_12spidermonkey_ObjectAdapter)); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 38; goto __pyx_L1;} - if (__pyx_2) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":39 */ - if (!__Pyx_TypeTest(__pyx_v_tmp, __pyx_ptype_12spidermonkey_ObjectAdapter)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 39; goto __pyx_L1;} - Py_INCREF(__pyx_v_tmp); - Py_DECREF(((PyObject *)__pyx_v_oa)); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_v_tmp); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":40 */ - Py_INCREF(__pyx_v_oa->py_obj); - __pyx_r = __pyx_v_oa->py_obj; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_2 = PyObject_IsInstance(__pyx_v_tmp,((PyObject *)__pyx_ptype_12spidermonkey_FunctionAdapter)); if (__pyx_2 == -1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 41; goto __pyx_L1;} - if (__pyx_2) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":42 */ - if (!__Pyx_TypeTest(__pyx_v_tmp, __pyx_ptype_12spidermonkey_FunctionAdapter)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 42; goto __pyx_L1;} - Py_INCREF(__pyx_v_tmp); - Py_DECREF(((PyObject *)__pyx_v_fa)); - __pyx_v_fa = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_v_tmp); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":43 */ - Py_INCREF(__pyx_v_fa->py_obj); - __pyx_r = __pyx_v_fa->py_obj; - goto __pyx_L0; - goto __pyx_L2; - } - /*else*/ { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 45; goto __pyx_L1;} - Py_INCREF(__pyx_k57p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k57p); - __pyx_4 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 45; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[6]; __pyx_lineno = 45; goto __pyx_L1;} - } - __pyx_L2:; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey.js2py_object"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ca); - Py_DECREF(__pyx_v_oa); - Py_DECREF(__pyx_v_fa); - Py_DECREF(__pyx_v_tmp); - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_object(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - struct __pyx_obj_12spidermonkey_ClassAdapter *__pyx_v_ca; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_oa; - struct JSObject *__pyx_v_js_obj; - __pyx_t_12spidermonkey_jsval __pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":53 */ - __pyx_1 = PyObject_GetAttr(((PyObject *)__pyx_v_cx), __pyx_n_install_class); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 53; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n___class__); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 53; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 53; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 53; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_ClassAdapter)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 53; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_ca)); - __pyx_v_ca = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":54 */ - __pyx_v_js_obj = JS_NewObject(__pyx_v_cx->cx,__pyx_v_ca->js_class,NULL,NULL); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":55 */ - __pyx_4 = (__pyx_v_js_obj == NULL); - if (__pyx_4) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 56; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 56; goto __pyx_L1;} - Py_INCREF(__pyx_k58p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k58p); - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 56; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[6]; __pyx_lineno = 56; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":57 */ - __pyx_1 = PyTuple_New(4); if (!__pyx_1) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 57; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(((PyObject *)__pyx_v_ca)); - PyTuple_SET_ITEM(__pyx_1, 1, ((PyObject *)__pyx_v_ca)); - Py_INCREF(Py_None); - PyTuple_SET_ITEM(__pyx_1, 2, Py_None); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_1, 3, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_ObjectAdapter), __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 57; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(((PyObject *)__pyx_v_oa)); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_3); - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":58 */ - __pyx_v_oa->js_obj = __pyx_v_js_obj; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":59 */ - js_object_attach(__pyx_v_cx->cx,__pyx_v_oa->js_obj,((struct PyObject *)__pyx_v_oa)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsobject.pxi":61 */ - __pyx_r = OBJECT_TO_JSVAL(__pyx_v_js_obj); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_WriteUnraisable("spidermonkey.py2js_object"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ca); - Py_DECREF(__pyx_v_oa); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static int __pyx_f_12spidermonkey_8Function___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_8Function___init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - int __pyx_r; - static char *__pyx_argnames[] = {"cx",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "O", __pyx_argnames, &__pyx_v_cx)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 6; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx)); - ((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx = __pyx_v_cx; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("spidermonkey.Function.__init__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_8Function___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_8Function___call__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - PyObject *__pyx_v_args = 0; - __pyx_t_12spidermonkey_jsval *__pyx_v_argv; - __pyx_t_12spidermonkey_jsval __pyx_v_rval; - __pyx_t_12spidermonkey_jsval __pyx_v_jsarg; - PyObject *__pyx_v_nr_args; - PyObject *__pyx_v_i; - PyObject *__pyx_v_arg; - PyObject *__pyx_v_retval; - PyObject *__pyx_r; - Py_ssize_t __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - __pyx_t_12spidermonkey_size_t __pyx_4; - void *__pyx_5; - long __pyx_6; - long __pyx_7; - __pyx_t_12spidermonkey_jsval __pyx_8; - __pyx_t_12spidermonkey_uintN __pyx_9; - __pyx_t_12spidermonkey_JSBool __pyx_10; - int __pyx_11; - PyObject *__pyx_12 = 0; - static char *__pyx_argnames[] = {0}; - if (__Pyx_GetStarArgs(&__pyx_args, &__pyx_kwds, __pyx_argnames, 0, &__pyx_v_args, 0, 0) < 0) return 0; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "", __pyx_argnames)) { - Py_XDECREF(__pyx_args); - Py_XDECREF(__pyx_kwds); - Py_XDECREF(__pyx_v_args); - return 0; - } - Py_INCREF(__pyx_v_self); - __pyx_v_nr_args = Py_None; Py_INCREF(Py_None); - __pyx_v_i = Py_None; Py_INCREF(Py_None); - __pyx_v_arg = Py_None; Py_INCREF(Py_None); - __pyx_v_retval = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":14 */ - __pyx_1 = PyObject_Length(__pyx_v_args); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 14; goto __pyx_L1;} - __pyx_2 = PyInt_FromSsize_t(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 14; goto __pyx_L1;} - Py_DECREF(__pyx_v_nr_args); - __pyx_v_nr_args = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":15 */ - __pyx_2 = PyInt_FromLong((sizeof(__pyx_t_12spidermonkey_jsval))); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 15; goto __pyx_L1;} - __pyx_3 = PyNumber_Multiply(__pyx_2, __pyx_v_nr_args); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 15; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyInt_AsLong(__pyx_3); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 15; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_5 = __pyx_f_12spidermonkey_xmalloc(__pyx_4); if (__pyx_5 == NULL) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 15; goto __pyx_L1;} - __pyx_v_argv = ((__pyx_t_12spidermonkey_jsval *)__pyx_5); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":16 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":17 */ - __pyx_7 = PyInt_AsLong(__pyx_v_nr_args); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 17; goto __pyx_L3;} - for (__pyx_6 = 0; __pyx_6 < __pyx_7; ++__pyx_6) { - __pyx_2 = PyInt_FromLong(__pyx_6); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 17; goto __pyx_L3;} - Py_DECREF(__pyx_v_i); - __pyx_v_i = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":18 */ - __pyx_3 = PyObject_GetItem(__pyx_v_args, __pyx_v_i); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 18; goto __pyx_L3;} - Py_DECREF(__pyx_v_arg); - __pyx_v_arg = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":19 */ - __pyx_8 = __pyx_f_12spidermonkey_py2js(((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx,__pyx_v_arg,NULL); if (__pyx_8 == 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 19; goto __pyx_L3;} - __pyx_v_jsarg = __pyx_8; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":20 */ - __pyx_1 = PyInt_AsSsize_t(__pyx_v_i); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 20; goto __pyx_L3;} - (__pyx_v_argv[__pyx_1]) = __pyx_v_jsarg; - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":22 */ - __pyx_9 = PyInt_AsLong(__pyx_v_nr_args); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 22; goto __pyx_L3;} - __pyx_10 = JS_CallFunctionValue(((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->cx,((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->root->js_obj,((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->func,__pyx_9,__pyx_v_argv,(&__pyx_v_rval)); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 22; goto __pyx_L3;} - __pyx_11 = (!__pyx_10); - if (__pyx_11) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 23; goto __pyx_L3;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 23; goto __pyx_L3;} - Py_INCREF(((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->error); - PyTuple_SET_ITEM(__pyx_3, 0, ((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->error); - __pyx_12 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_12) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 23; goto __pyx_L3;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_12, 0, 0); - Py_DECREF(__pyx_12); __pyx_12 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 23; goto __pyx_L3;} - goto __pyx_L7; - } - __pyx_L7:; - } - /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_why = 0; goto __pyx_L4; - __pyx_L3: { - __pyx_why = 4; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_12); __pyx_12 = 0; - PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L4; - } - __pyx_L4:; - free(__pyx_v_argv); - switch (__pyx_why) { - case 4: { - PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1; - } - } - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":27 */ - __pyx_2 = __pyx_f_12spidermonkey_js2py(((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx,__pyx_v_rval); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 27; goto __pyx_L1;} - Py_DECREF(__pyx_v_retval); - __pyx_v_retval = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":28 */ - ((struct __pyx_vtabstruct_12spidermonkey_GC *)((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->gc->__pyx_vtab)->run_maybe(((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->gc); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":30 */ - Py_INCREF(__pyx_v_retval); - __pyx_r = __pyx_v_retval; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_12); - __Pyx_AddTraceback("spidermonkey.Function.__call__"); - __pyx_r = 0; - __pyx_L0:; - Py_XDECREF(__pyx_v_args); - Py_DECREF(__pyx_v_nr_args); - Py_DECREF(__pyx_v_i); - Py_DECREF(__pyx_v_arg); - Py_DECREF(__pyx_v_retval); - Py_DECREF(__pyx_v_self); - Py_XDECREF(__pyx_args); - Py_XDECREF(__pyx_kwds); - return __pyx_r; -} - -static void __pyx_f_12spidermonkey_8Function___dealloc__(PyObject *__pyx_v_self); /*proto*/ -static void __pyx_f_12spidermonkey_8Function___dealloc__(PyObject *__pyx_v_self) { - Py_INCREF(__pyx_v_self); - JS_RemoveRoot(((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->cx->cx,(&((struct __pyx_obj_12spidermonkey_Function *)__pyx_v_self)->func)); - - Py_DECREF(__pyx_v_self); -} - -static int __pyx_f_12spidermonkey_15FunctionAdapter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static int __pyx_f_12spidermonkey_15FunctionAdapter___cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_obj = 0; - int __pyx_r; - static char *__pyx_argnames[] = {"cx","obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_obj)) return -1; - Py_INCREF(__pyx_v_self); - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 41; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":42 */ - Py_INCREF(((PyObject *)__pyx_v_cx)); - Py_DECREF(((PyObject *)((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_v_self)->cx)); - ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_v_self)->cx = __pyx_v_cx; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":43 */ - Py_INCREF(__pyx_v_obj); - Py_DECREF(((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_v_self)->py_obj); - ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_v_self)->py_obj = __pyx_v_obj; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - __Pyx_AddTraceback("spidermonkey.FunctionAdapter.__cinit__"); - __pyx_r = -1; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_15FunctionAdapter___repr__(PyObject *__pyx_v_self); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_15FunctionAdapter___repr__(PyObject *__pyx_v_self) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_self); - __pyx_1 = PyNumber_Remainder(__pyx_k59p, ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_v_self)->py_obj); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 46; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.FunctionAdapter.__repr__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_self); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___bound_method_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_obj,__pyx_t_12spidermonkey_uintN __pyx_v_argc,__pyx_t_12spidermonkey_jsval *__pyx_v_argv,__pyx_t_12spidermonkey_jsval *__pyx_v_rval) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_ObjectAdapter *__pyx_v_oa; - struct JSFunction *__pyx_v_jsfunc; - int __pyx_v_i; - PyObject *__pyx_v_method_name; - PyObject *__pyx_v_method; - PyObject *__pyx_v_args; - PyObject *__pyx_v_py_rval; - __pyx_t_12spidermonkey_JSBool __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_t_12spidermonkey_jsval __pyx_5; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_method_name = Py_None; Py_INCREF(Py_None); - __pyx_v_method = Py_None; Py_INCREF(Py_None); - __pyx_v_args = Py_None; Py_INCREF(Py_None); - __pyx_v_py_rval = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":55 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":56 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 57; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 57; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 57; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 57; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":59 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 59; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 59; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":61 */ - __pyx_1 = (!js_object_has_data(__pyx_v_cx,__pyx_v_obj)); - if (__pyx_1) { - __pyx_r = JS_FALSE; - goto __pyx_L0; - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":64 */ - __pyx_3 = js_object_fetch(__pyx_v_cx,__pyx_v_obj); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 64; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_12spidermonkey_ObjectAdapter)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 64; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_oa)); - __pyx_v_oa = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)__pyx_3); - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":66 */ - __pyx_v_jsfunc = JS_ValueToFunction(__pyx_v_cx,(__pyx_v_argv[(-2)])); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":67 */ - __pyx_4 = PyString_FromString(JS_GetFunctionName(__pyx_v_jsfunc)); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 67; goto __pyx_L2;} - Py_DECREF(__pyx_v_method_name); - __pyx_v_method_name = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":68 */ - __pyx_2 = PyObject_GetAttr(__pyx_v_oa->py_obj,__pyx_v_method_name); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 68; goto __pyx_L2;} - Py_DECREF(__pyx_v_method); - __pyx_v_method = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":70 */ - __pyx_3 = PyList_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 70; goto __pyx_L2;} - Py_INCREF(Py_None); - PyList_SET_ITEM(__pyx_3, 0, Py_None); - __pyx_4 = PyInt_FromLong(__pyx_v_argc); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 70; goto __pyx_L2;} - __pyx_2 = PyNumber_Multiply(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 70; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_v_args); - __pyx_v_args = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":71 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_argc; ++__pyx_v_i) { - __pyx_3 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,(__pyx_v_argv[__pyx_v_i])); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 72; goto __pyx_L2;} - if (__Pyx_SetItemInt(__pyx_v_args, __pyx_v_i, __pyx_3) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 72; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":74 */ - __pyx_4 = PySequence_Tuple(__pyx_v_args); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 74; goto __pyx_L2;} - __pyx_2 = PyObject_CallObject(__pyx_v_method, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 74; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_v_py_rval); - __pyx_v_py_rval = __pyx_2; - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":75 */ - __pyx_5 = __pyx_f_12spidermonkey_py2js(__pyx_v_pycx,__pyx_v_py_rval,__pyx_v_obj); if (__pyx_5 == 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 75; goto __pyx_L2;} - (__pyx_v_rval[0]) = __pyx_5; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":77 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":78 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__bound_method_callback__"); - if (__Pyx_GetException(&__pyx_3, &__pyx_4, &__pyx_2) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 78; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - goto __pyx_L0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.__bound_method_callback__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_oa); - Py_DECREF(__pyx_v_method_name); - Py_DECREF(__pyx_v_method); - Py_DECREF(__pyx_v_args); - Py_DECREF(__pyx_v_py_rval); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_JSBool __pyx_f_12spidermonkey___function_callback__(struct JSContext *__pyx_v_cx,struct JSObject *__pyx_v_obj,__pyx_t_12spidermonkey_uintN __pyx_v_argc,__pyx_t_12spidermonkey_jsval *__pyx_v_argv,__pyx_t_12spidermonkey_jsval *__pyx_v_rval) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_pycx; - struct __pyx_obj_12spidermonkey_FunctionAdapter *__pyx_v_fa; - struct JSFunction *__pyx_v_jsfunc; - struct JSObject *__pyx_v_jsobj; - int __pyx_v_i; - PyObject *__pyx_v_args; - PyObject *__pyx_v_py_rval; - __pyx_t_12spidermonkey_JSBool __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_t_12spidermonkey_jsval __pyx_5; - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - __pyx_v_fa = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_args = Py_None; Py_INCREF(Py_None); - __pyx_v_py_rval = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":88 */ - /*try:*/ { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":89 */ - __pyx_1 = (!js_context_has_data(__pyx_v_cx)); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L2;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L2;} - Py_INCREF(__pyx_k38p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k38p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 90; goto __pyx_L2;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":92 */ - __pyx_2 = js_context_fetch(__pyx_v_cx); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 92; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_2, __pyx_ptype_12spidermonkey_Context)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 92; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_pycx)); - __pyx_v_pycx = ((struct __pyx_obj_12spidermonkey_Context *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":93 */ - __pyx_v_jsfunc = JS_ValueToFunction(__pyx_v_cx,(__pyx_v_argv[(-2)])); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":94 */ - __pyx_v_jsobj = JS_GetFunctionObject(__pyx_v_jsfunc); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":96 */ - __pyx_1 = (!js_function_has_data(__pyx_v_cx,__pyx_v_jsobj)); - if (__pyx_1) { - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; goto __pyx_L2;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; goto __pyx_L2;} - Py_INCREF(__pyx_k60p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k60p); - __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; goto __pyx_L2;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 97; goto __pyx_L2;} - goto __pyx_L5; - } - __pyx_L5:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":99 */ - __pyx_3 = js_function_fetch(__pyx_v_cx,__pyx_v_jsobj); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 99; goto __pyx_L2;} - if (!__Pyx_TypeTest(__pyx_3, __pyx_ptype_12spidermonkey_FunctionAdapter)) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 99; goto __pyx_L2;} - Py_DECREF(((PyObject *)__pyx_v_fa)); - __pyx_v_fa = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_3); - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":101 */ - __pyx_4 = PyList_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 101; goto __pyx_L2;} - Py_INCREF(Py_None); - PyList_SET_ITEM(__pyx_4, 0, Py_None); - __pyx_2 = PyInt_FromLong(__pyx_v_argc); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 101; goto __pyx_L2;} - __pyx_3 = PyNumber_Multiply(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 101; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_v_args); - __pyx_v_args = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":102 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_argc; ++__pyx_v_i) { - __pyx_4 = __pyx_f_12spidermonkey_js2py(__pyx_v_pycx,(__pyx_v_argv[__pyx_v_i])); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 103; goto __pyx_L2;} - if (__Pyx_SetItemInt(__pyx_v_args, __pyx_v_i, __pyx_4) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 103; goto __pyx_L2;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":105 */ - __pyx_2 = PySequence_Tuple(__pyx_v_args); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 105; goto __pyx_L2;} - __pyx_3 = PyObject_CallObject(__pyx_v_fa->py_obj, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 105; goto __pyx_L2;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_v_py_rval); - __pyx_v_py_rval = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":106 */ - __pyx_5 = __pyx_f_12spidermonkey_py2js(__pyx_v_pycx,__pyx_v_py_rval,__pyx_v_obj); if (__pyx_5 == 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 106; goto __pyx_L2;} - (__pyx_v_rval[0]) = __pyx_5; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":108 */ - __pyx_r = JS_TRUE; - goto __pyx_L0; - } - goto __pyx_L3; - __pyx_L2:; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":109 */ - /*except:*/ { - __Pyx_AddTraceback("spidermonkey.__function_callback__"); - if (__Pyx_GetException(&__pyx_4, &__pyx_2, &__pyx_3) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 109; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_report_python_error(__pyx_v_cx); - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - goto __pyx_L0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - goto __pyx_L3; - } - __pyx_L3:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.__function_callback__"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_pycx); - Py_DECREF(__pyx_v_fa); - Py_DECREF(__pyx_v_args); - Py_DECREF(__pyx_v_py_rval); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 112; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong((JS_TypeOfValue(__pyx_v_cx->cx,__pyx_v_jsv) == JSTYPE_FUNCTION)); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 113; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_is_function"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_function(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 115; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_FunctionType); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_LambdaType); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); - __pyx_2 = 0; - __pyx_3 = 0; - __pyx_4 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_1); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyInt_FromLong(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 116; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.py_is_function"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_bound_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_bound_method(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 118; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 119; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_MethodType); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 119; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 119; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyInt_FromLong(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 119; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.py_is_bound_method"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_function(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - struct __pyx_obj_12spidermonkey_Function *__pyx_v_ret; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - Py_INCREF(__pyx_v_cx); - __pyx_v_ret = ((struct __pyx_obj_12spidermonkey_Function *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":123 */ - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 123; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_cx)); - __pyx_2 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_Function), __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 123; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(((PyObject *)__pyx_v_ret)); - __pyx_v_ret = ((struct __pyx_obj_12spidermonkey_Function *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":124 */ - __pyx_v_ret->func = __pyx_v_jsv; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":125 */ - JS_AddRoot(__pyx_v_cx->cx,(&__pyx_v_ret->func)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":126 */ - Py_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = ((PyObject *)__pyx_v_ret); - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.js2py_function"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ret); - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_bound_method(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - struct JSFunction *__pyx_v_func; - struct JSObject *__pyx_v_obj; - PyObject *__pyx_v_name; - __pyx_t_12spidermonkey_jsval __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - char *__pyx_5; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_v_name = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":133 */ - __pyx_1 = PyObject_HasAttr(__pyx_v_py_obj,__pyx_n_func_name); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 133; goto __pyx_L1;} - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n_func_name); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 134; goto __pyx_L1;} - Py_DECREF(__pyx_v_name); - __pyx_v_name = __pyx_2; - __pyx_2 = 0; - goto __pyx_L2; - } - __pyx_1 = PyObject_HasAttr(__pyx_v_py_obj,__pyx_n_im_fun); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 135; goto __pyx_L1;} - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n_im_fun); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 135; goto __pyx_L1;} - __pyx_1 = PyObject_HasAttr(__pyx_2,__pyx_n_func_name); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 135; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - } - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n_im_fun); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 136; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_func_name); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 136; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_v_name); - __pyx_v_name = __pyx_3; - __pyx_3 = 0; - goto __pyx_L2; - } - /*else*/ { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 138; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 138; goto __pyx_L1;} - Py_INCREF(__pyx_k66p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 138; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 138; goto __pyx_L1;} - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":140 */ - __pyx_5 = PyString_AsString(__pyx_v_name); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 140; goto __pyx_L1;} - __pyx_v_func = JS_NewFunction(__pyx_v_cx->cx,__pyx_f_12spidermonkey___bound_method_callback__,0,0,NULL,__pyx_5); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":141 */ - __pyx_v_obj = JS_GetFunctionObject(__pyx_v_func); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":142 */ - __pyx_r = OBJECT_TO_JSVAL(__pyx_v_obj); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.py2js_bound_method"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_name); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_function(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - struct __pyx_obj_12spidermonkey_FunctionAdapter *__pyx_v_fa; - struct JSFunction *__pyx_v_func; - PyObject *__pyx_v_name; - __pyx_t_12spidermonkey_jsval __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - char *__pyx_5; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_v_fa = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)Py_None); Py_INCREF(Py_None); - __pyx_v_name = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":150 */ - __pyx_1 = PyObject_HasAttr(__pyx_v_py_obj,__pyx_n_func_name); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 150; goto __pyx_L1;} - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n_func_name); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 151; goto __pyx_L1;} - Py_DECREF(__pyx_v_name); - __pyx_v_name = __pyx_2; - __pyx_2 = 0; - goto __pyx_L2; - } - __pyx_1 = PyObject_HasAttr(__pyx_v_py_obj,__pyx_n_im_fun); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 152; goto __pyx_L1;} - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n_im_fun); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 152; goto __pyx_L1;} - __pyx_1 = PyObject_HasAttr(__pyx_2,__pyx_n_func_name); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 152; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - } - if (__pyx_1) { - __pyx_2 = PyObject_GetAttr(__pyx_v_py_obj, __pyx_n_im_fun); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 153; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_2, __pyx_n_func_name); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 153; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_v_name); - __pyx_v_name = __pyx_3; - __pyx_3 = 0; - goto __pyx_L2; - } - /*else*/ { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 155; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 155; goto __pyx_L1;} - Py_INCREF(__pyx_k66p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k66p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 155; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[7]; __pyx_lineno = 155; goto __pyx_L1;} - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":157 */ - __pyx_5 = PyString_AsString(__pyx_v_name); if (!__pyx_5) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 157; goto __pyx_L1;} - __pyx_v_func = JS_NewFunction(__pyx_v_cx->cx,__pyx_f_12spidermonkey___function_callback__,0,0,NULL,__pyx_5); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":158 */ - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 158; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_FunctionAdapter), __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 158; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(((PyObject *)__pyx_v_fa)); - __pyx_v_fa = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)__pyx_3); - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":159 */ - __pyx_v_fa->js_obj = JS_GetFunctionObject(__pyx_v_func); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":161 */ - js_function_attach(__pyx_v_cx->cx,__pyx_v_fa->js_obj,((struct PyObject *)__pyx_v_fa)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsfunction.pxi":163 */ - __pyx_r = OBJECT_TO_JSVAL(__pyx_v_fa->js_obj); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.py2js_function"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_fa); - Py_DECREF(__pyx_v_name); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_v; - struct JSObject *__pyx_v_obj; - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - static char *__pyx_argnames[] = {"cx","v",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_v)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 2; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":4 */ - __pyx_1 = (!JSVAL_IS_OBJECT(__pyx_v_v)); - if (__pyx_1) { - Py_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":6 */ - __pyx_v_obj = JSVAL_TO_OBJECT(__pyx_v_v); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":7 */ - __pyx_2 = PyInt_FromLong(JS_IsArrayObject(__pyx_v_cx->cx,__pyx_v_obj)); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 7; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.js_is_array"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_array(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 9; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_ListType); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_TupleType); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); - __pyx_2 = 0; - __pyx_3 = 0; - __pyx_4 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_1); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyInt_FromLong(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 10; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.py_is_array"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_array(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_v) { - __pyx_t_12spidermonkey_jsuint __pyx_v_nr_elems; - __pyx_t_12spidermonkey_jsval __pyx_v_elem; - struct JSObject *__pyx_v_jsobj; - int __pyx_v_i; - PyListObject *__pyx_v_ret; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - Py_INCREF(__pyx_v_cx); - __pyx_v_ret = ((PyListObject *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":19 */ - __pyx_v_jsobj = JSVAL_TO_OBJECT(__pyx_v_v); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":20 */ - JS_GetArrayLength(__pyx_v_cx->cx,__pyx_v_jsobj,(&__pyx_v_nr_elems)); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":21 */ - __pyx_1 = PyList_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 21; goto __pyx_L1;} - Py_INCREF(Py_None); - PyList_SET_ITEM(__pyx_1, 0, Py_None); - __pyx_2 = PyInt_FromLong(__pyx_v_nr_elems); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 21; goto __pyx_L1;} - __pyx_3 = PyNumber_Multiply(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 21; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (!__Pyx_TypeTest(__pyx_3, (&PyList_Type))) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 21; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_ret)); - __pyx_v_ret = ((PyListObject *)__pyx_3); - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":23 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nr_elems; ++__pyx_v_i) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":24 */ - __pyx_4 = (!JS_GetElement(__pyx_v_cx->cx,__pyx_v_jsobj,__pyx_v_i,(&__pyx_v_elem))); - if (__pyx_4) { - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;} - Py_INCREF(__pyx_k69p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k69p); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 25; goto __pyx_L1;} - goto __pyx_L4; - } - __pyx_L4:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":26 */ - __pyx_1 = __pyx_f_12spidermonkey_js2py(__pyx_v_cx,__pyx_v_elem); if (!__pyx_1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; goto __pyx_L1;} - if (__Pyx_SetItemInt(((PyObject *)__pyx_v_ret), __pyx_v_i, __pyx_1) < 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 26; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":28 */ - Py_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = ((PyObject *)__pyx_v_ret); - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.js2py_array"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ret); - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_array(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyListObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - int __pyx_v_nr_elems; - int __pyx_v_i; - struct JSObject *__pyx_v_ret; - __pyx_t_12spidermonkey_jsval __pyx_v_elem; - __pyx_t_12spidermonkey_jsval __pyx_r; - Py_ssize_t __pyx_1; - PyObject *__pyx_2 = 0; - __pyx_t_12spidermonkey_jsval __pyx_3; - int __pyx_4; - PyObject *__pyx_5 = 0; - PyObject *__pyx_6 = 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":35 */ - __pyx_1 = PyObject_Length(((PyObject *)__pyx_v_py_obj)); if (__pyx_1 == -1) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_v_nr_elems = __pyx_1; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":36 */ - __pyx_v_ret = JS_NewArrayObject(__pyx_v_cx->cx,0,NULL); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":38 */ - for (__pyx_v_i = 0; __pyx_v_i < __pyx_v_nr_elems; ++__pyx_v_i) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":39 */ - __pyx_2 = __Pyx_GetItemInt(((PyObject *)__pyx_v_py_obj), __pyx_v_i); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; goto __pyx_L1;} - __pyx_3 = __pyx_f_12spidermonkey_py2js(__pyx_v_cx,__pyx_2,__pyx_v_parent); if (__pyx_3 == 0) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 39; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_v_elem = __pyx_3; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":40 */ - __pyx_4 = (!JS_SetElement(__pyx_v_cx->cx,__pyx_v_ret,__pyx_v_i,(&__pyx_v_elem))); - if (__pyx_4) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;} - __pyx_5 = PyTuple_New(1); if (!__pyx_5) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;} - Py_INCREF(__pyx_k70p); - PyTuple_SET_ITEM(__pyx_5, 0, __pyx_k70p); - __pyx_6 = PyObject_CallObject(__pyx_2, __pyx_5); if (!__pyx_6) {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_5); __pyx_5 = 0; - __Pyx_Raise(__pyx_6, 0, 0); - Py_DECREF(__pyx_6); __pyx_6 = 0; - {__pyx_filename = __pyx_f[8]; __pyx_lineno = 41; goto __pyx_L1;} - goto __pyx_L4; - } - __pyx_L4:; - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jsarray.pxi":43 */ - __pyx_r = OBJECT_TO_JSVAL(__pyx_v_ret); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_5); - Py_XDECREF(__pyx_6); - __Pyx_WriteUnraisable("spidermonkey.py2js_array"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 1; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(JSVAL_IS_BOOLEAN(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_is_bool"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_bool(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 4; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_BooleanType); if (!__pyx_2) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 5; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 5; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyInt_FromLong(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.py_is_bool"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_bool(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - PyObject *__pyx_r; - __pyx_t_12spidermonkey_JSBool __pyx_1; - Py_INCREF(__pyx_v_cx); - __pyx_1 = JSVAL_TO_BOOLEAN(__pyx_v_jsv); - if (__pyx_1) { - Py_INCREF(Py_True); - __pyx_r = Py_True; - goto __pyx_L0; - goto __pyx_L2; - } - /*else*/ { - Py_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - } - __pyx_L2:; - - __pyx_r = Py_None; Py_INCREF(Py_None); - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_bool(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - __pyx_t_12spidermonkey_jsval __pyx_r; - int __pyx_1; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_1 = PyObject_IsTrue(__pyx_v_py_obj); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[9]; __pyx_lineno = 14; goto __pyx_L1;} - if (__pyx_1) { - __pyx_r = BOOLEAN_TO_JSVAL(JS_TRUE); - goto __pyx_L0; - goto __pyx_L2; - } - /*else*/ { - __pyx_r = BOOLEAN_TO_JSVAL(JS_FALSE); - goto __pyx_L0; - } - __pyx_L2:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - __Pyx_WriteUnraisable("spidermonkey.py2js_bool"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_double(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_double(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(JSVAL_IS_DOUBLE(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 3; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_is_double"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_double(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_double(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_FloatType); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyInt_FromLong(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.py_is_double"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_double(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_cx); - __pyx_1 = PyFloat_FromDouble((JSVAL_TO_DOUBLE(__pyx_v_jsv)[0])); if (!__pyx_1) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 9; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js2py_double"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_double(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,double __pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - __pyx_t_12spidermonkey_jsval __pyx_v_ret; - __pyx_t_12spidermonkey_jsval __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - Py_INCREF(__pyx_v_cx); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsdouble.pxi":13 */ - __pyx_1 = (!JS_NewNumberValue(__pyx_v_cx->cx,__pyx_v_py_obj,(&__pyx_v_ret))); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; goto __pyx_L1;} - Py_INCREF(__pyx_k73p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k73p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[10]; __pyx_lineno = 14; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsdouble.pxi":15 */ - __pyx_r = __pyx_v_ret; - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_WriteUnraisable("spidermonkey.py2js_double"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_hash(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_hash(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_v; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","v",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_v)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(JSVAL_IS_OBJECT(__pyx_v_v)); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 3; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_is_hash"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_hash(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_hash(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_DictionaryType); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_DictType); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); - __pyx_2 = 0; - __pyx_3 = 0; - __pyx_4 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_1); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyInt_FromLong(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.py_is_hash"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_hash(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_v) { - struct JSObject *__pyx_v_hash; - struct JSIdArray *__pyx_v_props; - __pyx_t_12spidermonkey_jsval __pyx_v_jskey; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - int __pyx_v_i; - PyDictObject *__pyx_v_ret; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_js_str; - PyObject *__pyx_v_key; - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_t_12spidermonkey_jsint __pyx_5; - __pyx_t_12spidermonkey_jsint __pyx_6; - Py_INCREF(__pyx_v_cx); - __pyx_v_ret = ((PyDictObject *)Py_None); Py_INCREF(Py_None); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - __pyx_v_key = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":18 */ - __pyx_v_hash = JSVAL_TO_OBJECT(__pyx_v_v); - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":20 */ - __pyx_v_props = JS_Enumerate(__pyx_v_cx->cx,__pyx_v_hash); - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":21 */ - __pyx_1 = (__pyx_v_props == NULL); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 22; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 22; goto __pyx_L1;} - Py_INCREF(__pyx_k76p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k76p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 22; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 22; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":24 */ - __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 24; goto __pyx_L1;} - if (!__Pyx_TypeTest(__pyx_2, (&PyDict_Type))) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 24; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_ret)); - __pyx_v_ret = ((PyDictObject *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":26 */ - /*try:*/ { - __pyx_5 = __pyx_v_props->length; - for (__pyx_v_i = 0; __pyx_v_i < __pyx_5; ++__pyx_v_i) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":28 */ - __pyx_1 = (!JS_IdToValue(__pyx_v_cx->cx,(__pyx_v_props->vector[__pyx_v_i]),(&__pyx_v_jskey))); - if (__pyx_1) { - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 29; goto __pyx_L4;} - __pyx_4 = PyTuple_New(1); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 29; goto __pyx_L4;} - Py_INCREF(__pyx_k77p); - PyTuple_SET_ITEM(__pyx_4, 0, __pyx_k77p); - __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 29; goto __pyx_L4;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_4); __pyx_4 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 29; goto __pyx_L4;} - goto __pyx_L8; - } - __pyx_L8:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":31 */ - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_string); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 31; goto __pyx_L4;} - __pyx_4 = PyInt_FromLong(__pyx_v_jskey); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 31; goto __pyx_L4;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 31; goto __pyx_L4;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_4); - __pyx_4 = 0; - __pyx_4 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 31; goto __pyx_L4;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyObject_IsTrue(__pyx_4); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 31; goto __pyx_L4;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":32 */ - __pyx_3 = __pyx_f_12spidermonkey_js2py_string(__pyx_v_cx,__pyx_v_jskey); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 32; goto __pyx_L4;} - Py_DECREF(__pyx_v_key); - __pyx_v_key = __pyx_3; - __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":33 */ - __pyx_2 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(__pyx_v_cx->cx,__pyx_v_key)); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 33; goto __pyx_L4;} - Py_DECREF(((PyObject *)__pyx_v_js_str)); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":35 */ - __pyx_1 = (!JS_GetUCProperty(__pyx_v_cx->cx,__pyx_v_hash,((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->chars(__pyx_v_js_str),((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->length(__pyx_v_js_str),(&__pyx_v_jsv))); - if (__pyx_1) { - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L4;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L4;} - Py_INCREF(__pyx_k79p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k79p); - __pyx_2 = PyObject_CallObject(__pyx_4, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L4;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 36; goto __pyx_L4;} - goto __pyx_L10; - } - __pyx_L10:; - goto __pyx_L9; - } - __pyx_4 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_int); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 37; goto __pyx_L4;} - __pyx_3 = PyInt_FromLong(__pyx_v_jskey); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 37; goto __pyx_L4;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 37; goto __pyx_L4;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_3); - __pyx_3 = 0; - __pyx_3 = PyObject_CallObject(__pyx_4, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 37; goto __pyx_L4;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyObject_IsTrue(__pyx_3); if (__pyx_1 < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 37; goto __pyx_L4;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_1) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":38 */ - __pyx_4 = __pyx_f_12spidermonkey_js2py_int(__pyx_v_cx,__pyx_v_jskey); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 38; goto __pyx_L4;} - Py_DECREF(__pyx_v_key); - __pyx_v_key = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":39 */ - __pyx_6 = PyInt_AsLong(__pyx_v_key); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 39; goto __pyx_L4;} - __pyx_1 = (!JS_GetElement(__pyx_v_cx->cx,__pyx_v_hash,__pyx_6,(&__pyx_v_jsv))); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; goto __pyx_L4;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; goto __pyx_L4;} - Py_INCREF(__pyx_k81p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k81p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; goto __pyx_L4;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 40; goto __pyx_L4;} - goto __pyx_L11; - } - __pyx_L11:; - goto __pyx_L9; - } - /*else*/ { - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 42; goto __pyx_L4;} - Py_INCREF(__pyx_k82p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k82p); - __pyx_3 = PyObject_CallObject(PyExc_AssertionError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 42; goto __pyx_L4;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 42; goto __pyx_L4;} - } - __pyx_L9:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":44 */ - __pyx_4 = __pyx_f_12spidermonkey_js2py(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 44; goto __pyx_L4;} - if (PyObject_SetItem(((PyObject *)__pyx_v_ret), __pyx_v_key, __pyx_4) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 44; goto __pyx_L4;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - } - } - /*finally:*/ { - int __pyx_why; - PyObject *__pyx_exc_type, *__pyx_exc_value, *__pyx_exc_tb; - int __pyx_exc_lineno; - __pyx_why = 0; goto __pyx_L5; - __pyx_L4: { - __pyx_why = 4; - Py_XDECREF(__pyx_2); __pyx_2 = 0; - Py_XDECREF(__pyx_3); __pyx_3 = 0; - Py_XDECREF(__pyx_4); __pyx_4 = 0; - PyErr_Fetch(&__pyx_exc_type, &__pyx_exc_value, &__pyx_exc_tb); - __pyx_exc_lineno = __pyx_lineno; - goto __pyx_L5; - } - __pyx_L5:; - JS_DestroyIdArray(__pyx_v_cx->cx,__pyx_v_props); - switch (__pyx_why) { - case 4: { - PyErr_Restore(__pyx_exc_type, __pyx_exc_value, __pyx_exc_tb); - __pyx_lineno = __pyx_exc_lineno; - __pyx_exc_type = 0; - __pyx_exc_value = 0; - __pyx_exc_tb = 0; - goto __pyx_L1; - } - } - } - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":48 */ - Py_INCREF(((PyObject *)__pyx_v_ret)); - __pyx_r = ((PyObject *)__pyx_v_ret); - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey.js2py_hash"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_ret); - Py_DECREF(__pyx_v_js_str); - Py_DECREF(__pyx_v_key); - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_hash(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyDictObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - struct JSObject *__pyx_v_obj; - __pyx_t_12spidermonkey_jsval __pyx_v_elem; - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_js_str; - PyObject *__pyx_v_k; - PyObject *__pyx_v_v; - __pyx_t_12spidermonkey_jsval __pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_t_12spidermonkey_jsval __pyx_5; - PyObject *__pyx_6 = 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - __pyx_v_k = Py_None; Py_INCREF(Py_None); - __pyx_v_v = Py_None; Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":56 */ - __pyx_v_obj = JS_NewObject(__pyx_v_cx->cx,NULL,NULL,__pyx_v_parent); - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":57 */ - __pyx_1 = (__pyx_v_obj == NULL); - if (__pyx_1) { - __pyx_2 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 58; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 58; goto __pyx_L1;} - Py_INCREF(__pyx_k83p); - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_k83p); - __pyx_4 = PyObject_CallObject(__pyx_2, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 58; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __Pyx_Raise(__pyx_4, 0, 0); - Py_DECREF(__pyx_4); __pyx_4 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 58; goto __pyx_L1;} - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":60 */ - __pyx_2 = PyObject_GetAttr(((PyObject *)__pyx_v_py_obj), __pyx_n_iteritems); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - __pyx_3 = PyObject_CallObject(__pyx_2, 0); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_GetIter(__pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - for (;;) { - __pyx_2 = PyIter_Next(__pyx_4); - if (!__pyx_2) { - if (PyErr_Occurred()) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - break; - } - __pyx_3 = PyObject_GetIter(__pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_2 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_v_k); - __pyx_v_k = __pyx_2; - __pyx_2 = 0; - __pyx_2 = __Pyx_UnpackItem(__pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_v_v); - __pyx_v_v = __pyx_2; - __pyx_2 = 0; - if (__Pyx_EndUnpack(__pyx_3) < 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 60; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":61 */ - __pyx_2 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(__pyx_v_cx->cx,__pyx_v_k)); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 61; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_js_str)); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_2); - __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":62 */ - __pyx_5 = __pyx_f_12spidermonkey_py2js(__pyx_v_cx,__pyx_v_v,__pyx_v_obj); if (__pyx_5 == 0) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 62; goto __pyx_L1;} - __pyx_v_elem = __pyx_5; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":64 */ - __pyx_1 = (!JS_SetUCProperty(__pyx_v_cx->cx,__pyx_v_obj,((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->chars(__pyx_v_js_str),((struct __pyx_vtabstruct_12spidermonkey_PyJSString *)__pyx_v_js_str->__pyx_vtab)->length(__pyx_v_js_str),(&__pyx_v_elem))); - if (__pyx_1) { - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_JSError); if (!__pyx_3) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 65; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 65; goto __pyx_L1;} - Py_INCREF(__pyx_k85p); - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_k85p); - __pyx_6 = PyObject_CallObject(__pyx_3, __pyx_2); if (!__pyx_6) {__pyx_filename = __pyx_f[11]; __pyx_lineno = 65; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_6, 0, 0); - Py_DECREF(__pyx_6); __pyx_6 = 0; - {__pyx_filename = __pyx_f[11]; __pyx_lineno = 65; goto __pyx_L1;} - goto __pyx_L5; - } - __pyx_L5:; - } - Py_DECREF(__pyx_4); __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jshash.pxi":67 */ - __pyx_r = OBJECT_TO_JSVAL(__pyx_v_obj); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - Py_XDECREF(__pyx_6); - __Pyx_WriteUnraisable("spidermonkey.py2js_hash"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_js_str); - Py_DECREF(__pyx_v_k); - Py_DECREF(__pyx_v_v); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(JSVAL_IS_INT(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 3; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_is_int"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_int(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_IntType); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_3 = PyObject_GetAttr(__pyx_1, __pyx_n_LongType); if (!__pyx_3) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_3); - __pyx_2 = 0; - __pyx_3 = 0; - __pyx_4 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_1); if (__pyx_4 == -1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_2 = PyInt_FromLong(__pyx_4); if (!__pyx_2) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.py_is_int"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_int(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_cx); - __pyx_1 = PyInt_FromLong(JSVAL_TO_INT(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[12]; __pyx_lineno = 9; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js2py_int"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_int(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsint __pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - __pyx_t_12spidermonkey_jsval __pyx_r; - Py_INCREF(__pyx_v_cx); - __pyx_r = INT_TO_JSVAL(__pyx_v_py_obj); - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_string(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_string(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 4; goto __pyx_L1;} - __pyx_1 = PyInt_FromLong(JSVAL_IS_STRING(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_is_string"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_string(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_string(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - int __pyx_4; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 7; goto __pyx_L1;} - - /* "/usr/local/src/python-spidermonkey/old-sm/jsstring.pxi":8 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_StringTypes); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 8; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_3) { - - /* "/usr/local/src/python-spidermonkey/old-sm/jsstring.pxi":9 */ - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_UnicodeType); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 9; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = (!__pyx_3); - if (__pyx_4) { - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; goto __pyx_L1;} - Py_INCREF(__pyx_k87p); - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_k87p); - __pyx_2 = PyObject_CallObject(PyExc_UnicodeError, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_2, 0, 0); - Py_DECREF(__pyx_2); __pyx_2 = 0; - {__pyx_filename = __pyx_f[13]; __pyx_lineno = 10; goto __pyx_L1;} - goto __pyx_L3; - } - __pyx_L3:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsstring.pxi":11 */ - Py_INCREF(Py_True); - __pyx_r = Py_True; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_L2:; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsstring.pxi":12 */ - Py_INCREF(Py_False); - __pyx_r = Py_False; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.py_is_string"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_string(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - struct __pyx_obj_12spidermonkey_PyJSString *__pyx_v_js_str; - __pyx_t_12spidermonkey_jsval __pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsstring.pxi":16 */ - __pyx_1 = ((PyObject *)__pyx_f_12spidermonkey_py2js_jsstring(__pyx_v_cx->cx,__pyx_v_py_obj)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 16; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_js_str)); - __pyx_v_js_str = ((struct __pyx_obj_12spidermonkey_PyJSString *)__pyx_1); - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsstring.pxi":17 */ - __pyx_r = STRING_TO_JSVAL(__pyx_v_js_str->data); - goto __pyx_L0; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_WriteUnraisable("spidermonkey.py2js_string"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_js_str); - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_string(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - Py_INCREF(__pyx_v_cx); - __pyx_1 = __pyx_f_12spidermonkey_js2py_jsstring(JSVAL_TO_STRING(__pyx_v_jsv)); if (!__pyx_1) {__pyx_filename = __pyx_f[13]; __pyx_lineno = 20; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js2py_string"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js_is_void(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_js_is_void(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - __pyx_t_12spidermonkey_jsval __pyx_v_jsv; - PyObject *__pyx_r; - int __pyx_1; - PyObject *__pyx_2 = 0; - static char *__pyx_argnames[] = {"cx","jsv",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "Oi", __pyx_argnames, &__pyx_v_cx, &__pyx_v_jsv)) return 0; - Py_INCREF(__pyx_v_cx); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_1 = JSVAL_IS_VOID(__pyx_v_jsv); - if (!__pyx_1) { - __pyx_1 = (__pyx_v_jsv == 0); - } - __pyx_2 = PyInt_FromLong(__pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 3; goto __pyx_L1;} - __pyx_r = __pyx_2; - __pyx_2 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.js_is_void"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_py_is_void(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/ -static PyObject *__pyx_f_12spidermonkey_py_is_void(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) { - struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx = 0; - PyObject *__pyx_v_py_obj = 0; - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - int __pyx_3; - static char *__pyx_argnames[] = {"cx","py_obj",0}; - if (!PyArg_ParseTupleAndKeywords(__pyx_args, __pyx_kwds, "OO", __pyx_argnames, &__pyx_v_cx, &__pyx_v_py_obj)) return 0; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - if (!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_cx), __pyx_ptype_12spidermonkey_Context, 1, "cx")) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_types); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_2 = PyObject_GetAttr(__pyx_1, __pyx_n_NoneType); if (!__pyx_2) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_3 = PyObject_IsInstance(__pyx_v_py_obj,__pyx_2); if (__pyx_3 == -1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 6; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_1 = PyInt_FromLong(__pyx_3); if (!__pyx_1) {__pyx_filename = __pyx_f[14]; __pyx_lineno = 6; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - __Pyx_AddTraceback("spidermonkey.py_is_void"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py_void(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - PyObject *__pyx_r; - Py_INCREF(__pyx_v_cx); - Py_INCREF(Py_None); - __pyx_r = Py_None; - goto __pyx_L0; - - __pyx_r = Py_None; Py_INCREF(Py_None); - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js_void(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - __pyx_t_12spidermonkey_jsval __pyx_r; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_r = JSVAL_VOID; - goto __pyx_L0; - - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static __pyx_t_12spidermonkey_jsval __pyx_f_12spidermonkey_py2js(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,PyObject *__pyx_v_py_obj,struct JSObject *__pyx_v_parent) { - __pyx_t_12spidermonkey_jsval __pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - __pyx_t_12spidermonkey_jsint __pyx_5; - double __pyx_6; - Py_INCREF(__pyx_v_cx); - Py_INCREF(__pyx_v_py_obj); - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_void); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 3; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 3; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 3; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 3; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_r = __pyx_f_12spidermonkey_py2js_void(__pyx_v_cx,__pyx_v_py_obj,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_bool); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 5; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_r = __pyx_f_12spidermonkey_py2js_bool(__pyx_v_cx,__pyx_v_py_obj,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_int); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 7; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 7; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 7; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 7; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_5 = PyInt_AsLong(__pyx_v_py_obj); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 8; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_py2js_int(__pyx_v_cx,__pyx_5,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_double); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 9; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 9; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 9; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 9; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_6 = PyFloat_AsDouble(__pyx_v_py_obj); if (PyErr_Occurred()) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 10; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_py2js_double(__pyx_v_cx,__pyx_6,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_string); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 11; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 11; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 11; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 11; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_r = __pyx_f_12spidermonkey_py2js_string(__pyx_v_cx,__pyx_v_py_obj,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_array); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 13; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 13; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 13; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 13; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - if (!__Pyx_TypeTest(__pyx_v_py_obj, (&PyList_Type))) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 14; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_py2js_array(__pyx_v_cx,((PyListObject *)__pyx_v_py_obj),__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_hash); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 15; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 15; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 15; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 15; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - if (!__Pyx_TypeTest(__pyx_v_py_obj, (&PyDict_Type))) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 16; goto __pyx_L1;} - __pyx_r = __pyx_f_12spidermonkey_py2js_hash(__pyx_v_cx,((PyDictObject *)__pyx_v_py_obj),__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_bound_method); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 17; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 17; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 17; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 17; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_r = __pyx_f_12spidermonkey_py2js_bound_method(__pyx_v_cx,__pyx_v_py_obj,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_function); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 19; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 19; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 19; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 19; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_r = __pyx_f_12spidermonkey_py2js_function(__pyx_v_cx,__pyx_v_py_obj,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_py_is_object); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 21; goto __pyx_L1;} - __pyx_2 = PyTuple_New(2); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 21; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_2, 0, ((PyObject *)__pyx_v_cx)); - Py_INCREF(__pyx_v_py_obj); - PyTuple_SET_ITEM(__pyx_2, 1, __pyx_v_py_obj); - __pyx_3 = PyObject_CallObject(__pyx_1, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 21; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_3); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 21; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (__pyx_4) { - __pyx_r = __pyx_f_12spidermonkey_py2js_object(__pyx_v_cx,__pyx_v_py_obj,__pyx_v_parent); - goto __pyx_L0; - goto __pyx_L2; - } - /*else*/ { - __pyx_1 = PyNumber_Remainder(__pyx_k99p, __pyx_v_py_obj); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 26; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 26; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_2, 0, __pyx_1); - __pyx_1 = 0; - __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 26; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[15]; __pyx_lineno = 26; goto __pyx_L1;} - } - __pyx_L2:; - - __pyx_r = 0; - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.py2js"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - Py_DECREF(__pyx_v_py_obj); - return __pyx_r; -} - -static PyObject *__pyx_f_12spidermonkey_js2py(struct __pyx_obj_12spidermonkey_Context *__pyx_v_cx,__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - PyObject *__pyx_r; - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - int __pyx_4; - Py_INCREF(__pyx_v_cx); - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_void); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 29; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 29; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 29; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 29; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_1 = __pyx_f_12spidermonkey_js2py_void(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 30; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_bool); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 31; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 31; goto __pyx_L1;} - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 31; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 31; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 31; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_3 = __pyx_f_12spidermonkey_js2py_bool(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 32; goto __pyx_L1;} - __pyx_r = __pyx_3; - __pyx_3 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_int); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 33; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 33; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 33; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 33; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_1 = __pyx_f_12spidermonkey_js2py_int(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 34; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_double); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 35; goto __pyx_L1;} - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 35; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 35; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 35; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_3 = __pyx_f_12spidermonkey_js2py_double(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 36; goto __pyx_L1;} - __pyx_r = __pyx_3; - __pyx_3 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_string); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 37; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 37; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 37; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 37; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 37; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_1 = __pyx_f_12spidermonkey_js2py_string(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 38; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_array); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 39; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 39; goto __pyx_L1;} - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 39; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 39; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 39; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_3 = __pyx_f_12spidermonkey_js2py_array(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 40; goto __pyx_L1;} - __pyx_r = __pyx_3; - __pyx_3 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_function); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 41; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 41; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 41; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 41; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 41; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_1 = __pyx_f_12spidermonkey_js2py_function(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 42; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_3 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_object); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 43; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 43; goto __pyx_L1;} - __pyx_1 = PyTuple_New(2); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 43; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_1, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_3, __pyx_1); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 43; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 43; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_3 = __pyx_f_12spidermonkey_js2py_object(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 44; goto __pyx_L1;} - __pyx_r = __pyx_3; - __pyx_3 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - __pyx_1 = __Pyx_GetName(__pyx_m, __pyx_n_js_is_hash); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_2 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 45; goto __pyx_L1;} - __pyx_3 = PyTuple_New(2); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 45; goto __pyx_L1;} - Py_INCREF(((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 0, ((PyObject *)__pyx_v_cx)); - PyTuple_SET_ITEM(__pyx_3, 1, __pyx_2); - __pyx_2 = 0; - __pyx_2 = PyObject_CallObject(__pyx_1, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 45; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_4 = PyObject_IsTrue(__pyx_2); if (__pyx_4 < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 45; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (__pyx_4) { - __pyx_1 = __pyx_f_12spidermonkey_js2py_hash(__pyx_v_cx,__pyx_v_jsv); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 46; goto __pyx_L1;} - __pyx_r = __pyx_1; - __pyx_1 = 0; - goto __pyx_L0; - goto __pyx_L2; - } - /*else*/ { - __pyx_3 = PyInt_FromLong(__pyx_v_jsv); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; goto __pyx_L1;} - __pyx_2 = PyNumber_Remainder(__pyx_k107p, __pyx_3); if (!__pyx_2) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - __pyx_1 = PyTuple_New(1); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_1, 0, __pyx_2); - __pyx_2 = 0; - __pyx_3 = PyObject_CallObject(PyExc_TypeError, __pyx_1); if (!__pyx_3) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - __Pyx_Raise(__pyx_3, 0, 0); - Py_DECREF(__pyx_3); __pyx_3 = 0; - {__pyx_filename = __pyx_f[15]; __pyx_lineno = 48; goto __pyx_L1;} - } - __pyx_L2:; - - __pyx_r = Py_None; Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - __Pyx_AddTraceback("spidermonkey.js2py"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_cx); - return __pyx_r; -} - -static struct __pyx_obj_12spidermonkey_Value *__pyx_f_12spidermonkey_js_create_value(__pyx_t_12spidermonkey_jsval __pyx_v_jsv) { - struct __pyx_obj_12spidermonkey_Value *__pyx_v_v; - struct __pyx_obj_12spidermonkey_Value *__pyx_r; - PyObject *__pyx_1 = 0; - __pyx_v_v = ((struct __pyx_obj_12spidermonkey_Value *)Py_None); Py_INCREF(Py_None); - - /* "/usr/local/src/python-spidermonkey/old-sm/jsvalue.pxi":55 */ - __pyx_1 = PyObject_CallObject(((PyObject *)__pyx_ptype_12spidermonkey_Value), 0); if (!__pyx_1) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 55; goto __pyx_L1;} - Py_DECREF(((PyObject *)__pyx_v_v)); - __pyx_v_v = ((struct __pyx_obj_12spidermonkey_Value *)__pyx_1); - __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsvalue.pxi":56 */ - __pyx_v_v->jsv = __pyx_v_jsv; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsvalue.pxi":57 */ - Py_INCREF(((PyObject *)__pyx_v_v)); - __pyx_r = __pyx_v_v; - goto __pyx_L0; - - __pyx_r = ((struct __pyx_obj_12spidermonkey_Value *)Py_None); Py_INCREF(Py_None); - goto __pyx_L0; - __pyx_L1:; - Py_XDECREF(__pyx_1); - __Pyx_AddTraceback("spidermonkey.js_create_value"); - __pyx_r = 0; - __pyx_L0:; - Py_DECREF(__pyx_v_v); - return __pyx_r; -} -static struct __pyx_vtabstruct_12spidermonkey_PyJSString __pyx_vtable_12spidermonkey_PyJSString; - -static PyObject *__pyx_tp_new_12spidermonkey_PyJSString(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_PyJSString *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_PyJSString *)o); - *(struct __pyx_vtabstruct_12spidermonkey_PyJSString **)&p->__pyx_vtab = __pyx_vtabptr_12spidermonkey_PyJSString; - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_PyJSString(PyObject *o) { - (*o->ob_type->tp_free)(o); -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_PyJSString[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_PyJSString = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_PyJSString = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_PyJSString = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_PyJSString = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_PyJSString = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.PyJSString", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_PyJSString), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_PyJSString, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_PyJSString, /*tp_as_number*/ - &__pyx_tp_as_sequence_PyJSString, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_PyJSString, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_PyJSString, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_PyJSString, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_PyJSString, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_Context(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_Context *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_Context *)o); - p->rt = ((struct __pyx_obj_12spidermonkey_Runtime *)Py_None); Py_INCREF(Py_None); - p->root = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - p->gc = ((struct __pyx_obj_12spidermonkey_GC *)Py_None); Py_INCREF(Py_None); - p->reg = Py_None; Py_INCREF(Py_None); - p->classes = Py_None; Py_INCREF(Py_None); - p->error = Py_None; Py_INCREF(Py_None); - if (__pyx_f_12spidermonkey_7Context___cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_Context(PyObject *o) { - struct __pyx_obj_12spidermonkey_Context *p = (struct __pyx_obj_12spidermonkey_Context *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++o->ob_refcnt; - __pyx_f_12spidermonkey_7Context___dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --o->ob_refcnt; - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(((PyObject *)p->rt)); - Py_XDECREF(((PyObject *)p->root)); - Py_XDECREF(((PyObject *)p->gc)); - Py_XDECREF(p->reg); - Py_XDECREF(p->classes); - Py_XDECREF(p->error); - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_12spidermonkey_Context(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_12spidermonkey_Context *p = (struct __pyx_obj_12spidermonkey_Context *)o; - if (p->rt) { - e = (*v)(((PyObject*)p->rt), a); if (e) return e; - } - if (p->root) { - e = (*v)(((PyObject*)p->root), a); if (e) return e; - } - if (p->gc) { - e = (*v)(((PyObject*)p->gc), a); if (e) return e; - } - if (p->reg) { - e = (*v)(p->reg, a); if (e) return e; - } - if (p->classes) { - e = (*v)(p->classes, a); if (e) return e; - } - if (p->error) { - e = (*v)(p->error, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_12spidermonkey_Context(PyObject *o) { - struct __pyx_obj_12spidermonkey_Context *p = (struct __pyx_obj_12spidermonkey_Context *)o; - PyObject *t; - t = ((PyObject *)p->rt); - p->rt = ((struct __pyx_obj_12spidermonkey_Runtime *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = ((PyObject *)p->root); - p->root = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = ((PyObject *)p->gc); - p->gc = ((struct __pyx_obj_12spidermonkey_GC *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = p->reg; - p->reg = Py_None; Py_INCREF(Py_None); - Py_XDECREF(t); - t = p->classes; - p->classes = Py_None; Py_INCREF(Py_None); - Py_XDECREF(t); - t = p->error; - p->error = Py_None; Py_INCREF(Py_None); - Py_XDECREF(t); - return 0; -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_Context[] = { - {"install_class", (PyCFunction)__pyx_f_12spidermonkey_7Context_install_class, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12spidermonkey_7Context_install_class}, - {"bind", (PyCFunction)__pyx_f_12spidermonkey_7Context_bind, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12spidermonkey_7Context_bind}, - {"unbind", (PyCFunction)__pyx_f_12spidermonkey_7Context_unbind, METH_VARARGS|METH_KEYWORDS, 0}, - {"execute", (PyCFunction)__pyx_f_12spidermonkey_7Context_execute, METH_VARARGS|METH_KEYWORDS, __pyx_doc_12spidermonkey_7Context_execute}, - {"set_error", (PyCFunction)__pyx_f_12spidermonkey_7Context_set_error, METH_VARARGS|METH_KEYWORDS, 0}, - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Context = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_Context = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Context = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_Context = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_Context = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.Context", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_Context), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_Context, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_Context, /*tp_as_number*/ - &__pyx_tp_as_sequence_Context, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Context, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Context, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_12spidermonkey_Context, /*tp_traverse*/ - __pyx_tp_clear_12spidermonkey_Context, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_Context, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_f_12spidermonkey_7Context___init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_Context, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_Function(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_Function *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_Function *)o); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_Function(PyObject *o) { - struct __pyx_obj_12spidermonkey_Function *p = (struct __pyx_obj_12spidermonkey_Function *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++o->ob_refcnt; - __pyx_f_12spidermonkey_8Function___dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --o->ob_refcnt; - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(((PyObject *)p->cx)); - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_12spidermonkey_Function(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_12spidermonkey_Function *p = (struct __pyx_obj_12spidermonkey_Function *)o; - if (p->cx) { - e = (*v)(((PyObject*)p->cx), a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_12spidermonkey_Function(PyObject *o) { - struct __pyx_obj_12spidermonkey_Function *p = (struct __pyx_obj_12spidermonkey_Function *)o; - PyObject *t; - t = ((PyObject *)p->cx); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - return 0; -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_Function[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Function = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_Function = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Function = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_Function = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_Function = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.Function", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_Function), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_Function, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_Function, /*tp_as_number*/ - &__pyx_tp_as_sequence_Function, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Function, /*tp_as_mapping*/ - 0, /*tp_hash*/ - __pyx_f_12spidermonkey_8Function___call__, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Function, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_12spidermonkey_Function, /*tp_traverse*/ - __pyx_tp_clear_12spidermonkey_Function, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_Function, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - __pyx_f_12spidermonkey_8Function___init__, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_Function, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; -static struct __pyx_vtabstruct_12spidermonkey_GC __pyx_vtable_12spidermonkey_GC; - -static PyObject *__pyx_tp_new_12spidermonkey_GC(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_GC *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_GC *)o); - *(struct __pyx_vtabstruct_12spidermonkey_GC **)&p->__pyx_vtab = __pyx_vtabptr_12spidermonkey_GC; - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - if (__pyx_f_12spidermonkey_2GC___cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_GC(PyObject *o) { - struct __pyx_obj_12spidermonkey_GC *p = (struct __pyx_obj_12spidermonkey_GC *)o; - Py_XDECREF(((PyObject *)p->cx)); - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_12spidermonkey_GC(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_12spidermonkey_GC *p = (struct __pyx_obj_12spidermonkey_GC *)o; - if (p->cx) { - e = (*v)(((PyObject*)p->cx), a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_12spidermonkey_GC(PyObject *o) { - struct __pyx_obj_12spidermonkey_GC *p = (struct __pyx_obj_12spidermonkey_GC *)o; - PyObject *t; - t = ((PyObject *)p->cx); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - return 0; -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_GC[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_GC = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_GC = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_GC = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_GC = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_GC = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.GC", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_GC), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_GC, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_GC, /*tp_as_number*/ - &__pyx_tp_as_sequence_GC, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_GC, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_GC, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_12spidermonkey_GC, /*tp_traverse*/ - __pyx_tp_clear_12spidermonkey_GC, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_GC, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_GC, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_Runtime(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - if (__pyx_f_12spidermonkey_7Runtime___cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_Runtime(PyObject *o) { - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++o->ob_refcnt; - __pyx_f_12spidermonkey_7Runtime___dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --o->ob_refcnt; - PyErr_Restore(etype, eval, etb); - } - (*o->ob_type->tp_free)(o); -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_Runtime[] = { - {"create_context", (PyCFunction)__pyx_f_12spidermonkey_7Runtime_create_context, METH_VARARGS|METH_KEYWORDS, 0}, - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Runtime = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_Runtime = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Runtime = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_Runtime = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_Runtime = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.Runtime", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_Runtime), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_Runtime, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_Runtime, /*tp_as_number*/ - &__pyx_tp_as_sequence_Runtime, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Runtime, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Runtime, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_Runtime, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_Runtime, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_Value(PyTypeObject *t, PyObject *a, PyObject *k) { - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_Value(PyObject *o) { - (*o->ob_type->tp_free)(o); -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_Value[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_Value = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_Value = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_Value = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_Value = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_Value = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.Value", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_Value), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_Value, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - 0, /*tp_repr*/ - &__pyx_tp_as_number_Value, /*tp_as_number*/ - &__pyx_tp_as_sequence_Value, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_Value, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_Value, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE, /*tp_flags*/ - 0, /*tp_doc*/ - 0, /*tp_traverse*/ - 0, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_Value, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_Value, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_ClassAdapter(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_ClassAdapter *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)o); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - p->parent = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - p->py_class = Py_None; Py_INCREF(Py_None); - if (__pyx_f_12spidermonkey_12ClassAdapter___cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_ClassAdapter(PyObject *o) { - struct __pyx_obj_12spidermonkey_ClassAdapter *p = (struct __pyx_obj_12spidermonkey_ClassAdapter *)o; - { - PyObject *etype, *eval, *etb; - PyErr_Fetch(&etype, &eval, &etb); - ++o->ob_refcnt; - __pyx_f_12spidermonkey_12ClassAdapter___dealloc__(o); - if (PyErr_Occurred()) PyErr_WriteUnraisable(o); - --o->ob_refcnt; - PyErr_Restore(etype, eval, etb); - } - Py_XDECREF(((PyObject *)p->cx)); - Py_XDECREF(((PyObject *)p->parent)); - Py_XDECREF(p->py_class); - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_12spidermonkey_ClassAdapter(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_12spidermonkey_ClassAdapter *p = (struct __pyx_obj_12spidermonkey_ClassAdapter *)o; - if (p->cx) { - e = (*v)(((PyObject*)p->cx), a); if (e) return e; - } - if (p->parent) { - e = (*v)(((PyObject*)p->parent), a); if (e) return e; - } - if (p->py_class) { - e = (*v)(p->py_class, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_12spidermonkey_ClassAdapter(PyObject *o) { - struct __pyx_obj_12spidermonkey_ClassAdapter *p = (struct __pyx_obj_12spidermonkey_ClassAdapter *)o; - PyObject *t; - t = ((PyObject *)p->cx); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = ((PyObject *)p->parent); - p->parent = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = p->py_class; - p->py_class = Py_None; Py_INCREF(Py_None); - Py_XDECREF(t); - return 0; -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_ClassAdapter[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_ClassAdapter = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_ClassAdapter = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_ClassAdapter = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_ClassAdapter = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_ClassAdapter = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.ClassAdapter", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_ClassAdapter), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_ClassAdapter, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - __pyx_f_12spidermonkey_12ClassAdapter___repr__, /*tp_repr*/ - &__pyx_tp_as_number_ClassAdapter, /*tp_as_number*/ - &__pyx_tp_as_sequence_ClassAdapter, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_ClassAdapter, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_ClassAdapter, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_12spidermonkey_ClassAdapter, /*tp_traverse*/ - __pyx_tp_clear_12spidermonkey_ClassAdapter, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_ClassAdapter, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_ClassAdapter, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_ObjectAdapter(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_ObjectAdapter *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)o); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - p->cl_adapter = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - p->parent = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - p->py_obj = Py_None; Py_INCREF(Py_None); - if (__pyx_f_12spidermonkey_13ObjectAdapter___cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_ObjectAdapter(PyObject *o) { - struct __pyx_obj_12spidermonkey_ObjectAdapter *p = (struct __pyx_obj_12spidermonkey_ObjectAdapter *)o; - Py_XDECREF(((PyObject *)p->cx)); - Py_XDECREF(((PyObject *)p->cl_adapter)); - Py_XDECREF(((PyObject *)p->parent)); - Py_XDECREF(p->py_obj); - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_12spidermonkey_ObjectAdapter(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_12spidermonkey_ObjectAdapter *p = (struct __pyx_obj_12spidermonkey_ObjectAdapter *)o; - if (p->cx) { - e = (*v)(((PyObject*)p->cx), a); if (e) return e; - } - if (p->cl_adapter) { - e = (*v)(((PyObject*)p->cl_adapter), a); if (e) return e; - } - if (p->parent) { - e = (*v)(((PyObject*)p->parent), a); if (e) return e; - } - if (p->py_obj) { - e = (*v)(p->py_obj, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_12spidermonkey_ObjectAdapter(PyObject *o) { - struct __pyx_obj_12spidermonkey_ObjectAdapter *p = (struct __pyx_obj_12spidermonkey_ObjectAdapter *)o; - PyObject *t; - t = ((PyObject *)p->cx); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = ((PyObject *)p->cl_adapter); - p->cl_adapter = ((struct __pyx_obj_12spidermonkey_ClassAdapter *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = ((PyObject *)p->parent); - p->parent = ((struct __pyx_obj_12spidermonkey_ObjectAdapter *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = p->py_obj; - p->py_obj = Py_None; Py_INCREF(Py_None); - Py_XDECREF(t); - return 0; -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_ObjectAdapter[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_ObjectAdapter = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_ObjectAdapter = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_ObjectAdapter = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_ObjectAdapter = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_ObjectAdapter = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.ObjectAdapter", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_ObjectAdapter), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_ObjectAdapter, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - __pyx_f_12spidermonkey_13ObjectAdapter___repr__, /*tp_repr*/ - &__pyx_tp_as_number_ObjectAdapter, /*tp_as_number*/ - &__pyx_tp_as_sequence_ObjectAdapter, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_ObjectAdapter, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_ObjectAdapter, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_12spidermonkey_ObjectAdapter, /*tp_traverse*/ - __pyx_tp_clear_12spidermonkey_ObjectAdapter, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_ObjectAdapter, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_ObjectAdapter, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static PyObject *__pyx_tp_new_12spidermonkey_FunctionAdapter(PyTypeObject *t, PyObject *a, PyObject *k) { - struct __pyx_obj_12spidermonkey_FunctionAdapter *p; - PyObject *o = (*t->tp_alloc)(t, 0); - if (!o) return 0; - p = ((struct __pyx_obj_12spidermonkey_FunctionAdapter *)o); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - p->py_obj = Py_None; Py_INCREF(Py_None); - if (__pyx_f_12spidermonkey_15FunctionAdapter___cinit__(o, a, k) < 0) { - Py_DECREF(o); o = 0; - } - return o; -} - -static void __pyx_tp_dealloc_12spidermonkey_FunctionAdapter(PyObject *o) { - struct __pyx_obj_12spidermonkey_FunctionAdapter *p = (struct __pyx_obj_12spidermonkey_FunctionAdapter *)o; - Py_XDECREF(((PyObject *)p->cx)); - Py_XDECREF(p->py_obj); - (*o->ob_type->tp_free)(o); -} - -static int __pyx_tp_traverse_12spidermonkey_FunctionAdapter(PyObject *o, visitproc v, void *a) { - int e; - struct __pyx_obj_12spidermonkey_FunctionAdapter *p = (struct __pyx_obj_12spidermonkey_FunctionAdapter *)o; - if (p->cx) { - e = (*v)(((PyObject*)p->cx), a); if (e) return e; - } - if (p->py_obj) { - e = (*v)(p->py_obj, a); if (e) return e; - } - return 0; -} - -static int __pyx_tp_clear_12spidermonkey_FunctionAdapter(PyObject *o) { - struct __pyx_obj_12spidermonkey_FunctionAdapter *p = (struct __pyx_obj_12spidermonkey_FunctionAdapter *)o; - PyObject *t; - t = ((PyObject *)p->cx); - p->cx = ((struct __pyx_obj_12spidermonkey_Context *)Py_None); Py_INCREF(Py_None); - Py_XDECREF(t); - t = p->py_obj; - p->py_obj = Py_None; Py_INCREF(Py_None); - Py_XDECREF(t); - return 0; -} - -static struct PyMethodDef __pyx_methods_12spidermonkey_FunctionAdapter[] = { - {0, 0, 0, 0} -}; - -static PyNumberMethods __pyx_tp_as_number_FunctionAdapter = { - 0, /*nb_add*/ - 0, /*nb_subtract*/ - 0, /*nb_multiply*/ - 0, /*nb_divide*/ - 0, /*nb_remainder*/ - 0, /*nb_divmod*/ - 0, /*nb_power*/ - 0, /*nb_negative*/ - 0, /*nb_positive*/ - 0, /*nb_absolute*/ - 0, /*nb_nonzero*/ - 0, /*nb_invert*/ - 0, /*nb_lshift*/ - 0, /*nb_rshift*/ - 0, /*nb_and*/ - 0, /*nb_xor*/ - 0, /*nb_or*/ - 0, /*nb_coerce*/ - 0, /*nb_int*/ - 0, /*nb_long*/ - 0, /*nb_float*/ - 0, /*nb_oct*/ - 0, /*nb_hex*/ - 0, /*nb_inplace_add*/ - 0, /*nb_inplace_subtract*/ - 0, /*nb_inplace_multiply*/ - 0, /*nb_inplace_divide*/ - 0, /*nb_inplace_remainder*/ - 0, /*nb_inplace_power*/ - 0, /*nb_inplace_lshift*/ - 0, /*nb_inplace_rshift*/ - 0, /*nb_inplace_and*/ - 0, /*nb_inplace_xor*/ - 0, /*nb_inplace_or*/ - 0, /*nb_floor_divide*/ - 0, /*nb_true_divide*/ - 0, /*nb_inplace_floor_divide*/ - 0, /*nb_inplace_true_divide*/ - #if Py_TPFLAGS_DEFAULT & Py_TPFLAGS_HAVE_INDEX - 0, /*nb_index*/ - #endif -}; - -static PySequenceMethods __pyx_tp_as_sequence_FunctionAdapter = { - 0, /*sq_length*/ - 0, /*sq_concat*/ - 0, /*sq_repeat*/ - 0, /*sq_item*/ - 0, /*sq_slice*/ - 0, /*sq_ass_item*/ - 0, /*sq_ass_slice*/ - 0, /*sq_contains*/ - 0, /*sq_inplace_concat*/ - 0, /*sq_inplace_repeat*/ -}; - -static PyMappingMethods __pyx_tp_as_mapping_FunctionAdapter = { - 0, /*mp_length*/ - 0, /*mp_subscript*/ - 0, /*mp_ass_subscript*/ -}; - -static PyBufferProcs __pyx_tp_as_buffer_FunctionAdapter = { - 0, /*bf_getreadbuffer*/ - 0, /*bf_getwritebuffer*/ - 0, /*bf_getsegcount*/ - 0, /*bf_getcharbuffer*/ -}; - -PyTypeObject __pyx_type_12spidermonkey_FunctionAdapter = { - PyObject_HEAD_INIT(0) - 0, /*ob_size*/ - "spidermonkey.FunctionAdapter", /*tp_name*/ - sizeof(struct __pyx_obj_12spidermonkey_FunctionAdapter), /*tp_basicsize*/ - 0, /*tp_itemsize*/ - __pyx_tp_dealloc_12spidermonkey_FunctionAdapter, /*tp_dealloc*/ - 0, /*tp_print*/ - 0, /*tp_getattr*/ - 0, /*tp_setattr*/ - 0, /*tp_compare*/ - __pyx_f_12spidermonkey_15FunctionAdapter___repr__, /*tp_repr*/ - &__pyx_tp_as_number_FunctionAdapter, /*tp_as_number*/ - &__pyx_tp_as_sequence_FunctionAdapter, /*tp_as_sequence*/ - &__pyx_tp_as_mapping_FunctionAdapter, /*tp_as_mapping*/ - 0, /*tp_hash*/ - 0, /*tp_call*/ - 0, /*tp_str*/ - 0, /*tp_getattro*/ - 0, /*tp_setattro*/ - &__pyx_tp_as_buffer_FunctionAdapter, /*tp_as_buffer*/ - Py_TPFLAGS_DEFAULT|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/ - 0, /*tp_doc*/ - __pyx_tp_traverse_12spidermonkey_FunctionAdapter, /*tp_traverse*/ - __pyx_tp_clear_12spidermonkey_FunctionAdapter, /*tp_clear*/ - 0, /*tp_richcompare*/ - 0, /*tp_weaklistoffset*/ - 0, /*tp_iter*/ - 0, /*tp_iternext*/ - __pyx_methods_12spidermonkey_FunctionAdapter, /*tp_methods*/ - 0, /*tp_members*/ - 0, /*tp_getset*/ - 0, /*tp_base*/ - 0, /*tp_dict*/ - 0, /*tp_descr_get*/ - 0, /*tp_descr_set*/ - 0, /*tp_dictoffset*/ - 0, /*tp_init*/ - 0, /*tp_alloc*/ - __pyx_tp_new_12spidermonkey_FunctionAdapter, /*tp_new*/ - 0, /*tp_free*/ - 0, /*tp_is_gc*/ - 0, /*tp_bases*/ - 0, /*tp_mro*/ - 0, /*tp_cache*/ - 0, /*tp_subclasses*/ - 0, /*tp_weaklist*/ -}; - -static struct PyMethodDef __pyx_methods[] = { - {"test_utf_16_round_trip", (PyCFunction)__pyx_f_12spidermonkey_test_utf_16_round_trip, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_classname", (PyCFunction)__pyx_f_12spidermonkey_js_classname, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_object", (PyCFunction)__pyx_f_12spidermonkey_js_is_object, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_object", (PyCFunction)__pyx_f_12spidermonkey_py_is_object, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_function", (PyCFunction)__pyx_f_12spidermonkey_js_is_function, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_function", (PyCFunction)__pyx_f_12spidermonkey_py_is_function, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_bound_method", (PyCFunction)__pyx_f_12spidermonkey_py_is_bound_method, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_array", (PyCFunction)__pyx_f_12spidermonkey_js_is_array, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_array", (PyCFunction)__pyx_f_12spidermonkey_py_is_array, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_bool", (PyCFunction)__pyx_f_12spidermonkey_js_is_bool, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_bool", (PyCFunction)__pyx_f_12spidermonkey_py_is_bool, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_double", (PyCFunction)__pyx_f_12spidermonkey_js_is_double, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_double", (PyCFunction)__pyx_f_12spidermonkey_py_is_double, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_hash", (PyCFunction)__pyx_f_12spidermonkey_js_is_hash, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_hash", (PyCFunction)__pyx_f_12spidermonkey_py_is_hash, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_int", (PyCFunction)__pyx_f_12spidermonkey_js_is_int, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_int", (PyCFunction)__pyx_f_12spidermonkey_py_is_int, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_string", (PyCFunction)__pyx_f_12spidermonkey_js_is_string, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_string", (PyCFunction)__pyx_f_12spidermonkey_py_is_string, METH_VARARGS|METH_KEYWORDS, 0}, - {"js_is_void", (PyCFunction)__pyx_f_12spidermonkey_js_is_void, METH_VARARGS|METH_KEYWORDS, 0}, - {"py_is_void", (PyCFunction)__pyx_f_12spidermonkey_py_is_void, METH_VARARGS|METH_KEYWORDS, 0}, - {0, 0, 0, 0} -}; - -static void __pyx_init_filenames(void); /*proto*/ - -PyMODINIT_FUNC initspidermonkey(void); /*proto*/ -PyMODINIT_FUNC initspidermonkey(void) { - PyObject *__pyx_1 = 0; - PyObject *__pyx_2 = 0; - PyObject *__pyx_3 = 0; - PyObject *__pyx_4 = 0; - __pyx_init_filenames(); - __pyx_m = Py_InitModule4("spidermonkey", __pyx_methods, 0, 0, PYTHON_API_VERSION); - if (!__pyx_m) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; goto __pyx_L1;}; - Py_INCREF(__pyx_m); - __pyx_b = PyImport_AddModule("__builtin__"); - if (!__pyx_b) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; goto __pyx_L1;}; - if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; goto __pyx_L1;}; - if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[16]; __pyx_lineno = 3; goto __pyx_L1;}; - __pyx_vtabptr_12spidermonkey_PyJSString = &__pyx_vtable_12spidermonkey_PyJSString; - *(void(**)(void))&__pyx_vtable_12spidermonkey_PyJSString.chars = (void(*)(void))__pyx_f_12spidermonkey_10PyJSString_chars; - *(void(**)(void))&__pyx_vtable_12spidermonkey_PyJSString.length = (void(*)(void))__pyx_f_12spidermonkey_10PyJSString_length; - if (PyType_Ready(&__pyx_type_12spidermonkey_PyJSString) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} - if (__Pyx_SetVtable(__pyx_type_12spidermonkey_PyJSString.tp_dict, __pyx_vtabptr_12spidermonkey_PyJSString) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "PyJSString", (PyObject *)&__pyx_type_12spidermonkey_PyJSString) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 390; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_PyJSString = &__pyx_type_12spidermonkey_PyJSString; - __pyx_type_12spidermonkey_Context.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_12spidermonkey_Context) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "Context", (PyObject *)&__pyx_type_12spidermonkey_Context) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 5; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_Context = &__pyx_type_12spidermonkey_Context; - __pyx_type_12spidermonkey_Function.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_12spidermonkey_Function) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 2; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "Function", (PyObject *)&__pyx_type_12spidermonkey_Function) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_Function = &__pyx_type_12spidermonkey_Function; - __pyx_vtabptr_12spidermonkey_GC = &__pyx_vtable_12spidermonkey_GC; - *(void(**)(void))&__pyx_vtable_12spidermonkey_GC.run = (void(*)(void))__pyx_f_12spidermonkey_2GC_run; - *(void(**)(void))&__pyx_vtable_12spidermonkey_GC.run_maybe = (void(*)(void))__pyx_f_12spidermonkey_2GC_run_maybe; - *(void(**)(void))&__pyx_vtable_12spidermonkey_GC.add_root = (void(*)(void))__pyx_f_12spidermonkey_2GC_add_root; - *(void(**)(void))&__pyx_vtable_12spidermonkey_GC.add_named_root = (void(*)(void))__pyx_f_12spidermonkey_2GC_add_named_root; - *(void(**)(void))&__pyx_vtable_12spidermonkey_GC.rem_root = (void(*)(void))__pyx_f_12spidermonkey_2GC_rem_root; - __pyx_type_12spidermonkey_GC.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_12spidermonkey_GC) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 2; goto __pyx_L1;} - if (__Pyx_SetVtable(__pyx_type_12spidermonkey_GC.tp_dict, __pyx_vtabptr_12spidermonkey_GC) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 2; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "GC", (PyObject *)&__pyx_type_12spidermonkey_GC) < 0) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_GC = &__pyx_type_12spidermonkey_GC; - if (PyType_Ready(&__pyx_type_12spidermonkey_Runtime) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 2; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "Runtime", (PyObject *)&__pyx_type_12spidermonkey_Runtime) < 0) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_Runtime = &__pyx_type_12spidermonkey_Runtime; - if (PyType_Ready(&__pyx_type_12spidermonkey_Value) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 50; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "Value", (PyObject *)&__pyx_type_12spidermonkey_Value) < 0) {__pyx_filename = __pyx_f[15]; __pyx_lineno = 50; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_Value = &__pyx_type_12spidermonkey_Value; - __pyx_type_12spidermonkey_ClassAdapter.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_12spidermonkey_ClassAdapter) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 178; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "ClassAdapter", (PyObject *)&__pyx_type_12spidermonkey_ClassAdapter) < 0) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 178; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_ClassAdapter = &__pyx_type_12spidermonkey_ClassAdapter; - __pyx_type_12spidermonkey_ObjectAdapter.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_12spidermonkey_ObjectAdapter) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 2; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "ObjectAdapter", (PyObject *)&__pyx_type_12spidermonkey_ObjectAdapter) < 0) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_ObjectAdapter = &__pyx_type_12spidermonkey_ObjectAdapter; - __pyx_type_12spidermonkey_FunctionAdapter.tp_free = _PyObject_GC_Del; - if (PyType_Ready(&__pyx_type_12spidermonkey_FunctionAdapter) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 36; goto __pyx_L1;} - if (PyObject_SetAttrString(__pyx_m, "FunctionAdapter", (PyObject *)&__pyx_type_12spidermonkey_FunctionAdapter) < 0) {__pyx_filename = __pyx_f[7]; __pyx_lineno = 36; goto __pyx_L1;} - __pyx_ptype_12spidermonkey_FunctionAdapter = &__pyx_type_12spidermonkey_FunctionAdapter; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":436 */ - __pyx_1 = __Pyx_Import(__pyx_n_inspect, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_inspect, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":437 */ - __pyx_1 = __Pyx_Import(__pyx_n_sys, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_sys, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 437; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":438 */ - __pyx_1 = __Pyx_Import(__pyx_n_traceback, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_traceback, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 438; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":439 */ - __pyx_1 = __Pyx_Import(__pyx_n_types, 0); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;} - if (PyObject_SetAttr(__pyx_m, __pyx_n_types, __pyx_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 439; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":441 */ - __pyx_1 = PyDict_New(); if (!__pyx_1) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;} - __pyx_2 = PyTuple_New(1); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;} - Py_INCREF(PyExc_Exception); - PyTuple_SET_ITEM(__pyx_2, 0, PyExc_Exception); - __pyx_3 = __Pyx_CreateClass(__pyx_2, __pyx_1, __pyx_n_JSError, "spidermonkey"); if (!__pyx_3) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":442 */ - __pyx_2 = PyCFunction_New(&__pyx_mdef_12spidermonkey_7JSError___init__, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;} - __pyx_4 = PyMethod_New(__pyx_2, 0, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (PyObject_SetAttr(__pyx_3, __pyx_n___init__, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":444 */ - __pyx_2 = PyCFunction_New(&__pyx_mdef_12spidermonkey_7JSError___str__, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} - __pyx_4 = PyMethod_New(__pyx_2, 0, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (PyObject_SetAttr(__pyx_3, __pyx_n___str__, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 444; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsapi.pxi":446 */ - __pyx_2 = PyCFunction_New(&__pyx_mdef_12spidermonkey_7JSError___repr__, 0); if (!__pyx_2) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} - __pyx_4 = PyMethod_New(__pyx_2, 0, __pyx_3); if (!__pyx_4) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} - Py_DECREF(__pyx_2); __pyx_2 = 0; - if (PyObject_SetAttr(__pyx_3, __pyx_n___repr__, __pyx_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; goto __pyx_L1;} - Py_DECREF(__pyx_4); __pyx_4 = 0; - if (PyObject_SetAttr(__pyx_m, __pyx_n_JSError, __pyx_3) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 441; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - Py_DECREF(__pyx_1); __pyx_1 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsruntime.pxi":13 */ - Py_INCREF(Py_None); - __pyx_d1 = Py_None; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":2 */ - __pyx_2 = PyDict_New(); if (!__pyx_2) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_4 = __Pyx_GetName(__pyx_b, __pyx_n_object); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; goto __pyx_L1;} - __pyx_3 = PyTuple_New(1); if (!__pyx_3) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; goto __pyx_L1;} - PyTuple_SET_ITEM(__pyx_3, 0, __pyx_4); - __pyx_4 = 0; - __pyx_1 = __Pyx_CreateClass(__pyx_3, __pyx_2, __pyx_n_JSRootObject, "spidermonkey"); if (!__pyx_1) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; goto __pyx_L1;} - Py_DECREF(__pyx_3); __pyx_3 = 0; - if (PyObject_SetAttr(__pyx_m, __pyx_n_JSRootObject, __pyx_1) < 0) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 2; goto __pyx_L1;} - Py_DECREF(__pyx_1); __pyx_1 = 0; - Py_DECREF(__pyx_2); __pyx_2 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jscontext.pxi":54 */ - Py_INCREF(Py_True); - __pyx_d2 = Py_True; - Py_INCREF(Py_False); - __pyx_d3 = Py_False; - __pyx_4 = PyInt_FromLong(0); if (!__pyx_4) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 54; goto __pyx_L1;} - __pyx_d4 = __pyx_4; - __pyx_4 = 0; - - /* "/usr/local/src/python-spidermonkey/old-sm/jsvalue.pxi":53 */ - return; - __pyx_L1:; - Py_XDECREF(__pyx_1); - Py_XDECREF(__pyx_2); - Py_XDECREF(__pyx_3); - Py_XDECREF(__pyx_4); - __Pyx_AddTraceback("spidermonkey"); -} - -static char *__pyx_filenames[] = { - "jsapi.pxi", - "jserror.pxi", - "jsgc.pxi", - "jsruntime.pxi", - "jscontext.pxi", - "jsclass.pxi", - "jsobject.pxi", - "jsfunction.pxi", - "jsarray.pxi", - "jsbool.pxi", - "jsdouble.pxi", - "jshash.pxi", - "jsint.pxi", - "jsstring.pxi", - "jsvoid.pxi", - "jsvalue.pxi", - "spidermonkey.pyx", -}; - -/* Runtime support code */ - -static void __pyx_init_filenames(void) { - __pyx_f = __pyx_filenames; -} - -static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb) { - Py_XINCREF(type); - Py_XINCREF(value); - Py_XINCREF(tb); - /* First, check the traceback argument, replacing None with NULL. */ - if (tb == Py_None) { - Py_DECREF(tb); - tb = 0; - } - else if (tb != NULL && !PyTraceBack_Check(tb)) { - PyErr_SetString(PyExc_TypeError, - "raise: arg 3 must be a traceback or None"); - goto raise_error; - } - /* Next, replace a missing value with None */ - if (value == NULL) { - value = Py_None; - Py_INCREF(value); - } - #if PY_VERSION_HEX < 0x02050000 - if (!PyClass_Check(type)) - #else - if (!PyType_Check(type)) - #endif - { - /* Raising an instance. The value should be a dummy. */ - if (value != Py_None) { - PyErr_SetString(PyExc_TypeError, - "instance exception may not have a separate value"); - goto raise_error; - } - /* Normalize to raise , */ - Py_DECREF(value); - value = type; - #if PY_VERSION_HEX < 0x02050000 - if (PyInstance_Check(type)) { - type = (PyObject*) ((PyInstanceObject*)type)->in_class; - Py_INCREF(type); - } - else { - PyErr_SetString(PyExc_TypeError, - "raise: exception must be an old-style class or instance"); - goto raise_error; - } - #else - type = (PyObject*) type->ob_type; - Py_INCREF(type); - if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) { - PyErr_SetString(PyExc_TypeError, - "raise: exception class must be a subclass of BaseException"); - goto raise_error; - } - #endif - } - PyErr_Restore(type, value, tb); - return; -raise_error: - Py_XDECREF(value); - Py_XDECREF(type); - Py_XDECREF(tb); - return; -} - -static int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed, char *name) { - if (!type) { - PyErr_Format(PyExc_SystemError, "Missing type object"); - return 0; - } - if ((none_allowed && obj == Py_None) || PyObject_TypeCheck(obj, type)) - return 1; - PyErr_Format(PyExc_TypeError, - "Argument '%s' has incorrect type (expected %s, got %s)", - name, type->tp_name, obj->ob_type->tp_name); - return 0; -} - -static PyObject *__Pyx_GetName(PyObject *dict, PyObject *name) { - PyObject *result; - result = PyObject_GetAttr(dict, name); - if (!result) - PyErr_SetObject(PyExc_NameError, name); - return result; -} - -static void __Pyx_WriteUnraisable(char *name) { - PyObject *old_exc, *old_val, *old_tb; - PyObject *ctx; - PyErr_Fetch(&old_exc, &old_val, &old_tb); - ctx = PyString_FromString(name); - PyErr_Restore(old_exc, old_val, old_tb); - if (!ctx) - ctx = Py_None; - PyErr_WriteUnraisable(ctx); -} - -static int __Pyx_TypeTest(PyObject *obj, PyTypeObject *type) { - if (!type) { - PyErr_Format(PyExc_SystemError, "Missing type object"); - return 0; - } - if (obj == Py_None || PyObject_TypeCheck(obj, type)) - return 1; - PyErr_Format(PyExc_TypeError, "Cannot convert %s to %s", - obj->ob_type->tp_name, type->tp_name); - return 0; -} - -static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) { - PyThreadState *tstate = PyThreadState_Get(); - PyErr_Fetch(type, value, tb); - PyErr_NormalizeException(type, value, tb); - if (PyErr_Occurred()) - goto bad; - Py_INCREF(*type); - Py_INCREF(*value); - Py_INCREF(*tb); - Py_XDECREF(tstate->exc_type); - Py_XDECREF(tstate->exc_value); - Py_XDECREF(tstate->exc_traceback); - tstate->exc_type = *type; - tstate->exc_value = *value; - tstate->exc_traceback = *tb; - return 0; -bad: - Py_XDECREF(*type); - Py_XDECREF(*value); - Py_XDECREF(*tb); - return -1; -} - -static int __Pyx_GetStarArgs( - PyObject **args, - PyObject **kwds, - char *kwd_list[], - Py_ssize_t nargs, - PyObject **args2, - PyObject **kwds2, - char rqd_kwds[]) -{ - PyObject *x = 0, *args1 = 0, *kwds1 = 0; - int i; - char **p; - - if (args2) - *args2 = 0; - if (kwds2) - *kwds2 = 0; - - if (args2) { - args1 = PyTuple_GetSlice(*args, 0, nargs); - if (!args1) - goto bad; - *args2 = PyTuple_GetSlice(*args, nargs, PyTuple_GET_SIZE(*args)); - if (!*args2) - goto bad; - } - else if (PyTuple_GET_SIZE(*args) > nargs) { - int m = nargs; - int n = PyTuple_GET_SIZE(*args); - PyErr_Format(PyExc_TypeError, - "function takes at most %d positional arguments (%d given)", - m, n); - goto bad; - } - else { - args1 = *args; - Py_INCREF(args1); - } - - if (rqd_kwds && !*kwds) - for (i = 0, p = kwd_list; *p; i++, p++) - if (rqd_kwds[i]) - goto missing_kwarg; - - if (kwds2) { - if (*kwds) { - kwds1 = PyDict_New(); - if (!kwds1) - goto bad; - *kwds2 = PyDict_Copy(*kwds); - if (!*kwds2) - goto bad; - for (i = 0, p = kwd_list; *p; i++, p++) { - x = PyDict_GetItemString(*kwds, *p); - if (x) { - if (PyDict_SetItemString(kwds1, *p, x) < 0) - goto bad; - if (PyDict_DelItemString(*kwds2, *p) < 0) - goto bad; - } - else if (rqd_kwds && rqd_kwds[i]) - goto missing_kwarg; - } - } - else { - *kwds2 = PyDict_New(); - if (!*kwds2) - goto bad; - } - } - else { - kwds1 = *kwds; - Py_XINCREF(kwds1); - if (rqd_kwds && *kwds) - for (i = 0, p = kwd_list; *p; i++, p++) - if (rqd_kwds[i] && !PyDict_GetItemString(*kwds, *p)) - goto missing_kwarg; - } - - *args = args1; - *kwds = kwds1; - return 0; -missing_kwarg: - PyErr_Format(PyExc_TypeError, - "required keyword argument '%s' is missing", *p); -bad: - Py_XDECREF(args1); - Py_XDECREF(kwds1); - if (args2) { - Py_XDECREF(*args2); - } - if (kwds2) { - Py_XDECREF(*kwds2); - } - return -1; -} - -static int __Pyx_SetItemInt(PyObject *o, Py_ssize_t i, PyObject *v) { - PyTypeObject *t = o->ob_type; - int r; - if (t->tp_as_sequence && t->tp_as_sequence->sq_item) - r = PySequence_SetItem(o, i, v); - else { - PyObject *j = PyInt_FromLong(i); - if (!j) - return -1; - r = PyObject_SetItem(o, j, v); - Py_DECREF(j); - } - return r; -} - -static PyObject *__Pyx_GetItemInt(PyObject *o, Py_ssize_t i) { - PyTypeObject *t = o->ob_type; - PyObject *r; - if (t->tp_as_sequence && t->tp_as_sequence->sq_item) - r = PySequence_GetItem(o, i); - else { - PyObject *j = PyInt_FromLong(i); - if (!j) - return 0; - r = PyObject_GetItem(o, j); - Py_DECREF(j); - } - return r; -} - -static void __Pyx_UnpackError(void) { - PyErr_SetString(PyExc_ValueError, "unpack sequence of wrong size"); -} - -static PyObject *__Pyx_UnpackItem(PyObject *iter) { - PyObject *item; - if (!(item = PyIter_Next(iter))) { - if (!PyErr_Occurred()) - __Pyx_UnpackError(); - } - return item; -} - -static int __Pyx_EndUnpack(PyObject *iter) { - PyObject *item; - if ((item = PyIter_Next(iter))) { - Py_DECREF(item); - __Pyx_UnpackError(); - return -1; - } - else if (!PyErr_Occurred()) - return 0; - else - return -1; -} - -static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) { - while (t->p) { - *t->p = PyString_FromStringAndSize(t->s, t->n - 1); - if (!*t->p) - return -1; - if (t->i) - PyString_InternInPlace(t->p); - ++t; - } - return 0; -} - -static int __Pyx_SetVtable(PyObject *dict, void *vtable) { - PyObject *pycobj = 0; - int result; - - pycobj = PyCObject_FromVoidPtr(vtable, 0); - if (!pycobj) - goto bad; - if (PyDict_SetItemString(dict, "__pyx_vtable__", pycobj) < 0) - goto bad; - result = 0; - goto done; - -bad: - result = -1; -done: - Py_XDECREF(pycobj); - return result; -} - -static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list) { - PyObject *__import__ = 0; - PyObject *empty_list = 0; - PyObject *module = 0; - PyObject *global_dict = 0; - PyObject *empty_dict = 0; - PyObject *list; - __import__ = PyObject_GetAttrString(__pyx_b, "__import__"); - if (!__import__) - goto bad; - if (from_list) - list = from_list; - else { - empty_list = PyList_New(0); - if (!empty_list) - goto bad; - list = empty_list; - } - global_dict = PyModule_GetDict(__pyx_m); - if (!global_dict) - goto bad; - empty_dict = PyDict_New(); - if (!empty_dict) - goto bad; - module = PyObject_CallFunction(__import__, "OOOO", - name, global_dict, empty_dict, list); -bad: - Py_XDECREF(empty_list); - Py_XDECREF(__import__); - Py_XDECREF(empty_dict); - return module; -} - -static PyObject *__Pyx_CreateClass( - PyObject *bases, PyObject *dict, PyObject *name, char *modname) -{ - PyObject *py_modname; - PyObject *result = 0; - - py_modname = PyString_FromString(modname); - if (!py_modname) - goto bad; - if (PyDict_SetItemString(dict, "__module__", py_modname) < 0) - goto bad; - result = PyClass_New(bases, dict, name); -bad: - Py_XDECREF(py_modname); - return result; -} - -#include "compile.h" -#include "frameobject.h" -#include "traceback.h" - -static void __Pyx_AddTraceback(char *funcname) { - PyObject *py_srcfile = 0; - PyObject *py_funcname = 0; - PyObject *py_globals = 0; - PyObject *empty_tuple = 0; - PyObject *empty_string = 0; - PyCodeObject *py_code = 0; - PyFrameObject *py_frame = 0; - - py_srcfile = PyString_FromString(__pyx_filename); - if (!py_srcfile) goto bad; - py_funcname = PyString_FromString(funcname); - if (!py_funcname) goto bad; - py_globals = PyModule_GetDict(__pyx_m); - if (!py_globals) goto bad; - empty_tuple = PyTuple_New(0); - if (!empty_tuple) goto bad; - empty_string = PyString_FromString(""); - if (!empty_string) goto bad; - py_code = PyCode_New( - 0, /*int argcount,*/ - 0, /*int nlocals,*/ - 0, /*int stacksize,*/ - 0, /*int flags,*/ - empty_string, /*PyObject *code,*/ - empty_tuple, /*PyObject *consts,*/ - empty_tuple, /*PyObject *names,*/ - empty_tuple, /*PyObject *varnames,*/ - empty_tuple, /*PyObject *freevars,*/ - empty_tuple, /*PyObject *cellvars,*/ - py_srcfile, /*PyObject *filename,*/ - py_funcname, /*PyObject *name,*/ - __pyx_lineno, /*int firstlineno,*/ - empty_string /*PyObject *lnotab*/ - ); - if (!py_code) goto bad; - py_frame = PyFrame_New( - PyThreadState_Get(), /*PyThreadState *tstate,*/ - py_code, /*PyCodeObject *code,*/ - py_globals, /*PyObject *globals,*/ - 0 /*PyObject *locals*/ - ); - if (!py_frame) goto bad; - py_frame->f_lineno = __pyx_lineno; - PyTraceBack_Here(py_frame); -bad: - Py_XDECREF(py_srcfile); - Py_XDECREF(py_funcname); - Py_XDECREF(empty_tuple); - Py_XDECREF(empty_string); - Py_XDECREF(py_code); - Py_XDECREF(py_frame); -} diff --git a/old-sm/spidermonkey.dep b/old-sm/spidermonkey.dep deleted file mode 100644 index 22c23da..0000000 --- a/old-sm/spidermonkey.dep +++ /dev/null @@ -1,16 +0,0 @@ -include jsapi.pxi -include jsarray.pxi -include jsbool.pxi -include jsclass.pxi -include jscontext.pxi -include jsdouble.pxi -include jserror.pxi -include jsfunction.pxi -include jsgc.pxi -include jshash.pxi -include jsint.pxi -include jsobject.pxi -include jsruntime.pxi -include jsstring.pxi -include jsvalue.pxi -include jsvoid.pxi diff --git a/old-sm/spidermonkey.pyx b/old-sm/spidermonkey.pyx deleted file mode 100644 index 9c251b7..0000000 --- a/old-sm/spidermonkey.pyx +++ /dev/null @@ -1,27 +0,0 @@ - -# Import API -include "jsapi.pxi" - -# Basic Necessities -include "jserror.pxi" -include "jsgc.pxi" - -# Core Classes -include "jsruntime.pxi" -include "jscontext.pxi" - -# Adapters -include "jsclass.pxi" -include "jsobject.pxi" -include "jsfunction.pxi" - -# Type Conversions -include "jsarray.pxi" -include "jsbool.pxi" -include "jsdouble.pxi" -include "jshash.pxi" -include "jsint.pxi" -include "jsstring.pxi" -include "jsvoid.pxi" - -include "jsvalue.pxi" diff --git a/old-t/class_test.py b/old-t/class_test.py deleted file mode 100644 index 03507ff..0000000 --- a/old-t/class_test.py +++ /dev/null @@ -1,92 +0,0 @@ -import types -import unittest -import spidermonkey - -class ClassTests(unittest.TestCase): - def setUp(self): - rt = spidermonkey.Runtime() - self.cx = rt.create_context() - class spam(object): - def __init__(self): - self.args = [] - self.val = 42 - self._private = u"no peeking" - def foo(self, *args): - self.args.append(args) - def _private_method(self): - assert False - def __getitem__(self, key): - assert isinstance(key, (types.IntType, types.LongType)) - self.args.append(key) - return self.val - def __setitem__(self, key, value): - assert isinstance(key, (types.IntType, types.LongType)) - self.args.append((key, value)) - self.val = value - self.cx.install_class(spam) - self.spam = spam() - self.cx.bind(u"bs", self.spam) - - def test_private(self): - self.assertEqual(self.cx.execute(u"bs._private;"), None) - self.cx.execute(u"bs._private = 1;") - self.assertEqual(self.spam._private, u"no peeking") - self.assertEqual(self.cx.execute(u"bs._private_method;"), None) - self.assertEqual(self.cx.execute(u"bs._private_method = 1;"), True) - self.assertEqual(isinstance(self.spam._private_method, types.MethodType), True) - # in fact, even normal methods shouldn't be assignable to - self.assertEqual(self.cx.execute(u"bs.foo = 1;"), True) - self.assertEqual(isinstance(self.spam.foo, types.MethodType), True) - - def test_bind_module(self): - self.assertRaises(TypeError, self.cx.install_class, __builtins__) - - def test_no_constructor(self): - class foo: - pass - self.cx.install_class(foo, bind_constructor=False) - self.assertRaises(spidermonkey.JSError, self.cx.execute, u"var f = new foo();") - f2 = foo() - self.cx.bind(u"f2", f2) - self.assertEqual(self.cx.execute(u"f2;"), f2) - - def test_js_specific(self): - class bar: - __jsname__ = u"eggs" - def __init__(self, arg): - self.arg = arg - - @staticmethod - def __jsinit__(cx): - return bar(42) - self.cx.install_class(bar) - self.cx.execute(u"var e = new eggs();") - self.assertEqual(self.cx.execute(u"e.arg;"), 42) - - def test_assign_new_property(self): - self.cx.execute(u"bs.xyzzy = 1;") - self.assertEqual(self.cx.execute(u"bs.xyzzy;"), 1) - - def test_identity(self): - self.assertEqual(self.cx.execute(u"bs;"), self.spam) - - def test_call(self): - self.cx.execute(u'bs.foo("hi");') - self.assertEqual(self.spam.args.pop(), (u"hi",)) - - def test_construct(self): - s = self.cx.execute(u"""\ - var s = new spam(); - s.foo(1, "blah", ["1", 2, "three"]); - s; - """) - self.assertEqual(s.args.pop(), (1, u"blah", [u"1", 2, u"three"])) - - def test_getsetitem(self): - # property lookup with an integer is mapped to __get/__setitem__ - self.assertEqual(self.cx.execute(u"bs[0];"), 42) - self.cx.execute(u"bs[0] = 2;") - self.assertEqual(self.cx.execute(u"bs[0];"), 2) - -if __name__ == "__main__": - unittest.main() diff --git a/setup.py b/setup.py index ae630c0..dabb917 100644 --- a/setup.py +++ b/setup.py @@ -149,7 +149,7 @@ def platform_config(): setup( name = "python-spidermonkey", - version = "0.0.6", + version = "0.0.9", license = "MIT", author = "Paul J. Davis", author_email = "paul.joseph.davis@gmail.com", diff --git a/spidermonkey/context.c b/spidermonkey/context.c index 99d577e..6db6d83 100644 --- a/spidermonkey/context.c +++ b/spidermonkey/context.c @@ -13,12 +13,15 @@ #include #include +// Forward decl for add_prop +JSBool set_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval); + JSBool add_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval) { JSObject* obj = NULL; - if(!JSVAL_IS_OBJECT(*rval)) return JS_TRUE; + if(JSVAL_IS_NULL(*rval) || !JSVAL_IS_OBJECT(*rval)) return JS_TRUE; obj = JSVAL_TO_OBJECT(*rval); if(JS_ObjectIsFunction(jscx, obj)) return set_prop(jscx, jsobj, key, rval); @@ -46,6 +49,9 @@ del_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval) ret = JS_TRUE; goto done; } + + // Check access to python land. + if(Context_has_access(pycx, jscx, pycx->global, pykey) <= 0) goto done; // Bail if the global doesn't have a __delitem__ if(!PyObject_HasAttrString(pycx->global, "__delitem__")) @@ -92,6 +98,8 @@ get_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval) pykey = js2py(pycx, key); if(pykey == NULL) goto done; + if(Context_has_access(pycx, jscx, pycx->global, pykey) <= 0) goto done; + pyval = PyObject_GetItem(pycx->global, pykey); if(pyval == NULL) { @@ -138,6 +146,8 @@ set_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* rval) pykey = js2py(pycx, key); if(pykey == NULL) goto done; + if(Context_has_access(pycx, jscx, pycx->global, pykey) <= 0) goto done; + pyval = js2py(pycx, *rval); if(pyval == NULL) goto done; @@ -175,6 +185,8 @@ resolve(JSContext* jscx, JSObject* jsobj, jsval key) pykey = js2py(pycx, key); if(pykey == NULL) goto done; + + if(Context_has_access(pycx, jscx, pycx->global, pykey) <= 0) goto done; if(!PyMapping_HasKey(pycx->global, pykey)) { @@ -275,14 +287,26 @@ Context_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) Context* self = NULL; Runtime* runtime = NULL; PyObject* global = NULL; + PyObject* access = NULL; + int strict = 0; + uint32_t jsopts; + + char* keywords[] = {"runtime", "glbl", "access", "strict", NULL}; - if(!PyArg_ParseTuple( - args, - "O!|O", + if(!PyArg_ParseTupleAndKeywords( + args, kwargs, + "O!|OOI", + keywords, RuntimeType, &runtime, - &global + &global, + &access, + &strict )) goto error; + if(global == Py_None) global = NULL; + if(access == Py_None) access = NULL; + strict &= 1; /* clamp at 1 */ + if(global != NULL && !PyMapping_Check(global)) { PyErr_SetString(PyExc_TypeError, @@ -290,6 +314,13 @@ Context_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) goto error; } + if(access != NULL && !PyCallable_Check(access)) + { + PyErr_SetString(PyExc_TypeError, + "Access handler must be callable."); + goto error; + } + self = (Context*) type->tp_alloc(type, 0); if(self == NULL) goto error; @@ -317,10 +348,6 @@ Context_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) * garbage collection from happening on either side of the * bridge. * - * To make sure that the context stays alive we'll add a - * reference to the Context* anytime we wrap a Python - * object for use in JS. - * */ JS_SetContextPrivate(self->cx, self); @@ -344,6 +371,9 @@ Context_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) if(global != NULL) Py_INCREF(global); self->global = global; + if(access != NULL) Py_INCREF(access); + self->access = access; + // Setup counters for resource limits self->branch_count = 0; self->max_time = 0; @@ -352,6 +382,15 @@ Context_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) JS_SetBranchCallback(self->cx, branch_cb); JS_SetErrorReporter(self->cx, report_error_cb); + + jsopts = JS_GetOptions(self->cx); + jsopts |= JSOPTION_VAROBJFIX; + if (strict) { + jsopts |= JSOPTION_STRICT; + } else { + jsopts &= ~JSOPTION_STRICT; + } + JS_SetOptions(self->cx, jsopts); Py_INCREF(runtime); self->rt = runtime; @@ -383,6 +422,7 @@ Context_dealloc(Context* self) } Py_XDECREF(self->global); + Py_XDECREF(self->access); Py_XDECREF(self->objects); Py_XDECREF(self->classes); Py_XDECREF(self->rt); @@ -473,6 +513,42 @@ Context_rem_global(Context* self, PyObject* args, PyObject* kwargs) return ret; } +PyObject* +Context_set_access(Context* self, PyObject* args, PyObject* kwargs) +{ + PyObject* ret = NULL; + PyObject* newval = NULL; + + if(!PyArg_ParseTuple(args, "|O", &newval)) goto done; + if(newval != NULL && newval != Py_None) + { + if(!PyCallable_Check(newval)) + { + PyErr_SetString(PyExc_TypeError, + "Access handler must be callable."); + ret = NULL; + goto done; + } + } + + ret = self->access; + + if(newval != NULL && newval != Py_None) + { + Py_INCREF(newval); + self->access = newval; + } + + if(ret == NULL) + { + ret = Py_None; + Py_INCREF(ret); + } + +done: + return ret; +} + PyObject* Context_execute(Context* self, PyObject* args, PyObject* kwargs) { @@ -483,11 +559,18 @@ Context_execute(Context* self, PyObject* args, PyObject* kwargs) JSString* script = NULL; jschar* schars = NULL; JSBool started_counter = JS_FALSE; + char *fname = ""; + unsigned int lineno = 1; size_t slen; jsval rval; + char *keywords[] = {"code", "filename", "lineno", NULL}; + + if(!PyArg_ParseTupleAndKeywords(args, kwargs, "O|sI", keywords, + &obj, &fname, &lineno)) + goto error; + JS_BeginRequest(self->cx); - if(!PyArg_ParseTuple(args, "O", &obj)) goto error; script = py2js_string_obj(self, obj); if(script == NULL) goto error; @@ -505,11 +588,11 @@ Context_execute(Context* self, PyObject* args, PyObject* kwargs) self->start_time = time(NULL); } - if(!JS_EvaluateUCScript(cx, root, schars, slen, "", 1, &rval)) + if(!JS_EvaluateUCScript(cx, root, schars, slen, fname, lineno, &rval)) { if(!PyErr_Occurred()) { - PyErr_SetString(PyExc_RuntimeError, "Failed to execute script."); + PyErr_SetString(PyExc_RuntimeError, "Script execution failed and no exception was set"); } goto error; } @@ -594,10 +677,16 @@ static PyMethodDef Context_methods[] = { METH_VARARGS, "Remove a global object in the JS VM." }, + { + "set_access", + (PyCFunction)Context_set_access, + METH_VARARGS, + "Set the access handler for wrapped python objects." + }, { "execute", (PyCFunction)Context_execute, - METH_VARARGS, + METH_VARARGS | METH_KEYWORDS, "Execute JavaScript source code." }, { @@ -663,6 +752,42 @@ PyTypeObject _ContextType = { Context_new, /*tp_new*/ }; +int +Context_has_access(Context* pycx, JSContext* jscx, PyObject* obj, PyObject* key) +{ + PyObject* tpl = NULL; + PyObject* tmp = NULL; + int res = -1; + + if(pycx->access == NULL) + { + res = 1; + goto done; + } + + tpl = Py_BuildValue("(OO)", obj, key); + if(tpl == NULL) goto done; + + tmp = PyObject_Call(pycx->access, tpl, NULL); + res = PyObject_IsTrue(tmp); + +done: + Py_XDECREF(tpl); + Py_XDECREF(tmp); + + if(res < 0) + { + PyErr_Clear(); + JS_ReportError(jscx, "Failed to check python access."); + } + else if(res == 0) + { + JS_ReportError(jscx, "Python access prohibited."); + } + + return res; +} + PyObject* Context_get_class(Context* cx, const char* key) { diff --git a/spidermonkey/context.h b/spidermonkey/context.h index 3365c39..b8b0921 100644 --- a/spidermonkey/context.h +++ b/spidermonkey/context.h @@ -18,6 +18,7 @@ typedef struct { PyObject_HEAD Runtime* rt; PyObject* global; + PyObject* access; JSContext* cx; JSObject* root; PyDictObject* classes; @@ -31,6 +32,8 @@ typedef struct { PyObject* Context_get_class(Context* cx, const char* key); int Context_add_class(Context* cx, const char* key, PyObject* val); +int Context_has_access(Context*, JSContext*, PyObject*, PyObject*); + int Context_has_object(Context* cx, PyObject* val); int Context_add_object(Context* cx, PyObject* val); int Context_rem_object(Context* cx, PyObject* val); diff --git a/spidermonkey/error.c b/spidermonkey/error.c index 5ec95d7..b325a26 100644 --- a/spidermonkey/error.c +++ b/spidermonkey/error.c @@ -75,16 +75,24 @@ add_frame(const char* srcfile, const char* funcname, int linenum) void report_error_cb(JSContext* cx, const char* message, JSErrorReport* report) { + /* Subtle note about JSREPORT_EXCEPTION: it triggers whenever exceptions + * are raised, even if they're caught and the Mozilla docs say you can + * ignore it. + */ + /* TODO What should we do about warnings? A callback somehow? */ + if (report->flags & JSREPORT_WARNING) + return; + const char* srcfile = report->filename; const char* mesg = message; + if(srcfile == NULL) srcfile = ""; + if(mesg == NULL) mesg = "Unknown JavaScript execution error"; + if(!PyErr_Occurred()) { - PyErr_SetString(JSError, "Error executing JavaScript."); + PyErr_SetString(JSError, message); } - if(srcfile == NULL) srcfile = ""; - if(mesg == NULL) mesg = ""; - - add_frame(srcfile, mesg, report->lineno); + add_frame(srcfile, "JavaScript code", report->lineno); } diff --git a/spidermonkey/jsfunction.c b/spidermonkey/jsfunction.c index 40392d2..49cd80f 100644 --- a/spidermonkey/jsfunction.c +++ b/spidermonkey/jsfunction.c @@ -101,7 +101,9 @@ Function_call(Function* self, PyObject* args, PyObject* kwargs) if(!JS_CallFunctionValue(cx, parent, func, argc, argv, &rval)) { - PyErr_SetString(PyExc_RuntimeError, "Failed to execute JS Function."); + if(!PyErr_Occurred()) { + PyErr_SetString(PyExc_RuntimeError, "JavaScript Function failed to execute"); + } goto error; } diff --git a/spidermonkey/libjs/jsprf.c b/spidermonkey/libjs/jsprf.c index 416c16c..6735520 100644 --- a/spidermonkey/libjs/jsprf.c +++ b/spidermonkey/libjs/jsprf.c @@ -58,6 +58,8 @@ */ #ifdef HAVE_VA_COPY #define VARARGS_ASSIGN(foo, bar) VA_COPY(foo,bar) +#elif defined(va_copy) +#define VARARGS_ASSIGN(foo, bar) va_copy(foo,bar) #elif defined(HAVE_VA_LIST_AS_ARRAY) #define VARARGS_ASSIGN(foo, bar) foo[0] = bar[0] #else diff --git a/spidermonkey/pyiter.c b/spidermonkey/pyiter.c index e73d0dd..09e9292 100644 --- a/spidermonkey/pyiter.c +++ b/spidermonkey/pyiter.c @@ -34,6 +34,7 @@ finalize(JSContext* jscx, JSObject* jsobj) if(pycx == NULL) { fprintf(stderr, "*** NO PYTHON CONTEXT ***\n"); + JS_EndRequest(jscx); return; } diff --git a/spidermonkey/pyobject.c b/spidermonkey/pyobject.c index eaf8031..b0b9572 100644 --- a/spidermonkey/pyobject.c +++ b/spidermonkey/pyobject.c @@ -58,6 +58,8 @@ js_del_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* val) pykey = js2py(pycx, key); if(pykey == NULL) goto error; + if(Context_has_access(pycx, jscx, pyobj, pykey) <= 0) goto error; + if(PyObject_DelItem(pyobj, pykey) < 0) { PyErr_Clear(); @@ -101,6 +103,8 @@ js_get_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* val) pykey = js2py(pycx, key); if(pykey == NULL) goto done; + if(Context_has_access(pycx, jscx, pyobj, pykey) <= 0) goto done; + // Yeah. It's ugly as sin. if(PyString_Check(pykey) || PyUnicode_Check(pykey)) { @@ -177,6 +181,8 @@ js_set_prop(JSContext* jscx, JSObject* jsobj, jsval key, jsval* val) goto error; } + if(Context_has_access(pycx, jscx, pyobj, pykey) <= 0) goto error; + pyval = js2py(pycx, *val); if(pyval == NULL) { @@ -218,12 +224,6 @@ js_finalize(JSContext* jscx, JSObject* jsobj) JS_EndRequest(jscx); Py_DECREF(pyobj); - - // Technically, this could turn out to be nasty. If - // this is the last object keeping the python cx - // alive, then this call could be deleting the cx - // we're about to return to. - Py_DECREF(pycx); } PyObject* @@ -262,6 +262,7 @@ js_call(JSContext* jscx, JSObject* jsobj, uintN argc, jsval* argv, jsval* rval) PyObject* pyobj = NULL; PyObject* tpl = NULL; PyObject* ret = NULL; + PyObject* attrcheck = NULL; JSBool jsret = JS_FALSE; pycx = (Context*) JS_GetContextPrivate(jscx); @@ -275,10 +276,16 @@ js_call(JSContext* jscx, JSObject* jsobj, uintN argc, jsval* argv, jsval* rval) if(!PyCallable_Check(pyobj)) { - JS_ReportError(jscx, "Object is not callable."); + JS_ReportError(jscx, "Object not callable, unable to apply"); goto error; } + // Use '__call__' as a notice that we want to execute a function. + attrcheck = PyString_FromString("__call__"); + if(attrcheck == NULL) goto error; + + if(Context_has_access(pycx, jscx, pyobj, attrcheck) <= 0) goto error; + tpl = mk_args_tuple(pycx, jscx, argc, argv); if(tpl == NULL) goto error; @@ -307,6 +314,7 @@ js_call(JSContext* jscx, JSObject* jsobj, uintN argc, jsval* argv, jsval* rval) success: Py_XDECREF(tpl); Py_XDECREF(ret); + Py_XDECREF(attrcheck); return jsret; } @@ -317,6 +325,7 @@ js_ctor(JSContext* jscx, JSObject* jsobj, uintN argc, jsval* argv, jsval* rval) PyObject* pyobj = NULL; PyObject* tpl = NULL; PyObject* ret = NULL; + PyObject* attrcheck = NULL; JSBool jsret = JS_FALSE; pycx = (Context*) JS_GetContextPrivate(jscx); @@ -330,7 +339,7 @@ js_ctor(JSContext* jscx, JSObject* jsobj, uintN argc, jsval* argv, jsval* rval) if(!PyCallable_Check(pyobj)) { - JS_ReportError(jscx, "Object is not callable."); + JS_ReportError(jscx, "Object not callable, unable to construct"); goto error; } @@ -340,6 +349,12 @@ js_ctor(JSContext* jscx, JSObject* jsobj, uintN argc, jsval* argv, jsval* rval) goto error; } + // Use '__init__' to signal use as a constructor. + attrcheck = PyString_FromString("__init__"); + if(attrcheck == NULL) goto error; + + if(Context_has_access(pycx, jscx, pyobj, attrcheck) <= 0) goto error; + tpl = mk_args_tuple(pycx, jscx, argc, argv); if(tpl == NULL) goto error; @@ -472,12 +487,6 @@ py2js_object(Context* cx, PyObject* pyobj) goto error; } - /* - As noted in Context_new, here we must ref the Python context - to make sure it stays alive while a Python object may be - referenced in the JS VM. - */ - Py_INCREF(cx); ret = OBJECT_TO_JSVAL(jsobj); goto success; diff --git a/spidermonkey/runtime.c b/spidermonkey/runtime.c index e66caac..233bc8b 100644 --- a/spidermonkey/runtime.c +++ b/spidermonkey/runtime.c @@ -20,12 +20,17 @@ Runtime_new(PyTypeObject* type, PyObject* args, PyObject* kwargs) if(self == NULL) goto error; self->rt = JS_NewRuntime(stacksize); - if(self->rt == NULL) goto error; + if(self->rt == NULL) + { + PyErr_SetString(JSError, "Failed to allocate new JSRuntime."); + goto error; + } goto success; error: Py_XDECREF(self); + self = NULL; success: return (PyObject*) self; @@ -51,20 +56,22 @@ Runtime_new_context(Runtime* self, PyObject* args, PyObject* kwargs) { PyObject* cx = NULL; PyObject* tpl = NULL; - PyObject* global = NULL; + PyObject* global = Py_None; + PyObject* access = Py_None; - if(!PyArg_ParseTuple(args, "|O", &global)) goto error; - - if(global == NULL) - { - tpl = Py_BuildValue("(O)", self); - } - else - { - tpl = Py_BuildValue("(OO)", self, global); - } + char* keywords[] = {"glbl", "access", NULL}; + + if(!PyArg_ParseTupleAndKeywords( + args, kwargs, + "|OO", + keywords, + &global, + &access + )) goto error; + + tpl = Py_BuildValue("OOO", self, global, access); if(tpl == NULL) goto error; - + cx = PyObject_CallObject((PyObject*) ContextType, tpl); goto success; diff --git a/tests/t.py b/tests/t.py index 70e6fba..339757c 100644 --- a/tests/t.py +++ b/tests/t.py @@ -45,8 +45,6 @@ def eq(a, b): assert a == b, "%r != %r" % (a, b) def ne(a, b): - print "%r" % a - print "%r" % b assert a != b, "%r == %r" % (a, b) def lt(a, b): diff --git a/tests/test-access.py b/tests/test-access.py new file mode 100644 index 0000000..f5e7c5b --- /dev/null +++ b/tests/test-access.py @@ -0,0 +1,125 @@ +# Copyright 2009 Paul J. Davis +# Copyright 2009 Richard Boulton +# +# This file is part of the python-spidermonkey package released +# under the MIT license. +import t + +@t.cx() +def test_set_callback(cx): + t.eq(cx.set_access(), None) + t.raises(TypeError, cx.set_access, "foo") + t.raises(TypeError, cx.set_access, 1) + def cb(obj, name): return True + t.eq(cx.set_access(cb), None) + t.eq(cx.set_access(), cb) + # Check that we don't erase it. + t.eq(cx.set_access(), cb) + +@t.cx() +def test_always_callback(cx): + names = [] + def fn(obj, name): + names.append(name) + return True + cx.set_access(fn) + cx.add_global("foo", {"bar": "baz"}) + t.eq(cx.execute('foo["bar"]'), "baz") + t.eq(names, ["bar"]) + +@t.cx() +def test_no_underscores(cx): + def fn(obj, name): + return name.strip()[:1] != "_" + cx.set_access(fn) + cx.add_global("foo", {"bar": "baz", "_bar": "_baz"}) + t.eq(cx.execute('foo["bar"]'), "baz") + t.raises(t.JSError, cx.execute, 'foo["_bar"]') + +@t.cx() +def test_no_set_invalid(cx): + def fn(obj, name): + return name.strip()[:1] != "_" + cx.set_access(fn) + glbl = {} + cx.add_global("foo", glbl) + cx.execute('foo["bar"] = "baz";') + t.raises(t.JSError, cx.execute, 'foo["_bar"] = "baz"') + t.eq(glbl, {"bar": "baz"}) + +@t.rt() +def test_access_in_ctor(rt): + def fn(obj, name): + return name != "bing" + cx = rt.new_context(access=fn) + cx.add_global("foo", {"bing": "boo"}) + t.raises(t.JSError, cx.execute, 'foo["bing"];') + +@t.rt() +def test_access_global(rt): + names = [] + def fn(obj, name): + names.append(name) + return not name.startswith("_") + glbl = {"foo": "bar", "_bin": "zingle"} + cx = rt.new_context(glbl, fn) + t.eq(cx.execute('foo;'), "bar") + t.raises(t.JSError, cx.execute, '_bin;') + t.eq(names, ["foo", "foo", "_bin"]) + +@t.cx() +def test_dissallow_ctor(cx): + class DirtyCar(object): + def __init__(self): + self.zap = 2 + def check(obj, name): + return name != "__init__" + cx.add_global("DirtyCar", DirtyCar) + cx.set_access(check) + t.raises(t.JSError, cx.execute, "DirtyCall();") + +@t.cx() +def test_dissalow_call(cx): + class PepsiCan(object): + def __init__(self): + self.caffeine = "zaney!" + def __call__(self, arg): + return arg * 2 + def check(obj, name): + return name != "__call__" + cx.add_global("PepsiCan", PepsiCan) + cx.set_access(check) + t.eq(cx.execute("var c = new PepsiCan(); c.caffeine;"), "zaney!") + t.raises(t.JSError, cx.execute, "c();") + +@t.cx() +def test_on_wrapped_obj(cx): + class ShamWow(object): + def __init__(self): + self.bar = 2 + self._bing = 3 + def func(): + return ShamWow() + cx.add_global("whee", func) + + def check(obj, name): + return name in ["__call__", "__init__"] or not name.startswith("_") + cx.set_access(check); + + t.eq(cx.execute("var f = whee(); f.bar;"), 2) + t.raises(t.JSError, cx.execute, "f._bing") + +@t.cx() +def test_obj_method(cx): + class Checker(object): + def __init__(self): + self.names = [] + def check(self, obj, name): + self.names.append(name) + return name != "kablooie" + c = Checker() + cx.set_access(c.check) + cx.add_global("bing", {"kablooie": "bar", "bing": 3}) + t.eq(cx.execute('bing["bing"]'), 3) + t.raises(t.JSError, cx.execute, 'bing["kablooie"]') + t.eq(c.names, ["bing", "kablooie"]) diff --git a/tests/test-context.py b/tests/test-context.py index fe079db..34d6ca2 100644 --- a/tests/test-context.py +++ b/tests/test-context.py @@ -27,6 +27,11 @@ def test_reentry(cx): cx.execute("var x = 42;") t.eq(cx.execute("x;"), 42) +@t.cx() +def test_null(cx): + cx.execute("x = null;") + t.eq(cx.execute("x;"), None) + @t.cx() def test_get_set_limits(cx): t.eq(cx.max_time(), 0) @@ -41,7 +46,7 @@ def test_exceed_time(cx): script = """ var time = function() {return (new Date()).getTime();}; var start = time(); - while((time() - start) < 2000) {} + while((time() - start) < 100000) {} """ cx.max_time(1) t.raises(SystemError, cx.execute, script) diff --git a/tests/test-global.py b/tests/test-global.py index d950c4c..1c0104d 100644 --- a/tests/test-global.py +++ b/tests/test-global.py @@ -74,6 +74,12 @@ def test_py_get_global(rt): cx = rt.new_context(glbl) t.eq(cx.execute("foo;"), "bar") +@t.rt() +def test_py_global_by_kwarg(rt): + glbl = {"foo": "bar"} + cx = rt.new_context(glbl=glbl) + t.eq(cx.execute("foo;"), "bar") + @t.rt() def test_py_set_global(rt): glbl = {} diff --git a/tests/test-runtime.py b/tests/test-runtime.py index 297f653..f012bae 100644 --- a/tests/test-runtime.py +++ b/tests/test-runtime.py @@ -15,9 +15,9 @@ def test_create_no_memory(): def test_exceed_memory(): # This test actually tests nothing. I'm leaving it for a bit to # see if I hear about the bug noted below. - rt = t.spidermonkey.Runtime(10000) + rt = t.spidermonkey.Runtime(50000) cx = rt.new_context() - script = "var b = []; var f = 10; while(f-- > 0) b.push(2.456);" + script = "var b = []; var f = 1000; while(f-- > 0) b.push(2.456);" # I had this script below original and it triggers some sort of # bug in the JS VM. I even reduced the test case outside of # python-spidermonkey to show it. No word from the SM guys. diff --git a/tests/test-syntax-error.py b/tests/test-syntax-error.py index d23cfda..ab14deb 100644 --- a/tests/test-syntax-error.py +++ b/tests/test-syntax-error.py @@ -5,17 +5,9 @@ import t import traceback -ERROR = 'File "", line 1, in ' \ - 'SyntaxError: missing ) after formal parameters' - @t.cx() def test_syntax_error(cx): - try: - cx.execute("function(asdf;") - t.eq(1, 0) - except: - line = traceback.format_exc().split("\n")[-3].strip() - t.eq(line, ERROR) + t.raises(t.JSError, cx.execute, "function(asdf;") @t.cx() def test_invalid_octal(cx): diff --git a/tests/test-turnover.py b/tests/test-turnover.py new file mode 100644 index 0000000..db065a7 --- /dev/null +++ b/tests/test-turnover.py @@ -0,0 +1,27 @@ +# Copyright 2009 Paul J. Davis +# +# This file is part of the python-spidermonkey package released +# under the MIT license. +import t + +#def test_churn_runtimes(): +# for i in range(1000): +# rt = t.spidermonkey.Runtime() + + +class Session(object): + def __init__(self): + self.key = None + + def set(self, key): + self.key = key + return self + +@t.rt() +def test_churn_contexts(rt): + for i in range(1000): + cx = rt.new_context() + cx.add_global('session', Session) + data = cx.execute('new session().set("foo");') + t.eq(data.key, "foo") +