MCPcopy Create free account
hub / github.com/Tencent/sluaunreal / Foo

Class Foo

Source/democpp/SluaTestCase.cpp:48–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

46 };
47
48 class Foo : public Base {
49
50 LuaClassBody()
51
52 public:
53 Foo(int v):value(v) {}
54 virtual ~Foo() {
55 Log::Log("Foo object %p had been freed",this);
56 }
57
58 // constructor function for lua
59 // LuaOwnedPtr will hold ptr by lua and auto collect it;
60 static LuaOwnedPtr<Foo> create(int v) {
61 return new Foo(v);
62 }
63
64 // raw ptr not hold by lua, lua not collect it
65 static const Foo* getInstance() {
66 static Foo s_inst(2048);
67 return &s_inst;
68 }
69
70 EInputEvent testEnum(const char* v, EInputEvent evt) {
71 Log::Log("get text %s, evt is %d", v, evt);
72 return evt;
73 }
74
75 void bar(const char* v) {
76 Log::Log("get text %s and value is %d",v,value);
77 }
78
79 static FString getStr() {
80 return FString(UTF8_TO_TCHAR("some text"));
81 }
82
83 virtual int virtualFunc() const {
84 Log::Log("virtual func from Foo");
85 return 1;
86 }
87
88 Fruit getFruit() {
89 return Fruit::Apple;
90 }
91
92 // overriade version
93 Fruit getFruit(int) {
94 return Fruit::Apple;
95 }
96
97 void setCallback(const TFunction<void(int)>& func) {
98 callback = func;
99 }
100
101 void docall() {
102 callback(1024);
103 callback = nullptr;
104 }
105

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected