From 449d8ceb2144626175e4e8ff52e393641f5e7380 Mon Sep 17 00:00:00 2001 From: "Alex A. Naanou" Date: Tue, 8 Dec 2015 05:24:06 +0300 Subject: [PATCH] minor tweaks... Signed-off-by: Alex A. Naanou --- ui (gen4)/lib/actions.js | 6 ++++++ ui (gen4)/object.js | 18 ++++++++++++++++-- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/ui (gen4)/lib/actions.js b/ui (gen4)/lib/actions.js index 62f19069..a315d1f9 100755 --- a/ui (gen4)/lib/actions.js +++ b/ui (gen4)/lib/actions.js @@ -670,6 +670,7 @@ module.MetaActions = { // Mixin a set of local actions into an object... // + // XXX this will not work on non-actions... mixinTo: function(to, all, descriptors, all_attr_types){ return this.mixin.call(to, this, all, descriptors, all_attr_types) }, @@ -741,6 +742,11 @@ module.MetaActions = { mixoutFrom: function(to, all, descriptors, all_attr_types){ return this.mixout.call(to, this, all, descriptors, all_attr_types) }, + + // XXX is this correct??? + clone: function(){ + return Object.create(this) + }, } diff --git a/ui (gen4)/object.js b/ui (gen4)/object.js index f0cef116..093f0df5 100755 --- a/ui (gen4)/object.js +++ b/ui (gen4)/object.js @@ -23,10 +23,11 @@ function makeConstructor(name, a, b){ var cls_proto = b == null ? b : a var _constructor = function Constructor(){ + /* // in case this is called as a function (without new)... if(this.constructor !== _constructor){ - // NOTE: the folowing does the job of the 'new' operator but - // with one advantage, we can now pass arbitrarry args + // NOTE: the following does the job of the 'new' operator but + // with one advantage, we can now pass arbitrary args // in... // This is equivalent to: // return new _constructor(json) @@ -39,6 +40,19 @@ function makeConstructor(name, a, b){ } else { var obj = this } + */ + + // NOTE: the following does the job of the 'new' operator but + // with one advantage, we can now pass arbitrary args + // in... + // This is equivalent to: + // return new _constructor(json) + var obj = {} + obj.__proto__ = _constructor.prototype + // XXX for some reason this does not resolve from .__proto__ + obj.constructor = _constructor + //obj.__proto__.constructor = _constructor + // load initial state... if(obj.__init__ != null){