diff --git a/lib/class_builder.js b/lib/class_builder.js index f06b299..8548ae3 100644 --- a/lib/class_builder.js +++ b/lib/class_builder.js @@ -268,19 +268,21 @@ function createConcreteCtor( cname, members ) { var args = null; - // constructor function to be returned - var __self = function() + // constructor function to be returned (the name is set to ClassInstance + // because some debuggers (e.g. v8) will show the name of this function for + // constructor instances rather than invoking the toString() method) + var ClassInstance = function ClassInstance() { - if ( !( this instanceof __self ) ) + if ( !( this instanceof ClassInstance ) ) { // store arguments to be passed to constructor and // instantiate new object args = arguments; - return new __self(); + return new ClassInstance(); } // generate and store unique instance id - attachInstanceId( this, ++instance_id, __self ); + attachInstanceId( this, ++instance_id, ClassInstance ); initInstance( instance_id, this ); this.__initProps(); @@ -324,12 +326,12 @@ function createConcreteCtor( cname, members ) }; // provide a more intuitive string representation - __self.toString = ( cname ) + ClassInstance.toString = ( cname ) ? function() { return cname; } : function() { return '(Class)'; } ; - return __self; + return ClassInstance; }