Author: gotcha
Date: Mon Dec 24 12:19:19 2007
New Revision: 50056

Modified:
   kukit/kukit.js/branch/finish-closures/kukit/TODO.txt
   kukit/kukit.js/branch/finish-closures/kukit/utils.js
Log:
module and class closures

Modified: kukit/kukit.js/branch/finish-closures/kukit/TODO.txt
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/TODO.txt        (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/TODO.txt        Mon Dec 24 
12:19:19 2007
@@ -1,8 +1,6 @@
 files where closures are missing
 
 plugin.js
-utils.js move to kukit the names that are defined in kukit namespaces.
-
 
 files where indentation has to be undone and initialize needs to be done
 

Modified: kukit/kukit.js/branch/finish-closures/kukit/utils.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/utils.js        (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/utils.js        Mon Dec 24 
12:19:19 2007
@@ -246,37 +246,43 @@
 * class FifoQueue
 */
 ut.FifoQueue = function () {
+
+this.initialize = function () {
     this.reset();
 };
 
-ut.FifoQueue.prototype.reset = function() {
+this.reset = function() {
     this.elements = new Array();
 };
 
-ut.FifoQueue.prototype.push = function(obj) {
+this.push = function(obj) {
     this.elements.push(obj);
 };
 
-ut.FifoQueue.prototype.pop = function() {
+this.pop = function() {
     return this.elements.shift();
 };
 
-ut.FifoQueue.prototype.empty = function() {
+this.empty = function() {
     return ! this.elements.length;
 };
 
-ut.FifoQueue.prototype.size = function() {
+this.size = function() {
     return this.elements.length;
 };
 
-ut.FifoQueue.prototype.front = function() {
+this.front = function() {
     return this.elements[0];
 };
+this.initialize.apply(this, arguments);
+};
 
 /*
 * class SortedQueue
 */
-ut.SortedQueue = function (comparefunc) {
+ut.SortedQueue = function() {
+
+this.initialize = function(comparefunc) {
     // comparefunc(left, right) determines the order by returning 
     // -1 if left should occur before right,
     // +1 if left should occur after right or 
@@ -289,7 +295,7 @@
     this.reset();
 };
 
-ut.SortedQueue.prototype.comparefunc = function(a, b) {
+this.comparefunc = function(a, b) {
     if (a < b) {
         return -1;
     } else if (a > b) {
@@ -299,11 +305,11 @@
     }
 };
 
-ut.SortedQueue.prototype.reset = function() {
+this.reset = function() {
     this.elements = new Array();
 };
 
-ut.SortedQueue.prototype.push = function(obj) {
+this.push = function(obj) {
     // Find the position of the object.
     var i = 0;
     var length = this.elements.length;
@@ -314,31 +320,33 @@
     this.elements.splice(i, 0, obj);
 };
 
-ut.SortedQueue.prototype.pop = function() {
+this.pop = function() {
     // takes minimal element
     return this.elements.shift();
 };
 
-ut.SortedQueue.prototype.popn = function(n) {
+this.popn = function(n) {
     // takes first n minimal element
     return this.elements.splice(0, n);
 };
 
-ut.SortedQueue.prototype.empty = function() {
+this.empty = function() {
     return ! this.elements.length;
 };
 
-ut.SortedQueue.prototype.size = function() {
+this.size = function() {
     return this.elements.length;
 };
 
-ut.SortedQueue.prototype.get = function(n) {
+this.get = function(n) {
     return this.elements[n];
 };
 
-ut.SortedQueue.prototype.front = function() {
+this.front = function() {
     return this.elements[0];
 };
+this.initialize.apply(this, arguments);
+};
 
 ut.evalBool = function(value, errname) {
     if (value == 'true' || value == 'True' || value == '1') {
@@ -386,7 +394,9 @@
 *
 * for repeating or one time timing
 */
-ut.TimerCounter = function(delay, func, restart) {
+ut.TimerCounter = function() {
+
+this.initialize = function(delay, func, restart) {
     this.delay = delay;
     this.func = func;
     if (typeof(restart) == 'undefined') {
@@ -396,7 +406,7 @@
     this.timer = null;
 };
 
-ut.TimerCounter.prototype.start = function() {
+this.start = function() {
     if (this.timer) {
 ;;;     kukit.E = 'Timer already started.';
 
@@ -409,7 +419,7 @@
     this.timer = setTimeout(func, this.delay);
 };
 
-ut.TimerCounter.prototype.timeout = function() {
+this.timeout = function() {
     // Call the event action
     this.func();
     // Restart the timer
@@ -419,24 +429,28 @@
     }
 };
 
-ut.TimerCounter.prototype.clear = function() {
+this.clear = function() {
     if (this.timer) {
         window.clearTimeout(this.timer);
         this.timer = null;
     }
     this.restart = false;
 };
+this.initialize.apply(this, arguments);
+};
 
 /*
 * class Scheduler
 */
-ut.Scheduler = function(func) {
+ut.Scheduler = function() {
+
+this.initialize = function(func) {
     this.func = func;
     this.timer = null;
     this.nextWake = null;
 };
 
-ut.Scheduler.prototype.setNextWake = function(ts) {
+this.setNextWake = function(ts) {
     // Sets wakeup time, null clears
     if (this.nextWake) {
         this.clear();
@@ -458,7 +472,7 @@
     }
 };
 
-ut.Scheduler.prototype.setNextWakeAtLeast = function(ts) {
+this.setNextWakeAtLeast = function(ts) {
     // Sets wakeup time, unless it would wake up later than the
     // currently set timeout. Null clears the timer.
     if (! ts || ! this.nextWake || ts < this.nextWake) {
@@ -469,7 +483,7 @@
     }
 };
 
-ut.Scheduler.prototype.timeout = function() {
+this.timeout = function() {
     // clear the timer
     this.timer = null;
     this.nextWake = null;
@@ -477,14 +491,15 @@
     this.func();
 };
 
-
-ut.Scheduler.prototype.clear = function() {
+this.clear = function() {
     if (this.nextWake) {
         window.clearTimeout(this.timer);
         this.timer = null;
         this.nextWake = null;
     }
 };
+this.initialize.apply(this, arguments);
+};
 
 /* 
 * class SerializeScheduler
@@ -492,21 +507,23 @@
 * Scheduler for serializing bind and load procedures
 */
 ut.SerializeScheduler = function() {
+
+this.initialize = function() {
     this.items = [];
     this.lock = false;
 };
 
-ut.SerializeScheduler.prototype.addPre = function(func, remark) {
+this.addPre = function(func, remark) {
     this.items.push({func: func, remark: remark});
     this.execute();
 };
 
-ut.SerializeScheduler.prototype.addPost = function(func, remark) {
+this.addPost = function(func, remark) {
     this.items.unshift({func: func, remark: remark});
     this.execute();
 };
 
-ut.SerializeScheduler.prototype.execute = function() {
+this.execute = function() {
     if (! this.lock) {
         this.lock = true;
         while (true) {
@@ -530,6 +547,8 @@
         this.lock = false;
     }
 };
+this.initialize.apply(this, arguments);
+};
 
 /* Browser event binding */
 
@@ -553,21 +572,35 @@
 
 /* collecting keys-values into a dict or into a tuple list */
 
+/*
+* class DictCollector
+*/
 ut.DictCollector = function() {
+
+this.initialize = function() {
     this.result = {};
 };
 
-ut.DictCollector.prototype.add = function(key, value) {
+this.add = function(key, value) {
     this.result[key] = value;
 };
+this.initialize.apply(this, arguments);
+};
 
+/*
+* class TupleCollector
+*/
 ut.TupleCollector = function() {
+
+this.initialize = function() {
     this.result = [];
 };
 
-ut.TupleCollector.prototype.add = function(key, value) {
+this.add = function(key, value) {
     this.result.push([key, value]);
 };
+this.initialize.apply(this, arguments);
+};
 
 }();                              /// MODULE END
 
_______________________________________________
Kukit-checkins mailing list
[email protected]
http://codespeak.net/mailman/listinfo/kukit-checkins

Reply via email to