summaryrefslogtreecommitdiff
path: root/addons/web/static/src/js/core.js
diff options
context:
space:
mode:
authorniv-openerp <nicolas.vanhoren@openerp.com>2012-03-13 17:37:19 +0100
committerniv-openerp <nicolas.vanhoren@openerp.com>2012-03-13 17:37:19 +0100
commit4e7796cfeea94e3225fed1c9b99f4f25afe6cd6a (patch)
treeecd64c474301364301e666f958267daddfe925f5 /addons/web/static/src/js/core.js
parent89061adc7d8b6af9632cda42ea96dbabad050807 (diff)
[imp] added some stuff to manage interfaces
bzr revid: nicolas.vanhoren@openerp.com-20120313163719-ez4n7ca4qxus0m9t
Diffstat (limited to 'addons/web/static/src/js/core.js')
-rw-r--r--addons/web/static/src/js/core.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/addons/web/static/src/js/core.js b/addons/web/static/src/js/core.js
index a962d205c1c..650939c843c 100644
--- a/addons/web/static/src/js/core.js
+++ b/addons/web/static/src/js/core.js
@@ -1335,6 +1335,23 @@ openerp.web.qweb.preprocess_node = function() {
}
};
+/**
+ * A small utility function to check if a class implements correctly an interface, assuming that
+ * interface is simply specified using a dictionary containing methods and attributes with the
+ * correct type. It only performs the check when in debug mode and the only effect of an invalid
+ * check is messages in the console.
+ */
+openerp.web.check_interface = function(_class, _interface) {
+ if (! openerp.web.check_interface.debug)
+ return;
+ for (var member in _interface) {
+ if ( (typeof _class.prototype[member] != typeof _interface[member]) ) {
+ console.error("class failed to implement interface member '" + member + "'");
+ }
+ }
+}
+openerp.web.check_interface.debug = ($.deparam($.param.querystring()).debug != undefined);
+
/** Jquery extentions */
$.Mutex = (function() {
function Mutex() {