PythonMonkey   v1.1.1 (dev)
Loading...
Searching...
No Matches
JSStringProxy.hh
Go to the documentation of this file.
1
11#ifndef PythonMonkey_JSStringProxy_
12#define PythonMonkey_JSStringProxy_
13
14#include <jsapi.h>
15
16#include <Python.h>
17
18#include <unordered_set>
19
24typedef struct {
25 PyUnicodeObject str;
26 JS::PersistentRootedValue *jsString;
28
29extern std::unordered_set<JSStringProxy *> jsStringProxies; // a collection of all JSStringProxy objects, used during a GCCallback to ensure they continue to point to the correct char buffer
30
36public:
42 static void JSStringProxy_dealloc(JSStringProxy *self);
43
50 static PyObject *JSStringProxy_copy_method(JSStringProxy *self);
51};
52
53// docs for methods, copied from cpython
54PyDoc_STRVAR(stringproxy_deepcopy__doc__,
55 "__deepcopy__($self, memo, /)\n"
56 "--\n"
57 "\n");
58
59PyDoc_STRVAR(stringproxy_copy__doc__,
60 "__copy__($self, /)\n"
61 "--\n"
62 "\n");
63
68static PyMethodDef JSStringProxy_methods[] = {
69 {"__deepcopy__", (PyCFunction)JSStringProxyMethodDefinitions::JSStringProxy_copy_method, METH_O, stringproxy_deepcopy__doc__}, // ignores any memo argument
70 {"__copy__", (PyCFunction)JSStringProxyMethodDefinitions::JSStringProxy_copy_method, METH_NOARGS, stringproxy_copy__doc__},
71 {NULL, NULL} /* sentinel */
72};
73
77extern PyTypeObject JSStringProxyType;
78
79#endif
std::unordered_set< JSStringProxy * > jsStringProxies
Definition JSStringProxy.cc:15
PyTypeObject JSStringProxyType
Struct for the JSStringProxyType, used by all JSStringProxy objects.
Definition pythonmonkey.cc:158
PyDoc_STRVAR(stringproxy_deepcopy__doc__, "__deepcopy__($self, memo, /)\n" "--\n" "\n")
This struct is a bundle of methods used by the JSStringProxy type.
Definition JSStringProxy.hh:35
static PyObject * JSStringProxy_copy_method(JSStringProxy *self)
copy protocol method for both copy and deepcopy
Definition JSStringProxy.cc:25
static void JSStringProxy_dealloc(JSStringProxy *self)
Deallocation method (.tp_dealloc), removes the reference to the underlying JSString before freeing th...
Definition JSStringProxy.cc:19
The typedef for the backing store that will be used by JSStringProxy objects. All it contains is a po...
Definition JSStringProxy.hh:24
PyUnicodeObject str
Definition JSStringProxy.hh:25
JS::PersistentRootedValue * jsString
Definition JSStringProxy.hh:26