comparison context.c @ 91:97d1faf02460

Got rid of Py_UNICODE_WIDE ifdefs.
author Atul Varma <varmaa@toolness.com>
date Sat, 15 Aug 2009 00:10:29 -0700
parents e77bc7c799e8
children
comparison
equal deleted inserted replaced
90:c41f1d2e8f9d 91:97d1faf02460
210 210
211 static PyObject * 211 static PyObject *
212 PYM_getProperty(PYM_JSContextObject *self, PyObject *args) 212 PYM_getProperty(PYM_JSContextObject *self, PyObject *args)
213 { 213 {
214 PYM_SANITY_CHECK(self->runtime); 214 PYM_SANITY_CHECK(self->runtime);
215 #ifndef Py_UNICODE_WIDE
216 PYM_JSObject *object; 215 PYM_JSObject *object;
217 Py_UNICODE *string; 216 char *buffer = NULL;
218 217 int size;
219 if (!PyArg_ParseTuple(args, "O!u", &PYM_JSObjectType, &object, 218
220 &string)) 219 if (!PyArg_ParseTuple(args, "O!es#", &PYM_JSObjectType, &object,
221 return NULL; 220 "utf-16", &buffer, &size))
222 221 return NULL;
223 PYM_ENSURE_RUNTIME_MATCH(self->runtime, object->runtime); 222
224 223 if (self->runtime != object->runtime) {
225 JSString *jsString = JS_NewUCStringCopyZ(self->cx, 224 PyMem_Free(buffer);
226 (const jschar *) string); 225 PYM_ENSURE_RUNTIME_MATCH(self->runtime, object->runtime);
227 if (jsString == NULL) {
228 PyErr_SetString(PYM_error, "JS_NewStringCopyZ() failed");
229 return NULL;
230 } 226 }
231 227
232 jsval val; 228 jsval val;
233 JSBool result; 229 JSBool result;
234 Py_BEGIN_ALLOW_THREADS; 230 Py_BEGIN_ALLOW_THREADS;
235 result = JS_GetUCProperty(self->cx, object->obj, 231 // Note that we're manipulating buffer and size here to get rid of
236 JS_GetStringChars(jsString), 232 // the BOM.
237 JS_GetStringLength(jsString), &val); 233 result = JS_GetUCProperty(self->cx, object->obj, (jschar *) (buffer + 2),
234 (size / 2) - 1, &val);
238 Py_END_ALLOW_THREADS; 235 Py_END_ALLOW_THREADS;
236
237 PyMem_Free(buffer);
239 238
240 if (!result) { 239 if (!result) {
241 PYM_jsExceptionToPython(self); 240 PYM_jsExceptionToPython(self);
242 return NULL; 241 return NULL;
243 } 242 }
244 243
245 return PYM_jsvalToPyObject(self, val); 244 return PYM_jsvalToPyObject(self, val);
246 #else
247 PyErr_SetString(PyExc_NotImplementedError,
248 "This function is not yet implemented for wide "
249 "unicode builds of Python.");
250 return NULL;
251 #endif
252 } 245 }
253 246
254 static PyObject * 247 static PyObject *
255 PYM_gc(PYM_JSContextObject *self, PyObject *args) 248 PYM_gc(PYM_JSContextObject *self, PyObject *args)
256 { 249 {