MCPcopy Create free account
hub / github.com/Distributive-Network/PythonMonkey / JSArrayProxy_get

Method JSArrayProxy_get

src/JSArrayProxy.cc:56–83  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

54}
55
56PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_get(JSArrayProxy *self, PyObject *key)
57{
58 JS::RootedId id(GLOBAL_CX);
59 if (!keyToId(key, &id)) {
60 PyErr_SetString(PyExc_AttributeError, "JSArrayProxy property name must be of type str or int");
61 return NULL;
62 }
63
64 // look through the methods for dispatch and return key if no method found
65 for (size_t index = 0;; index++) {
66 const char *methodName = JSArrayProxyType.tp_methods[index].ml_name;
67 if (methodName == NULL || !PyUnicode_Check(key)) { // reached end of list
68 JS::RootedValue value(GLOBAL_CX);
69 JS_GetPropertyById(GLOBAL_CX, *(self->jsArray), id, &value);
70 if (value.isUndefined() && PyUnicode_Check(key)) {
71 if (strcmp("__class__", PyUnicode_AsUTF8(key)) == 0) {
72 return PyObject_GenericGetAttr((PyObject *)self, key);
73 }
74 }
75 return pyTypeFactory(GLOBAL_CX, value);
76 }
77 else {
78 if (strcmp(methodName, PyUnicode_AsUTF8(key)) == 0) {
79 return PyObject_GenericGetAttr((PyObject *)self, key);
80 }
81 }
82 }
83}
84
85// private
86static PyObject *list_slice(JSArrayProxy *self, Py_ssize_t ilow, Py_ssize_t ihigh)

Callers

nothing calls this directly

Calls 2

keyToIdFunction · 0.85
pyTypeFactoryFunction · 0.85

Tested by

no test coverage detected