Mercurial > pymonkey
comparison src/function.cpp @ 160:56181fb5fc7e
Added a function.is_python property indicating whether the js function is implemented in python.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Sun, 30 Aug 2009 15:47:23 -0700 |
parents | 5ec81091cb89 |
children | dd32a92f6b4f |
comparison
equal
deleted
inserted
replaced
159:e57d8083fb3d | 160:56181fb5fc7e |
---|---|
142 "Filename of function's source code."}, | 142 "Filename of function's source code."}, |
143 {"base_lineno", T_UINT, offsetof(PYM_JSFunction, baseLineno), READONLY, | 143 {"base_lineno", T_UINT, offsetof(PYM_JSFunction, baseLineno), READONLY, |
144 "Base line number of function's source code."}, | 144 "Base line number of function's source code."}, |
145 {"line_extent", T_UINT, offsetof(PYM_JSFunction, lineExtent), READONLY, | 145 {"line_extent", T_UINT, offsetof(PYM_JSFunction, lineExtent), READONLY, |
146 "Line extent of function's source code."}, | 146 "Line extent of function's source code."}, |
147 {"is_python", T_BYTE, offsetof(PYM_JSFunction, isPython), READONLY, | |
148 "Whether or not the function is implemented in Python."}, | |
147 {NULL, NULL, NULL, NULL, NULL} | 149 {NULL, NULL, NULL, NULL, NULL} |
148 }; | 150 }; |
149 | 151 |
150 PyTypeObject PYM_JSFunctionType = { | 152 PyTypeObject PYM_JSFunctionType = { |
151 PyObject_HEAD_INIT(NULL) | 153 PyObject_HEAD_INIT(NULL) |
204 jsFunction->fun = function; | 206 jsFunction->fun = function; |
205 jsFunction->name = NULL; | 207 jsFunction->name = NULL; |
206 jsFunction->filename = NULL; | 208 jsFunction->filename = NULL; |
207 jsFunction->baseLineno = 0; | 209 jsFunction->baseLineno = 0; |
208 jsFunction->lineExtent = 0; | 210 jsFunction->lineExtent = 0; |
211 jsFunction->isPython = 0; | |
209 | 212 |
210 JSString *name = JS_GetFunctionId(jsFunction->fun); | 213 JSString *name = JS_GetFunctionId(jsFunction->fun); |
211 if (name != NULL) { | 214 if (name != NULL) { |
212 // It's not an anonymous function. | 215 // It's not an anonymous function. |
213 jsFunction->name = PYM_jsvalToPyObject(context, | 216 jsFunction->name = PYM_jsvalToPyObject(context, |
282 Py_DECREF((PyObject *) object); | 285 Py_DECREF((PyObject *) object); |
283 PyErr_SetString(PYM_error, "JS_SetReservedSlot() failed"); | 286 PyErr_SetString(PYM_error, "JS_SetReservedSlot() failed"); |
284 return NULL; | 287 return NULL; |
285 } | 288 } |
286 | 289 |
290 object->isPython = 1; | |
291 | |
287 return object; | 292 return object; |
288 } | 293 } |