[KSS-checkins] r49576 - kukit/kukit.js/branch/finish-closures/kukit
gotcha at codespeak.net
gotcha at codespeak.net
Sun Dec 9 19:09:11 CET 2007
Author: gotcha
Date: Sun Dec 9 19:09:11 2007
New Revision: 49576
Modified:
kukit/kukit.js/branch/finish-closures/kukit/providerreg.js
Log:
class closures
Modified: kukit/kukit.js/branch/finish-closures/kukit/providerreg.js
==============================================================================
--- kukit/kukit.js/branch/finish-closures/kukit/providerreg.js (original)
+++ kukit/kukit.js/branch/finish-closures/kukit/providerreg.js Sun Dec 9 19:09:11 2007
@@ -29,62 +29,39 @@
pr.ValueProviderRegistry = function () {
this.content = {};
-};
-
-var ValueProviderRegistry = pr.ValueProviderRegistry.prototype;
-ValueProviderRegistry.register = function(name, func) {
- if (typeof(func) == 'undefined') {
-;;; kukit.E = 'func argument is mandatory when registering a parameter'
-;;; kukit.E += ' provider [ValueProviderRegistry.register].';
- throw new Error(kukit.E);
- }
-;;; if (this.content[name]) {
-;;; // Do not allow redefinition
-;;; var msg = 'Error : parameter provider [' + name;
-;;; msg += '] already registered.';
-;;; kukit.logError(msg);
-;;; return;
-;;; }
- this.content[name] = func;
-};
-
-ValueProviderRegistry.exists = function(name) {
- var entry = this.content[name];
- return (typeof(entry) != 'undefined');
-};
-
-ValueProviderRegistry.get = function(name) {
- var func = this.content[name];
- if (! func) {
- // not found
- if (name == '') {
- // default provider for the strings
- return kukit.pr.IdentityPP;
- } else {
+ this.register = function(name, func) {
+ if (typeof(func) == 'undefined') {
+;;; kukit.E = 'func argument is mandatory when registering a parameter'
+;;; kukit.E += ' provider [ValueProviderRegistry.register].';
+ throw new Error(kukit.E);
+ }
+;;; if (this.content[name]) {
+;;; // Do not allow redefinition
+;;; var msg = 'Error : parameter provider [' + name;
+;;; msg += '] already registered.';
+;;; kukit.logError(msg);
+;;; return;
+;;; }
+ this.content[name] = func;
+ };
+
+ this.exists = function(name) {
+ var entry = this.content[name];
+ return (typeof(entry) != 'undefined');
+ };
+
+ this.get = function(name) {
+ var func = this.content[name];
+ if (! func) {
;;; kukit.E = 'Error : undefined parameter provider [' + name + '].';
throw new Error(kukit.E);
}
- }
- return func;
-};
+ return func;
+ };
-pr.IdentityPP = function() {};
-pr.IdentityPP.prototype = {
- check: function(args) {
- // check does not need to be used here actually.
-;;; if (args.length != 1) {
-;;; throw new Error('internal error, IdentityPP needs 1 argument');
-;;; }
- },
- eval: function(args, node) {
- return args[0];
- }
};
-}(); /// MODULE END
-
-kukit.dummy = new function() { /// MODULE START
/*
* Register the core parameter providers
*
@@ -108,26 +85,37 @@
* this provider expects a single parameter, the string.
*/
-var FormVarPP = function() {};
-FormVarPP.prototype = {
- check: function(args) {
+var IdentityPP = function() {
+ this.check = function(args) {
+ // check does not need to be used here actually.
+;;; if (args.length != 1) {
+;;; throw new Error('internal error, IdentityPP needs 1 argument');
+;;; }
+ };
+
+ this.eval = function(args, node) {
+ return args[0];
+ };
+};
+
+var FormVarPP = function() {
+ this.check = function(args) {
;;; if (args.length != 2) {
;;; throw new Error('formVar method needs 2 arguments [formname, varname]');
;;; }
- },
- eval:function(args, node) {
+ };
+ this.eval = function(args, node) {
return kukit.fo.getFormVar(new kukit.fo.NamedFormLocator(args[0]), args[1]);
- }
+ };
};
-var CurrentFormVarPP = function() {};
-CurrentFormVarPP.prototype = {
- check: function(args) {
+var CurrentFormVarPP = function() {
+ this.check = function(args) {
;;; if (args.length != 0 && args.length != 1) {
;;; throw new Error('currentFormVar method needs 0 or 1 argument [varname]');
;;; }
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
if (args.length == 1) {
return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node),
args[0]);
@@ -135,19 +123,18 @@
// no form var name, just get the value of the node.
return kukit.fo.getValueOfFormElement(node);
}
- }
+ };
};
-var CurrentFormVarFromKssAttrPP = function() {};
-CurrentFormVarFromKssAttrPP.prototype = {
- check: function(args) {
+var CurrentFormVarFromKssAttrPP = function() {
+ this.check = function(args) {
;;; if (args.length != 1 && args.length != 2) {
;;; kukit.E = 'currentFormVarFromKssAttr method needs 1 or 2 argument';
;;; kukit.E += ' [attrname, [recurseParents]]';
;;; throw new Error(kukit.E);
;;; }
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
var argname = args[0];
var recurseParents = false;
if (args.length == 2) {
@@ -160,47 +147,44 @@
recurseParents, kukit.dom.getKssAttribute);
return kukit.fo.getFormVar(new kukit.fo.CurrentFormLocator(node),
formvarname);
- }
+ };
};
/* BBB. To be deprecated at 2007-08-15 */
-var FormPP = function() {};
-FormPP.prototype = {
- check: function(args) {
+var FormPP = function() {
+ this.check = function(args) {
;;; if (args.length != 1) {
;;; throw new Error('form method needs 1 arguments [formname]');
;;; }
;;; var msg = 'Deprecated the [form(formname)] parameter provider,';
;;; msg += ' use [xxx-kssSubmitForm: form(formname)] instead !';
;;; kukit.logWarning(msg);
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
return kukit.fo.getAllFormVars(new kukit.fo.NamedFormLocator(args[0]),
new kukit.ut.DictCollector());
- }
+ };
};
/* BBB. To be deprecated at 2007-08-15 */
-var CurrentFormPP = function() {};
-CurrentFormPP.prototype = {
- check: function(args) {
+var CurrentFormPP = function() {
+ this.check = function(args) {
;;; if (args.length != 0) {
;;; throw new Error('currentForm method needs no argument');
;;; }
;;; var msg = 'Deprecated the [currentForm()] parameter provider,';
;;; msg += ' use [xxx-kssSubmitForm: currentForm()] instead !';
;;; kukit.logWarning(msg);
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
return kukit.fo.getAllFormVars(new kukit.fo.CurrentFormLocator(node),
new kukit.ut.DictCollector());
- }
+ };
};
-var NodeAttrPP = function() {};
-NodeAttrPP.prototype = {
- check: function(args) {
+var NodeAttrPP = function() {
+ this.check = function(args) {
;;; if (args.length != 1 && args.length != 2) {
;;; kukit.E = 'nodeAttr method needs 1 or 2 argument (attrname,';
;;; kukit.E += ' [recurseParents]).';
@@ -212,8 +196,8 @@
;;; if (args[0].match(/[ ]/)) {
;;; throw new Error('attrname parameter in nodeAttr method cannot contain space.');
;;; }
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
var argname = args[0];
var recurseParents = false;
if (args.length == 2) {
@@ -223,12 +207,11 @@
}
return kukit.dom.getRecursiveAttribute(node, argname, recurseParents,
kukit.dom.getAttribute);
- }
+ };
};
-var KssAttrPP = function() {};
-KssAttrPP.prototype = {
- check: function(args) {
+var KssAttrPP = function() {
+ this.check = function(args) {
;;; if (args.length != 1 && args.length != 2) {
;;; kukit.E = 'kssAttr method needs 1 or 2 argument (attrname,';
;;; kukit.E += ' [recurseParents]).';
@@ -239,8 +222,8 @@
;;; kukit.E += ' dashes or spaces.';
;;; throw new Error(kukit.E);
;;; }
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
var argname = args[0];
var recurseParents = false;
if (args.length == 2) {
@@ -250,33 +233,31 @@
}
return kukit.dom.getRecursiveAttribute(node, argname, recurseParents,
kukit.dom.getKssAttribute);
- }
+ };
};
-var NodeContentPP = function() {};
-NodeContentPP.prototype = {
- check: function(args) {
+var NodeContentPP = function() {
+ this.check = function(args) {
;;; if (args.length != 0 && args.length != 1) {
;;; throw new Error('nodeContent method needs 0 or 1 argument [recursive].');
;;; }
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
var recursive = false;
if (args.length == 1) {
recursive = args[0];
}
return kukit.dom.textContent(node, recursive);
- }
+ };
};
-var StateVarPP = function() {};
-StateVarPP.prototype = {
- check: function(args) {
+var StateVarPP = function() {
+ this.check = function(args) {
;;; if (args.length != 1) {
;;; throw new Error('stateVar method needs 1 argument [varname].');
;;; }
- },
- eval: function(args, node) {
+ };
+ this.eval = function(args, node) {
var key = args[0];
var value = kukit.engine.stateVariables[key];
if (typeof(value) == 'undefined') {
@@ -285,17 +266,16 @@
throw new Error(kukit.E);
}
return value;
- }
+ };
};
-var PassPP = function() {};
-PassPP.prototype = {
- check: function(args) {
+var PassPP = function() {
+ this.check = function(args) {
;;; if (args.length != 1) {
;;; throw new Error('pass method needs 1 argument [attrname].');
;;; }
- },
- eval: function(args, node, defaultParameters) {
+ };
+ this.eval = function(args, node, defaultParameters) {
var key = args[0];
var value = defaultParameters[key];
if (typeof(value) == 'undefined') {
@@ -304,13 +284,13 @@
throw new Error(kukit.E);
}
return value;
- }
+ };
};
-kukit.pprovidersGlobalRegistry = new kukit.pr.ValueProviderRegistry();
+kukit.pprovidersGlobalRegistry = new this.ValueProviderRegistry();
-kukit.pprovidersGlobalRegistry.register('', kukit.pr.IdentityPP);
+kukit.pprovidersGlobalRegistry.register('', IdentityPP);
kukit.pprovidersGlobalRegistry.register('currentFormVar',
CurrentFormVarPP);
kukit.pprovidersGlobalRegistry.register('currentFormVarFromKssAttr',
@@ -325,3 +305,4 @@
kukit.pprovidersGlobalRegistry.register('currentForm', CurrentFormPP);
}(); /// MODULE END
+
More information about the Kukit-checkins
mailing list