|
2 | 2 |
|
3 | 3 | using namespace Napi;
|
4 | 4 |
|
| 5 | +// Native wrappers for testing Object::Get() |
| 6 | +Value GetPropertyWithNapiValue(const CallbackInfo& info); |
| 7 | +Value GetPropertyWithNapiWrapperValue(const CallbackInfo& info); |
| 8 | +Value GetPropertyWithCStyleString(const CallbackInfo& info); |
| 9 | +Value GetPropertyWithCppStyleString(const CallbackInfo& info); |
| 10 | + |
| 11 | +// Native wrappers for testing Object::Set() |
| 12 | +void SetPropertyWithNapiValue(const CallbackInfo& info); |
| 13 | +void SetPropertyWithNapiWrapperValue(const CallbackInfo& info); |
| 14 | +void SetPropertyWithCStyleString(const CallbackInfo& info); |
| 15 | +void SetPropertyWithCppStyleString(const CallbackInfo& info); |
| 16 | + |
| 17 | +// Native wrappers for testing Object::Delete() |
| 18 | +Value DeletePropertyWithNapiValue(const CallbackInfo& info); |
| 19 | +Value DeletePropertyWithNapiWrapperValue(const CallbackInfo& info); |
| 20 | +Value DeletePropertyWithCStyleString(const CallbackInfo& info); |
| 21 | +Value DeletePropertyWithCppStyleString(const CallbackInfo& info); |
| 22 | + |
| 23 | +// Native wrappers for testing Object::HasOwnProperty() |
| 24 | +Value HasOwnPropertyWithNapiValue(const CallbackInfo& info); |
| 25 | +Value HasOwnPropertyWithNapiWrapperValue(const CallbackInfo& info); |
| 26 | +Value HasOwnPropertyWithCStyleString(const CallbackInfo& info); |
| 27 | +Value HasOwnPropertyWithCppStyleString(const CallbackInfo& info); |
| 28 | + |
5 | 29 | static bool testValue = true;
|
6 | 30 |
|
7 | 31 | Value TestGetter(const CallbackInfo& info) {
|
@@ -88,32 +112,6 @@ void DefineValueProperty(const CallbackInfo& info) {
|
88 | 112 | obj.DefineProperty(PropertyDescriptor::Value(name, value));
|
89 | 113 | }
|
90 | 114 |
|
91 |
| -Value GetProperty(const CallbackInfo& info) { |
92 |
| - Object obj = info[0].As<Object>(); |
93 |
| - Name name = info[1].As<Name>(); |
94 |
| - Value value = obj.Get(name); |
95 |
| - return value; |
96 |
| -} |
97 |
| - |
98 |
| -void SetProperty(const CallbackInfo& info) { |
99 |
| - Object obj = info[0].As<Object>(); |
100 |
| - Name name = info[1].As<Name>(); |
101 |
| - Value value = info[2]; |
102 |
| - obj.Set(name, value); |
103 |
| -} |
104 |
| - |
105 |
| -Value DeleteProperty(const CallbackInfo& info) { |
106 |
| - Object obj = info[0].As<Object>(); |
107 |
| - Name name = info[1].As<Name>(); |
108 |
| - return Boolean::New(info.Env(), obj.Delete(name)); |
109 |
| -} |
110 |
| - |
111 |
| -Value HasOwnProperty(const CallbackInfo& info) { |
112 |
| - Object obj = info[0].As<Object>(); |
113 |
| - Name name = info[1].As<Name>(); |
114 |
| - return Boolean::New(info.Env(), obj.HasOwnProperty(name)); |
115 |
| -} |
116 |
| - |
117 | 115 | Value CreateObjectUsingMagic(const CallbackInfo& info) {
|
118 | 116 | Env env = info.Env();
|
119 | 117 | Object obj = Object::New(env);
|
@@ -142,10 +140,27 @@ Object InitObject(Env env) {
|
142 | 140 | exports["GetPropertyNames"] = Function::New(env, GetPropertyNames);
|
143 | 141 | exports["defineProperties"] = Function::New(env, DefineProperties);
|
144 | 142 | exports["defineValueProperty"] = Function::New(env, DefineValueProperty);
|
145 |
| - exports["getProperty"] = Function::New(env, GetProperty); |
146 |
| - exports["setProperty"] = Function::New(env, SetProperty); |
147 |
| - exports["deleteProperty"] = Function::New(env, DeleteProperty); |
148 |
| - exports["hasOwnPropertyFromNative"] = Function::New(env, HasOwnProperty); |
| 143 | + |
| 144 | + exports["getPropertyWithNapiValue"] = Function::New(env, GetPropertyWithNapiValue); |
| 145 | + exports["getPropertyWithNapiWrapperValue"] = Function::New(env, GetPropertyWithNapiWrapperValue); |
| 146 | + exports["getPropertyWithCStyleString"] = Function::New(env, GetPropertyWithCStyleString); |
| 147 | + exports["getPropertyWithCppStyleString"] = Function::New(env, GetPropertyWithCppStyleString); |
| 148 | + |
| 149 | + exports["setPropertyWithNapiValue"] = Function::New(env, SetPropertyWithNapiValue); |
| 150 | + exports["setPropertyWithNapiWrapperValue"] = Function::New(env, SetPropertyWithNapiWrapperValue); |
| 151 | + exports["setPropertyWithCStyleString"] = Function::New(env, SetPropertyWithCStyleString); |
| 152 | + exports["setPropertyWithCppStyleString"] = Function::New(env, SetPropertyWithCppStyleString); |
| 153 | + |
| 154 | + exports["deletePropertyWithNapiValue"] = Function::New(env, DeletePropertyWithNapiValue); |
| 155 | + exports["deletePropertyWithNapiWrapperValue"] = Function::New(env, DeletePropertyWithNapiWrapperValue); |
| 156 | + exports["deletePropertyWithCStyleString"] = Function::New(env, DeletePropertyWithCStyleString); |
| 157 | + exports["deletePropertyWithCppStyleString"] = Function::New(env, DeletePropertyWithCppStyleString); |
| 158 | + |
| 159 | + exports["hasOwnPropertyWithNapiValue"] = Function::New(env, HasOwnPropertyWithNapiValue); |
| 160 | + exports["hasOwnPropertyWithNapiWrapperValue"] = Function::New(env, HasOwnPropertyWithNapiWrapperValue); |
| 161 | + exports["hasOwnPropertyWithCStyleString"] = Function::New(env, HasOwnPropertyWithCStyleString); |
| 162 | + exports["hasOwnPropertyWithCppStyleString"] = Function::New(env, HasOwnPropertyWithCppStyleString); |
| 163 | + |
149 | 164 | exports["createObjectUsingMagic"] = Function::New(env, CreateObjectUsingMagic);
|
150 | 165 |
|
151 | 166 | return exports;
|
|
0 commit comments