Function signature for Signature::New--
static Local<Signature> New(
  Handle<FunctionTemplate> receiver = Handle<FunctionTemplate>(),
  int argc = 0,
  Handle<FunctionTemplate> argv[] = 0
);

The first param is the FunctionTemplate of your "this" object. If it's a
method, you would put your ctor's FunctionTemplate there. Then just set argc
to the number of arguments the function is supposed to have followed by an
array of FunctionTemplates for each parameter type.

Then you'll notice the 3rd argument of FunctionTemplate::New is a Signature,
just pass your instantiated function signature into that and v8
will guarantee your arguments are as expected per the Signature. I don't
think it's possible to specify optional arguments, multiple types, etc. I
saw you were doing some method overloading stuff so maybe this is the wrong
solution.

There is a simple usage example in my node-fibers project:
https://github.com/laverdet/node-fibers/blob/master/src/fibers.cc

On Mon, Jun 27, 2011 at 5:21 AM, Stephan Beal <[email protected]> wrote:

> On Sun, Jun 26, 2011 at 10:20 PM, Stephan Beal <[email protected]>wrote:
>
>> On Sun, Jun 26, 2011 at 10:16 PM, Marcel Laverdet <[email protected]>wrote:
>>
>>> Couldn't you use a Signature to avoid all the manual type checking?
>>>
>>
>> If they were documented i might just be able to.
>>
>
> For reference, here is the whole v8 documentation for Signature:
>
>   A Signature specifies which receivers and arguments a function can
> legally be called with.
>
>
> --
> ----- stephan beal
> http://wanderinghorse.net/home/stephan/
>
> --
> 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