I want to have javascript access to my C ++ function with google v8 engine and return the result according to the arguments provided in my javascript function.
My javascript function is as follows:
var result = MyFc( { 'stringData':'abc', 'numberData':123, 'arrData':[1,2,3], 'objData':{'a':true,'b':false,'c':true}, 'callback':function(){} } );
I used
global->Set(v8::String::New("myFc"), v8::FunctionTemplate::New(MyFc)); v8::Handle<v8::Value> MyFc(const v8::Arguments& args) { obj = args[0]->... if( obj->stringData != 'abc' ){ //.... } if( obj->numberData != 123 ){ //.... } if( obj->arrData[2] != 3 ){ //.... } if( obj->objData->b == false ){ //.... } if( obj->callback !='abc' ){ //.... } }
My question is how to parse argument objects in C ++ v8? I want to access all the key values ββof an object in arguments, the values ββcan be a number, a string, an array, an anonymous function, or an object.
Darm
source share