Skip to content
Browse files

Add missing files.

  • Loading branch information...
1 parent 6f25d4f commit 4ec2b89cf31a4c582274dfd77acb0e5c65a7171d @mbebenita mbebenita committed Apr 5, 2013
Showing with 81 additions and 0 deletions.
  1. +81 −0 src/avm2/proxy.js
View
81 src/avm2/proxy.js
@@ -0,0 +1,81 @@
+/**
+ * Proxy.as
+ */
+function ProxyClass(runtime, scope, instance, baseClass) {
+ function ProxyConstructor() {
+ somewhatImplemented("Proxy");
+ }
+ var c = new runtime.domain.system.Class("Proxy", ProxyConstructor, Domain.coerceCallable(ProxyConstructor));
+ c.extendBuiltin(baseClass);
+ return c;
+}
+
+var proxyTrapQns = {
+ "getProperty": null,
+ "setProperty": null,
+ "hasProperty": null
+};
+
+for (var name in proxyTrapQns) {
+ proxyTrapQns[name] = Multiname.getQualifiedName(new Multiname([ShumwayNamespace.PROXY], name));
+}
+
+console.info(proxyTrapQns.getProperty);
+
+function extractActionScriptName(name) {
+ if (name.indexOf("public$") === 0) {
+ return name.substr(7);
+ }
+ return false;
+ // return name.indexOf("public$") >= 0 || name.indexOf("private$") >= 0;
+}
+
+function installProxyClass(cls) {
+ var instance = cls.instance;
+ function construct() {
+ var target = Object.create(instance.prototype);
+ var proxy = Proxy.create({
+ get: function(o, name) {
+ if (inRuntime()) {
+ return target[name];
+ }
+ var externalName = extractActionScriptName(name);
+ if (externalName) {
+ return target[proxyTrapQns.getProperty](externalName);
+ }
+ return target[name];
+ },
+ set: function(o, name, value) {
+ target[name] = value;
+ // notImplemented("set");
+ },
+ has: function(name) {
+ if (inRuntime()) {
+ return name in target;
+ }
+ var externalName = extractActionScriptName(name);
+ if (externalName) {
+ return target[proxyTrapQns.hasProperty](externalName);
+ }
+ return name in target;
+ },
+ hasOwn: function(name) {
+ if (extractActionScriptName(name)) {
+
+ }
+ return !!Object.getOwnPropertyDescriptor(target, name);
+ },
+ enumerate: function() {
+ notImplemented("enumerate");
+ },
+ keys: function() {
+ notImplemented("keys");
+ }
+ }, instance.prototype);
+ // The derived proxy constructor needs to have a reference to the proxy object itself.
+ instance.apply(proxy, sliceArguments(arguments, 0));
+ return proxy;
+ }
+
+ cls.instance = construct;
+}

0 comments on commit 4ec2b89

Please sign in to comment.
Something went wrong with that request. Please try again.