Mercurial > pymonkey
comparison utils.c @ 31:d0a3f358072a
gcc now shows all warnings (-Wall).
JS-wrapped Python functions can now return integers.
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Tue, 30 Jun 2009 22:28:04 -0700 |
parents | 3b2bdf2823bb |
children | abf14cba9ef5 |
comparison
equal
deleted
inserted
replaced
30:3b2bdf2823bb | 31:d0a3f358072a |
---|---|
21 | 21 |
22 *rval = STRING_TO_JSVAL(jsString); | 22 *rval = STRING_TO_JSVAL(jsString); |
23 Py_RETURN_NONE; | 23 Py_RETURN_NONE; |
24 } | 24 } |
25 #endif | 25 #endif |
26 | |
27 if (PyInt_Check(object)) { | |
28 long number = PyInt_AS_LONG(object); | |
29 if (INT_FITS_IN_JSVAL(number)) | |
30 *rval = INT_TO_JSVAL(number); | |
31 else { | |
32 jsdouble *numberAsJsdouble = JS_NewDouble(cx, number); | |
33 if (numberAsJsdouble == NULL) { | |
34 PyErr_SetString(PYM_error, "JS_NewDouble() failed"); | |
35 return NULL; | |
36 } | |
37 *rval = DOUBLE_TO_JSVAL(numberAsJsdouble); | |
38 } | |
39 Py_RETURN_NONE; | |
40 } | |
26 | 41 |
27 // TODO: Support more types. | 42 // TODO: Support more types. |
28 PyErr_SetString(PyExc_NotImplementedError, | 43 PyErr_SetString(PyExc_NotImplementedError, |
29 "Data type conversion not implemented."); | 44 "Data type conversion not implemented."); |
30 return NULL; | 45 return NULL; |