zone117x/node-multi-hashing

Compile on mac node v8.4.0

Opened this issue · 1 comments

npm install multi-hashing

macOS 10.12.6
Apple LLVM version 8.1.0 (clang-802.0.42)
node-gyp v3.3.0
node v8.4.0
npm v5.4.1

> multi-hashing@0.0.4 install /Users/bob/projects/intense-poolui/node_modules/multi-hashing
> node-gyp rebuild

  CXX(target) Release/obj.target/multihashing/multihashing.o
../multihashing.cc:93:52: error: no member named 'New' in 'v8::String'
    return ThrowException(Exception::Error(String::New(msg)));
                                           ~~~~~~~~^
../multihashing.cc:96:27: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
Handle<Value> quark(const Arguments& args) {
                          ^~~~~~~~~
                          v8::internal::Arguments
/Users/bob/.node-gyp/8.4.0/include/node/v8.h:141:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../multihashing.cc:97:17: error: calling a protected constructor of class 'v8::HandleScope'
    HandleScope scope;
                ^
/Users/bob/.node-gyp/8.4.0/include/node/v8.h:876:13: note: declared protected here
  V8_INLINE HandleScope() {}
            ^
../multihashing.cc:99:13: error: member access into incomplete type 'const v8::internal::Arguments'
    if (args.Length() < 1)
            ^
/Users/bob/.node-gyp/8.4.0/include/node/v8.h:141:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
../multihashing.cc:102:32: error: type 'const v8::internal::Arguments' does not provide a subscript operator
    Local<Object> target = args[0]->ToObject();
                           ~~~~^~
../multihashing.cc:112:5: error: unexpected namespace name 'Buffer': expected expression
    Buffer* buff = Buffer::New(output, 32);
    ^
../multihashing.cc:112:13: error: use of undeclared identifier 'buff'
    Buffer* buff = Buffer::New(output, 32);
            ^
../multihashing.cc:112:20: error: no matching function for call to 'New'
    Buffer* buff = Buffer::New(output, 32);
                   ^~~~~~~~~~~
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:52:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for
      1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:55:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for
      1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:67:40: note: candidate function not viable: requires 3 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:60:40: note: candidate function not viable: requires 5 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
../multihashing.cc:113:18: error: no member named 'Close' in 'v8::HandleScope'
    return scope.Close(buff->handle_);
           ~~~~~ ^
../multihashing.cc:113:24: error: use of undeclared identifier 'buff'
    return scope.Close(buff->handle_);
                       ^
../multihashing.cc:116:25: error: unknown type name 'Arguments'; did you mean 'v8::internal::Arguments'?
Handle<Value> x11(const Arguments& args) {
                        ^~~~~~~~~
                        v8::internal::Arguments
/Users/bob/.node-gyp/8.4.0/include/node/v8.h:141:7: note: 'v8::internal::Arguments' declared here
class Arguments;
      ^
../multihashing.cc:117:17: error: calling a protected constructor of class 'v8::HandleScope'
    HandleScope scope;
                ^
/Users/bob/.node-gyp/8.4.0/include/node/v8.h:876:13: note: declared protected here
  V8_INLINE HandleScope() {}
            ^
../multihashing.cc:119:13: error: member access into incomplete type 'const v8::internal::Arguments'
    if (args.Length() < 1)
            ^
/Users/bob/.node-gyp/8.4.0/include/node/v8.h:141:7: note: forward declaration of 'v8::internal::Arguments'
class Arguments;
      ^
../multihashing.cc:122:32: error: type 'const v8::internal::Arguments' does not provide a subscript operator
    Local<Object> target = args[0]->ToObject();
                           ~~~~^~
../multihashing.cc:132:5: error: unexpected namespace name 'Buffer': expected expression
    Buffer* buff = Buffer::New(output, 32);
    ^
../multihashing.cc:132:13: error: use of undeclared identifier 'buff'
    Buffer* buff = Buffer::New(output, 32);
            ^
../multihashing.cc:132:20: error: no matching function for call to 'New'
    Buffer* buff = Buffer::New(output, 32);
                   ^~~~~~~~~~~
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:52:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for
      1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate, size_t length);
                                       ^
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:55:40: note: candidate function not viable: no known conversion from 'char *' to 'v8::Isolate *' for
      1st argument
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:67:40: note: candidate function not viable: requires 3 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
/Users/bob/.node-gyp/8.4.0/include/node/node_buffer.h:60:40: note: candidate function not viable: requires 5 arguments, but 2 were provided
NODE_EXTERN v8::MaybeLocal<v8::Object> New(v8::Isolate* isolate,
                                       ^
../multihashing.cc:133:18: error: no member named 'Close' in 'v8::HandleScope'
    return scope.Close(buff->handle_);
           ~~~~~ ^
../multihashing.cc:133:24: error: use of undeclared identifier 'buff'
    return scope.Close(buff->handle_);
                       ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
make: *** [Release/obj.target/multihashing/multihashing.o] Error 1

To make this work on Node8 you have to rewrite multihashing.cc like:

void quark(const FunctionCallbackInfo<Value>& args) {
	Isolate* isolate = args.GetIsolate();
	HandleScope scope(isolate);
	if (args.Length() < 1) {
		isolate->ThrowException(Exception::TypeError(
			String::NewFromUtf8(isolate, "You must provide one argument.")));
		return;
	}
	Local<Object> target = args[0]->ToObject();
	if(!Buffer::HasInstance(target)) { //?
		isolate->ThrowException(Exception::TypeError(
			String::NewFromUtf8(isolate, "Argument should be a buffer object.")));
		return;
	}
	char* input = Buffer::Data(target);
	char output[32];
	uint32_t input_len = Buffer::Length(target);

	quark_hash(input, output, input_len);

	args.GetReturnValue().Set(Buffer::Copy(isolate, (char*) &output, 32).ToLocalChecked());
}
// do the same for all methods
void init(Local<Object> exports) {
    NODE_SET_METHOD(exports, "quark", quark);
// do the same for all methods