Ok guys, my bad. Sorry for that.

The method for setting properties to FunctionTemplate described abocve
actually works. I had a bad test there.

Though, I'm still not sur if it's possible to add methods to the
constructor function (se my last paragraph).

On May 21, 9:57 am, Martin Cohen <[email protected]> wrote:
> Hello guys,
>
> I'm trying to set properties on a constructor function. Typically to
> have constants used with the API. Something like this:
>
> var file = new File( ... );
> file.seek( 20, File.SEEK_END );
>
> Is it even possible to define "File.SEEK_END" from C++? I see that
> there's this Set method on FunctionTemplate, and there is this
> sentence in the docs:
>
> >> A FunctionTemplate can have properties, these properties are added to the 
> >> function object when it is created.
>
> So I did this:
>
> v8::Persistent<v8::FunctionTemplate> constructor;
> ...
> constructor =
> v8::Persistent<v8::FunctionTemplate>::New( v8::FunctionTemplate::New( 
> TClass<W,T>::constructorCall,
> v8::External::New(s_instance) ) );
> constructor->SetClassName( v8::String::New( "constructor" ) );
> ...
> constructor->Set( "SEEK_SET", v8::Integer::New( SEEK_SET ) );
> ...
> global->Set( v8::String::New( "File" ), constructor )
>
> I'm also interested in something similar to "static functions" --
> methods bound to the constructor. For example: var file =
> File.open( "test.txt", "rb" ), while still being able to use File
> constructor (var file = new File)
>
> Any ideas, please?
>
> --
> v8-users mailing list
> [email protected]http://groups.google.com/group/v8-users

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

Reply via email to