Author: gotcha
Date: Fri Sep 28 12:05:15 2007
New Revision: 46997

Modified:
   kukit/kukit.js/trunk/kukit/commandprocessor.js
   kukit/kukit.js/trunk/kukit/eventreg.js
   kukit/kukit.js/trunk/kukit/oper.js
   kukit/kukit.js/trunk/kukit/plugin.js
   kukit/kukit.js/trunk/kukit/resourcedata.js
Log:
- rename binderInstance to binder
- move makeId and makeMergeId from rd to er


Modified: kukit/kukit.js/trunk/kukit/commandprocessor.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/commandprocessor.js      (original)
+++ kukit/kukit.js/trunk/kukit/commandprocessor.js      Fri Sep 28 12:05:15 2007
@@ -113,7 +113,7 @@
 
 cp.CommandProcessor.prototype.executeCommands = function(oper) {
     kukit.engine.beginSetupEventsCollection();
-    // node, eventRule, binderInstance are given on oper, in case
+    // node, eventRule, binder are given on oper, in case
     // the command was called up from an event
     if (typeof(oper) == 'undefined' || oper == null) {
         oper = new kukit.op.Oper();

Modified: kukit/kukit.js/trunk/kukit/eventreg.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/eventreg.js      (original)
+++ kukit/kukit.js/trunk/kukit/eventreg.js      Fri Sep 28 12:05:15 2007
@@ -70,7 +70,7 @@
     return (typeof(func) != 'undefined');
 };
 
-_EventRegistry.prototype.getBinder = function(className) {
+_EventRegistry.prototype.getBinderClass = function(className) {
     var func = this.classes[className];
     if (! func) {
         // not found
@@ -264,7 +264,7 @@
 *
 * trigger an event bound to a given state instance, same node
 *
-*     binderInstance.__continueEvent__('doit', oper.node, {'extravalue': '5'});
+*     binder.__continueEvent__('doit', oper.node, {'extravalue': '5'});
 *
 *   with kss rule:
 *
@@ -283,7 +283,7 @@
 * trigger an event bound to a given state instance, and the document
 * (different from current scope)
 *
-*     binderInstance.__continueEvent__('doit', null, {'extravalue': '5'});
+*     binder.__continueEvent__('doit', null, {'extravalue': '5'});
 *
 *   with kss rule:
 *
@@ -301,7 +301,7 @@
 *
 * trigger an event on all the nodes + document bound to a given state instance
 *
-*     binderInstance.__continueEvent_allNodes__('doit', {'extravalue': '5'});
+*     binder.__continueEvent_allNodes__('doit', {'extravalue': '5'});
 *
 *   with kss rule:
 *
@@ -403,15 +403,15 @@
 * postpone binding of actions until called first time
 *
 */
-var _LateBinder = function(binderInstance, name, node) {
-    this.binderInstance = binderInstance;
+var _LateBinder = function(binder, name, node) {
+    this.binder = binder;
     this.name = name;
     this.node = node;
-    this.bound = null;
+    this.boundEvent = null;
 };
 
 _LateBinder.prototype.executeActions = function() {
-    if (! this.bound) {
+    if (! this.boundEvent) {
 ;;;        var msg = 'Attempt of late binding for event [' + this.name;
 ;;;        msg += '], node [' + this.node.nodeName + '].';
 ;;;        kukit.log(msg);
@@ -419,27 +419,27 @@
             kukit.log(this.node);
         }
         var info = kukit.engine.binderInfoRegistry.getBinderInfoById(
-            this.binderInstance.__binderId__);
+            this.binder.__binderId__);
         var oper = info.bound.getBoundOperForNode(this.name, this.node);
         if (oper) {
             // (if eventRule is null here, we could still have the default
             // method, so go on.)
             oper.parms = {};
-            this.bound = function() {
-                this.binderInstance._EventBinder_triggerEvent(this.name, oper);
+            this.boundEvent = function() {
+                this.binder._EventBinder_triggerEvent(this.name, oper);
             };
 ;;;         kukit.log('Node bound.');
         } else {
 ;;;         kukit.logWarning('No node bound.');
-            this.bound = function() {};
+            this.boundEvent = function() {};
         }
     }
-    this.bound();
+    this.boundEvent();
 };        
 
 var _EventBinder_triggerEvent = function(name, oper) {
     // Private. Called from __continueEvent__ or from main event execution.
-    oper.binderInstance = this;
+    oper.binder = this;
     if (oper.eventRule) {
         // Call the actions, if we had an event rule.
         // This includes calling the default action.
@@ -476,7 +476,7 @@
         throw new Error(kukit.E);
     }
     // call it
-    oper.binderInstance = this;
+    oper.binder = this;
     method.call(this, name, oper);
 };
 
@@ -510,22 +510,22 @@
 ;;;     var msg = 'Instantiating event id [' + id + '], className [';
 ;;;     msg += className + '], namespace [' + namespace + '].';
 ;;;     kukit.logDebug(msg);
-        var binder = kukit.eventsGlobalRegistry.getBinder(className);
-        var binderInstance = new binder();
+        var binderClass = kukit.eventsGlobalRegistry.getBinderClass(className);
+        var binder = new binderClass();
         
-        binderInfo = this.info[id] = new _BinderInfo(binderInstance);
+        binderInfo = this.info[id] = new _BinderInfo(binder);
 
         // decorate it with id and class
-        binderInstance.__binderId__ = id;
-        binderInstance.__binderClassName__ = className;
-        binderInstance.__eventNamespace__ = namespace;
+        binder.__binderId__ = id;
+        binder.__binderClassName__ = className;
+        binder.__eventNamespace__ = namespace;
         // store the bound rules
-        //binderInstance.__bound_rules__ = [];
-    } else if (binderInfo.getBinderInstance().__binderClassName__ != 
+        //binder.__bound_rules__ = [];
+    } else if (binderInfo.getBinder().__binderClassName__ != 
         className) {
         // just paranoia
 ;;;     kukit.E = 'Conflicting class for event id [' + id + '], [';
-;;;     kukit.E += binderInfo.getBinderInstance().__binderClassName__;
+;;;     kukit.E += binderInfo.getBinder().__binderClassName__;
 ;;;     kukit.E += '] != [' + className + '].';
         throw new Error(kukit.E);
     }
@@ -547,7 +547,7 @@
     //Get className
     var className = kukit.eventsGlobalRegistry.get(namespace, name).className;
     // Get an event.
-    var id = kukit.rd.makeId(namespace, className);
+    var id = er.makeId(namespace, className);
     var binderInfo = this.info[id];
     if (typeof(binderInfo) == 'undefined') {
 ;;;     kukit.E = 'Singleton event with namespace [' + namespace;
@@ -585,14 +585,14 @@
 *
 */
 
-var _BinderInfo = function (binderInstance) {
-    this.binderInstance = binderInstance;
+var _BinderInfo = function (binder) {
+    this.binder = binder;
     this.bound = new _OperRegistry();
     this.startBindingPhase();
 };
 
-_BinderInfo.prototype.getBinderInstance = function () {
-    return this.binderInstance;
+_BinderInfo.prototype.getBinder = function () {
+    return this.binder;
 };
 
 _BinderInfo.prototype.startBindingPhase = function () {
@@ -602,7 +602,7 @@
 };
 
 _BinderInfo.prototype.bindOper = function (oper) {
-    // We mark a given oper. This means a binding on the binderInstance 
+    // We mark a given oper. This means a binding on the binder 
     // for given event, node and eventRule (containing event namespace,
     // name, and evt- parms.)
     //
@@ -615,7 +615,7 @@
 _BinderInfo.prototype.processBindingEvents = function () {
     // We came to the end of the binding phase. Now we process all our binding
     // events, This will do the actual binding on the browser side.
-    this.binding.processBindingEvents(this.binderInstance);
+    this.binding.processBindingEvents(this.binder);
     // Now we to add these to the new ones.
     this.binding.propagateTo(this.bound);
     // Delete them from the registry, to protect against accidents.
@@ -677,7 +677,7 @@
 };
     
 _OperRegistry.prototype.bindOper = function (oper) {
-    // Marks binding between binderInstance, eventName, node.
+    // Marks binding between binder, eventName, node.
     var name = oper.eventRule.kssSelector.name;
     var nodeHash = kukit.rd.hashNode(oper.node);
     var rulesPerName = this.checkOperBindable(oper, name, nodeHash);
@@ -694,18 +694,18 @@
 // XXX This will need refactoring.
 /// We would only want to lookup from our registry and not the other way 
around.
 _OperRegistry.prototype.processBindingEvents = 
-    function (binderInstance) {
+    function (binder) {
     var eventRegistry = kukit.eventsGlobalRegistry;
     for (var i=0; i < eventRegistry.eventSets.length; i++) {
         var eventSet = eventRegistry.eventSets[i];
         // Only process binding events (and ignore non-binding ones)
         if (eventSet.bindMethodName) {
-            if (binderInstance.__eventNamespace__ == eventSet.namespace) {
+            if (binder.__eventNamespace__ == eventSet.namespace) {
                 // Process the binding event set.
                 // This will call the actual bindmethods
                 // according to the specified iterator.
                 var iterator = er.getBindIterator(eventSet.iterName);
-                iterator.call(this, eventSet, binderInstance);
+                iterator.call(this, eventSet, binder);
             }
         }
     }
@@ -716,7 +716,7 @@
 
 _OperRegistry.prototype.getBoundOperForNode = function (name, node) {
     // Get the oper that is bound to a given eventName
-    // to a node in this binderInstance
+    // to a node in this binder
     // returns null, if there is no such oper.
     var rulesPerName = this.infoPerName[name];
     if (typeof(rulesPerName) == 'undefined') {
@@ -733,7 +733,7 @@
 
 _OperRegistry.prototype.getBoundOpers = function (name) {
     // Get the opers bound to a given eventName (to any node)
-    // in this binderInstance
+    // in this binder
     var opers = [];
     var rulesPerName = this.infoPerName[name];
     if (typeof(rulesPerName) != 'undefined') {
@@ -751,8 +751,8 @@
 // the oper registry.
 //
 // Iterators receive the eventSet as a parameter
-// plus a binderInstance and a method. They need to iterate by calling this
-// as method.call(binderInstance, ...); where ... can be any parms this
+// plus a binder and a method. They need to iterate by calling this
+// as method.call(binder, ...); where ... can be any parms this
 // given iteration specifies.
 //
 
@@ -780,11 +780,11 @@
 };
 
 _OperRegistry.prototype.callBindMethod = 
-    function (eventSet, binderInstance, p1, p2, p3, p4, p5, p6) {
-    var method = binderInstance[eventSet.bindMethodName];
+    function (eventSet, binder, p1, p2, p3, p4, p5, p6) {
+    var method = binder[eventSet.bindMethodName];
     // Protect the binding for better logging
 ;;; try {
-        method.call(binderInstance, p1, p2, p3, p4, p5, p6);
+        method.call(binder, p1, p2, p3, p4, p5, p6);
 ;;; } catch(e) {
 ;;;     var names = eventSet.names;
 ;;;     var namespace = eventSet.namespace;
@@ -797,7 +797,7 @@
 // Eventname and funcToBind are passed too.
 // this is the legacy ([EachLegacy]) way
 _OperRegistry.prototype._iterateEachLegacy =
-    function (eventSet, binderInstance) {
+    function (eventSet, binder) {
     for (var i=0; i<eventSet.names.length; i++) {
         var rulesPerName = this.infoPerName[eventSet.names[i]];
         if (typeof(rulesPerName) != 'undefined') {
@@ -805,7 +805,7 @@
                 var oper = rulesPerName[nodeHash];
                 var eventName = oper.getEventName();
                 var funcToBind = oper.makeExecuteActionsHook();
-                this.callBindMethod(eventSet, binderInstance, eventName,
+                this.callBindMethod(eventSet, binder, eventName,
                     funcToBind, oper);
             }
         }
@@ -817,13 +817,13 @@
 // Eventname and funcToBind are passed too.
 // this is the preferred ([Each]) way. Parameters are different from 
EachLegacy.
 _OperRegistry.prototype._iterateEach =
-    function (eventSet, binderInstance) {
+    function (eventSet, binder) {
     for (var i=0; i<eventSet.names.length; i++) {
         var rulesPerName = this.infoPerName[eventSet.names[i]];
         if (typeof(rulesPerName) != 'undefined') {
             for (var nodeHash in rulesPerName) {
                 var oper = rulesPerName[nodeHash];
-                this.callBindMethod(eventSet, binderInstance, oper);
+                this.callBindMethod(eventSet, binder, oper);
             }
         }
     }
@@ -831,7 +831,7 @@
 
 // This calls the bind method by the list of bound opers
 _OperRegistry.prototype._iterateOpers =
-    function (eventSet, binderInstance) {
+    function (eventSet, binder) {
     var opers = [];
     for (var i=0; i<eventSet.names.length; i++) {
         var rulesPerName = this.infoPerName[eventSet.names[i]];
@@ -841,13 +841,13 @@
             }
         }
     }
-    this.callBindMethod(eventSet, binderInstance, opers);
+    this.callBindMethod(eventSet, binder, opers);
 };
 
 // This calls the bind method by a mapping eventName:oper
 // per each bound node individually
 _OperRegistry.prototype._iterateNode =
-    function (eventSet, binderInstance) {
+    function (eventSet, binder) {
     for (var nodeHash in this.infoPerNode) {
         var rulesPerNode = this.infoPerNode[nodeHash];
         // filter only the events we are interested in
@@ -866,7 +866,7 @@
         // we use it as a second parameter to the call.
         // The method may or may not want to use this.
         if (operFound) {
-            this.callBindMethod(eventSet, binderInstance, filteredRules,
+            this.callBindMethod(eventSet, binder, filteredRules,
                 operFound.node);
         }
     }
@@ -876,7 +876,7 @@
 // items, where item.node is the node and item.opersByEventName nodeHash:item
 // in item there is item.node and item.opersByEventName
 _OperRegistry.prototype._iterateAllNodes = 
-    function (eventSet, binderInstance) {
+    function (eventSet, binder) {
     var items = [];
     var hasResult = false;
     for (var nodeHash in this.infoPerNode) {
@@ -901,8 +901,22 @@
     }
     // call the binder method
     if (hasResult) {
-        this.callBindMethod(eventSet, binderInstance, items);
+        this.callBindMethod(eventSet, binder, items);
     }
 };
 
+er.makeId = function(namespace, name) {
+    if (namespace == null) {
+        namespace = '';
+    }
+    return '@' + namespace + '@' + name;
+};
+
+er.makeMergeId = function(id, namespace, name) {
+    if (namespace == null) {
+        namespace = '';
+    }
+    return id + '@' + namespace + '@' + name;
+};
+
 }();                              /// MODULE END

Modified: kukit/kukit.js/trunk/kukit/oper.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/oper.js  (original)
+++ kukit/kukit.js/trunk/kukit/oper.js  Fri Sep 28 12:05:15 2007
@@ -41,7 +41,7 @@
 *
 *  eventRule: The eventRule associated by the trigger.
 *
-*  binderInstance: The event binder instance that holds the event state
+*  binder: The event binder instance that holds the event state
 *       and on which all events are executed.
 *
 *  orignode: in case when a command has returned from a server action, 
@@ -53,7 +53,7 @@
     this.node = null;
     this.parms = {};
     this.eventRule = null;
-    this.binderInstance = null;
+    this.binder = null;
     this.orignode = null;
     this.action = null;
     this.browserevent = null;
@@ -82,7 +82,7 @@
 ;;;             var isNode = key == 'node';
 ;;;             var isParameters = key == 'parms';
 ;;;             var isEventRule = key == 'eventRule';
-;;;             var isBinder = key == 'binderInstance';
+;;;             var isBinder = key == 'binder';
 ;;;             var isOrig = key == 'orignode';
 ;;;         return isNode || isParameters || isEventRule || isBinder || isOrig;
 ;;;         };
@@ -175,7 +175,7 @@
 ;;;     throw new Error(kukit.E);
 ;;; }
     //
-    var namespace = this.binderInstance.__eventNamespace__;
+    var namespace = this.binder.__eventNamespace__;
     var kssevent = kukit.eventsGlobalRegistry.get(namespace, name);
     var methodName = kssevent.defaultActionMethodName;
     var success = false;
@@ -192,7 +192,7 @@
         // you do need not to specify pass(xxx)
         // for making the parms arrive to the action.
         this.parms = this.defaultParameters;
-        this.binderInstance._EventBinder_callMethod(
+        this.binder._EventBinder_callMethod(
             namespace, name, this, methodName);
         success = true;
     }
@@ -273,7 +273,7 @@
         // call the filter and if it says skip it, we are done
         if (filter && ! filter(newoper)) return false;
         // execute the event's actions
-        newoper.binderInstance._EventBinder_triggerEvent(eventName, newoper);
+        newoper.binder._EventBinder_triggerEvent(eventName, newoper);
         // show that the event's actions have been executed
         return true;
     };

Modified: kukit/kukit.js/trunk/kukit/plugin.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/plugin.js        (original)
+++ kukit/kukit.js/trunk/kukit/plugin.js        Fri Sep 28 12:05:15 2007
@@ -901,7 +901,7 @@
     oper.evaluateParameters(['name'], {'allnodes': 'false'}, '', true);
     oper.evalBool('allnodes', 'continueEvent');
     var parms = oper.parms;
-    var binderInstance = oper.binderInstance;
+    var binder = oper.binder;
     var allNodes = parms.allnodes;
     // marshall it, the rest of the parms will be passed
     var actionParameters = {};
@@ -911,11 +911,11 @@
         }
     }
     if (parms.allnodes) {
-        binderInstance.__continueEvent_allNodes__(parms.name,
+        binder.__continueEvent_allNodes__(parms.name,
             actionParameters);
     } else {
         // execution happens on the orignode
-        binderInstance.__continueEvent__(parms.name, oper.orignode,
+        binder.__continueEvent__(parms.name, oper.orignode,
             actionParameters);
     }
 });

Modified: kukit/kukit.js/trunk/kukit/resourcedata.js
==============================================================================
--- kukit/kukit.js/trunk/kukit/resourcedata.js  (original)
+++ kukit/kukit.js/trunk/kukit/resourcedata.js  Fri Sep 28 12:05:15 2007
@@ -21,20 +21,6 @@
 
 kukit.rd = {};
 
-kukit.rd.makeId = function(namespace, name) {
-    if (namespace == null) {
-        namespace = '';
-    }
-    return '@' + namespace + '@' + name;
-};
-
-kukit.rd.makeMergeId = function(id, namespace, name) {
-    if (namespace == null) {
-        namespace = '';
-    }
-    return id + '@' + namespace + '@' + name;
-};
-
 /*
 *  class KssSelector
 */
@@ -89,11 +75,11 @@
 
     if (this.id == null) {
         // singleton for class
-        this.id = kukit.rd.makeId(this.namespace, this.className);
+        this.id = kukit.er.makeId(this.namespace, this.className);
     }
     // Also set the merge id. The rules with the same merge
     // id should be merged on the same node.
-    this.mergeId = kukit.rd.makeMergeId(this.id, this.namespace, this.name);
+    this.mergeId = kukit.er.makeMergeId(this.id, this.namespace, this.name);
 };
 
 /*
@@ -290,7 +276,7 @@
     var binderInfo = this.getBinderInfo();
     oper.node = node;
     oper.eventRule = this;
-    oper.binderInstance = binderInfo.binderInstance;
+    oper.binder = binderInfo.binder;
     oper.parms = this.parms;
     // mark on the instance as bound
     binderInfo.bindOper(oper); 
@@ -762,7 +748,7 @@
 };
 
 kukit.rd.MethodTable.prototype.getMergedRule =
-    function(category, name, binderInstance) {
+    function(category, name, binder) {
 
     // Returns the rule for a given event instance, 
     // Get the entry by category (= document or behaviour)
@@ -771,9 +757,9 @@
 ;;;     throw new Error('Unknown method rule category [' + category + '].');
 ;;; }
     // look up the rule
-    var namespace = binderInstance.__eventNamespace__;
-    var id = binderInstance.__binderId__;
-    var mergeId = kukit.rd.makeMergeId(id, namespace, name);
+    var namespace = binder.__eventNamespace__;
+    var id = binder.__binderId__;
+    var mergeId = kukit.er.makeMergeId(id, namespace, name);
     var mergedRule = dict[mergeId];
     if (typeof(mergedRule) == 'undefined') {
         // no error, just return null.
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to