Browse Source

Axes ext methods in JSObjectProxy as well.

Herbert Vojčík 6 years ago
parent
commit
df953a730b
2 changed files with 287 additions and 1 deletions
  1. 244 1
      src/Axxord.js
  2. 43 0
      src/Axxord.st

+ 244 - 1
src/Axxord.js

@@ -1,4 +1,4 @@
-define(["amber/boot", "amber_core/Kernel-Collections", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Objects"], function($boot){"use strict";
+define(["amber/boot", "amber_core/Kernel-Collections", "amber_core/Kernel-Exceptions", "amber_core/Kernel-Infrastructure", "amber_core/Kernel-Objects"], function($boot){"use strict";
 if(!$boot.nilAsReceiver)$boot.nilAsReceiver=$boot.nil;
 if(!("nilAsValue" in $boot))$boot.nilAsValue=$boot.nilAsReceiver;
 var $core=$boot.api,nil=$boot.nilAsValue,$nil=$boot.nilAsReceiver,$recv=$boot.asReceiver,$globals=$boot.globals;
@@ -1345,6 +1345,249 @@ messageSends: ["asMutator", "first", "yourself", "on:do:", "perform:withArgument
 }),
 $globals.Array);
 
+$core.addMethod(
+$core.method({
+selector: "asAxisIn:ifAbsent:",
+protocol: "*Axxord",
+fn: function (anObject,aBlock){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv(aBlock)._value();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"asAxisIn:ifAbsent:",{anObject:anObject,aBlock:aBlock},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock"],
+source: "asAxisIn: anObject ifAbsent: aBlock\x0a\x09^ aBlock value",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["value"]
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "asAxisIn:ifAbsent:put:",
+protocol: "*Axxord",
+fn: function (anObject,aBlock,anotherObject){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $recv(aBlock)._value();
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"asAxisIn:ifAbsent:put:",{anObject:anObject,aBlock:aBlock,anotherObject:anotherObject},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anObject", "aBlock", "anotherObject"],
+source: "asAxisIn: anObject ifAbsent: aBlock put: anotherObject\x0a\x09^ aBlock value",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["value"]
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "atAxes:ifAbsent:",
+protocol: "*Axxord",
+fn: function (aCollection,aBlock){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $early={};
+try {
+return $recv(aCollection)._inject_into_(self,(function(soFar,segment){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx2) {
+//>>excludeEnd("ctx");
+return $recv(segment)._asAxisIn_ifAbsent_(soFar,(function(){
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx3) {
+//>>excludeEnd("ctx");
+throw $early=[$recv(aBlock)._value()];
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx3) {$ctx3.fillBlock({},$ctx2,2)});
+//>>excludeEnd("ctx");
+}));
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx2) {$ctx2.fillBlock({soFar:soFar,segment:segment},$ctx1,1)});
+//>>excludeEnd("ctx");
+}));
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atAxes:ifAbsent:",{aCollection:aCollection,aBlock:aBlock},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aCollection", "aBlock"],
+source: "atAxes: aCollection ifAbsent: aBlock\x0a\x09^ aCollection inject: self into: [ :soFar :segment |\x0a\x09\x09segment asAxisIn: soFar ifAbsent: [ ^ aBlock value ]]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["inject:into:", "asAxisIn:ifAbsent:", "value"]
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "atAxes:ifAbsent:put:",
+protocol: "*Axxord",
+fn: function (aCollection,aBlock,value){
+var self=this,$self=this;
+var penultimate;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+penultimate=$self._atAxes_ifAbsent_($recv(aCollection)._allButLast(),aBlock);
+return $recv($recv(aCollection)._last())._asAxisIn_ifAbsent_put_(penultimate,aBlock,value);
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"atAxes:ifAbsent:put:",{aCollection:aCollection,aBlock:aBlock,value:value,penultimate:penultimate},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aCollection", "aBlock", "value"],
+source: "atAxes: aCollection ifAbsent: aBlock put: value\x0a\x09| penultimate |\x0a\x09penultimate := self atAxes: aCollection allButLast ifAbsent: aBlock.\x0a\x09^ aCollection last asAxisIn: penultimate ifAbsent: aBlock put: value",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["atAxes:ifAbsent:", "allButLast", "asAxisIn:ifAbsent:put:", "last"]
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "axes:consume:",
+protocol: "*Axxord",
+fn: function (aCollection,aBlock){
+var self=this,$self=this;
+var value;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $early={};
+try {
+value=$self._atAxes_ifAbsent_(aCollection,(function(){
+throw $early=[self];
+
+}));
+return $recv(aBlock)._value_(value);
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"axes:consume:",{aCollection:aCollection,aBlock:aBlock,value:value},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aCollection", "aBlock"],
+source: "axes: aCollection consume: aBlock\x0a\x09| value |\x0a\x09value := self atAxes: aCollection ifAbsent: [ ^self ].\x0a\x09^ aBlock value: value",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["atAxes:ifAbsent:", "value:"]
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "axes:transform:",
+protocol: "*Axxord",
+fn: function (aCollection,aBlock){
+var self=this,$self=this;
+var value,newValue;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+var $1,$2,$receiver;
+var $early={};
+try {
+value=$self._atAxes_ifAbsent_(aCollection,(function(){
+throw $early=[self];
+
+}));
+newValue=$recv(aBlock)._value_(value);
+$1=$recv(value).__eq_eq(newValue);
+if(!$core.assert($1)){
+$self._atAxes_ifAbsent_put_(aCollection,(function(){
+throw $early=[self];
+
+}),newValue);
+}
+$2=$self._axxord();
+if(($receiver = $2) == null || $receiver.a$nil){
+$2;
+} else {
+var axon;
+axon=$receiver;
+$recv(axon)._changed_(aCollection);
+}
+return self;
+}
+catch(e) {if(e===$early)return e[0]; throw e}
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"axes:transform:",{aCollection:aCollection,aBlock:aBlock,value:value,newValue:newValue},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["aCollection", "aBlock"],
+source: "axes: aCollection transform: aBlock\x0a\x09| value newValue |\x0a\x09value := self atAxes: aCollection ifAbsent: [ ^self ].\x0a\x09newValue := aBlock value: value.\x0a\x09value == newValue ifFalse: [ self atAxes: aCollection ifAbsent: [ ^self ] put: newValue ].\x0a\x09self axxord ifNotNil: [:axon | axon changed: aCollection]",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: ["atAxes:ifAbsent:", "value:", "ifFalse:", "==", "atAxes:ifAbsent:put:", "ifNotNil:", "axxord", "changed:"]
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "axxord",
+protocol: "*Axxord",
+fn: function (){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+return $self["@jsObject"].$axxord$;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"axxord",{},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: [],
+source: "axxord\x0a<inlineJS: 'return $self[\x22@jsObject\x22].$axxord$'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.JSObjectProxy);
+
+$core.addMethod(
+$core.method({
+selector: "axxord:",
+protocol: "*Axxord",
+fn: function (anAxon){
+var self=this,$self=this;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+return $core.withContext(function($ctx1) {
+//>>excludeEnd("ctx");
+$self["@jsObject"].$axxord$ = anAxon;
+return self;
+//>>excludeStart("ctx", pragmas.excludeDebugContexts);
+}, function($ctx1) {$ctx1.fill(self,"axxord:",{anAxon:anAxon},$globals.JSObjectProxy)});
+//>>excludeEnd("ctx");
+},
+//>>excludeStart("ide", pragmas.excludeIdeData);
+args: ["anAxon"],
+source: "axxord: anAxon\x0a<inlineJS: '$self[\x22@jsObject\x22].$axxord$ = anAxon'>",
+referencedClasses: [],
+//>>excludeEnd("ide");
+messageSends: []
+}),
+$globals.JSObjectProxy);
+
 $core.addMethod(
 $core.method({
 selector: "asAxisIn:ifAbsent:",

+ 43 - 0
src/Axxord.st

@@ -303,6 +303,49 @@ asAxisIn: anObject ifAbsent: aBlock put: anotherObject
 	^ result
 ! !
 
+!JSObjectProxy methodsFor: '*Axxord'!
+
+asAxisIn: anObject ifAbsent: aBlock
+	^ aBlock value
+!
+
+asAxisIn: anObject ifAbsent: aBlock put: anotherObject
+	^ aBlock value
+!
+
+atAxes: aCollection ifAbsent: aBlock
+	^ aCollection inject: self into: [ :soFar :segment |
+		segment asAxisIn: soFar ifAbsent: [ ^ aBlock value ]]
+!
+
+atAxes: aCollection ifAbsent: aBlock put: value
+	| penultimate |
+	penultimate := self atAxes: aCollection allButLast ifAbsent: aBlock.
+	^ aCollection last asAxisIn: penultimate ifAbsent: aBlock put: value
+!
+
+axes: aCollection consume: aBlock
+	| value |
+	value := self atAxes: aCollection ifAbsent: [ ^self ].
+	^ aBlock value: value
+!
+
+axes: aCollection transform: aBlock
+	| value newValue |
+	value := self atAxes: aCollection ifAbsent: [ ^self ].
+	newValue := aBlock value: value.
+	value == newValue ifFalse: [ self atAxes: aCollection ifAbsent: [ ^self ] put: newValue ].
+	self axxord ifNotNil: [:axon | axon changed: aCollection]
+!
+
+axxord
+<inlineJS: 'return $self["@jsObject"].$axxord$'>
+!
+
+axxord: anAxon
+<inlineJS: '$self["@jsObject"].$axxord$ = anAxon'>
+! !
+
 !Number methodsFor: '*Axxord'!
 
 asAxisIn: anObject ifAbsent: aBlock