MCPcopy Create free account
hub / github.com/Tencent/UnLua / Bind

Method Bind

Plugins/UnLua/Source/UnLua/Private/Registries/DelegateRegistry.cpp:143–167  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

141 }
142
143 void FDelegateRegistry::Bind(lua_State* L, int32 Index, FScriptDelegate* Delegate, UObject* SelfObject)
144 {
145 check(lua_type(L, Index) == LUA_TFUNCTION);
146 const auto LuaFunction = lua_topointer(L, Index);
147 auto& Info = Delegates.FindChecked(Delegate);
148 if (!Info.Owner.IsValid())
149 Info.Owner = SelfObject;
150
151 const auto DelegatePair = FLuaDelegatePair(SelfObject, LuaFunction);
152 const auto Cached = CachedHandlers.Find(DelegatePair);
153 if (Cached && Cached->IsValid())
154 {
155 (*Cached)->BindTo(Delegate);
156 Info.Handlers.Add(*Cached);
157 return;
158 }
159
160 lua_pushvalue(L, Index);
161 const auto Ref = luaL_ref(L, LUA_REGISTRYINDEX);
162 const auto Handler = CreateHandler(Ref, Info.Owner.Get(), SelfObject);
163 Handler->BindTo(Delegate);
164 Env->AutoObjectReference.Add(Handler);
165 CachedHandlers.Add(DelegatePair, Handler);
166 Info.Handlers.Add(Handler);
167 }
168
169 void FDelegateRegistry::Unbind(void* Delegate)
170 {

Callers

nothing calls this directly

Calls 11

checkFunction · 0.85
lua_typeFunction · 0.85
lua_topointerFunction · 0.85
FLuaDelegatePairClass · 0.85
lua_pushvalueFunction · 0.85
luaL_refFunction · 0.85
BindToMethod · 0.80
IsValidMethod · 0.45
FindMethod · 0.45
AddMethod · 0.45
GetMethod · 0.45

Tested by

no test coverage detected