Mercurial > pymonkey
annotate pymonkey.c @ 25:3c2151124cee
Converted pavement.py to manage.py and added a README.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 29 Jun 2009 10:19:33 -0700 |
parents | 532b7ddca616 |
children | 21045074139f |
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" |
11
551ba05fe6ad
factored out Runtime, Context, and utils into separate files.
Atul Varma <varmaa@toolness.com>
parents:
10
diff
changeset
|
5 #include "utils.h" |
8
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
6 |
0 | 7 static PyMethodDef PYM_methods[] = { |
8 {NULL, NULL, 0, NULL} | |
9 }; | |
10 | |
11 PyMODINIT_FUNC | |
12 initpymonkey(void) | |
13 { | |
9
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
14 if (!JS_CStringsAreUTF8()) |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
15 JS_SetCStringsAreUTF8(); |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
16 |
0 | 17 PyObject *module; |
18 | |
19 module = Py_InitModule("pymonkey", PYM_methods); | |
20 if (module == NULL) | |
21 return; | |
22 | |
8
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
23 if (PyType_Ready(&PYM_undefinedType) < 0) |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
24 return; |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
25 |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
26 Py_INCREF(PYM_undefined); |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
27 PyModule_AddObject(module, "undefined", PYM_undefined); |
6647870380cc
Added support for undefined.
Atul Varma <varmaa@toolness.com>
parents:
7
diff
changeset
|
28 |
0 | 29 PYM_error = PyErr_NewException("pymonkey.error", NULL, NULL); |
30 Py_INCREF(PYM_error); | |
31 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
|
32 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
33 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
|
34 return; |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
35 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
36 Py_INCREF(&PYM_JSRuntimeType); |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
37 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
|
38 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
39 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
|
40 return; |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
41 |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
42 Py_INCREF(&PYM_JSContextType); |
032cfc448079
Added pymonkey.Runtime and pymonkey.Context as new types.
Atul Varma <varmaa@toolness.com>
parents:
8
diff
changeset
|
43 PyModule_AddObject(module, "Context", (PyObject *) &PYM_JSContextType); |
13 | 44 |
45 if (!PyType_Ready(&PYM_JSObjectType) < 0) | |
46 return; | |
47 | |
48 Py_INCREF(&PYM_JSObjectType); | |
49 PyModule_AddObject(module, "Object", (PyObject *) &PYM_JSObjectType); | |
0 | 50 } |