Hi,

I'm trying to make a function-template that apart from having some
default functions or values on new instances and the prototype also
has some default properties (getters, to be more specific) on the
actual function object.
Something like the following Javascript example:

function SillyString(str) {
  this.str=str;
  return this;
}
SillyString.prototype.silly=function() {
print("Silly"+this.str);
}
//This is the part that I can't find out:
SillyString.__defineGetter__("default",function() { return new
SillyString("String"); });
//Usage example
var y=new SillyString("HelloWorld"); //<-- this should be possible
var y=SillyString.default; //<-- Should return the equivalent of new
SillyString("String");

Would anyone have any idea how to go about doing this ? I've tried
using just an ObjectTemplate with a SetCallAsFunctionHandler, but that
throws a type error when used with "new".

Thanks,
TB
--~--~---------~--~----~------------~-------~--~----~
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
-~----------~----~----~----~------~----~------~--~---

Reply via email to