Mercurial > pymonkey
changeset 45:03aec8572461
Python-wrapped JS functions can now return null/None.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Mon, 06 Jul 2009 00:09:42 -0700 |
parents | 0b9a316ce4ef |
children | a0f677cfc679 |
files | test_pymonkey.py utils.c |
diffstat | 2 files changed, 11 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/test_pymonkey.py Sun Jul 05 23:55:42 2009 -0700 +++ b/test_pymonkey.py Mon Jul 06 00:09:42 2009 -0700 @@ -39,6 +39,12 @@ self.assertEqual(self._evalJsWrappedPyFunc(hai2u, 'hai2u()'), u"o hai") + def testJsWrappedPythonFunctionReturnsNone(self): + def hai2u(cx): + pass + self.assertEqual(self._evalJsWrappedPyFunc(hai2u, 'hai2u()'), + None) + def testJsWrappedPythonFunctionReturnsTrue(self): def hai2u(cx): return True
--- a/utils.c Sun Jul 05 23:55:42 2009 -0700 +++ b/utils.c Mon Jul 06 00:09:42 2009 -0700 @@ -73,6 +73,11 @@ return 0; } + if (object == Py_None) { + *rval = JSVAL_NULL; + return 0; + } + // TODO: Support more types. PyErr_SetString(PyExc_NotImplementedError, "Data type conversion not implemented.");