PythonMonkey   v0.7.2 (dev)
Loading...
Searching...
No Matches
jsTypeFactory.hh
Go to the documentation of this file.
1
11#ifndef PythonMonkey_JsTypeFactory_
12#define PythonMonkey_JsTypeFactory_
13
14#include <jsapi.h>
15
16#include <Python.h>
17
18
19struct PythonExternalString : public JSExternalStringCallbacks {
20public:
27 static PyObject *getPyString(const char16_t *chars);
28 static PyObject *getPyString(const JS::Latin1Char *chars);
29
35 void finalize(char16_t *chars) const override;
36 void finalize(JS::Latin1Char *chars) const override;
37
38 size_t sizeOfBuffer(const char16_t *chars, mozilla::MallocSizeOf mallocSizeOf) const override;
39 size_t sizeOfBuffer(const JS::Latin1Char *chars, mozilla::MallocSizeOf mallocSizeOf) const override;
40};
42
51size_t UCS4ToUTF16(const uint32_t *chars, size_t length, uint16_t *outStr);
52
60JS::Value jsTypeFactory(JSContext *cx, PyObject *object);
65JS::Value jsTypeFactorySafe(JSContext *cx, PyObject *object);
66
76bool callPyFunc(JSContext *cx, unsigned int argc, JS::Value *vp);
77#endif
PythonExternalString PythonExternalStringCallbacks
Definition jsTypeFactory.cc:94
bool callPyFunc(JSContext *cx, unsigned int argc, JS::Value *vp)
Helper function for jsTypeFactory to create a JSFunction* through JS_NewFunction that knows how to ca...
Definition jsTypeFactory.cc:333
size_t UCS4ToUTF16(const uint32_t *chars, size_t length, uint16_t *outStr)
Function that makes a UTF16-encoded copy of a UCS4 string.
JS::Value jsTypeFactorySafe(JSContext *cx, PyObject *object)
same to jsTypeFactory, but it's guaranteed that no error would be set on the Python error stack,...
Definition jsTypeFactory.cc:294
JS::Value jsTypeFactory(JSContext *cx, PyObject *object)
Function that takes a PyObject and returns a corresponding JS::Value, doing shared memory management ...
Definition jsTypeFactory.cc:117
Definition jsTypeFactory.hh:19
void finalize(char16_t *chars) const override
decrefs the underlying PyObject string when the JSString is finalized
Definition jsTypeFactory.cc:65
static PyObject * getPyString(const char16_t *chars)
Get the PyObject using the given char buffer.
Definition jsTypeFactory.cc:55
size_t sizeOfBuffer(const char16_t *chars, mozilla::MallocSizeOf mallocSizeOf) const override
Definition jsTypeFactory.cc:84