Skip to content

Instantly share code, notes, and snippets.

@chrivers
Created March 2, 2011 15:53
Show Gist options
  • Save chrivers/851139 to your computer and use it in GitHub Desktop.
Save chrivers/851139 to your computer and use it in GitHub Desktop.
chrivers
load("py-builtins.js");
load("datadumper.js");
d = function(x, y) {
if (defined(y)) {
print(x, Dumper(y));
} else {
print("Dump", Dumper(x));
}
};
d = function(x, y) {
print(x, Dumper(y));
print();
};
var FooClass = function() {
x = function() { /* Class constructor */ };
x.prototype.foo = "bar";
x.prototype.__init__ = function() {
this.something = "other";
};
x.prototype.__call__ = function() {
return 42;
};
q = new x();
q.__call__ = function() {
obj = new x();
obj.__init__(arguments);
return obj;
};
return q;
}();
var fc = FooClass;
d('FooClass', fc);
var f = FooClass.__call__();
d('foo = FooClass.__call__()', f);
var res = f.__call__();
d('foo.__call__()', res);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment