lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


You could have a look at my solution in the source code for Grunt in LuaForge. The basic is to store C Closures in a table indexed by the command name. The closure stores the command id and the function reference as upvalues and is a closure over a generic C-Function which calls the function from the upvalue passing it the command id from the other upvalue and then passing through any other calling parameters.

 

From: lua-bounces@bazar2.conectiva.com.br [mailto:lua-bounces@bazar2.conectiva.com.br] On Behalf Of Gergely BOROMISSZA
Sent: 23 March 2009 13:06
To: Lua list
Subject: Function registration with parameter binding?

 

Hi!

My question is whether there’s a solution to bind a parameter of a given function registration.

I have a map with command id’s and command names. I want to bind the command names for a C function in Lua and the first (or any) parameter should be the command id and after that the other calling parameters.

My current solution is that I generate a string from code side: DoCommand( commandId, … ) , make a DoString and register the return function to the commandName. Of course I register the DoCommand function as well and do there what I really want.

Is there a more simple way to do the same maybe without string manipulation?

Thanks for the answers!

 

Kind regards,

Gergely BOROMISSZA
Developer

T: +36 (1) 872-0000
F: +36 (1) 872-0100
E: Gergely.BOROMISSZA@navngo.com

 

Nav N Go Kft.

Bérc u. 23.

H-1016 Budapest

Hungary

 

Nav N Go stands for innovative software for satellite navigation, mobile applications and content on a variety of platforms, enhanced by updates and online services delivered via www.naviextras.com. Find out more about us at www.navngo.com.

This message, including attachments, is confidential and may be privileged. If you are not an intended recipient, please notify the sender then delete and destroy the original message and all copies. You should not copy, forward and/or disclose this message, in whole or in part, without permission of the sender.

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature