|
Binding a function in a class is nothing more than this:[Pancake.Script.AttrLuaFunc( "Log", "Log to activity console", "string to log" )] public void Log( string _message ) { ListViewItem item = activityconsole.Items.Add( _message ); item.EnsureVisible(); }
...which will spit out the name and description of itself and it's params if queried... (oh, and binding a class etc is simply rather meaningless, since it's already in .net to begin with)
Not sure how any of that would be done even remotely as elegant with C, but probably some form of elaborate wrapping mechanism, or as Matias
suggested, using the debug library.Sorry for ranting, I just like using it this way, it's like a fresh breeze compared to C+lua (even though that's an order of magnitude easier than most other scripting languages), and I do have to say, this list is pretty predominantly C related... :)
Keffo. Wesley Smith wrote:
When you say it's easy in C#, how would this be any different from C++? wes On 9/14/07, Stefan Sandberg <keffo.sandberg@gmail.com> wrote:It's very easy and elegant in C#.. http://www.gamedev.net/reference/articles/article2275.asp Matias Guijarro wrote:Hello, I would like to implement a kind of "help" function, that would return a string documenting the function, taken from the function source code (like Python docstrings...). Maybe someone already tried ? For Lua functions, I think a possible solution would be to use the debug library (debug.getinfo) to find the source file and to extract a kind of "docstring" out of the function code. Of course it will not be possible to do the same for functions defined at runtime (for example if someone does "f=function() return 'HELLO' end" no docstring can be extracted...)... And what about C functions ? If I write a Lua library with C functions, I have no idea how I could get a "docstring" out of it. Any ideas ? Thanks in advance!!!