Skip to content

Commit a8b7fd9

Browse files
Refactor addCallback to check function type before adding
Simplifies the addCallback method by only adding the callback if the provided function is of type TFunction, aligning with PsychLua's expectations and removing unnecessary null checks. Co-Authored-By: Homura <[email protected]>
1 parent fcb9dd4 commit a8b7fd9

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

source/psychlua/Convert.hx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ class Convert
1515
{
1616
public static function addCallback(l:State, name:String, func:Dynamic)
1717
{
18-
// PsychLua expects the function to be null for local callbacks, too lazy to do something about that
19-
if (Type.typeof(func) != TFunction || func == null)
20-
return;
21-
22-
callbacks.set(name, func);
18+
// PsychLua expects the function to be null for local callbacks so if func is not TFunction we don't add the callback here
19+
if (Type.typeof(func) == TFunction)
20+
callbacks.set(name, func);
2321

2422
Lua.pushstring(l, name);
2523
Lua.pushcclosure(l, cpp.Callable.fromStaticFunction(handleCallback), 1);

0 commit comments

Comments
 (0)