Просмотр исходного кода

trap:modify: inlined into binder

Herbert Vojčík 11 лет назад
Родитель
Сommit
e2c09ea7ff
3 измененных файлов с 6 добавлено и 54 удалено
  1. 1 19
      js/Trapped-Frontend.deploy.js
  2. 3 26
      js/Trapped-Frontend.js
  3. 2 9
      st/Trapped-Frontend.st

+ 1 - 19
js/Trapped-Frontend.deploy.js

@@ -83,13 +83,11 @@ var snap;
 snap=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_snapshot",[]);
 snap;
 return smalltalk.send(self["@brush"],"_onChange_",[(function(){
-return smalltalk.send(snap,"_do_",[(function(){
-return smalltalk.send(self["@brush"],"_trap_modify_",[[],(function(){
+return smalltalk.send(smalltalk.send(snap,"_model",[]),"_modify_do_",[smalltalk.send(smalltalk.send(snap,"_path",[]),"_allButFirst",[]),(function(){
 return smalltalk.send(smalltalk.send(smalltalk.send(self["@brush"],"_asJQuery",[]),"_attr_",["checked"]),"_notNil",[]);
 })]);
 })]);
 })]);
-})]);
 return self}
 }),
 smalltalk.TrappedAttrBinder);
@@ -676,22 +674,6 @@ return self}
 }),
 smalltalk.TagBrush);
 
-smalltalk.addMethod(
-"_trap_modify_",
-smalltalk.method({
-selector: "trap:modify:",
-fn: function (path,aBlock){
-var self=this;
-smalltalk.send(path,"_trapDescend_",[(function(){
-var snap;
-snap=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_snapshot",[]);
-snap;
-return smalltalk.send(smalltalk.send(snap,"_model",[]),"_modify_do_",[smalltalk.send(smalltalk.send(snap,"_path",[]),"_allButFirst",[]),aBlock]);
-})]);
-return self}
-}),
-smalltalk.TagBrush);
-
 smalltalk.addMethod(
 "_trap_read_",
 smalltalk.method({

+ 3 - 26
js/Trapped-Frontend.js

@@ -109,17 +109,15 @@ var snap;
 snap=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_snapshot",[]);
 snap;
 return smalltalk.send(self["@brush"],"_onChange_",[(function(){
-return smalltalk.send(snap,"_do_",[(function(){
-return smalltalk.send(self["@brush"],"_trap_modify_",[[],(function(){
+return smalltalk.send(smalltalk.send(snap,"_model",[]),"_modify_do_",[smalltalk.send(smalltalk.send(snap,"_path",[]),"_allButFirst",[]),(function(){
 return smalltalk.send(smalltalk.send(smalltalk.send(self["@brush"],"_asJQuery",[]),"_attr_",["checked"]),"_notNil",[]);
 })]);
 })]);
 })]);
-})]);
 return self},
 args: ["path"],
-source: "installFor: path\x0a\x09super installFor: path.\x0a    path trapDescend: [ | snap |\x0a        snap := Trapped current snapshot.\x0a\x09    brush onChange: [ snap do: [ brush trap: #() modify: [\x0a            (brush asJQuery attr: 'checked') notNil\x0a        ]]]\x0a    ]",
-messageSends: ["installFor:", "trapDescend:", "snapshot", "current", "onChange:", "do:", "trap:modify:", "notNil", "attr:", "asJQuery"],
+source: "installFor: path\x0a\x09super installFor: path.\x0a    path trapDescend: [ | snap |\x0a        snap := Trapped current snapshot.\x0a\x09    brush onChange: [ snap model modify: snap path allButFirst do: [\x0a            (brush asJQuery attr: 'checked') notNil\x0a        ]]\x0a    ]",
+messageSends: ["installFor:", "trapDescend:", "snapshot", "current", "onChange:", "modify:do:", "allButFirst", "path", "notNil", "attr:", "asJQuery", "model"],
 referencedClasses: ["Trapped"]
 }),
 smalltalk.TrappedAttrBinder);
@@ -896,27 +894,6 @@ referencedClasses: ["Trapped"]
 }),
 smalltalk.TagBrush);
 
-smalltalk.addMethod(
-"_trap_modify_",
-smalltalk.method({
-selector: "trap:modify:",
-category: '*Trapped-Frontend',
-fn: function (path,aBlock){
-var self=this;
-smalltalk.send(path,"_trapDescend_",[(function(){
-var snap;
-snap=smalltalk.send(smalltalk.send((smalltalk.Trapped || Trapped),"_current",[]),"_snapshot",[]);
-snap;
-return smalltalk.send(smalltalk.send(snap,"_model",[]),"_modify_do_",[smalltalk.send(smalltalk.send(snap,"_path",[]),"_allButFirst",[]),aBlock]);
-})]);
-return self},
-args: ["path", "aBlock"],
-source: "trap: path modify: aBlock\x0a\x09path trapDescend: [ | snap |\x0a        snap := Trapped current snapshot.\x0a        snap model modify: snap path allButFirst do: aBlock\x0a    ]",
-messageSends: ["trapDescend:", "snapshot", "current", "modify:do:", "allButFirst", "path", "model"],
-referencedClasses: ["Trapped"]
-}),
-smalltalk.TagBrush);
-
 smalltalk.addMethod(
 "_trap_read_",
 smalltalk.method({

+ 2 - 9
st/Trapped-Frontend.st

@@ -41,9 +41,9 @@ installFor: path
 	super installFor: path.
     path trapDescend: [ | snap |
         snap := Trapped current snapshot.
-	    brush onChange: [ snap do: [ brush trap: #() modify: [
+	    brush onChange: [ snap model modify: snap path allButFirst do: [
             (brush asJQuery attr: 'checked') notNil
-        ]]]
+        ]]
     ]
 !
 
@@ -360,13 +360,6 @@ trap: path
 	(Trapped current binder: self) installFor: path
 !
 
-trap: path modify: aBlock
-	path trapDescend: [ | snap |
-        snap := Trapped current snapshot.
-        snap model modify: snap path allButFirst do: aBlock
-    ]
-!
-
 trap: path read: aBlock
 	path trapDescend: [ | snap |
         snap := Trapped current snapshot.