comparison context.c @ 29:608d086d12e3

Added a new PYM_pyObjectToJsval() function that only supports unicode for the moment. Also, whereever we're assuming that Py_UNICODE is UCS-2, we're surrounding such code with #ifndef Py_UNICODE_WIDE.
author Atul Varma <varmaa@toolness.com>
date Tue, 30 Jun 2009 21:23:04 -0700
parents 21045074139f
children 3b2bdf2823bb
comparison
equal deleted inserted replaced
28:bd30f5c02fc3 29:608d086d12e3
38 } 38 }
39 39
40 static PyObject * 40 static PyObject *
41 PYM_getProperty(PYM_JSContextObject *self, PyObject *args) 41 PYM_getProperty(PYM_JSContextObject *self, PyObject *args)
42 { 42 {
43 // TODO: We're making a lot of copies of the string here, which 43 #ifndef Py_UNICODE_WIDE
44 // can't be very efficient.
45
46 PYM_JSObject *object; 44 PYM_JSObject *object;
47 Py_UNICODE *string; 45 Py_UNICODE *string;
48 46
49 if (!PyArg_ParseTuple(args, "O!u", &PYM_JSObjectType, &object, 47 if (!PyArg_ParseTuple(args, "O!u", &PYM_JSObjectType, &object,
50 &string)) 48 &string))
66 PyErr_SetString(PYM_error, "Getting property failed."); 64 PyErr_SetString(PYM_error, "Getting property failed.");
67 return NULL; 65 return NULL;
68 } 66 }
69 67
70 return PYM_jsvalToPyObject(self, val); 68 return PYM_jsvalToPyObject(self, val);
69 #else
70 PyErr_SetString(PyExc_NotImplementedError,
71 "This function is not yet implemented for wide "
72 "unicode builds of Python.");
73 return NULL;
74 #endif
71 } 75 }
72 76
73 static PyObject * 77 static PyObject *
74 PYM_initStandardClasses(PYM_JSContextObject *self, PyObject *args) 78 PYM_initStandardClasses(PYM_JSContextObject *self, PyObject *args)
75 { 79 {
143 // TODO: Get the actual exception. 147 // TODO: Get the actual exception.
144 JS_ReportError(cx, "Python function failed."); 148 JS_ReportError(cx, "Python function failed.");
145 return JS_FALSE; 149 return JS_FALSE;
146 } 150 }
147 151
148 // TODO: Convert result to JS value. 152 JSBool success = PYM_pyObjectToJsval(cx, result, rval);
149 Py_DECREF(result); 153 Py_DECREF(result);
150 154 return success;
151 return JS_TRUE;
152 } 155 }
153 156
154 static PyObject * 157 static PyObject *
155 PYM_defineFunction(PYM_JSContextObject *self, PyObject *args) 158 PYM_defineFunction(PYM_JSContextObject *self, PyObject *args)
156 { 159 {