News for hackers. Stuff that matters.
Re:TLC, a tiny lua cocoa bridge by jws on Wednesday March 28, 2012 @09:24AM (#3766070)
That is a spectacular amount of functionality in one small source file. It appears to open all objective C classes and their methods to Lua.
Re:TLC, a tiny lua cocoa bridge by gravitronic on Wednesday March 28, 2012 @10:47AM (#3766478)
I looked at these comments before the code and assumed it was going to be an ugly first-principals dump of code connecting lua to objc.

What I found instead is beautiful.

Re:TLC, a tiny lua cocoa bridge by limmeau on Wednesday March 28, 2012 @09:47AM (#3766191)
Plus it claims to have the Lua GC perform automatic ObjC refcounting.
Re:TLC, a tiny lua cocoa bridge by seany on Wednesday March 28, 2012 @12:26PM (#3767013)
What's the reason to use this over https://bitbucket.org/ewing/luacocoa ?
Re:TLC, a tiny lua cocoa bridge by rainysunday on Wednesday March 28, 2012 @10:52AM (#3766515)
Amazing. Can you use this to run a LuaCocoa example? Like https://bitbucket.org/ewing/luacocoa/src/e939d422b62a/LuaCoc...

Can you load a framework with this? I know hardly anything about Objective-C.

Re:TLC, a tiny lua cocoa bridge by fyolnish on Wednesday March 28, 2012 @11:07AM (#3766598)
There's no need to load a framework since linking to a framework means all of it's classes are added to the runtime. You simply request the class you want. That is, if you are embedding lua in your app.

I haven't tried using TLC from the standalone luajit interpreter, but in that case you would probably have to use fii.load() to load the Framework & libobjc before being able to use objc. But that is not what it was designed for

To translate a LuaCocoa example you'd in most cases just have to add objc_loadClass calls for any class you want to use, and use dots instead of colons to call methods (obj:method() -> obj.method() ).

Re:TLC, a tiny lua cocoa bridge by wildmXranat on Wednesday March 28, 2012 @10:32AM (#3766396)
Hmm, this looks very interesting. Could it be used as a scripting layer within a OSX/iOS application or could you whip up a complete application with this ?
Re:TLC, a tiny lua cocoa bridge by fyolnish on Wednesday March 28, 2012 @10:42AM (#3766449)
It was designed for use for scripting within an objc app. (http://github.com/aptiva/tranquil to be precise)

It doesn't support subclassing objective-c objects so that would probably limit you if you tried to write your app exclusively in lua.

Re:TLC, a tiny lua cocoa bridge by pirateking on Wednesday March 28, 2012 @11:55AM (#3766843)
Anyone know any real world examples of Lua being used with Objective-C, and what use cases it is good for? Sounds very interesting.
Re:TLC, a tiny lua cocoa bridge by hjaltij on Wednesday March 28, 2012 @12:19PM (#3766971)
Take a look at the app that the OP is building. It's pretty interesting and uses this scripting bridge for generating OpenGL visuals. (http://github.com/aptiva/tranquil)
Re:TLC, a tiny lua cocoa bridge by prpatel on Wednesday March 28, 2012 @10:29AM (#3766381)
Question: how is this different than iPhoneWax?
Re:TLC, a tiny lua cocoa bridge by fyolnish on Wednesday March 28, 2012 @10:38AM (#3766426)
Well, the biggest difference is that it's written in Lua. And it uses LuaJIT not vanilla Lua. (LuaJIT being orders of magnitude faster)

And from what I can tell, iphonewax is intended for writing entire apps in lua, this project is intended to be used when embedding bits of lua code in your objc app. (But there's nothing stopping you from writing most of your app in it)

Re:TLC, a tiny lua cocoa bridge by atilimcetin on Wednesday March 28, 2012 @09:29AM (#3766094)
Is it using LuaJIT or any another ffi library?
Re:TLC, a tiny lua cocoa bridge by pygy_ on Wednesday March 28, 2012 @10:24AM (#3766353)
James McKaskill ported LuaJIT's FFI to standard (PUC) Lua, but there are a few differences. I don't know for which one it was developed.

https://github.com/jmckaskill/luaffi

Re:TLC, a tiny lua cocoa bridge by chrisdevereux on Wednesday March 28, 2012 @09:47AM (#3766197)
Re:TLC, a tiny lua cocoa bridge by fyolnish on Wednesday March 28, 2012 @10:27AM (#3766368)
Yes, it does indeed require LuaJIT. (I probably should indicate this more clearly in the source)
Re:TLC, a tiny lua cocoa bridge by pygy_ on Wednesday March 28, 2012 @10:35AM (#3766411)
Did you try it in vanilla Lua with the FFI port linked in a sibling of your post?
Re:TLC, a tiny lua cocoa bridge by fyolnish on Wednesday March 28, 2012 @10:47AM (#3766476)
Nope, can't say I have.
Re:TLC, a tiny lua cocoa bridge by akadien on Wednesday March 28, 2012 @10:17AM (#3766320)
It's LuaJIT (FFI). Legacy wrappers involve mostly C code and a lot of code managing metatables.
Re:TLC, a tiny lua cocoa bridge by dubya on Wednesday March 28, 2012 @09:34AM (#3766125)
I know exactly zero Lua, but

  if ffi == nil then
  	ffi = require("ffi")
  end
is suggestive.
Re:TLC, a tiny lua cocoa bridge by gregholmberg on Wednesday March 28, 2012 @03:37PM (#3767961)
There are some idioms in Lua that you might recognize from Python or Ruby. I have seen this one in Perl and the Bourne shell, as well.

  ffi = ffi or require("ffi")
If the ffi expression evaluates to something that is not nil, we keep the previous value of ffi. The assignment becomes a no-op.

If it evaluates to a nil, we initialize it by calling require().

Re:TLC, a tiny lua cocoa bridge by fyolnish on Friday March 30, 2012 @05:57AM (#3775179)
Re:TLC, a tiny lua cocoa bridge by seclorum on Wednesday March 28, 2012 @10:15AM (#3766313)
Amazing .. off to pack it into an iOS bundle and wire it up to an editor. ;)