Mercurial > pymonkey
changeset 30:3b2bdf2823bb
Changed PYM_pyObjectToJsval() to assume the caller is in Python-space for consistency.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 30 Jun 2009 21:53:45 -0700 |
parents | 608d086d12e3 |
children | d0a3f358072a |
files | context.c utils.c utils.h |
diffstat | 3 files changed, 16 insertions(+), 9 deletions(-) [+] |
line wrap: on
line diff
--- a/context.c Tue Jun 30 21:23:04 2009 -0700 +++ b/context.c Tue Jun 30 21:53:45 2009 -0700 @@ -149,9 +149,15 @@ return JS_FALSE; } - JSBool success = PYM_pyObjectToJsval(cx, result, rval); + PyObject *success = PYM_pyObjectToJsval(cx, result, rval); Py_DECREF(result); - return success; + + if (success == NULL) { + // TODO: Get the actual exception. + JS_ReportError(cx, "Python function failed."); + return JS_FALSE; + } + return JS_TRUE; } static PyObject *
--- a/utils.c Tue Jun 30 21:23:04 2009 -0700 +++ b/utils.c Tue Jun 30 21:53:45 2009 -0700 @@ -4,7 +4,7 @@ PyObject *PYM_error; -JSBool +PyObject * PYM_pyObjectToJsval(JSContext *cx, PyObject *object, jsval *rval) @@ -15,18 +15,19 @@ JSString *jsString = JS_NewUCStringCopyZ(cx, (const jschar *) string); if (jsString == NULL) { - JS_ReportError(cx, "JS_NewUCStringCopyZ() failed"); - return JS_FALSE; + PyErr_SetString(PYM_error, "JS_NewUCStringCopyZ() failed"); + return NULL; } *rval = STRING_TO_JSVAL(jsString); - return JS_TRUE; + Py_RETURN_NONE; } #endif // TODO: Support more types. - JS_ReportError(cx, "Data type conversion not implemented."); - return JS_FALSE; + PyErr_SetString(PyExc_NotImplementedError, + "Data type conversion not implemented."); + return NULL; } PyObject *