MCPcopy Create free account
hub / github.com/mozilla/rhino / NativeProxy

Class NativeProxy

rhino/src/main/java/org/mozilla/javascript/NativeProxy.java:22–1379  ·  view source on GitHub ↗

This class implements the Proxy object. @author Ronald Brill

Source from the content-addressed store, hash-verified

20 * @author Ronald Brill
21 */
22class NativeProxy extends ScriptableObject {
23 @Serial private static final long serialVersionUID = 6676871870513494844L;
24
25 private static final String PROXY_TAG = "Proxy";
26
27 private static final String TRAP_GET_PROTOTYPE_OF = "getPrototypeOf";
28 private static final String TRAP_SET_PROTOTYPE_OF = "setPrototypeOf";
29 private static final String TRAP_IS_EXTENSIBLE = "isExtensible";
30 private static final String TRAP_PREVENT_EXTENSIONS = "preventExtensions";
31 private static final String TRAP_GET_OWN_PROPERTY_DESCRIPTOR = "getOwnPropertyDescriptor";
32 private static final String TRAP_DEFINE_PROPERTY = "defineProperty";
33 private static final String TRAP_HAS = "has";
34 private static final String TRAP_GET = "get";
35 private static final String TRAP_SET = "set";
36 private static final String TRAP_DELETE_PROPERTY = "deleteProperty";
37 private static final String TRAP_OWN_KEYS = "ownKeys";
38 private static final String TRAP_APPLY = "apply";
39 private static final String TRAP_CONSTRUCT = "construct";
40
41 private static final ClassDescriptor DESCRIPTOR;
42
43 static {
44 DESCRIPTOR =
45 new ClassDescriptor.Builder(
46 PROXY_TAG,
47 2,
48 ClassDescriptor.typeError(),
49 NativeProxy::js_constructor)
50 .withMethod(CTOR, "revocable", 2, NativeProxy::revocable)
51 .build();
52 }
53
54 private ScriptableObject targetObj;
55 private Scriptable handlerObj;
56 private final String typeOf;
57
58 private static final class Revoker implements SerializableCallable {
59 private NativeProxy revocableProxy = null;
60
61 public Revoker(NativeProxy proxy) {
62 revocableProxy = proxy;
63 }
64
65 @Override
66 public Object call(Context cx, VarScope scope, Scriptable thisObj, Object[] args) {
67 if (revocableProxy != null) {
68 revocableProxy.handlerObj = null;
69 revocableProxy.targetObj = null;
70 revocableProxy = null;
71 }
72 return Undefined.instance;
73 }
74 }
75
76 public static Object init(Context cx, VarScope scope, boolean sealed) {
77 return DESCRIPTOR.buildConstructor(cx, scope, null, sealed);
78 }
79

Callers

nothing calls this directly

Calls 3

typeErrorMethod · 0.95
withMethodMethod · 0.80
buildMethod · 0.45

Tested by

no test coverage detected