Last active
September 29, 2024 14:57
-
-
Save fjolnir/2211379 to your computer and use it in GitHub Desktop.
LuaJIT ObjC bridge
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
The bridge is now located at https://github.com/fjolnir/TLC |
Fixed cache.
Added option to toggle automatically appending underscores on selectors(enabled by default)
Moved CG types from global to objc namespace
Added __tostring to objects and selectors so you can now print() them directly
fixes
Added convenience functions to convert lua values to objects. NSArr(), NSDic(), NSNum(), NSStr() and the general Obj() which type checks and calls the correct function
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're welcome :-)
Some more suggestions:
I removed all assignments from the fast path, and added a cache for the class names as well (with weak keys).
I also rewrote the column appending code, with the assumption that there is at most one trailing column. More readable and efficient this way, but it doesn't notice when people pass too many parameters (beside the first one). Since this check is only performed the first time a method is called, I supposed that I could drop it.
On the same topic:
I'm not very familiar with ObjC, so I may be wrong, but isn't it possible to have both
msg
andmsg:
as distinct messages on the same class? If yes, then the current caching behavior is flawed, and you'd have to make trailing underscores mandatory (if you want to keep the doc simple g), witch is ugly, but you may not have the choice...This is 100% untested (typed in the browser).
Edit: I also updated my log function suggestion above to make it more robust.
table.concat
doesn't generate the intermediate strings, which otherwise have to be interned and collected.Edit2 : These are still globals (and should be defined with
ffi.typeof()
according to Mike Pall. I'm not familiar with the FFI, but I suppose he's right g)