Created
September 26, 2012 20:07
-
-
Save syg/3790265 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
["Test"].forEach(function makeStub(className) { | |
const global = this; | |
global[className] = function () { | |
if (!avm2) { | |
throw new Error("AVM2 not initialized"); | |
} | |
var c = avm2.systemDomain.getClass(className); | |
assert(c.instance); | |
global[className] = c.instance; | |
return c.createInstance.apply(c, arguments); | |
}; | |
}); | |
var TestImpl = { | |
initialize: function (x) { | |
print("native constructor"); | |
this.x_ = x; | |
}, | |
getX: function() { | |
return this.x_; | |
} | |
}; | |
natives.TestClass = function TestClass(runtime, scope, instance, baseClass) { | |
function TestInstance() { | |
this.initialize(arguments[0]); | |
instance.apply(this, arguments); | |
} | |
var c = new runtime.domain.system.Class("Test", TestInstance); | |
c.extend(baseClass); | |
c.mixin(TestImpl); | |
c.nativeStatics = { | |
spawn: function (arg) { | |
var o = new Test(arg); | |
print(o.getX()); | |
return o; | |
} | |
}; | |
c.nativeMethods = { | |
"get x": TestImpl.getX | |
}; | |
return c; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment