| 19 | } |
| 20 | |
| 21 | void DefineProperties(const CallbackInfo& info) { |
| 22 | Object obj = info[0].As<Object>(); |
| 23 | String nameType = info[1].As<String>(); |
| 24 | Env env = info.Env(); |
| 25 | |
| 26 | if (nameType.Utf8Value() == "literal") { |
| 27 | obj.DefineProperties({ |
| 28 | PropertyDescriptor::Accessor("readonlyAccessor", TestGetter), |
| 29 | PropertyDescriptor::Accessor( |
| 30 | "readwriteAccessor", TestGetter, TestSetter), |
| 31 | PropertyDescriptor::Function("function", TestFunction), |
| 32 | }); |
| 33 | } else if (nameType.Utf8Value() == "string") { |
| 34 | // VS2013 has lifetime issues when passing temporary objects into the |
| 35 | // constructor of another object. It generates code to destruct the object |
| 36 | // as soon as the constructor call returns. Since this isn't a common case |
| 37 | // for using std::string objects, I'm refactoring the test to work around |
| 38 | // the issue. |
| 39 | std::string str1("readonlyAccessor"); |
| 40 | std::string str2("readwriteAccessor"); |
| 41 | std::string str7("function"); |
| 42 | |
| 43 | obj.DefineProperties({ |
| 44 | PropertyDescriptor::Accessor(str1, TestGetter), |
| 45 | PropertyDescriptor::Accessor(str2, TestGetter, TestSetter), |
| 46 | PropertyDescriptor::Function(str7, TestFunction), |
| 47 | }); |
| 48 | } else if (nameType.Utf8Value() == "value") { |
| 49 | obj.DefineProperties({ |
| 50 | PropertyDescriptor::Accessor(Napi::String::New(env, "readonlyAccessor"), |
| 51 | TestGetter), |
| 52 | PropertyDescriptor::Accessor( |
| 53 | Napi::String::New(env, "readwriteAccessor"), |
| 54 | TestGetter, |
| 55 | TestSetter), |
| 56 | PropertyDescriptor::Function(Napi::String::New(env, "function"), |
| 57 | TestFunction), |
| 58 | }); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | } // end of anonymous namespace |
| 63 |
nothing calls this directly
no test coverage detected