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

Function getProxyDetails

src/internalBinding/utils.cc:87–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

85}
86
87static bool getProxyDetails(JSContext *cx, unsigned argc, JS::Value *vp) {
88 JS::CallArgs args = JS::CallArgsFromVp(argc, vp);
89 JSObject *proxyObj = JS::ToObject(cx, args.get(0));
90
91 // Return undefined if it's not a proxy.
92 if (!js::IsScriptedProxy(proxyObj)) { // must be a scripted (JS-defined) proxy
93 args.rval().setUndefined();
94 return true;
95 }
96
97 // Return [target, handler]
98 JS::RootedValueArray<2> resArr(cx);
99 resArr[0].set(JS::ObjectOrNullValue(js::GetProxyTargetObject(proxyObj)));
100 // see `ScriptedProxyHandler::handlerObject`
101 // https://hg.mozilla.org/releases/mozilla-esr102/file/a03fde6/js/src/proxy/ScriptedProxyHandler.cpp#l173
102 resArr[1].set(js::GetProxyReservedSlot(proxyObj, 0 /*ScriptedProxyHandler::HANDLER_EXTRA*/));
103
104 args.rval().setObjectOrNull(JS::NewArrayObject(cx, resArr));
105 return true;
106}
107
108JSFunctionSpec InternalBinding::utils[] = {
109 JS_FN("defineGlobal", defineGlobal, /* nargs */ 2, 0),

Callers 1

formatValueFunction · 0.85

Calls 2

getMethod · 0.80
setMethod · 0.65

Tested by

no test coverage detected