How can I get the signature of a registered function

View: New views
2 Messages — Rating Filter:   Alert me  

How can I get the signature of a registered function

by Román Montes Muñoz :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi everyone!
 
I'm trying to do an autocompleter like (Visual Studio IntelliSense) for LUA but I have a problem, I can't obtain function signatures.
 
I do the following:
 
...
if(luabind::type(table) == LUA_TTABLE)
{
   for(luabind::iterator i(table), end; i != end; ++i)
   {
      const luabind::object& key_obj = i.key();
      const luabind::object& obj = *i;
      ...
 
      switch(luabind::type(*i))
      {
         case LUA_FUNCTION:
            ...
            ... 
      }
   }
...
 
Checking the LUA type of my luabind object obj, I can know if this is a global variable, a function, a class, ... But I don't find a method or something to obtain the signature in the case that the obj is a function.
 
Can anybody help me?
 
Thank you very much and sorry for my poor English!  

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user

Re: How can I get the signature of a registered function

by Ilia Trendafilov :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

I don't think you can do that. Based on the description of
lua_pushcclosure
(http://www.lua.org/manual/5.1/manual.html#lua_pushcclosure) and
lua_CFunction (http://www.lua.org/manual/5.1/manual.html#lua_CFunction)
it seems that only the function itself "knows" how many parameters it
can handle. Basically, Lua will allow you to call any function with
any number of parameters, it's the function's responsibility to handle
missing or extra parameters. Having a function in the Lua stack or
luabind::object of type function cannot give you any information about
the function - not even the number of parameters.

2009/10/13 Román Montes Muñoz <romanmontes@...>:

> Hi everyone!
>
> I'm trying to do an autocompleter like (Visual Studio IntelliSense) for
> LUA but I have a problem, I can't obtain function signatures.
>
> I do the following:
>
> ...
> if(luabind::type(table) == LUA_TTABLE)
> {
>    for(luabind::iterator i(table), end; i != end; ++i)
>    {
>       const luabind::object& key_obj = i.key();
>       const luabind::object& obj = *i;
>       ...
>
>       switch(luabind::type(*i))
>       {
>          case LUA_FUNCTION:
>             ...
>             ...
>       }
>    }
> ...
>
> Checking the LUA type of my luabind object obj, I can know if this is a
> global variable, a function, a class, ... But I don't find a method or
> something to obtain the signature in the case that the obj is a function.
>
> Can anybody help me?
>
> Thank you very much and sorry for my poor English!
> ------------------------------------------------------------------------------
> Come build with us! The BlackBerry(R) Developer Conference in SF, CA
> is the only developer event you need to attend this year. Jumpstart your
> developing skills, take BlackBerry mobile applications to market and stay
> ahead of the curve. Join us from November 9 - 12, 2009. Register now!
> http://p.sf.net/sfu/devconference
> _______________________________________________
> luabind-user mailing list
> luabind-user@...
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
luabind-user mailing list
luabind-user@...
https://lists.sourceforge.net/lists/listinfo/luabind-user