Mercurial > pymonkey
annotate object.c @ 40:8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Fri, 03 Jul 2009 20:04:01 -0700 |
parents | d4efcbb06964 |
children | bc4263c6ae82 |
rev | line source |
---|---|
13 | 1 #include "object.h" |
40
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
2 #include "function.h" |
21
fc04e5f1c675
Changed object constructor to take a context instead of a runtime.
Atul Varma <varmaa@toolness.com>
parents:
18
diff
changeset
|
3 #include "runtime.h" |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
4 #include "utils.h" |
13 | 5 |
6 JSClass PYM_JS_ObjectClass = { | |
7 "PymonkeyObject", JSCLASS_GLOBAL_FLAGS, | |
8 JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, | |
9 JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, JS_FinalizeStub, | |
10 JSCLASS_NO_OPTIONAL_MEMBERS | |
11 }; | |
12 | |
13 static void | |
14 PYM_JSObjectDealloc(PYM_JSObject *self) | |
15 { | |
15
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
16 if (self->obj) { |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
17 JS_DHashTableOperate(&self->runtime->objects, |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
18 (void *) self->uniqueId, |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
19 JS_DHASH_REMOVE); |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
20 |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
21 // JS_RemoveRoot() always returns JS_TRUE, so don't |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
22 // bother checking its return value. |
15
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
23 JS_RemoveRootRT(self->runtime->rt, &self->obj); |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
24 self->obj = NULL; |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
25 } |
baa4cb961330
JS objects in python-land are now rooted while in python-land so that they're not gc'd while in python-land.
Atul Varma <varmaa@toolness.com>
parents:
13
diff
changeset
|
26 |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
27 if (self->runtime) { |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
28 Py_DECREF(self->runtime); |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
29 self->runtime = NULL; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
30 } |
37
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
31 |
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
32 self->ob_type->tp_free((PyObject *) self); |
13 | 33 } |
34 | |
35 PyTypeObject PYM_JSObjectType = { | |
36 PyObject_HEAD_INIT(NULL) | |
37 0, /*ob_size*/ | |
38 "pymonkey.Object", /*tp_name*/ | |
39 sizeof(PYM_JSObject), /*tp_basicsize*/ | |
40 0, /*tp_itemsize*/ | |
41 /*tp_dealloc*/ | |
42 (destructor) PYM_JSObjectDealloc, | |
43 0, /*tp_print*/ | |
44 0, /*tp_getattr*/ | |
45 0, /*tp_setattr*/ | |
46 0, /*tp_compare*/ | |
47 0, /*tp_repr*/ | |
48 0, /*tp_as_number*/ | |
49 0, /*tp_as_sequence*/ | |
50 0, /*tp_as_mapping*/ | |
51 0, /*tp_hash */ | |
52 0, /*tp_call*/ | |
53 0, /*tp_str*/ | |
54 0, /*tp_getattro*/ | |
55 0, /*tp_setattro*/ | |
56 0, /*tp_as_buffer*/ | |
37
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
57 /*tp_flags*/ |
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
58 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE, |
13 | 59 /* tp_doc */ |
60 "JavaScript Object.", | |
61 0, /* tp_traverse */ | |
62 0, /* tp_clear */ | |
63 0, /* tp_richcompare */ | |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
64 0, /* tp_weaklistoffset */ |
13 | 65 0, /* tp_iter */ |
66 0, /* tp_iternext */ | |
67 0, /* tp_methods */ | |
68 0, /* tp_members */ | |
69 0, /* tp_getset */ | |
70 0, /* tp_base */ | |
71 0, /* tp_dict */ | |
72 0, /* tp_descr_get */ | |
73 0, /* tp_descr_set */ | |
74 0, /* tp_dictoffset */ | |
75 0, /* tp_init */ | |
76 0, /* tp_alloc */ | |
77 0, /* tp_new */ | |
78 }; | |
18
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
79 |
21
fc04e5f1c675
Changed object constructor to take a context instead of a runtime.
Atul Varma <varmaa@toolness.com>
parents:
18
diff
changeset
|
80 PYM_JSObject *PYM_newJSObject(PYM_JSContextObject *context, |
37
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
81 JSObject *obj, |
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
82 PYM_JSObject *subclass) { |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
83 jsid uniqueId; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
84 if (!JS_GetObjectId(context->cx, obj, &uniqueId)) { |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
85 PyErr_SetString(PYM_error, "JS_GetObjectId() failed"); |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
86 return NULL; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
87 } |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
88 |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
89 PYM_JSRuntimeObject *runtime = context->runtime; |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
90 PYM_HashEntry *cached = (PYM_HashEntry *) JS_DHashTableOperate( |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
91 &runtime->objects, |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
92 (void *) uniqueId, |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
93 JS_DHASH_LOOKUP |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
94 ); |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
95 |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
96 if (JS_DHASH_ENTRY_IS_BUSY((JSDHashEntryHdr *) cached)) { |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
97 Py_INCREF((PyObject *) cached->value); |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
98 return (PYM_JSObject *) cached->value; |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
99 } |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
100 |
37
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
101 PYM_JSObject *object; |
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
102 |
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
103 if (subclass) |
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
104 object = subclass; |
40
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
105 else { |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
106 if (JS_ObjectIsFunction(context->cx, obj)) { |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
107 PYM_JSFunction *func = PyObject_New(PYM_JSFunction, |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
108 &PYM_JSFunctionType); |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
109 if (func != NULL) |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
110 func->callable = NULL; |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
111 object = (PYM_JSObject *) func; |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
112 } else |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
113 object = PyObject_New(PYM_JSObject, |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
114 &PYM_JSObjectType); |
8a7abd0bb48d
Renamed PYM_newJSFunction() to PYM_newJSFunctionFromCallable(). PYM_newJSObject() now returns objects of type PYM_JSFunctionType as needed.
Atul Varma <varmaa@toolness.com>
parents:
37
diff
changeset
|
115 } |
37
d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
Atul Varma <varmaa@toolness.com>
parents:
23
diff
changeset
|
116 |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
117 if (object == NULL) |
18
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
118 return NULL; |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
119 |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
120 object->runtime = NULL; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
121 object->obj = NULL; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
122 object->uniqueId = NULL; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
123 |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
124 cached = (PYM_HashEntry *) JS_DHashTableOperate(&runtime->objects, |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
125 (void *) uniqueId, |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
126 JS_DHASH_ADD); |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
127 if (cached == NULL) { |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
128 Py_DECREF(object); |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
129 PyErr_SetString(PYM_error, "JS_DHashTableOperate() failed"); |
22
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
130 return NULL; |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
131 } |
988a8998c75f
JS objects reflected into Python are now identity-preserving, though the implementation for this is pretty bad right now.
Atul Varma <varmaa@toolness.com>
parents:
21
diff
changeset
|
132 |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
133 cached->base.key = (void *) uniqueId; |
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
134 cached->value = object; |
18
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
135 |
21
fc04e5f1c675
Changed object constructor to take a context instead of a runtime.
Atul Varma <varmaa@toolness.com>
parents:
18
diff
changeset
|
136 object->runtime = context->runtime; |
18
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
137 Py_INCREF(object->runtime); |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
138 |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
139 object->obj = obj; |
23
951ad1b15587
The hashtable of reflected JS objects now uses a JS_DHashTable instead of a PyDict. Also removed weakref-ability of the JSObject class since it didn't make any sense to use Python's weakref support for JSObjects.
Atul Varma <varmaa@toolness.com>
parents:
22
diff
changeset
|
140 object->uniqueId = uniqueId; |
18
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
141 |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
142 JS_AddNamedRootRT(object->runtime->rt, &object->obj, |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
143 "Pymonkey-Generated Object"); |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
144 |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
145 return object; |
f3223debd70b
Refactoring; moved PYM_JSObject creation code into a new public function in object.c.
Atul Varma <varmaa@toolness.com>
parents:
15
diff
changeset
|
146 } |