annotate src/script.cpp @ 141:96dc1beefc00

Regenerated docs.
author Atul Varma <varmaa@toolness.com>
date Mon, 24 Aug 2009 21:54:20 -0700
parents 1a982ee56458
children a2c1db5ece2b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
136
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
1 /* ***** BEGIN LICENSE BLOCK *****
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
2 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
3 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
4 * The contents of this file are subject to the Mozilla Public License Version
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
5 * 1.1 (the "License"); you may not use this file except in compliance with
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
6 * the License. You may obtain a copy of the License at
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
7 * http://www.mozilla.org/MPL/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
8 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
9 * Software distributed under the License is distributed on an "AS IS" basis,
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
10 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
11 * for the specific language governing rights and limitations under the
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
12 * License.
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
13 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
14 * The Original Code is Pymonkey.
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
15 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
16 * The Initial Developer of the Original Code is Mozilla.
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
17 * Portions created by the Initial Developer are Copyright (C) 2007
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
18 * the Initial Developer. All Rights Reserved.
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
19 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
20 * Contributor(s):
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
21 * Atul Varma <atul@mozilla.com>
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
22 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
23 * Alternatively, the contents of this file may be used under the terms of
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
24 * either the GNU General Public License Version 2 or later (the "GPL"), or
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
25 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
26 * in which case the provisions of the GPL or the LGPL are applicable instead
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
27 * of those above. If you wish to allow use of your version of this file only
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
28 * under the terms of either the GPL or the LGPL, and not to allow others to
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
29 * use your version of this file under the terms of the MPL, indicate your
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
30 * decision by deleting the provisions above and replace them with the notice
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
31 * and other provisions required by the GPL or the LGPL. If you do not delete
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
32 * the provisions above, a recipient may use your version of this file under
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
33 * the terms of any one of the MPL, the GPL or the LGPL.
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
34 *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
35 * ***** END LICENSE BLOCK ***** */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
36
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
37 #include "script.h"
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
38 #include "utils.h"
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
39
138
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
40 #include "jsscript.h"
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
41
136
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
42 static void
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
43 PYM_JSScriptDealloc(PYM_JSScript *self)
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
44 {
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
45 self->script = NULL;
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
46 PYM_JSObjectType.tp_dealloc((PyObject *) self);
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
47 }
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
48
138
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
49 Py_ssize_t PYM_readbuffer(PYM_JSScript *self, Py_ssize_t segment,
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
50 void **ptrptr)
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
51 {
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
52 *ptrptr = self->script->code;
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
53 return self->script->length;
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
54 }
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
55
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
56 Py_ssize_t PYM_segcount(PYM_JSScript *self, Py_ssize_t *lenp)
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
57 {
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
58 if (lenp)
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
59 *lenp = self->script->length;
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
60 return 1;
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
61 }
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
62
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
63 Py_ssize_t PYM_charbuffer(PYM_JSScript *self, Py_ssize_t segment,
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
64 const char **ptrptr)
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
65 {
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
66 *ptrptr = (char *) self->script->code;
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
67 return self->script->length;
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
68 }
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
69
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
70 static PyBufferProcs PYM_bufferProcs = {
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
71 (readbufferproc) PYM_readbuffer,
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
72 NULL,
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
73 (segcountproc) PYM_segcount,
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
74 (charbufferproc) PYM_charbuffer
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
75 };
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
76
136
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
77 PyTypeObject PYM_JSScriptType = {
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
78 PyObject_HEAD_INIT(NULL)
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
79 0, /*ob_size*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
80 "pymonkey.Script", /*tp_name*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
81 sizeof(PYM_JSScript), /*tp_basicsize*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
82 0, /*tp_itemsize*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
83 /*tp_dealloc*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
84 (destructor) PYM_JSScriptDealloc,
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
85 0, /*tp_print*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
86 0, /*tp_getattr*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
87 0, /*tp_setattr*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
88 0, /*tp_compare*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
89 0, /*tp_repr*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
90 0, /*tp_as_number*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
91 0, /*tp_as_sequence*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
92 0, /*tp_as_mapping*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
93 0, /*tp_hash */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
94 0, /*tp_call*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
95 0, /*tp_str*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
96 0, /*tp_getattro*/
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
97 0, /*tp_setattro*/
138
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
98 &PYM_bufferProcs, /*tp_as_buffer*/
136
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
99 /*tp_flags*/
138
1a982ee56458 A script's bytecode is now exposed as a buffer object.
Atul Varma <varmaa@toolness.com>
parents: 136
diff changeset
100 Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GETCHARBUFFER,
136
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
101 /* tp_doc */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
102 "JavaScript Script.",
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
103 0, /* tp_traverse */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
104 0, /* tp_clear */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
105 0, /* tp_richcompare */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
106 0, /* tp_weaklistoffset */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
107 0, /* tp_iter */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
108 0, /* tp_iternext */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
109 0, /* tp_methods */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
110 0, /* tp_members */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
111 0, /* tp_getset */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
112 0, /* tp_base */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
113 0, /* tp_dict */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
114 0, /* tp_descr_get */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
115 0, /* tp_descr_set */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
116 0, /* tp_dictoffset */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
117 0, /* tp_init */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
118 0, /* tp_alloc */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
119 0, /* tp_new */
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
120 };
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
121
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
122 PYM_JSScript *
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
123 PYM_newJSScript(PYM_JSContextObject *context, JSScript *script)
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
124 {
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
125 JSObject *scriptObj = JS_GetScriptObject(script);
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
126 PYM_JSScript *object = NULL;
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
127
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
128 if (scriptObj)
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
129 object = (PYM_JSScript *) PYM_findJSObject(context, scriptObj);
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
130 else {
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
131 scriptObj = JS_NewScriptObject(context->cx, script);
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
132
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
133 if (scriptObj == NULL) {
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
134 PyErr_SetString(PYM_error, "JS_NewScriptObject() failed");
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
135 return NULL;
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
136 }
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
137 }
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
138
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
139 if (object == NULL) {
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
140 object = PyObject_New(PYM_JSScript, &PYM_JSScriptType);
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
141 if (object == NULL)
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
142 return NULL;
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
143
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
144 object->script = script;
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
145 return (PYM_JSScript *) PYM_newJSObject(context, scriptObj,
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
146 (PYM_JSObject *) object);
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
147 }
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
148 return object;
b4e216d06e83 Added pymonkey.Script, which wraps a JSScript object, and context.compile_script()/execute_script().
Atul Varma <varmaa@toolness.com>
parents:
diff changeset
149 }