Home > Software engineering >  On v8: : argument into c type parameters
On v8: : argument into c type parameters

Time:10-04

Here have a class, in this class, one containing the boost: : the function parameters of member functions, to realize the interface in v8 now, but the problem is how to set the v8: : the parameters of the Argument into class need to boost: : the function, the code is as follows:

The class Node {
Typedef boost: : functionPublic:
Bool enumerateChildren (EnumCallBack callback) const
{
If (true==children_. Empty ())
{
return false;
}
For (Nodes: : const_iterator iter=children_. The begin ();
Iter!=children_. End ();
Iter++)
{
The callback (* iter);
}
return true;
};

Private:
Vector
};
Handle NodeEnumerateChildren (const Arguments& The args)
{
Local The self=args. Holder ();
Local Wrap=Local : : Cast (self - & gt; GetInternalField (0));
Void * PTR=wrap - & gt; The Value ();

If (args [0] - & gt; IsFunction ())
{//convert the argument to boost: : function
Handle Ff=Handle : : Cast (args [0]);
Boost: : functionReturn a Boolean: : the New (static_cast & lt; Node * & gt; (PTR) - & gt; EnumerateChildren func ());
}
The else
Return a Boolean: : the New (false);
}
  •  Tags:  
  • API
  • Related