| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
8 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,4 +5,11 @@ | |||
| 5 | 5 | ||
| 6 | 6 | extern ThreadPool libgit2ThreadPool; | |
| 7 | 7 | ||
| 8 | + v8::Local<v8::Value> GetPrivate(v8::Local<v8::Object> object, | ||
| 9 | + v8::Local<v8::String> key); | ||
| 10 | + | ||
| 11 | + void SetPrivate(v8::Local<v8::Object> object, | ||
| 12 | + v8::Local<v8::String> key, | ||
| 13 | + v8::Local<v8::Value> value); | ||
| 14 | + | ||
| 8 | 15 | #endif | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -124,7 +124,7 @@ void GitRevwalk::FastWalkWorker::HandleOKCallback() | |||
| 124 | 124 | } | |
| 125 | 125 | ||
| 126 | 126 | Local<v8::Object> nodeObj = node->ToObject(); | |
| 127 | - Local<v8::Value> checkValue = nodeObj->GetHiddenValue(Nan::New("NodeGitPromiseError").ToLocalChecked()); | ||
| 127 | + Local<v8::Value> checkValue = GetPrivate(nodeObj, Nan::New("NodeGitPromiseError").ToLocalChecked()); | ||
| 128 | 128 | ||
| 129 | 129 | if (!checkValue.IsEmpty() && !checkValue->IsNull() && !checkValue->IsUndefined()) | |
| 130 | 130 | { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -192,7 +192,7 @@ void {{ cppClassName }}::{{ cppFunctionName }}Worker::HandleOKCallback() { | |||
| 192 | 192 | } | |
| 193 | 193 | ||
| 194 | 194 | Local<v8::Object> nodeObj = node->ToObject(); | |
| 195 | - Local<v8::Value> checkValue = nodeObj->GetHiddenValue(Nan::New("NodeGitPromiseError").ToLocalChecked()); | ||
| 195 | + Local<v8::Value> checkValue = GetPrivate(nodeObj, Nan::New("NodeGitPromiseError").ToLocalChecked()); | ||
| 196 | 196 | ||
| 197 | 197 | if (!checkValue.IsEmpty() && !checkValue->IsNull() && !checkValue->IsUndefined()) { | |
| 198 | 198 | Local<v8::Value> argv[1] = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -128,7 +128,7 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_promiseComp | |||
| 128 | 128 | {% if arg.payload == true %}{{arg.name}}{% elsif arg.lastArg %}{{arg.name}}{% endif %} | |
| 129 | 129 | {% endeach %}); | |
| 130 | 130 | Local<v8::Object> parent = instance->handle(); | |
| 131 | - parent->SetHiddenValue(Nan::New("NodeGitPromiseError").ToLocalChecked(), result); | ||
| 131 | + SetPrivate(parent, Nan::New("NodeGitPromiseError").ToLocalChecked(), result); | ||
| 132 | 132 | ||
| 133 | 133 | baton->result = {{ cbFunction.return.error }}; | |
| 134 | 134 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -249,7 +249,7 @@ | |||
| 249 | 249 | {% if arg.payload == true %}{{arg.name}}{% elsif arg.lastArg %}{{arg.name}}{% endif %} | |
| 250 | 250 | {% endeach %}); | |
| 251 | 251 | Local<v8::Object> parent = instance->handle(); | |
| 252 | - parent->SetHiddenValue(Nan::New("NodeGitPromiseError").ToLocalChecked(), result); | ||
| 252 | + SetPrivate(parent, Nan::New("NodeGitPromiseError").ToLocalChecked(), result); | ||
| 253 | 253 | ||
| 254 | 254 | baton->result = {{ field.return.error }}; | |
| 255 | 255 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -8,6 +8,7 @@ extern "C" { | |||
| 8 | 8 | {% endeach %} | |
| 9 | 9 | } | |
| 10 | 10 | ||
| 11 | + #include "../include/nodegit.h" | ||
| 11 | 12 | #include "../include/lock_master.h" | |
| 12 | 13 | #include "../include/functions/copy.h" | |
| 13 | 14 | #include "../include/{{ filename }}.h" | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -22,6 +22,44 @@ | |||
| 22 | 22 | #include "../include/convenient_patch.h" | |
| 23 | 23 | #include "../include/convenient_hunk.h" | |
| 24 | 24 | ||
| 25 | + #if (NODE_MODULE_VERSION > 48) | ||
| 26 | + v8::Local<v8::Value> GetPrivate(v8::Local<v8::Object> object, | ||
| 27 | + v8::Local<v8::String> key) { | ||
| 28 | + v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| 29 | + v8::Local<v8::Context> context = isolate->GetCurrentContext(); | ||
| 30 | + v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key); | ||
| 31 | + v8::Local<v8::Value> value; | ||
| 32 | + v8::Maybe<bool> result = object->HasPrivate(context, privateKey); | ||
| 33 | + if (!(result.IsJust() && result.FromJust())) | ||
| 34 | + return v8::Local<v8::Value>(); | ||
| 35 | + if (object->GetPrivate(context, privateKey).ToLocal(&value)) | ||
| 36 | + return value; | ||
| 37 | + return v8::Local<v8::Value>(); | ||
| 38 | + } | ||
| 39 | + | ||
| 40 | + void SetPrivate(v8::Local<v8::Object> object, | ||
| 41 | + v8::Local<v8::String> key, | ||
| 42 | + v8::Local<v8::Value> value) { | ||
| 43 | + if (value.IsEmpty()) | ||
| 44 | + return; | ||
| 45 | + v8::Isolate* isolate = v8::Isolate::GetCurrent(); | ||
| 46 | + v8::Local<v8::Context> context = isolate->GetCurrentContext(); | ||
| 47 | + v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key); | ||
| 48 | + object->SetPrivate(context, privateKey, value); | ||
| 49 | + } | ||
| 50 | + #else | ||
| 51 | + v8::Local<v8::Value> GetPrivate(v8::Local<v8::Object> object, | ||
| 52 | + v8::Local<v8::String> key) { | ||
| 53 | + return object->GetHiddenValue(key); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + void SetPrivate(v8::Local<v8::Object> object, | ||
| 57 | + v8::Local<v8::String> key, | ||
| 58 | + v8::Local<v8::Value> value) { | ||
| 59 | + object->SetHiddenValue(key, value); | ||
| 60 | + } | ||
| 61 | + #endif | ||
| 62 | + | ||
| 25 | 63 | void LockMasterEnable(const FunctionCallbackInfo<Value>& info) { | |
| 26 | 64 | LockMaster::Enable(); | |
| 27 | 65 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -14,6 +14,7 @@ extern "C" { | |||
| 14 | 14 | } | |
| 15 | 15 | ||
| 16 | 16 | #include <iostream> | |
| 17 | + #include "../include/nodegit.h" | ||
| 17 | 18 | #include "../include/lock_master.h" | |
| 18 | 19 | #include "../include/functions/copy.h" | |
| 19 | 20 | #include "../include/{{ filename }}.h" | |
| Back | FazBrowse Home | New Git URL |
0 commit comments