sergi
11 years agoContributor
Share Function.prototype between Units
Hi,
I'm having problems sharing the prototype functions between different units.
I've read this:
http://smartbear.com/forums/f74/fp167/t49620/jscript-exception-propagation-between-script-un/
and this:
http://support.smartbear.com/viewarticle/57893/?_ga=%221.165320700.233964626.1367322859%22#JS
which seem to be related, but I can't figure out how to solve my particular case.
I have the following which is not working.
----------------------------
FunctionUnit
----------------------------
Function.prototype.inheritsFrom = function( parentClassOrObject ){
if ( parentClassOrObject.constructor == Function )
{
//Normal Inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject.prototype;
}
else
{
//Pure Virtual Inheritance
this.prototype = parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject;
}
return this;
}
----------------------------
TestUnit
----------------------------
//USEUNIT FunctionUnit
function MyClassA(){}
MyClassB.inheritsFrom(MyClassB);
function MyClassB(){}
Any suggestions?
Thanks
I'm having problems sharing the prototype functions between different units.
I've read this:
http://smartbear.com/forums/f74/fp167/t49620/jscript-exception-propagation-between-script-un/
and this:
http://support.smartbear.com/viewarticle/57893/?_ga=%221.165320700.233964626.1367322859%22#JS
which seem to be related, but I can't figure out how to solve my particular case.
I have the following which is not working.
----------------------------
FunctionUnit
----------------------------
Function.prototype.inheritsFrom = function( parentClassOrObject ){
if ( parentClassOrObject.constructor == Function )
{
//Normal Inheritance
this.prototype = new parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject.prototype;
}
else
{
//Pure Virtual Inheritance
this.prototype = parentClassOrObject;
this.prototype.constructor = this;
this.prototype.parent = parentClassOrObject;
}
return this;
}
----------------------------
TestUnit
----------------------------
//USEUNIT FunctionUnit
function MyClassA(){}
MyClassB.inheritsFrom(MyClassB);
function MyClassB(){}
Any suggestions?
Thanks