Browse Source

ModelWrapper->Frontend, Dispatcher->Backend

No more Trapped-Common.
Herbert Vojčík 12 years ago
parent
commit
1638beccb1

+ 1 - 1
demo.html

@@ -6,7 +6,7 @@
 <body>
 <script type="text/javascript">
     loadAmber({
-        packages:['Trapped-Common', 'Trapped-Backend', 'Trapped-Frontend', 'Trapped-Demo'],
+        packages:['Trapped-Backend', 'Trapped-Frontend', 'Trapped-Demo'],
         packageHome:'./',
         ready:function () {
             $(function() {

+ 67 - 0
js/Trapped-Backend.deploy.js

@@ -129,6 +129,73 @@ return $1;
 smalltalk.Isolator.klass);
 
 
+smalltalk.addClass('TrappedDispatcher', smalltalk.Object, [], 'Trapped-Backend');
+smalltalk.addMethod(
+"_changed_",
+smalltalk.method({
+selector: "changed:",
+fn: function (path){
+var self=this;
+var $1;
+var needsToRun;
+needsToRun=false;
+smalltalk.send(self,"_do_",[(function(each){
+var aPath;
+var lesser;
+aPath=smalltalk.send(each,"_second",[]);
+aPath;
+lesser=smalltalk.send(smalltalk.send(aPath,"_size",[]),"_min_",[smalltalk.send(path,"_size",[])]);
+lesser;
+$1=smalltalk.send(smalltalk.send(path,"_copyFrom_to_",[(1),lesser]),"__eq",[smalltalk.send(aPath,"_copyFrom_to_",[(1),lesser])]);
+if(smalltalk.assert($1)){
+smalltalk.send(each,"_at_put_",[(1),true]);
+needsToRun=true;
+return needsToRun;
+};
+})]);
+smalltalk.send(self,"_dirty_",[needsToRun]);
+return self}
+}),
+smalltalk.TrappedDispatcher);
+
+smalltalk.addMethod(
+"_dirty_",
+smalltalk.method({
+selector: "dirty:",
+fn: function (aBoolean){
+var self=this;
+if(smalltalk.assert(aBoolean)){
+smalltalk.send((function(){
+return smalltalk.send(self,"_run",[]);
+}),"_fork",[]);
+};
+return self}
+}),
+smalltalk.TrappedDispatcher);
+
+smalltalk.addMethod(
+"_run",
+smalltalk.method({
+selector: "run",
+fn: function (){
+var self=this;
+var $1;
+smalltalk.send(self,"_do_",[(function(each){
+$1=smalltalk.send(each,"_first",[]);
+if(smalltalk.assert($1)){
+return smalltalk.send((function(){
+return smalltalk.send(smalltalk.send(each,"_third",[]),"_value",[]);
+}),"_ensure_",[(function(){
+return smalltalk.send(each,"_at_put_",[(1),false]);
+})]);
+};
+})]);
+return self}
+}),
+smalltalk.TrappedDispatcher);
+
+
+
 smalltalk.addMethod(
 "_reverseTrapAt_",
 smalltalk.method({

+ 83 - 0
js/Trapped-Backend.js

@@ -180,6 +180,89 @@ referencedClasses: []
 smalltalk.Isolator.klass);
 
 
+smalltalk.addClass('TrappedDispatcher', smalltalk.Object, [], 'Trapped-Backend');
+smalltalk.TrappedDispatcher.comment="I am base class for change event dispatchers.\x0aI manage changed path - action block subscriptions.\x0aThese subscription must be three-element arrays\x0a\x09{ dirty. path. block }\x0a\x0aMy subclasses need to provide implementation for:\x0a\x09add:\x0a    do:\x0a    (optionally) run\x0a"
+smalltalk.addMethod(
+"_changed_",
+smalltalk.method({
+selector: "changed:",
+category: 'action',
+fn: function (path){
+var self=this;
+var $1;
+var needsToRun;
+needsToRun=false;
+smalltalk.send(self,"_do_",[(function(each){
+var aPath;
+var lesser;
+aPath=smalltalk.send(each,"_second",[]);
+aPath;
+lesser=smalltalk.send(smalltalk.send(aPath,"_size",[]),"_min_",[smalltalk.send(path,"_size",[])]);
+lesser;
+$1=smalltalk.send(smalltalk.send(path,"_copyFrom_to_",[(1),lesser]),"__eq",[smalltalk.send(aPath,"_copyFrom_to_",[(1),lesser])]);
+if(smalltalk.assert($1)){
+smalltalk.send(each,"_at_put_",[(1),true]);
+needsToRun=true;
+return needsToRun;
+};
+})]);
+smalltalk.send(self,"_dirty_",[needsToRun]);
+return self},
+args: ["path"],
+source: "changed: path\x0a\x09| needsToRun |\x0a    needsToRun := false.\x0a\x09self do: [ :each |\x0a\x09\x09| aPath lesser |\x0a\x09\x09aPath := each second.\x0a\x09\x09lesser := aPath size min: path size.\x0a\x09\x09(path copyFrom: 1 to: lesser) = (aPath copyFrom: 1 to: lesser) ifTrue: [\x0a\x09\x09\x09each at: 1 put: true.\x0a            needsToRun := true.\x0a\x09\x09]\x0a\x09].\x0a\x09self dirty: needsToRun",
+messageSends: ["do:", "second", "min:", "size", "ifTrue:", "at:put:", "=", "copyFrom:to:", "dirty:"],
+referencedClasses: []
+}),
+smalltalk.TrappedDispatcher);
+
+smalltalk.addMethod(
+"_dirty_",
+smalltalk.method({
+selector: "dirty:",
+category: 'action',
+fn: function (aBoolean){
+var self=this;
+if(smalltalk.assert(aBoolean)){
+smalltalk.send((function(){
+return smalltalk.send(self,"_run",[]);
+}),"_fork",[]);
+};
+return self},
+args: ["aBoolean"],
+source: "dirty: aBoolean\x0a\x09aBoolean ifTrue: [[ self run ] fork]",
+messageSends: ["ifTrue:", "fork", "run"],
+referencedClasses: []
+}),
+smalltalk.TrappedDispatcher);
+
+smalltalk.addMethod(
+"_run",
+smalltalk.method({
+selector: "run",
+category: 'action',
+fn: function (){
+var self=this;
+var $1;
+smalltalk.send(self,"_do_",[(function(each){
+$1=smalltalk.send(each,"_first",[]);
+if(smalltalk.assert($1)){
+return smalltalk.send((function(){
+return smalltalk.send(smalltalk.send(each,"_third",[]),"_value",[]);
+}),"_ensure_",[(function(){
+return smalltalk.send(each,"_at_put_",[(1),false]);
+})]);
+};
+})]);
+return self},
+args: [],
+source: "run\x0a\x09self do: [ :each |\x0a\x09\x09each first ifTrue: [[ each third value ] ensure: [ each at: 1 put: false ]]\x0a\x09]",
+messageSends: ["do:", "ifTrue:", "ensure:", "at:put:", "value", "third", "first"],
+referencedClasses: []
+}),
+smalltalk.TrappedDispatcher);
+
+
+
 smalltalk.addMethod(
 "_reverseTrapAt_",
 smalltalk.method({

+ 0 - 164
js/Trapped-Common.deploy.js

@@ -1,164 +0,0 @@
-smalltalk.addPackage('Trapped-Common', {});
-smalltalk.addClass('TrappedDispatcher', smalltalk.Object, [], 'Trapped-Common');
-smalltalk.addMethod(
-"_changed_",
-smalltalk.method({
-selector: "changed:",
-fn: function (path){
-var self=this;
-var $1;
-var needsToRun;
-needsToRun=false;
-smalltalk.send(self,"_do_",[(function(each){
-var aPath;
-var lesser;
-aPath=smalltalk.send(each,"_second",[]);
-aPath;
-lesser=smalltalk.send(smalltalk.send(aPath,"_size",[]),"_min_",[smalltalk.send(path,"_size",[])]);
-lesser;
-$1=smalltalk.send(smalltalk.send(path,"_copyFrom_to_",[(1),lesser]),"__eq",[smalltalk.send(aPath,"_copyFrom_to_",[(1),lesser])]);
-if(smalltalk.assert($1)){
-smalltalk.send(each,"_at_put_",[(1),true]);
-needsToRun=true;
-return needsToRun;
-};
-})]);
-smalltalk.send(self,"_dirty_",[needsToRun]);
-return self}
-}),
-smalltalk.TrappedDispatcher);
-
-smalltalk.addMethod(
-"_dirty_",
-smalltalk.method({
-selector: "dirty:",
-fn: function (aBoolean){
-var self=this;
-if(smalltalk.assert(aBoolean)){
-smalltalk.send((function(){
-return smalltalk.send(self,"_run",[]);
-}),"_fork",[]);
-};
-return self}
-}),
-smalltalk.TrappedDispatcher);
-
-smalltalk.addMethod(
-"_run",
-smalltalk.method({
-selector: "run",
-fn: function (){
-var self=this;
-var $1;
-smalltalk.send(self,"_do_",[(function(each){
-$1=smalltalk.send(each,"_first",[]);
-if(smalltalk.assert($1)){
-return smalltalk.send((function(){
-return smalltalk.send(smalltalk.send(each,"_third",[]),"_value",[]);
-}),"_ensure_",[(function(){
-return smalltalk.send(each,"_at_put_",[(1),false]);
-})]);
-};
-})]);
-return self}
-}),
-smalltalk.TrappedDispatcher);
-
-
-
-smalltalk.addClass('TrappedModelWrapper', smalltalk.Object, ['dispatcher', 'payload'], 'Trapped-Common');
-smalltalk.addMethod(
-"_dispatcher",
-smalltalk.method({
-selector: "dispatcher",
-fn: function (){
-var self=this;
-return self["@dispatcher"];
-}
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_dispatcher_",
-smalltalk.method({
-selector: "dispatcher:",
-fn: function (aDispatcher){
-var self=this;
-self["@dispatcher"]=aDispatcher;
-return self}
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_name",
-smalltalk.method({
-selector: "name",
-fn: function (){
-var self=this;
-var $1;
-$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
-return $1;
-}
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_payload",
-smalltalk.method({
-selector: "payload",
-fn: function (){
-var self=this;
-return self["@payload"];
-}
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_payload_",
-smalltalk.method({
-selector: "payload:",
-fn: function (anObject){
-var self=this;
-self["@payload"]=anObject;
-return self}
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_start",
-smalltalk.method({
-selector: "start",
-fn: function (){
-var self=this;
-smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
-return self}
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_watch_do_",
-smalltalk.method({
-selector: "watch:do:",
-fn: function (path,aBlock){
-var self=this;
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_add_",[[true,path,(function(){
-return smalltalk.send(self,"_read_do_",[path,aBlock]);
-})]]);
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_dirty_",[true]);
-return self}
-}),
-smalltalk.TrappedModelWrapper);
-
-
-smalltalk.addMethod(
-"_start",
-smalltalk.method({
-selector: "start",
-fn: function (){
-var self=this;
-smalltalk.send(smalltalk.send(self,"_new",[]),"_start",[]);
-return self}
-}),
-smalltalk.TrappedModelWrapper.klass);
-
-

+ 0 - 221
js/Trapped-Common.js

@@ -1,221 +0,0 @@
-smalltalk.addPackage('Trapped-Common', {});
-smalltalk.addClass('TrappedDispatcher', smalltalk.Object, [], 'Trapped-Common');
-smalltalk.TrappedDispatcher.comment="I am base class for change event dispatchers.\x0aI manage changed path - action block subscriptions.\x0aThese subscription must be three-element arrays\x0a\x09{ dirty. path. block }\x0a\x0aMy subclasses need to provide implementation for:\x0a\x09add:\x0a    do:\x0a    (optionally) run\x0a"
-smalltalk.addMethod(
-"_changed_",
-smalltalk.method({
-selector: "changed:",
-category: 'action',
-fn: function (path){
-var self=this;
-var $1;
-var needsToRun;
-needsToRun=false;
-smalltalk.send(self,"_do_",[(function(each){
-var aPath;
-var lesser;
-aPath=smalltalk.send(each,"_second",[]);
-aPath;
-lesser=smalltalk.send(smalltalk.send(aPath,"_size",[]),"_min_",[smalltalk.send(path,"_size",[])]);
-lesser;
-$1=smalltalk.send(smalltalk.send(path,"_copyFrom_to_",[(1),lesser]),"__eq",[smalltalk.send(aPath,"_copyFrom_to_",[(1),lesser])]);
-if(smalltalk.assert($1)){
-smalltalk.send(each,"_at_put_",[(1),true]);
-needsToRun=true;
-return needsToRun;
-};
-})]);
-smalltalk.send(self,"_dirty_",[needsToRun]);
-return self},
-args: ["path"],
-source: "changed: path\x0a\x09| needsToRun |\x0a    needsToRun := false.\x0a\x09self do: [ :each |\x0a\x09\x09| aPath lesser |\x0a\x09\x09aPath := each second.\x0a\x09\x09lesser := aPath size min: path size.\x0a\x09\x09(path copyFrom: 1 to: lesser) = (aPath copyFrom: 1 to: lesser) ifTrue: [\x0a\x09\x09\x09each at: 1 put: true.\x0a            needsToRun := true.\x0a\x09\x09]\x0a\x09].\x0a\x09self dirty: needsToRun",
-messageSends: ["do:", "second", "min:", "size", "ifTrue:", "at:put:", "=", "copyFrom:to:", "dirty:"],
-referencedClasses: []
-}),
-smalltalk.TrappedDispatcher);
-
-smalltalk.addMethod(
-"_dirty_",
-smalltalk.method({
-selector: "dirty:",
-category: 'action',
-fn: function (aBoolean){
-var self=this;
-if(smalltalk.assert(aBoolean)){
-smalltalk.send((function(){
-return smalltalk.send(self,"_run",[]);
-}),"_fork",[]);
-};
-return self},
-args: ["aBoolean"],
-source: "dirty: aBoolean\x0a\x09aBoolean ifTrue: [[ self run ] fork]",
-messageSends: ["ifTrue:", "fork", "run"],
-referencedClasses: []
-}),
-smalltalk.TrappedDispatcher);
-
-smalltalk.addMethod(
-"_run",
-smalltalk.method({
-selector: "run",
-category: 'action',
-fn: function (){
-var self=this;
-var $1;
-smalltalk.send(self,"_do_",[(function(each){
-$1=smalltalk.send(each,"_first",[]);
-if(smalltalk.assert($1)){
-return smalltalk.send((function(){
-return smalltalk.send(smalltalk.send(each,"_third",[]),"_value",[]);
-}),"_ensure_",[(function(){
-return smalltalk.send(each,"_at_put_",[(1),false]);
-})]);
-};
-})]);
-return self},
-args: [],
-source: "run\x0a\x09self do: [ :each |\x0a\x09\x09each first ifTrue: [[ each third value ] ensure: [ each at: 1 put: false ]]\x0a\x09]",
-messageSends: ["do:", "ifTrue:", "ensure:", "at:put:", "value", "third", "first"],
-referencedClasses: []
-}),
-smalltalk.TrappedDispatcher);
-
-
-
-smalltalk.addClass('TrappedModelWrapper', smalltalk.Object, ['dispatcher', 'payload'], 'Trapped-Common');
-smalltalk.TrappedModelWrapper.comment="I am base class for model wrappers.\x0aI wrap a model which can be any object.\x0a\x0aMy subclasses need to provide implementation for:\x0a\x09read:do:\x0a    modify:do:\x0a\x09(optionally) name\x0a\x0aand must initialize:\x0a\x09payload\x0a\x09dispatcher\x0a"
-smalltalk.addMethod(
-"_dispatcher",
-smalltalk.method({
-selector: "dispatcher",
-category: 'accessing',
-fn: function (){
-var self=this;
-return self["@dispatcher"];
-},
-args: [],
-source: "dispatcher\x0a\x09^dispatcher",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_dispatcher_",
-smalltalk.method({
-selector: "dispatcher:",
-category: 'accessing',
-fn: function (aDispatcher){
-var self=this;
-self["@dispatcher"]=aDispatcher;
-return self},
-args: ["aDispatcher"],
-source: "dispatcher: aDispatcher\x0a\x09dispatcher := aDispatcher",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_name",
-smalltalk.method({
-selector: "name",
-category: 'accessing',
-fn: function (){
-var self=this;
-var $1;
-$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
-return $1;
-},
-args: [],
-source: "name\x0a\x09^ self class name",
-messageSends: ["name", "class"],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_payload",
-smalltalk.method({
-selector: "payload",
-category: 'accessing',
-fn: function (){
-var self=this;
-return self["@payload"];
-},
-args: [],
-source: "payload\x0a\x09^payload",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_payload_",
-smalltalk.method({
-selector: "payload:",
-category: 'accessing',
-fn: function (anObject){
-var self=this;
-self["@payload"]=anObject;
-return self},
-args: ["anObject"],
-source: "payload: anObject\x0a\x09payload := anObject",
-messageSends: [],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_start",
-smalltalk.method({
-selector: "start",
-category: 'action',
-fn: function (){
-var self=this;
-smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
-return self},
-args: [],
-source: "start\x0a\x09Trapped current register: self name: self name",
-messageSends: ["register:name:", "name", "current"],
-referencedClasses: ["Trapped"]
-}),
-smalltalk.TrappedModelWrapper);
-
-smalltalk.addMethod(
-"_watch_do_",
-smalltalk.method({
-selector: "watch:do:",
-category: 'action',
-fn: function (path,aBlock){
-var self=this;
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_add_",[[true,path,(function(){
-return smalltalk.send(self,"_read_do_",[path,aBlock]);
-})]]);
-smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_dirty_",[true]);
-return self},
-args: ["path", "aBlock"],
-source: "watch: path do: aBlock\x0a\x09self dispatcher add: { true. path. [ self read: path do: aBlock ] }.\x0a    self dispatcher dirty: true",
-messageSends: ["add:", "read:do:", "dispatcher", "dirty:"],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper);
-
-
-smalltalk.addMethod(
-"_start",
-smalltalk.method({
-selector: "start",
-category: 'action',
-fn: function (){
-var self=this;
-smalltalk.send(smalltalk.send(self,"_new",[]),"_start",[]);
-return self},
-args: [],
-source: "start\x0a\x09self new start",
-messageSends: ["start", "new"],
-referencedClasses: []
-}),
-smalltalk.TrappedModelWrapper.klass);
-
-

+ 96 - 0
js/Trapped-Frontend.deploy.js

@@ -13,6 +13,102 @@ smalltalk.TrappedDumbView);
 
 
 
+smalltalk.addClass('TrappedModelWrapper', smalltalk.Object, ['dispatcher', 'payload'], 'Trapped-Frontend');
+smalltalk.addMethod(
+"_dispatcher",
+smalltalk.method({
+selector: "dispatcher",
+fn: function (){
+var self=this;
+return self["@dispatcher"];
+}
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_dispatcher_",
+smalltalk.method({
+selector: "dispatcher:",
+fn: function (aDispatcher){
+var self=this;
+self["@dispatcher"]=aDispatcher;
+return self}
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_name",
+smalltalk.method({
+selector: "name",
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
+return $1;
+}
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_payload",
+smalltalk.method({
+selector: "payload",
+fn: function (){
+var self=this;
+return self["@payload"];
+}
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_payload_",
+smalltalk.method({
+selector: "payload:",
+fn: function (anObject){
+var self=this;
+self["@payload"]=anObject;
+return self}
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
+return self}
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_watch_do_",
+smalltalk.method({
+selector: "watch:do:",
+fn: function (path,aBlock){
+var self=this;
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_add_",[[true,path,(function(){
+return smalltalk.send(self,"_read_do_",[path,aBlock]);
+})]]);
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_dirty_",[true]);
+return self}
+}),
+smalltalk.TrappedModelWrapper);
+
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send(self,"_new",[]),"_start",[]);
+return self}
+}),
+smalltalk.TrappedModelWrapper.klass);
+
+
 smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_start",

+ 137 - 0
js/Trapped-Frontend.js

@@ -19,6 +19,143 @@ smalltalk.TrappedDumbView);
 
 
 
+smalltalk.addClass('TrappedModelWrapper', smalltalk.Object, ['dispatcher', 'payload'], 'Trapped-Frontend');
+smalltalk.TrappedModelWrapper.comment="I am base class for model wrappers.\x0aI wrap a model which can be any object.\x0a\x0aMy subclasses need to provide implementation for:\x0a\x09read:do:\x0a    modify:do:\x0a\x09(optionally) name\x0a\x0aand must initialize:\x0a\x09payload\x0a\x09dispatcher\x0a"
+smalltalk.addMethod(
+"_dispatcher",
+smalltalk.method({
+selector: "dispatcher",
+category: 'accessing',
+fn: function (){
+var self=this;
+return self["@dispatcher"];
+},
+args: [],
+source: "dispatcher\x0a\x09^dispatcher",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_dispatcher_",
+smalltalk.method({
+selector: "dispatcher:",
+category: 'accessing',
+fn: function (aDispatcher){
+var self=this;
+self["@dispatcher"]=aDispatcher;
+return self},
+args: ["aDispatcher"],
+source: "dispatcher: aDispatcher\x0a\x09dispatcher := aDispatcher",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_name",
+smalltalk.method({
+selector: "name",
+category: 'accessing',
+fn: function (){
+var self=this;
+var $1;
+$1=smalltalk.send(smalltalk.send(self,"_class",[]),"_name",[]);
+return $1;
+},
+args: [],
+source: "name\x0a\x09^ self class name",
+messageSends: ["name", "class"],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_payload",
+smalltalk.method({
+selector: "payload",
+category: 'accessing',
+fn: function (){
+var self=this;
+return self["@payload"];
+},
+args: [],
+source: "payload\x0a\x09^payload",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_payload_",
+smalltalk.method({
+selector: "payload:",
+category: 'accessing',
+fn: function (anObject){
+var self=this;
+self["@payload"]=anObject;
+return self},
+args: ["anObject"],
+source: "payload: anObject\x0a\x09payload := anObject",
+messageSends: [],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+category: 'action',
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_register_name_",[self,smalltalk.send(self,"_name",[])]);
+return self},
+args: [],
+source: "start\x0a\x09Trapped current register: self name: self name",
+messageSends: ["register:name:", "name", "current"],
+referencedClasses: ["Trapped"]
+}),
+smalltalk.TrappedModelWrapper);
+
+smalltalk.addMethod(
+"_watch_do_",
+smalltalk.method({
+selector: "watch:do:",
+category: 'action',
+fn: function (path,aBlock){
+var self=this;
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_add_",[[true,path,(function(){
+return smalltalk.send(self,"_read_do_",[path,aBlock]);
+})]]);
+smalltalk.send(smalltalk.send(self,"_dispatcher",[]),"_dirty_",[true]);
+return self},
+args: ["path", "aBlock"],
+source: "watch: path do: aBlock\x0a\x09self dispatcher add: { true. path. [ self read: path do: aBlock ] }.\x0a    self dispatcher dirty: true",
+messageSends: ["add:", "read:do:", "dispatcher", "dirty:"],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper);
+
+
+smalltalk.addMethod(
+"_start",
+smalltalk.method({
+selector: "start",
+category: 'action',
+fn: function (){
+var self=this;
+smalltalk.send(smalltalk.send(self,"_new",[]),"_start",[]);
+return self},
+args: [],
+source: "start\x0a\x09self new start",
+messageSends: ["start", "new"],
+referencedClasses: []
+}),
+smalltalk.TrappedModelWrapper.klass);
+
+
 smalltalk.addClass('TrappedSingleton', smalltalk.Object, [], 'Trapped-Frontend');
 smalltalk.addMethod(
 "_start",

+ 41 - 0
st/Trapped-Backend.st

@@ -73,6 +73,47 @@ on: anObject
 ^self new root: anObject
 ! !
 
+Object subclass: #TrappedDispatcher
+	instanceVariableNames: ''
+	package: 'Trapped-Backend'!
+!TrappedDispatcher commentStamp!
+I am base class for change event dispatchers.
+I manage changed path - action block subscriptions.
+These subscription must be three-element arrays
+	{ dirty. path. block }
+
+My subclasses need to provide implementation for:
+	add:
+    do:
+    (optionally) run!
+
+!TrappedDispatcher methodsFor: 'action'!
+
+changed: path
+	| needsToRun |
+    needsToRun := false.
+	self do: [ :each |
+		| aPath lesser |
+		aPath := each second.
+		lesser := aPath size min: path size.
+		(path copyFrom: 1 to: lesser) = (aPath copyFrom: 1 to: lesser) ifTrue: [
+			each at: 1 put: true.
+            needsToRun := true.
+		]
+	].
+	self dirty: needsToRun
+!
+
+dirty: aBoolean
+	aBoolean ifTrue: [[ self run ] fork]
+!
+
+run
+	self do: [ :each |
+		each first ifTrue: [[ each third value ] ensure: [ each at: 1 put: false ]]
+	]
+! !
+
 !Object methodsFor: '*Trapped-Backend'!
 
 reverseTrapAt: anObject

+ 0 - 97
st/Trapped-Common.st

@@ -1,97 +0,0 @@
-Smalltalk current createPackage: 'Trapped-Common' properties: #{}!
-Object subclass: #TrappedDispatcher
-	instanceVariableNames: ''
-	package: 'Trapped-Common'!
-!TrappedDispatcher commentStamp!
-I am base class for change event dispatchers.
-I manage changed path - action block subscriptions.
-These subscription must be three-element arrays
-	{ dirty. path. block }
-
-My subclasses need to provide implementation for:
-	add:
-    do:
-    (optionally) run!
-
-!TrappedDispatcher methodsFor: 'action'!
-
-changed: path
-	| needsToRun |
-    needsToRun := false.
-	self do: [ :each |
-		| aPath lesser |
-		aPath := each second.
-		lesser := aPath size min: path size.
-		(path copyFrom: 1 to: lesser) = (aPath copyFrom: 1 to: lesser) ifTrue: [
-			each at: 1 put: true.
-            needsToRun := true.
-		]
-	].
-	self dirty: needsToRun
-!
-
-dirty: aBoolean
-	aBoolean ifTrue: [[ self run ] fork]
-!
-
-run
-	self do: [ :each |
-		each first ifTrue: [[ each third value ] ensure: [ each at: 1 put: false ]]
-	]
-! !
-
-Object subclass: #TrappedModelWrapper
-	instanceVariableNames: 'dispatcher payload'
-	package: 'Trapped-Common'!
-!TrappedModelWrapper commentStamp!
-I am base class for model wrappers.
-I wrap a model which can be any object.
-
-My subclasses need to provide implementation for:
-	read:do:
-    modify:do:
-	(optionally) name
-
-and must initialize:
-	payload
-	dispatcher!
-
-!TrappedModelWrapper methodsFor: 'accessing'!
-
-dispatcher
-	^dispatcher
-!
-
-dispatcher: aDispatcher
-	dispatcher := aDispatcher
-!
-
-name
-	^ self class name
-!
-
-payload
-	^payload
-!
-
-payload: anObject
-	payload := anObject
-! !
-
-!TrappedModelWrapper methodsFor: 'action'!
-
-start
-	Trapped current register: self name: self name
-!
-
-watch: path do: aBlock
-	self dispatcher add: { true. path. [ self read: path do: aBlock ] }.
-    self dispatcher dirty: true
-! !
-
-!TrappedModelWrapper class methodsFor: 'action'!
-
-start
-	self new start
-! !
-

+ 55 - 0
st/Trapped-Frontend.st

@@ -11,6 +11,61 @@ renderOn: html
 	html root trapShow: #()
 ! !
 
+Object subclass: #TrappedModelWrapper
+	instanceVariableNames: 'dispatcher payload'
+	package: 'Trapped-Frontend'!
+!TrappedModelWrapper commentStamp!
+I am base class for model wrappers.
+I wrap a model which can be any object.
+
+My subclasses need to provide implementation for:
+	read:do:
+    modify:do:
+	(optionally) name
+
+and must initialize:
+	payload
+	dispatcher!
+
+!TrappedModelWrapper methodsFor: 'accessing'!
+
+dispatcher
+	^dispatcher
+!
+
+dispatcher: aDispatcher
+	dispatcher := aDispatcher
+!
+
+name
+	^ self class name
+!
+
+payload
+	^payload
+!
+
+payload: anObject
+	payload := anObject
+! !
+
+!TrappedModelWrapper methodsFor: 'action'!
+
+start
+	Trapped current register: self name: self name
+!
+
+watch: path do: aBlock
+	self dispatcher add: { true. path. [ self read: path do: aBlock ] }.
+    self dispatcher dirty: true
+! !
+
+!TrappedModelWrapper class methodsFor: 'action'!
+
+start
+	self new start
+! !
+
 Object subclass: #TrappedSingleton
 	instanceVariableNames: ''
 	package: 'Trapped-Frontend'!