No Subject

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

No Subject

DASWorks
Hello:

I'm not sure where to insert the initialization function that was created via
toLua, and, despite various attempts, my simple test fails when called from
Lua.  Do you have any suggestions.  Is there an example, that demos this?
 Thank you very much in advance for your help.

David

int main (int argc, char *argv[])
{
  int i;
  int result = 0;
  
  iolib_open ();
  strlib_open ();
  mathlib_open ();
    
  toLua_test_1_open ();			/* via toLua ? */
  
  lua_register("testC", testC);
  if (argc < 2)
  . . . etc.
}


----------------------
Here is the output from toLua:
----------------------
#include "test_1.h"

#ifdef __cplusplus
extern "C"{
#endif
#include "lua.h"
#include "tolua.h"
#ifdef __cplusplus
}
#endif

static void toLua_beep (void)
{
 short i;

 if (!toLua_nistype(1,TOLUA_NUMBER_TAG)) {toLua_wrongarg("beep",1,"short");
return;}
 else  i = (short)toLua_ngetnumber(1);

 if (lua_getparam(2) != LUA_NOOBJECT) toLua_toomanyargs("beep");

 {
  beep(i);
 }
}

static void toLua_init_tags  (void)
{
 toLua_libtag("test_1");
}


/* ----------------------------------- PUBLIC INTERFACE */
void toLua_test_1_open (void)
{
 lua_beginblock();
 toLua_init();
 toLua_init_tags();

 /* Bind constants */

 /* Bind variables */

 /* Bind functions */
 lua_register("beep",toLua_beep);

 /* Bind classes */
 lua_endblock();

}

#ifdef __cplusplus
static int dummy = toLua_test_1_open();
#endif

Reply | Threaded
Open this post in threaded view
|

Lua & Objective-C?

Steve Dekorte
Is anyone using Lua with Objective-C?

I was just thinking about how easily the two could work together
since you'd only need to wrap a few runtime functions (like objc_messageSend)
to have full access to all Objective-C libraries.

Steve

Reply | Threaded
Open this post in threaded view
|

Re: Lua & Objective-C?

David Jeske-2
On Fri, Oct 17, 1997 at 02:55:06PM -0200, Steve Dekorte wrote:
> Is anyone using Lua with Objective-C?
> 
> I was just thinking about how easily the two could work together
> since you'd only need to wrap a few runtime functions (like objc_messageSend)
> to have full access to all Objective-C libraries.

If one were to do this, the best way would be to hook the tag functions
for lua "objects" and make all the Obj-C classes appear as Lua classes.
However, how would you handle mangling the argument/method naming
conventions? It would be decently messy. You would end up with:

an_objc_obj:doSomething_with_tIndex_(foo,bar,3);

On the other hand it wouldn't take much code and would work decently well.

-- 
David Jeske (N9LCA) + [hidden email]