Mercurial > pymonkey
diff 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 |
line wrap: on
line diff
--- a/object.c Fri Jul 03 19:40:42 2009 -0700 +++ b/object.c Fri Jul 03 20:04:01 2009 -0700 @@ -1,4 +1,5 @@ #include "object.h" +#include "function.h" #include "runtime.h" #include "utils.h" @@ -101,9 +102,17 @@ if (subclass) object = subclass; - else - object = PyObject_New(PYM_JSObject, - &PYM_JSObjectType); + else { + if (JS_ObjectIsFunction(context->cx, obj)) { + PYM_JSFunction *func = PyObject_New(PYM_JSFunction, + &PYM_JSFunctionType); + if (func != NULL) + func->callable = NULL; + object = (PYM_JSObject *) func; + } else + object = PyObject_New(PYM_JSObject, + &PYM_JSObjectType); + } if (object == NULL) return NULL;