This works for me:

#include "v8.h"
using namespace v8;

int main(int argc, char* argv[]) {
  HandleScope locals;

  Persistent<Context> context = Context::New();
  Context::Scope context_scope(context);

  Handle<FunctionTemplate> ctor = FunctionTemplate::New();
  context->Global()->Set(String::New("T"), ctor->GetFunction());

  Local<Value> result = Script::Compile(String::New("(new T) instanceof
T"))->Run();
  String::AsciiValue ascii(result);
  printf("%s\n", *ascii);
  return 0;
}


On Mon, Nov 28, 2011 at 9:28 PM, avasilev <[email protected]> wrote:

> I have the same problem:
>
> var http = new HttpClient;
>
> (http instanceof HttpClient) returns false
> (http instanceof Object) returns true;
>
> Here is now I expose the constructor in C++:
>
>     Handle<FunctionTemplate> ctor = FunctionTemplate::New(jsCtorCallback,
> External::New(userdata));
>     ctor->SetClassName(String::New(T.typeName));
>     objTempl = ctor->PrototypeTemplate();
>     customizeObjectTemplate(objTempl);
>     global->Set(String::New(T.typeName), ctor->GetFunction());
>
> Any ideas?
> Thanks in advance
> Alex
>
> --
> 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