koffi 2.3.17 → 2.3.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/build/2.3.19/koffi_darwin_arm64/koffi.node +0 -0
  3. package/build/{2.3.17 → 2.3.19}/koffi_darwin_x64/koffi.node +0 -0
  4. package/build/2.3.19/koffi_freebsd_arm64/koffi.node +0 -0
  5. package/build/{2.3.17 → 2.3.19}/koffi_freebsd_ia32/koffi.node +0 -0
  6. package/build/{2.3.17 → 2.3.19}/koffi_freebsd_x64/koffi.node +0 -0
  7. package/build/{2.3.17 → 2.3.19}/koffi_linux_arm32hf/koffi.node +0 -0
  8. package/build/{2.3.17 → 2.3.19}/koffi_linux_arm64/koffi.node +0 -0
  9. package/build/{2.3.17 → 2.3.19}/koffi_linux_ia32/koffi.node +0 -0
  10. package/build/{2.3.17 → 2.3.19}/koffi_linux_riscv64hf64/koffi.node +0 -0
  11. package/build/{2.3.17 → 2.3.19}/koffi_linux_x64/koffi.node +0 -0
  12. package/build/{2.3.17 → 2.3.19}/koffi_openbsd_ia32/koffi.node +0 -0
  13. package/build/{2.3.17 → 2.3.19}/koffi_openbsd_x64/koffi.node +0 -0
  14. package/build/2.3.19/koffi_win32_arm64/koffi.node +0 -0
  15. package/build/{2.3.17 → 2.3.19}/koffi_win32_ia32/koffi.node +0 -0
  16. package/build/2.3.19/koffi_win32_x64/koffi.node +0 -0
  17. package/package.json +2 -2
  18. package/src/koffi/src/call.cc +16 -8
  19. package/src/koffi/src/ffi.cc +3 -4
  20. package/src/koffi/src/ffi.hh +2 -0
  21. package/vendor/node-addon-api/CHANGELOG.md +41 -0
  22. package/vendor/node-addon-api/README.md +1 -1
  23. package/vendor/node-addon-api/doc/array_buffer.md +10 -0
  24. package/vendor/node-addon-api/doc/buffer.md +97 -0
  25. package/vendor/node-addon-api/doc/env.md +2 -2
  26. package/vendor/node-addon-api/doc/external.md +2 -2
  27. package/vendor/node-addon-api/doc/external_buffer.md +18 -0
  28. package/vendor/node-addon-api/doc/hierarchy.md +4 -2
  29. package/vendor/node-addon-api/doc/object.md +2 -29
  30. package/vendor/node-addon-api/doc/type_taggable.md +40 -0
  31. package/vendor/node-addon-api/doc/value.md +7 -1
  32. package/vendor/node-addon-api/napi-inl.h +317 -22
  33. package/vendor/node-addon-api/napi.h +84 -7
  34. package/vendor/node-addon-api/package.json +9 -1
  35. package/vendor/node-addon-api/test/async_progress_worker.cc +15 -3
  36. package/vendor/node-addon-api/test/binding.cc +4 -2
  37. package/vendor/node-addon-api/test/binding.gyp +11 -1
  38. package/vendor/node-addon-api/test/buffer.cc +13 -19
  39. package/vendor/node-addon-api/test/buffer.h +26 -0
  40. package/vendor/node-addon-api/test/buffer.js +82 -0
  41. package/vendor/node-addon-api/test/buffer_new_or_copy-inl.h +68 -0
  42. package/vendor/node-addon-api/test/buffer_no_external.cc +24 -0
  43. package/vendor/node-addon-api/test/error.cc +101 -0
  44. package/vendor/node-addon-api/test/error.js +15 -1
  45. package/vendor/node-addon-api/test/index.js +1 -1
  46. package/vendor/node-addon-api/test/object_reference.cc +220 -22
  47. package/vendor/node-addon-api/test/object_reference.js +83 -80
  48. package/vendor/node-addon-api/test/objectwrap.cc +23 -3
  49. package/vendor/node-addon-api/test/objectwrap.js +14 -2
  50. package/vendor/node-addon-api/test/reference.cc +55 -1
  51. package/vendor/node-addon-api/test/reference.js +7 -1
  52. package/vendor/node-addon-api/test/type_taggable.cc +66 -0
  53. package/vendor/node-addon-api/test/type_taggable.js +60 -0
  54. package/vendor/node-addon-api/test/value_type_cast.cc +60 -0
  55. package/vendor/node-addon-api/test/value_type_cast.js +106 -0
  56. package/vendor/node-addon-api/tools/eslint-format.js +2 -2
  57. package/build/2.3.17/koffi_darwin_arm64/koffi.node +0 -0
  58. package/build/2.3.17/koffi_freebsd_arm64/koffi.node +0 -0
  59. package/build/2.3.17/koffi_win32_arm64/koffi.node +0 -0
  60. package/build/2.3.17/koffi_win32_x64/koffi.node +0 -0
  61. package/vendor/node-addon-api/test/object/object_type_tag.cc +0 -39
  62. package/vendor/node-addon-api/test/object/object_type_tag.js +0 -55
  63. /package/build/{2.3.17 → 2.3.19}/koffi_win32_arm64/koffi.exp +0 -0
  64. /package/build/{2.3.17 → 2.3.19}/koffi_win32_arm64/koffi.lib +0 -0
  65. /package/build/{2.3.17 → 2.3.19}/koffi_win32_ia32/koffi.exp +0 -0
  66. /package/build/{2.3.17 → 2.3.19}/koffi_win32_ia32/koffi.lib +0 -0
  67. /package/build/{2.3.17 → 2.3.19}/koffi_win32_x64/koffi.exp +0 -0
  68. /package/build/{2.3.17 → 2.3.19}/koffi_win32_x64/koffi.lib +0 -0
@@ -1,4 +1,6 @@
1
+ #include <string.h>
1
2
  #include <future>
3
+ #include "assert.h"
2
4
  #include "napi.h"
3
5
 
4
6
  using namespace Napi;
@@ -69,6 +71,34 @@ void LastExceptionErrorCode(const CallbackInfo& info) {
69
71
  NAPI_THROW_VOID(Error::New(env));
70
72
  }
71
73
 
74
+ void TestErrorCopySemantics(const Napi::CallbackInfo& info) {
75
+ Napi::Error newError = Napi::Error::New(info.Env(), "errorCopyCtor");
76
+ Napi::Error existingErr;
77
+
78
+ #ifdef NAPI_CPP_EXCEPTIONS
79
+ std::string msg = "errorCopyCtor";
80
+ assert(strcmp(newError.what(), msg.c_str()) == 0);
81
+ #endif
82
+
83
+ Napi::Error errCopyCtor = newError;
84
+ assert(errCopyCtor.Message() == "errorCopyCtor");
85
+
86
+ existingErr = newError;
87
+ assert(existingErr.Message() == "errorCopyCtor");
88
+ }
89
+
90
+ void TestErrorMoveSemantics(const Napi::CallbackInfo& info) {
91
+ std::string errorMsg = "errorMoveCtor";
92
+ Napi::Error newError = Napi::Error::New(info.Env(), errorMsg.c_str());
93
+ Napi::Error errFromMove = std::move(newError);
94
+ assert(errFromMove.Message() == "errorMoveCtor");
95
+
96
+ newError = Napi::Error::New(info.Env(), "errorMoveAssign");
97
+ Napi::Error existingErr = std::move(newError);
98
+
99
+ assert(existingErr.Message() == "errorMoveAssign");
100
+ }
101
+
72
102
  #ifdef NAPI_CPP_EXCEPTIONS
73
103
 
74
104
  void ThrowJSError(const CallbackInfo& info) {
@@ -78,6 +108,13 @@ void ThrowJSError(const CallbackInfo& info) {
78
108
  throw Error::New(info.Env(), message);
79
109
  }
80
110
 
111
+ void ThrowTypeErrorCtor(const CallbackInfo& info) {
112
+ Napi::Value js_type_error = info[0];
113
+ ReleaseAndWaitForChildProcess(info, 1);
114
+
115
+ throw Napi::TypeError(info.Env(), js_type_error);
116
+ }
117
+
81
118
  void ThrowTypeError(const CallbackInfo& info) {
82
119
  std::string message = info[0].As<String>().Utf8Value();
83
120
 
@@ -85,6 +122,30 @@ void ThrowTypeError(const CallbackInfo& info) {
85
122
  throw TypeError::New(info.Env(), message);
86
123
  }
87
124
 
125
+ void ThrowTypeErrorCStr(const CallbackInfo& info) {
126
+ std::string message = info[0].As<String>().Utf8Value();
127
+
128
+ ReleaseAndWaitForChildProcess(info, 1);
129
+ throw TypeError::New(info.Env(), message.c_str());
130
+ }
131
+
132
+ void ThrowRangeErrorCStr(const CallbackInfo& info) {
133
+ std::string message = info[0].As<String>().Utf8Value();
134
+ ReleaseAndWaitForChildProcess(info, 1);
135
+ throw RangeError::New(info.Env(), message.c_str());
136
+ }
137
+
138
+ void ThrowRangeErrorCtor(const CallbackInfo& info) {
139
+ Napi::Value js_range_err = info[0];
140
+ ReleaseAndWaitForChildProcess(info, 1);
141
+ throw Napi::RangeError(info.Env(), js_range_err);
142
+ }
143
+
144
+ void ThrowEmptyRangeError(const CallbackInfo& info) {
145
+ ReleaseAndWaitForChildProcess(info, 1);
146
+ throw RangeError();
147
+ }
148
+
88
149
  void ThrowRangeError(const CallbackInfo& info) {
89
150
  std::string message = info[0].As<String>().Utf8Value();
90
151
 
@@ -156,6 +217,19 @@ void ThrowTypeError(const CallbackInfo& info) {
156
217
  TypeError::New(info.Env(), message).ThrowAsJavaScriptException();
157
218
  }
158
219
 
220
+ void ThrowTypeErrorCtor(const CallbackInfo& info) {
221
+ Napi::Value js_type_error = info[0];
222
+ ReleaseAndWaitForChildProcess(info, 1);
223
+ TypeError(info.Env(), js_type_error).ThrowAsJavaScriptException();
224
+ }
225
+
226
+ void ThrowTypeErrorCStr(const CallbackInfo& info) {
227
+ std::string message = info[0].As<String>().Utf8Value();
228
+
229
+ ReleaseAndWaitForChildProcess(info, 1);
230
+ TypeError::New(info.Env(), message.c_str()).ThrowAsJavaScriptException();
231
+ }
232
+
159
233
  void ThrowRangeError(const CallbackInfo& info) {
160
234
  std::string message = info[0].As<String>().Utf8Value();
161
235
 
@@ -163,6 +237,24 @@ void ThrowRangeError(const CallbackInfo& info) {
163
237
  RangeError::New(info.Env(), message).ThrowAsJavaScriptException();
164
238
  }
165
239
 
240
+ void ThrowRangeErrorCtor(const CallbackInfo& info) {
241
+ Napi::Value js_range_err = info[0];
242
+ ReleaseAndWaitForChildProcess(info, 1);
243
+ RangeError(info.Env(), js_range_err).ThrowAsJavaScriptException();
244
+ }
245
+
246
+ void ThrowRangeErrorCStr(const CallbackInfo& info) {
247
+ std::string message = info[0].As<String>().Utf8Value();
248
+ ReleaseAndWaitForChildProcess(info, 1);
249
+ RangeError::New(info.Env(), message.c_str()).ThrowAsJavaScriptException();
250
+ }
251
+
252
+ // TODO: Figure out the correct api for this
253
+ void ThrowEmptyRangeError(const CallbackInfo& info) {
254
+ ReleaseAndWaitForChildProcess(info, 1);
255
+ RangeError().ThrowAsJavaScriptException();
256
+ }
257
+
166
258
  Value CatchError(const CallbackInfo& info) {
167
259
  Function thrower = info[0].As<Function>();
168
260
  thrower({});
@@ -266,11 +358,20 @@ void ThrowDefaultError(const CallbackInfo& info) {
266
358
  Object InitError(Env env) {
267
359
  Object exports = Object::New(env);
268
360
  exports["throwApiError"] = Function::New(env, ThrowApiError);
361
+ exports["testErrorCopySemantics"] =
362
+ Function::New(env, TestErrorCopySemantics);
363
+ exports["testErrorMoveSemantics"] =
364
+ Function::New(env, TestErrorMoveSemantics);
269
365
  exports["lastExceptionErrorCode"] =
270
366
  Function::New(env, LastExceptionErrorCode);
271
367
  exports["throwJSError"] = Function::New(env, ThrowJSError);
272
368
  exports["throwTypeError"] = Function::New(env, ThrowTypeError);
369
+ exports["throwTypeErrorCtor"] = Function::New(env, ThrowTypeErrorCtor);
370
+ exports["throwTypeErrorCStr"] = Function::New(env, ThrowTypeErrorCStr);
273
371
  exports["throwRangeError"] = Function::New(env, ThrowRangeError);
372
+ exports["throwRangeErrorCtor"] = Function::New(env, ThrowRangeErrorCtor);
373
+ exports["throwRangeErrorCStr"] = Function::New(env, ThrowRangeErrorCStr);
374
+ exports["throwEmptyRangeError"] = Function::New(env, ThrowEmptyRangeError);
274
375
  exports["catchError"] = Function::New(env, CatchError);
275
376
  exports["catchErrorMessage"] = Function::New(env, CatchErrorMessage);
276
377
  exports["doNotCatch"] = Function::New(env, DoNotCatch);
@@ -11,6 +11,8 @@ module.exports = require('./common').runTestWithBindingPath(test);
11
11
 
12
12
  function test (bindingPath) {
13
13
  const binding = require(bindingPath);
14
+ binding.error.testErrorCopySemantics();
15
+ binding.error.testErrorMoveSemantics();
14
16
 
15
17
  assert.throws(() => binding.error.throwApiError('test'), function (err) {
16
18
  return err instanceof Error && err.message.includes('Invalid');
@@ -24,14 +26,26 @@ function test (bindingPath) {
24
26
  return err instanceof Error && err.message === 'test';
25
27
  });
26
28
 
27
- assert.throws(() => binding.error.throwTypeError('test'), function (err) {
29
+ assert.throws(() => binding.error.throwTypeErrorCStr('test'), function (err) {
28
30
  return err instanceof TypeError && err.message === 'test';
29
31
  });
30
32
 
33
+ assert.throws(() => binding.error.throwRangeErrorCStr('test'), function (err) {
34
+ return err instanceof RangeError && err.message === 'test';
35
+ });
36
+
31
37
  assert.throws(() => binding.error.throwRangeError('test'), function (err) {
32
38
  return err instanceof RangeError && err.message === 'test';
33
39
  });
34
40
 
41
+ assert.throws(() => binding.error.throwTypeErrorCtor(new TypeError('jsTypeError')), function (err) {
42
+ return err instanceof TypeError && err.message === 'jsTypeError';
43
+ });
44
+
45
+ assert.throws(() => binding.error.throwRangeErrorCtor(new RangeError('rangeTypeError')), function (err) {
46
+ return err instanceof RangeError && err.message === 'rangeTypeError';
47
+ });
48
+
35
49
  assert.throws(
36
50
  () => binding.error.doNotCatch(
37
51
  () => {
@@ -134,7 +134,7 @@ if (majorNodeVersion < 12 && !filterConditionsProvided) {
134
134
 
135
135
  if (napiVersion < 8 && !filterConditionsProvided) {
136
136
  testModules.splice(testModules.indexOf('object/object_freeze_seal'), 1);
137
- testModules.splice(testModules.indexOf('object/object_type_tag'), 1);
137
+ testModules.splice(testModules.indexOf('type_taggable'), 1);
138
138
  }
139
139
 
140
140
  (async function () {
@@ -2,7 +2,7 @@
2
2
  are not Objects by creating a blank Object and setting Values to
3
3
  it. Subclasses of Objects can only be set using an ObjectReference
4
4
  by first casting it as an Object. */
5
-
5
+ #include "assert.h"
6
6
  #include "napi.h"
7
7
  #include "test_helper.h"
8
8
 
@@ -16,11 +16,146 @@ ObjectReference casted_weak;
16
16
  ObjectReference casted_persistent;
17
17
  ObjectReference casted_reference;
18
18
 
19
- // info[0] is the key, which can be either a string or a number.
20
- // info[1] is the value.
21
- // info[2] is a flag that differentiates whether the key is a
22
- // C string or a JavaScript string.
23
- void SetObjects(const CallbackInfo& info) {
19
+ // Set keys can be one of:
20
+ // C style string, std::string& utf8, and const char *
21
+
22
+ // Set values can be one of:
23
+ // Napi::Value
24
+ // napi_value (req static_cast)
25
+ // const char* (c style string)
26
+ // boolean
27
+ // double
28
+
29
+ enum VAL_TYPES { JS = 0, C_STR, CPP_STR, BOOL, INT, DOUBLE, JS_CAST };
30
+
31
+ void MoveOperatorsTest(const Napi::CallbackInfo& info) {
32
+ Napi::ObjectReference existingRef;
33
+ Napi::ObjectReference existingRef2;
34
+ Napi::Object testObject = Napi::Object::New(info.Env());
35
+ testObject.Set("testProp", "tProp");
36
+
37
+ // ObjectReference(Reference<Object>&& other);
38
+ Napi::Reference<Napi::Object> refObj =
39
+ Napi::Reference<Napi::Object>::New(testObject);
40
+ Napi::ObjectReference objRef = std::move(refObj);
41
+ std::string prop = MaybeUnwrap(objRef.Get("testProp")).As<Napi::String>();
42
+ assert(prop == "tProp");
43
+
44
+ // ObjectReference& operator=(Reference<Object>&& other);
45
+ Napi::Reference<Napi::Object> refObj2 =
46
+ Napi::Reference<Napi::Object>::New(testObject);
47
+ existingRef = std::move(refObj2);
48
+ prop = MaybeUnwrap(existingRef.Get("testProp")).As<Napi::String>();
49
+ assert(prop == "tProp");
50
+
51
+ // ObjectReference(ObjectReference&& other);
52
+ Napi::ObjectReference objRef3 = std::move(existingRef);
53
+ prop = MaybeUnwrap(objRef3.Get("testProp")).As<Napi::String>();
54
+ assert(prop == "tProp");
55
+
56
+ // ObjectReference& operator=(ObjectReference&& other);
57
+ existingRef2 = std::move(objRef3);
58
+ prop = MaybeUnwrap(objRef.Get("testProp")).As<Napi::String>();
59
+ assert(prop == "tProp");
60
+ }
61
+
62
+ void SetObjectWithCStringKey(Napi::ObjectReference& obj,
63
+ Napi::Value key,
64
+ Napi::Value val,
65
+ int valType) {
66
+ std::string c_key = key.As<Napi::String>().Utf8Value();
67
+ switch (valType) {
68
+ case JS:
69
+ obj.Set(c_key.c_str(), val);
70
+ break;
71
+
72
+ case JS_CAST:
73
+ obj.Set(c_key.c_str(), static_cast<napi_value>(val));
74
+ break;
75
+
76
+ case C_STR: {
77
+ std::string c_val = val.As<Napi::String>().Utf8Value();
78
+ obj.Set(c_key.c_str(), c_val.c_str());
79
+ break;
80
+ }
81
+
82
+ case BOOL:
83
+ obj.Set(c_key.c_str(), val.As<Napi::Boolean>().Value());
84
+ break;
85
+
86
+ case DOUBLE:
87
+ obj.Set(c_key.c_str(), val.As<Napi::Number>().DoubleValue());
88
+ break;
89
+ }
90
+ }
91
+
92
+ void SetObjectWithCppStringKey(Napi::ObjectReference& obj,
93
+ Napi::Value key,
94
+ Napi::Value val,
95
+ int valType) {
96
+ std::string c_key = key.As<Napi::String>();
97
+ switch (valType) {
98
+ case JS:
99
+ obj.Set(c_key, val);
100
+ break;
101
+
102
+ case JS_CAST:
103
+ obj.Set(c_key, static_cast<napi_value>(val));
104
+ break;
105
+
106
+ case CPP_STR: {
107
+ std::string c_val = val.As<Napi::String>();
108
+ obj.Set(c_key, c_val);
109
+ break;
110
+ }
111
+
112
+ case BOOL:
113
+ obj.Set(c_key, val.As<Napi::Boolean>().Value());
114
+ break;
115
+
116
+ case DOUBLE:
117
+ obj.Set(c_key, val.As<Napi::Number>().DoubleValue());
118
+ break;
119
+ }
120
+ }
121
+
122
+ void SetObjectWithIntKey(Napi::ObjectReference& obj,
123
+ Napi::Value key,
124
+ Napi::Value val,
125
+ int valType) {
126
+ uint32_t c_key = key.As<Napi::Number>().Uint32Value();
127
+ switch (valType) {
128
+ case JS:
129
+ obj.Set(c_key, val);
130
+ break;
131
+
132
+ case JS_CAST:
133
+ obj.Set(c_key, static_cast<napi_value>(val));
134
+ break;
135
+
136
+ case C_STR: {
137
+ std::string c_val = val.As<Napi::String>();
138
+ obj.Set(c_key, c_val.c_str());
139
+ break;
140
+ }
141
+
142
+ case CPP_STR: {
143
+ std::string cpp_val = val.As<Napi::String>();
144
+ obj.Set(c_key, cpp_val);
145
+ break;
146
+ }
147
+
148
+ case BOOL:
149
+ obj.Set(c_key, val.As<Napi::Boolean>().Value());
150
+ break;
151
+
152
+ case DOUBLE:
153
+ obj.Set(c_key, val.As<Napi::Number>().DoubleValue());
154
+ break;
155
+ }
156
+ }
157
+
158
+ void SetObject(const Napi::CallbackInfo& info) {
24
159
  Env env = info.Env();
25
160
  HandleScope scope(env);
26
161
 
@@ -33,20 +168,35 @@ void SetObjects(const CallbackInfo& info) {
33
168
  reference = Reference<Object>::New(Object::New(env), 2);
34
169
  reference.SuppressDestruct();
35
170
 
36
- if (info[0].IsString()) {
37
- if (info[2].As<String>() == String::New(env, "javascript")) {
38
- weak.Set(info[0].As<String>(), info[1]);
39
- persistent.Set(info[0].As<String>(), info[1]);
40
- reference.Set(info[0].As<String>(), info[1]);
41
- } else {
42
- weak.Set(info[0].As<String>().Utf8Value(), info[1]);
43
- persistent.Set(info[0].As<String>().Utf8Value(), info[1]);
44
- reference.Set(info[0].As<String>().Utf8Value(), info[1]);
45
- }
46
- } else if (info[0].IsNumber()) {
47
- weak.Set(info[0].As<Number>(), info[1]);
48
- persistent.Set(info[0].As<Number>(), info[1]);
49
- reference.Set(info[0].As<Number>(), info[1]);
171
+ Napi::Object configObject = info[0].As<Napi::Object>();
172
+
173
+ int keyType =
174
+ MaybeUnwrap(configObject.Get("keyType")).As<Napi::Number>().Uint32Value();
175
+ int valType =
176
+ MaybeUnwrap(configObject.Get("valType")).As<Napi::Number>().Uint32Value();
177
+ Napi::Value key = MaybeUnwrap(configObject.Get("key"));
178
+ Napi::Value val = MaybeUnwrap(configObject.Get("val"));
179
+
180
+ switch (keyType) {
181
+ case CPP_STR:
182
+ SetObjectWithCppStringKey(weak, key, val, valType);
183
+ SetObjectWithCppStringKey(persistent, key, val, valType);
184
+ SetObjectWithCppStringKey(reference, key, val, valType);
185
+ break;
186
+
187
+ case C_STR:
188
+ SetObjectWithCStringKey(weak, key, val, valType);
189
+ SetObjectWithCStringKey(persistent, key, val, valType);
190
+ SetObjectWithCStringKey(reference, key, val, valType);
191
+ break;
192
+
193
+ case INT:
194
+ SetObjectWithIntKey(weak, key, val, valType);
195
+ SetObjectWithIntKey(persistent, key, val, valType);
196
+ SetObjectWithIntKey(reference, key, val, valType);
197
+
198
+ default:
199
+ break;
50
200
  }
51
201
  }
52
202
 
@@ -87,6 +237,53 @@ Value GetFromValue(const CallbackInfo& info) {
87
237
  }
88
238
  }
89
239
 
240
+ Value GetHelper(ObjectReference& ref,
241
+ Object& configObject,
242
+ const Napi::Env& env) {
243
+ int keyType =
244
+ MaybeUnwrap(configObject.Get("keyType")).As<Napi::Number>().Uint32Value();
245
+ if (ref.IsEmpty()) {
246
+ return String::New(env, "No referenced Value");
247
+ }
248
+
249
+ switch (keyType) {
250
+ case C_STR: {
251
+ std::string c_key =
252
+ MaybeUnwrap(configObject.Get("key")).As<String>().Utf8Value();
253
+ return MaybeUnwrap(ref.Get(c_key.c_str()));
254
+ break;
255
+ }
256
+ case CPP_STR: {
257
+ std::string cpp_key =
258
+ MaybeUnwrap(configObject.Get("key")).As<String>().Utf8Value();
259
+ return MaybeUnwrap(ref.Get(cpp_key));
260
+ break;
261
+ }
262
+ case INT: {
263
+ uint32_t key =
264
+ MaybeUnwrap(configObject.Get("key")).As<Number>().Uint32Value();
265
+ return MaybeUnwrap(ref.Get(key));
266
+ break;
267
+ }
268
+
269
+ default:
270
+ return String::New(env, "Error: Reached end of getter");
271
+ break;
272
+ }
273
+ }
274
+
275
+ Value GetFromGetters(const CallbackInfo& info) {
276
+ std::string object_req = info[0].As<String>();
277
+ Object configObject = info[1].As<Object>();
278
+ if (object_req == "weak") {
279
+ return GetHelper(weak, configObject, info.Env());
280
+ } else if (object_req == "persistent") {
281
+ return GetHelper(persistent, configObject, info.Env());
282
+ }
283
+
284
+ return GetHelper(reference, configObject, info.Env());
285
+ }
286
+
90
287
  // info[0] is a flag to determine if the weak, persistent, or
91
288
  // multiple reference ObjectReference is being requested.
92
289
  // info[1] is the key, and it be either a String or a Number.
@@ -207,13 +404,14 @@ Object InitObjectReference(Env env) {
207
404
  Object exports = Object::New(env);
208
405
 
209
406
  exports["setCastedObjects"] = Function::New(env, SetCastedObjects);
210
- exports["setObjects"] = Function::New(env, SetObjects);
407
+ exports["setObject"] = Function::New(env, SetObject);
211
408
  exports["getCastedFromValue"] = Function::New(env, GetCastedFromValue);
212
- exports["getFromGetter"] = Function::New(env, GetFromGetter);
409
+ exports["getFromGetters"] = Function::New(env, GetFromGetters);
213
410
  exports["getCastedFromGetter"] = Function::New(env, GetCastedFromGetter);
214
411
  exports["getFromValue"] = Function::New(env, GetFromValue);
215
412
  exports["unrefObjects"] = Function::New(env, UnrefObjects);
216
413
  exports["refObjects"] = Function::New(env, RefObjects);
414
+ exports["moveOpTest"] = Function::New(env, MoveOperatorsTest);
217
415
 
218
416
  return exports;
219
417
  }