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

Function Init

src/NodeRTLib/CppTemplates/InitExports.cpp:2–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1
2 static void Init(const Local<Object> exports) {
3 HandleScope scope;
4
5 Local<FunctionTemplate> localRef = Nan::New<FunctionTemplate>(New);
6 s_constructorTemplate.Reset(localRef);
7 localRef->SetClassName(Nan::New<String>("@(Model.Name)").ToLocalChecked());
8 localRef->InstanceTemplate()->SetInternalFieldCount(1);
9
10 @if(Model.MemberASyncMethods.Length > 0 || Model.StaticASyncMethods.Length > 0) {
11 @:Local<Function> func;
12 @:Local<FunctionTemplate> funcTemplate;
13 }
14
15 @if(Model.MemberSyncMethods.Length > 0) {
16 @:
17 foreach(var method in Model.MemberSyncMethods) {
18 @:Nan::SetPrototypeMethod(localRef, "@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))", @(TX.CSharpMethodToCppMethod(method.Name)));
19 }
20 @:
21 }
22
23 @if(Model.MemberASyncMethods.Length > 0) {
24 @:
25 foreach(var method in Model.MemberASyncMethods) {
26 @:Nan::SetPrototypeMethod(localRef, "@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))", @TX.CSharpMethodToCppMethod(method.Name));
27 }
28 @:
29 }
30
31 @if(Model.HasMemberEvents) {
32 @:
33 @:Nan::SetPrototypeMethod(localRef,"addListener", AddListener);
34 @:Nan::SetPrototypeMethod(localRef,"on", AddListener);
35 @:Nan::SetPrototypeMethod(localRef,"removeListener", RemoveListener);
36 @:Nan::SetPrototypeMethod(localRef, "off", RemoveListener);
37 }
38
39 @if(Model.MemberProperties.Length > 0) {
40 @:
41 foreach(var prop in Model.MemberProperties) {
42 var propName = TX.Uncap(prop.Name);
43 if (prop.GetSetMethod() != null) {
44 @:Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("@(propName)").ToLocalChecked(), @(prop.Name)Getter, @(prop.Name)Setter);
45 } else {
46 @:Nan::SetAccessor(localRef->PrototypeTemplate(), Nan::New<String>("@(propName)").ToLocalChecked(), @(prop.Name)Getter);
47 }
48 }
49 }
50
51 Local<Object> constructor = Nan::To<Object>(Nan::GetFunction(localRef).ToLocalChecked()).ToLocalChecked();
52 Nan::SetMethod(constructor, "castFrom", CastFrom);
53
54 @{
55 if(Model.StaticSyncMethods.Length > 0) {
56 foreach(var method in Model.StaticSyncMethods) {
57 @:Nan::SetMethod(constructor, "@(TX.Uncap(TX.CSharpMethodToCppMethod(method.Name)))", @TX.CSharpMethodToCppMethod(method.Name));
58 }
59 }
60 if (Model.StaticASyncMethods.Length > 0) {

Callers 10

CreateArrayWrapperMethod · 0.85
CreateIteratorWrapperMethod · 0.85
CreateIterableWrapperMethod · 0.85
CreateVectorWrapperMethod · 0.85
CreateMapViewWrapperMethod · 0.85
CreateMapWrapperMethod · 0.85
OpaqueWrapper.cppFile · 0.85
Type.cppFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected