Creating a Lua plugin with Objective C Knowledge
I want to build a plugin for an application(TeamSpeak), however I have no lu开发者_StackOverflowa knowledge. Is it possible to somehow wrap or bridge my Obj-C knowledge to lua?
If needed I could learn the basic syntax of lua to get my plugin started, but ultimately I want the meat of the program in Obj-C.Any advice appreciated!
Lua's api written in c so rather than going from obj-c to Lua, you will have to go from obj-c to c to Lua. This is not as bad as it sounds though, obj-c and c play well together so you can have functions to expose to Lua in your .m source files and/or use .c source files in your project. As far as I know there isn't a luabind type library for obj-c but if you are using c++ with your obj-c this may also be an option.
Once you get past the stack manipulation, you will probably find the api pretty intuitive. The c api for tables can be a little confusing at first but it is also extremely powerful and allows you to expose your application's functions in many interesting ways.
Lua is a fairly simple, yet extremely powerful language. For example, there is only one datastructure: tables. Unless you are trying to do complex things with metatables you can probably dive right in with little trouble coming from Objective C. Do note that array indices (i.e. tables with sequential numerical keys) are 1-based instead of 0-based. Take a look at Programming in Lua (PiL) to get started.
Search for iPhone Wax on Google. Might not be what you need, but might help your needs. It lets you call Obj-C via Lua.
精彩评论