123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193 |
- smalltalk.addPackage('Spaces', {});
- smalltalk.addClass('ObjectSpace', smalltalk.Object, ['frame'], 'Spaces');
- smalltalk.addMethod(
- "_connectTo_",
- smalltalk.method({
- selector: "connectTo:",
- fn: function (aFrame) {
- var self = this;
- smalltalk.send(self, "_release", []);
- self['@frame'] = aFrame;
- return self;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_create",
- smalltalk.method({
- selector: "create",
- fn: function () {
- var self = this;
- smalltalk.send(smalltalk.send(window, "_jQuery_", ["body"]), "_append_", ["<iframe style=\"display: none;\"></iframe>"]);
- self['@frame'] = smalltalk.send(smalltalk.send(smalltalk.send(window, "_jQuery_", ["iframe"]), "_get", []), "_last", []);
- smalltalk.send(smalltalk.send(self['@frame'], "_contentWindow", []), "_location_", [smalltalk.send(window, "_location", [])]);
- return self;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_destroy",
- smalltalk.method({
- selector: "destroy",
- fn: function () {
- var self = this;
- if (($receiver = self['@frame']) == nil || $receiver == undefined) {
- return self;
- } else {
- self['@frame'];
- }
- smalltalk.send(smalltalk.send(window, "_jQuery_", [self['@frame']]), "_remove", []);
- smalltalk.send(self, "_release", []);
- return self;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_do_",
- smalltalk.method({
- selector: "do:",
- fn: function (aBlock) {
- var self = this;
- var $1;
- $1 = smalltalk.send(smalltalk.send(self['@frame'], "_contentWindow", []), "_eval_", [smalltalk.send(smalltalk.send("(", "__comma", [smalltalk.send(aBlock, "_compiledSource", [])]), "__comma", [")()"])]);
- return $1;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_frame",
- smalltalk.method({
- selector: "frame",
- fn: function () {
- var self = this;
- return self['@frame'];
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_initialize",
- smalltalk.method({
- selector: "initialize",
- fn: function () {
- var self = this;
- smalltalk.send(self, "_initialize", [], smalltalk.Object);
- smalltalk.send(self, "_create", []);
- return self;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_release",
- smalltalk.method({
- selector: "release",
- fn: function () {
- var self = this;
- self['@frame'] = nil;
- return self;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_whenReadyDo_",
- smalltalk.method({
- selector: "whenReadyDo:",
- fn: function (aBlock) {
- var self = this;
- smalltalk.send(smalltalk.send(window, "_jQuery_", [self['@frame']]), "_bind_do_", ["load", aBlock]);
- return self;
- }
- }),
- smalltalk.ObjectSpace);
- smalltalk.addMethod(
- "_on_",
- smalltalk.method({
- selector: "on:",
- fn: function (aFrame) {
- var self = this;
- var $2, $3, $1;
- $2 = smalltalk.send(self, "_basicNew", []);
- smalltalk.send($2, "_connectTo_", [aFrame]);
- $3 = smalltalk.send($2, "_yourself", []);
- $1 = $3;
- return $1;
- }
- }),
- smalltalk.ObjectSpace.klass);
- smalltalk.addClass('ObjectSpaceTest', smalltalk.TestCase, ['space'], 'Spaces');
- smalltalk.addMethod(
- "_setUp",
- smalltalk.method({
- selector: "setUp",
- fn: function () {
- var self = this;
- self['@space'] = smalltalk.send(smalltalk.ObjectSpace || ObjectSpace, "_new", []);
- return self;
- }
- }),
- smalltalk.ObjectSpaceTest);
- smalltalk.addMethod(
- "_tearDown",
- smalltalk.method({
- selector: "tearDown",
- fn: function () {
- var self = this;
- smalltalk.send(self['@space'], "_destroy", []);
- self['@space'] = nil;
- return self;
- }
- }),
- smalltalk.ObjectSpaceTest);
- smalltalk.addMethod(
- "_testCreate",
- smalltalk.method({
- selector: "testCreate",
- fn: function () {
- var self = this;
- smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_notNil", [])]);
- return self;
- }
- }),
- smalltalk.ObjectSpaceTest);
- smalltalk.addMethod(
- "_testEvaluation",
- smalltalk.method({
- selector: "testEvaluation",
- fn: function () {
- var self = this;
- var result;
- smalltalk.send(self['@space'], "_whenReadyDo_", [function () {result = smalltalk.send(self['@space'], "_do_", [function () {return smalltalk;}]);result;smalltalk.send(self, "_assert_equals_", [smalltalk.send(smalltalk.send(result, "_class", []), "_name", []), "Smalltalk"]);smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(result, "_class", []), "__eq", [smalltalk.Smalltalk || Smalltalk])]);return smalltalk.send(self, "_deny_", [smalltalk.send(result, "__eq_eq", [smalltalk])]);}]);
- return self;
- }
- }),
- smalltalk.ObjectSpaceTest);
- smalltalk.addMethod(
- "_testRelease",
- smalltalk.method({
- selector: "testRelease",
- fn: function () {
- var self = this;
- smalltalk.send(self, "_deny_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_isNil", [])]);
- smalltalk.send(self['@space'], "_release", []);
- smalltalk.send(self, "_assert_", [smalltalk.send(smalltalk.send(self['@space'], "_frame", []), "_isNil", [])]);
- return self;
- }
- }),
- smalltalk.ObjectSpaceTest);
|