2010/1/22 Flier Lu <[email protected]>

> The Function class has provided the NewInstance which support variable
> amount of arguments
>
> class V8EXPORT Function : public Object {
>  public:
>  Local<Object> NewInstance() const;
>  Local<Object> NewInstance(int argc, Handle<Value> argv[]) const;
>  ...
> };
>
> You could fill your actual arguments in a array, and pass the length
> and pointer to the second one.
>
>

Ah, cool, this was exactly what was I looking for! The std::vector did the
trick.


Sincerely,
Ondrej Zara






> Here is some sample code in pyv8, <http://code.google.com/p/pyv8/
> source/browse/trunk/src/Wrapper.cpp#1039<http://code.google.com/p/pyv8/%0Asource/browse/trunk/src/Wrapper.cpp#1039>
> >
>
>  std::vector< v8::Handle<v8::Value> > params(::PyList_Size(args.ptr
> ()));
>
>  for (size_t i=0; i<params.size(); i++)
>  {
>    params[i] = CPythonObject::Wrap(args[i]);
>  }
>
>  v8::Handle<v8::Value> result;
>
>  Py_BEGIN_ALLOW_THREADS
>
>  result = func->Call(
>    self.IsEmpty() ? v8::Context::GetCurrent()->Global() : self,
>    params.size(), params.empty() ? NULL : &params[0]);
>
>  Py_END_ALLOW_THREADS
>
>
> On 1月18日, 下午4时18分, ondras <[email protected]> wrote:
> > Hi,
> >
> > I have some troubles implementing a js class/function which can fix
> > itself when not called with "new". What is my aim:
> >
> > ...
> > if (!args.IsConstructCall()) {
> >   return args.Callee()->NewInstance(args.Length(), ???);}
> >
> > ...
> >
> > However, I do not want this routine to be dependent on the actual
> > number of arguments passed. Can you please provide some help on this
> > topic?
> >
> > Thanks,
> > Ondrej
>
> --
> 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