node-addons icon indicating copy to clipboard operation
node-addons copied to clipboard

checking this out - outdated?

Open ORESoftware opened this issue 8 years ago • 2 comments

Hey! thanks for this repo of addon examples, nice

I have this question open just now: https://github.com/nodejs/help/issues/426

looking for answers, I saw your array example, is it up to date? I tried to compile it but I got this:

oleg@xps:~/WebstormProjects/oresoftware/replace-line$ sudo node-gyp rebuild
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | linux | x64
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/home/oleg/WebstormProjects/oresoftware/replace-line/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/home/oleg/.node-gyp/4.2.6/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/home/oleg/.node-gyp/4.2.6',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=node.lib',
gyp info spawn args   '-Dmodule_root_dir=/home/oleg/WebstormProjects/oresoftware/replace-line',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
gyp info spawn make
gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
make: Entering directory '/home/oleg/WebstormProjects/oresoftware/replace-line/build'
  CXX(target) Release/obj.target/hello/hello.o
../hello.cc:6:26: error: ‘Arguments’ does not name a type
 Handle<Value> Push(const Arguments &args);
                          ^
../hello.cc: In function ‘void Initialize(v8::Handle<v8::Object>)’:
../hello.cc:10:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
     exports->Set(String::NewSymbol("value"),
                  ^
../hello.cc:11:24: error: no matching function for call to ‘v8::Array::New()’
             Array::New());
                        ^
In file included from ../hello.cc:1:0:
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:2965:23: note: candidate: static v8::Local<v8::Array> v8::Array::New(v8::Isolate*, int)
   static Local<Array> New(Isolate* isolate, int length = 0);
                       ^
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:2965:23: note:   candidate expects 2 arguments, 0 provided
../hello.cc:13:18: error: ‘NewSymbol’ is not a member of ‘v8::String’
     exports->Set(String::NewSymbol("push"),
                  ^
../hello.cc:14:39: error: no matching function for call to ‘v8::FunctionTemplate::New(v8::Handle<v8::Value> (&)(const int&))’
             FunctionTemplate::New(Push)->GetFunction());
                                       ^
In file included from ../hello.cc:1:0:
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:4349:34: note: candidate: static v8::Local<v8::FunctionTemplate> v8::FunctionTemplate::New(v8::Isolate*, v8::FunctionCallback, v8::Local<v8::Value>, v8::Local<v8::Signature>, int)
   static Local<FunctionTemplate> New(
                                  ^
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:4349:34: note:   no known conversion for argument 1 from ‘v8::Handle<v8::Value>(const int&) {aka v8::Local<v8::Value>(const int&)}’ to ‘v8::Isolate*’
../hello.cc: At global scope:
../hello.cc:18:12: error: ‘Arguments’ does not name a type
 Push(const Arguments &args) {
            ^
In file included from ../hello.cc:1:0:
/home/oleg/.node-gyp/4.2.6/include/node/v8.h: In function ‘v8::Handle<v8::Value> Push(const int&)’:
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:885:13: error: ‘v8::HandleScope::HandleScope()’ is protected
   V8_INLINE HandleScope() {}
             ^
../hello.cc:19:17: error: within this context
     HandleScope scope;
                 ^
../hello.cc:21:16: error: invalid types ‘const int[int]’ for array subscript
     if (!args[0]->IsArray() || args[1]->IsUndefined()) {
                ^
../hello.cc:21:38: error: invalid types ‘const int[int]’ for array subscript
     if (!args[0]->IsArray() || args[1]->IsUndefined()) {
                                      ^
../hello.cc:23:21: error: ‘New’ is not a member of ‘v8::String’
                     String::New("Argument should be an Array.")));
                     ^
../hello.cc:23:65: error: ‘ThrowException’ was not declared in this scope
                     String::New("Argument should be an Array.")));
                                                                 ^
../hello.cc:25:22: error: ‘class v8::HandleScope’ has no member named ‘Close’
         return scope.Close(Undefined());
                      ^
../hello.cc:25:38: error: too few arguments to function ‘v8::Local<v8::Primitive> v8::Undefined(v8::Isolate*)’
         return scope.Close(Undefined());
                                      ^
In file included from ../hello.cc:1:0:
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:315:27: note: declared here
   friend Local<Primitive> Undefined(Isolate* isolate);
                           ^
../hello.cc:28:49: error: invalid types ‘const int[int]’ for array subscript
     Local<Array> arr = Local<Array>::Cast(args[0]->ToObject());
                                                 ^
../hello.cc:32:27: error: no matching function for call to ‘v8::Number::New(int&)’
     arr->Set(Number::New(i), args[1]);
                           ^
In file included from ../hello.cc:1:0:
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:2486:24: note: candidate: static v8::Local<v8::Number> v8::Number::New(v8::Isolate*, double)
   static Local<Number> New(Isolate* isolate, double value);
                        ^
/home/oleg/.node-gyp/4.2.6/include/node/v8.h:2486:24: note:   candidate expects 2 arguments, 1 provided
../hello.cc:32:36: error: invalid types ‘const int[int]’ for array subscript
     arr->Set(Number::New(i), args[1]);
                                    ^
../hello.cc:34:18: error: ‘class v8::HandleScope’ has no member named ‘Close’
     return scope.Close(arr);
                  ^
hello.target.mk:96: recipe for target 'Release/obj.target/hello/hello.o' failed
make: *** [Release/obj.target/hello/hello.o] Error 1
make: Leaving directory '/home/oleg/WebstormProjects/oresoftware/replace-line/build'
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/node-gyp/lib/build.js:276:23)
gyp ERR! stack     at emitTwo (events.js:87:13)
gyp ERR! stack     at ChildProcess.emit (events.js:172:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.4.0-57-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/local/bin/node-gyp" "rebuild"
gyp ERR! cwd /home/oleg/WebstormProjects/oresoftware/replace-line
gyp ERR! node -v v4.2.6
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok 

ORESoftware avatar Jan 02 '17 07:01 ORESoftware

Hey, yes you are right this repo isn't up to date anymore.

You will probably best suited to look here and here to see how C++ add ons work.

Also feel free to send a PR with the updated API.

Best Bodo

bodokaiser avatar Jan 02 '17 12:01 bodokaiser

thanks for the info!

ORESoftware avatar Jan 02 '17 21:01 ORESoftware