Skip to content

Commit

Permalink
Merge 2305fae into 120f745
Browse files Browse the repository at this point in the history
  • Loading branch information
XadillaX committed Jul 2, 2019
2 parents 120f745 + 2305fae commit 33eb394
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ node_js:
- "4"
- "6"
- "8"
- "10"
- "12"
install:
- export CXX="g++-4.8" CXX="gcc-4.8"
- $CXX --version
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@
},
"homepage": "https://github.com/XadillaX/bling_hashes#readme",
"dependencies": {
"big-number": "^1.0.0",
"long": "^3.0.1",
"nan": "^2.7.0"
"big-number": "^2.0.0",
"long": "^4.0.0",
"nan": "^2.14.0"
},
"devDependencies": {
"coveralls": "^2.11.4",
Expand Down
9 changes: 6 additions & 3 deletions src/byvoid/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
*/
#ifndef __BYVOID_ENTRY_H__
#define __BYVOID_ENTRY_H__
#include <nan.h>

#include "algorithms.h"
#include "../common.h"

using v8::String;

Expand All @@ -35,14 +36,16 @@ void ToUpperCase(std::string& str)

NAN_METHOD(CalcHash)
{
CURRENT_CONTEXT(ctx);

// argument length...
if(info.Length() < 2)
{
return Nan::ThrowError("invalid argument count");
}

String::Utf8Value v8_algorithm_type(info[0]->ToString());
String::Utf8Value v8_string(info[1]->ToString());
String::Utf8Value v8_algorithm_type(isolate, info[0]->ToString(ctx).ToLocalChecked());
String::Utf8Value v8_string(isolate, info[1]->ToString(ctx).ToLocalChecked());

// type to uppercase
std::string algorithm_type = *v8_algorithm_type;
Expand Down
14 changes: 10 additions & 4 deletions src/cityhash/entry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@
#ifndef __CITYHASH_ENTRY_H__
#define __CITYHASH_ENTRY_H__

#include <nan.h>
#include <string>
#include "cityhash.h"
#include "../common.h"

void __CityHash64FreeCallback(char* data, void* hint)
{
Expand All @@ -30,13 +30,15 @@ void __CityHash64FreeCallback(char* data, void* hint)

NAN_METHOD(_CityHash32)
{
CURRENT_CONTEXT(ctx);

// argument length...
if(info.Length() < 1)
{
return Nan::ThrowError("invalid argument count");
}

String::Utf8Value v8_source_string(info[0]->ToString());
String::Utf8Value v8_source_string(isolate, info[0]->ToString(ctx).ToLocalChecked());
std::string source_string = *v8_source_string;
unsigned int len = source_string.size();

Expand All @@ -52,13 +54,15 @@ NAN_METHOD(_CityHash32)

NAN_METHOD(_CityHash64)
{
CURRENT_CONTEXT(ctx);

// argument length...
if(info.Length() < 1)
{
return Nan::ThrowError("invalid argument count");
}

String::Utf8Value v8_source_string(info[0]->ToString());
String::Utf8Value v8_source_string(isolate, info[0]->ToString(ctx).ToLocalChecked());
std::string source_string = *v8_source_string;
unsigned int len = source_string.size();

Expand All @@ -77,13 +81,15 @@ const Extract128Func Extract128[] = { Uint128Low64, Uint128High64 };

NAN_METHOD(_CityHash128)
{
CURRENT_CONTEXT(ctx);

// argument length...
if(info.Length() < 1)
{
return Nan::ThrowError("invalid argument count");
}

String::Utf8Value v8_source_string(info[0]->ToString());
String::Utf8Value v8_source_string(isolate, info[0]->ToString(ctx).ToLocalChecked());
std::string source_string = *v8_source_string;
unsigned int len = source_string.size();

Expand Down
13 changes: 13 additions & 0 deletions src/common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#ifndef __COMMON_H__
#define __COMMON_H__

#include <nan.h>

using v8::Isolate;
using v8::Local;
using v8::Context;

#define CURRENT_CONTEXT(ctx) Isolate* isolate = Isolate::GetCurrent(); \
Local<Context> ctx = isolate->GetCurrentContext();

#endif

0 comments on commit 33eb394

Please sign in to comment.