MCPcopy Create free account
hub / github.com/NodeRT/NodeRT / Setter

Function Setter

src/NodeRTLib/CppTemplates/MemberPropertySetter.cpp:1–24  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1 static void @(Model.Name)Setter(Local<String> property, Local<Value> value, const Nan::PropertyCallbackInfo<void> &info) {
2 HandleScope scope;
3
4 if (!@(String.Format(Converter.TypeCheck(Model.PropertyType, TX.MainModel.Types.ContainsKey(Model.PropertyType)),"value"))) {
5 Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Value to set is of unexpected type")));
6 return;
7 }
8
9 if (!NodeRT::Utils::IsWinRtWrapperOf<@(TX.ToWinRT(Model.DeclaringType,true))>(info.This())) {
10 return;
11 }
12
13 @(Model.DeclaringType.Name) *wrapper = @(Model.DeclaringType.Name)::Unwrap<@(Model.DeclaringType.Name)>(info.This());
14
15 try {@{
16 var winrtConversionInfo = Converter.ToWinRT(Model.PropertyType); }
17
18 @(winrtConversionInfo[0]) winRtValue = @(string.Format(winrtConversionInfo[1], "value"));
19
20 wrapper->_instance->@(Model.Name) = winRtValue;
21 } catch (Platform::Exception ^exception) {
22 NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
23 }
24 }

Callers

nothing calls this directly

Calls 3

NewStringFunction · 0.85
TypeCheckMethod · 0.80
ToWinRTMethod · 0.45

Tested by

no test coverage detected