Mercurial > pymonkey
annotate pymonkey.c @ 37:d4efcbb06964
Added a new PYM_JSFunction type, PYM_JSContext.define_property(), and PYM_JSContext.new_function(). Also fixed a memory leak.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 02 Jul 2009 22:42:31 -0700 |
parents | 21045074139f |
children | bc4263c6ae82 |
rev | line source |
---|---|
10
29eaa1fceff1
Moved definition of undefined type into a separate module.
Atul Varma <varmaa@toolness.com>
parents:
9
diff
changeset
|
1 #include "undefined.h" |
11
551ba05fe6ad
factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
2 #include "runtime.h" |
551ba05fe6ad
factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
3 #include "context.h" |
13 | 4 #include "object.h" |
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:
27
diff
changeset
|
5 #include "function.h" |
11
551ba05fe6ad
factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
6 #include "utils.h" |
8
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
7 |
0 | 8 static PyMethodDef PYM_methods[] = { |
9 {NULL, NULL, 0, NULL} | |
10 }; | |
11 | |
12 PyMODINIT_FUNC | |
13 initpymonkey(void) | |
14 { | |
15 PyObject *module; | |
16 | |
17 module = Py_InitModule("pymonkey", PYM_methods); | |
18 if (module == NULL) | |
19 return; | |
20 | |
8
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
21 if (PyType_Ready(&PYM_undefinedType) < 0) |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
22 return; |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
23 |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
24 Py_INCREF(PYM_undefined); |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
25 PyModule_AddObject(module, "undefined", PYM_undefined); |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
26 |
0 | 27 PYM_error = PyErr_NewException("pymonkey.error", NULL, NULL); |
28 Py_INCREF(PYM_error); | |
29 PyModule_AddObject(module, "error", PYM_error); | |
9
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
30 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
31 if (!PyType_Ready(&PYM_JSRuntimeType) < 0) |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
32 return; |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
33 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
34 Py_INCREF(&PYM_JSRuntimeType); |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
35 PyModule_AddObject(module, "Runtime", (PyObject *) &PYM_JSRuntimeType); |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
36 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
37 if (!PyType_Ready(&PYM_JSContextType) < 0) |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
38 return; |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
39 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
40 Py_INCREF(&PYM_JSContextType); |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
41 PyModule_AddObject(module, "Context", (PyObject *) &PYM_JSContextType); |
13 | 42 |
43 if (!PyType_Ready(&PYM_JSObjectType) < 0) | |
44 return; | |
45 | |
46 Py_INCREF(&PYM_JSObjectType); | |
47 PyModule_AddObject(module, "Object", (PyObject *) &PYM_JSObjectType); | |
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:
27
diff
changeset
|
48 |
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:
27
diff
changeset
|
49 PYM_JSFunctionType.tp_base = &PYM_JSObjectType; |
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:
27
diff
changeset
|
50 if (!PyType_Ready(&PYM_JSFunctionType) < 0) |
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:
27
diff
changeset
|
51 return; |
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:
27
diff
changeset
|
52 |
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:
27
diff
changeset
|
53 Py_INCREF(&PYM_JSFunctionType); |
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:
27
diff
changeset
|
54 PyModule_AddObject(module, "Function", (PyObject *) &PYM_JSFunctionType); |
0 | 55 } |