Вопрос

i've been working with NodeJS 0.11.x distros for some time now, mainly because i believe that generators and the yield statement bring big advances in terms of asynchronous manageability (see coffy-script and suspend).

that said, there's a serious setback when running bleeding-edge, unstable NodeJS installs: when doing npm install xy-module, gyp will fail (always? sometimes?) when trying to compile any C components.

is there a general reason this must be so? is there any trick / patch / configuration i can apply to remedy the situation? if a given module does compile on NodeJS 0.10.x, but fails on 0.11.x, should i expect it to compile on 0.12.x as soon as that becomes available?

Update i cross-posted the issue on the NodeJS mailing list, and ben noordhuis was kind enough to share some details. quoting his message:

The two main changes are as follows:

  • Persistent<T> no longer derives from Handle<T>. To recreate the Handle from a Persistent, call Local<T>::New(isolate, persistent). You can obtain the isolate with Isolate::GetCurrent() (but note that Isolate::GetCurrent() will probably go away in newer versions of V8.)

  • The prototype of C++ callbacks and accessors has changed. Before, your function looked like this:

    Handle<Value> MyCallback(const Arguments& args) {
      HandleScope handle_scope;
      /* Do useful work, then: */
      return handle_scope.Close(Integer::New(42));
      /* Or: */
      return handle_scope.Close(String::New("hello"));
      /* Or: */
      return Null();
    }
    

    In v0.11 and v0.12 that becomes:

    void MyCallback(const FunctionCallbackInfo<Value>& args) {
      Isolate* isolate = args.GetIsolate();
      HandleScope handle_scope(isolate);
      /* Do useful work, then: */
      args.GetReturnValue().Set(42);
      /* Or: */
      args.GetReturnValue().Set(String::NewFromUtf8(isolate, "hello"));
      /* Or: */
      args.GetReturnValue().SetNull();
    }
    

There have been more changes but these two impact every native add-on.

Это было полезно?

Решение

Answered in detail in NodeUp #52: http://nodeup.com/fiftytwo

Summary: major changes in the v8 API, some minor changes in Node, and the changes are still ongoing. But there are two projects that are designed to help with the problem, NAN (github/rvagg/nan) and shim / node-addon-layer (github/tjfontaine/node-addon-layer).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top