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

Function CastFrom

src/NodeRTLib/CppTemplates/CastFrom.cpp:2–18  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1
2 static void CastFrom(Nan::NAN_METHOD_ARGS_TYPE info) {
3 HandleScope scope;
4 if (info.Length() < 1 || !NodeRT::Utils::IsWinRtWrapperOf<@TX.ToWinRT(Model.Type)>(info[0])) {
5 Nan::ThrowError(Nan::Error(NodeRT::Utils::NewString(L"Invalid arguments, no object provided, or given object could not be casted to requested type")));
6 return;
7 }
8
9 @TX.ToWinRT(Model.Type) winRtInstance;
10 try {
11 winRtInstance = (@TX.ToWinRT(Model.Type)) NodeRT::Utils::GetObjectInstance(info[0]);
12 } catch (Platform::Exception ^exception) {
13 NodeRT::Utils::ThrowWinRtExceptionInJs(exception);
14 return;
15 }
16
17 info.GetReturnValue().Set(Wrap@(Model.Name)(winRtInstance));
18 }

Callers

nothing calls this directly

Calls 3

NewStringFunction · 0.85
ToWinRTMethod · 0.45
SetMethod · 0.45

Tested by

no test coverage detected