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

Method JSArrayProxy_inplace_concat

src/JSArrayProxy.cc:708–726  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

706}
707
708PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_inplace_concat(JSArrayProxy *self, PyObject *value) {
709 Py_ssize_t selfLength = JSArrayProxy_length(self);
710 Py_ssize_t valueLength = Py_SIZE(value);
711
712 // allocate extra spacePy_SIZE
713 JS::SetArrayLength(GLOBAL_CX, *(self->jsArray), selfLength + valueLength);
714
715 JS::RootedValue jValue(GLOBAL_CX, jsTypeFactory(GLOBAL_CX, value));
716 JS::RootedObject jRootedValue = JS::RootedObject(GLOBAL_CX, jValue.toObjectOrNull());
717
718 JS::RootedValue elementVal(GLOBAL_CX);
719 for (Py_ssize_t inputIdx = 0; inputIdx < valueLength; inputIdx++) {
720 JS_GetElement(GLOBAL_CX, jRootedValue, inputIdx, &elementVal);
721 JS_SetElement(GLOBAL_CX, *(self->jsArray), selfLength + inputIdx, elementVal);
722 }
723
724 Py_INCREF(self);
725 return (PyObject *)self;
726}
727
728PyObject *JSArrayProxyMethodDefinitions::JSArrayProxy_inplace_repeat(JSArrayProxy *self, Py_ssize_t n) {
729 Py_ssize_t input_size = JSArrayProxy_length(self);

Callers

nothing calls this directly

Calls 1

jsTypeFactoryFunction · 0.85

Tested by

no test coverage detected