I need to convert one 0.10 node add-on to 0.12 and struggle with Persistent 
<Function> conversion.

Here are my baton structs

struct ClientBaton {
  uv_work_t request;
  Persistent<Function> callback;

  RFC_ERROR_INFO errorInfo;
  Client *wrapper;
};

struct InvokeBaton {
  uv_work_t request;
  Persistent<Function> callback;

  RFC_FUNCTION_HANDLE functionHandle;
  RFC_FUNCTION_DESC_HANDLE functionDescHandle;
  RFC_ERROR_INFO errorInfo;
  Client *wrapper;
};

and partly converted client code:

void Client::ConnectAsyncAfter(uv_work_t* req) {
    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope(isolate);
    ClientBaton* baton = static_cast<ClientBaton*>(req->data);
    if (baton->errorInfo.code != RFC_OK) {
        Handle<Value> argv[] = { wrapError(&baton->errorInfo) };

        TryCatch try_catch;
        baton->callback->Call(isolate->GetCurrentContext()->Global(), 1, 
argv);

        if (try_catch.HasCaught()) {
            node::FatalException(try_catch);
        }
    } 
    else {
        // connect
        baton->callback->Call(isolate->GetCurrentContext()->Global(), 0, 
NULL);
        baton->wrapper->alive = true;
    }

    baton->callback->Dispose();
    delete baton;
}

This results in following build errors:

gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory `/home/pos/src/node-rfc/build'
  CXX(target) Release/obj.target/rfc/src/Client.o
../src/Client.cc: In static member function ‘static void 
Client::ConnectAsyncAfter(uv_work_t*)’:
../src/Client.cc:135:24: error: base operand of ‘->’ has non-pointer type 
‘v8::Persistent<v8::Function>’
         baton->callback->Call(isolate->GetCurrentContext()->Global(), 1, 
argv);
                        ^
../src/Client.cc:143:24: error: base operand of ‘->’ has non-pointer type 
‘v8::Persistent<v8::Function>’
         baton->callback->Call(isolate->GetCurrentContext()->Global(), 0, 
NULL);
                        ^
../src/Client.cc:147:20: error: base operand of ‘->’ has non-pointer type 
‘v8::Persistent<v8::Function>’
     baton->callback->Dispose();
                    ^
../src/Client.cc: In static member function ‘static void 
Client::Connect(const v8::FunctionCallbackInfo<v8::Value>&)’:
../src/Client.cc:166:66: error: no matching function for call to 
‘v8::Persistent<v8::Function>::New(v8::Isolate*&, v8::Local<v8::Function>&)’
     baton->callback = Persistent<Function>::New(isolate, callback);

I am not sure how Persistent <Function> should be converted and 
hint/example would be of a great help.





-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/d1f7ae5c-d07a-4b77-8e09-9ffc33fe60a1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to