Author Topic: code complete cannot list the lua's function  (Read 7838 times)

Offline momocc

  • Single posting newcomer
  • *
  • Posts: 3
code complete cannot list the lua's function
« on: April 20, 2012, 03:18:12 am »
my codeblocks cannot list the functions of lua.
i try to find out the reason why codeblocks cannot do it.
i found that there is a small difference between lua's function declaration and our usual practice.

Usually, we define a function like this:
Code
void func();
???
but the defination in lua is:
Code
void (func)();

so, the code completion cannot recognize the functions..
if i remove the brackets, the code completion will list the function name correctly

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: code complete cannot list the lua's function
« Reply #1 on: April 20, 2012, 03:30:30 am »
Code::Blocks is a C/C++ IDE, and its codecompletion parser is also for C/C++ currently.
Lua language is not supported right now.

BTW: There is a FORTRAN codecompletion plugin for FORTRAN language. So we welcome user contribution for lua language. :)
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline momocc

  • Single posting newcomer
  • *
  • Posts: 3
Re: code complete cannot list the lua's function
« Reply #2 on: April 20, 2012, 06:09:47 am »
Oh, the way i expressed has some wrong, i mean the code completion cannot list the functions of lua's C API.
i am doing a lua binding library for c++, so i often need to call the lua's C API to achieve some features :P

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: code complete cannot list the lua's function
« Reply #3 on: April 20, 2012, 01:32:52 pm »
Oh, the way i expressed has some wrong, i mean the code completion cannot list the functions of lua's C API.
i am doing a lua binding library for c++, so i often need to call the lua's C API to achieve some features :P
Still not clear about your idea. If you would like to show C API, should should have C code parsed by the CC's parser. Where is you C API declaration? Please give more details.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline jarod42

  • Multiple posting newcomer
  • *
  • Posts: 87
Re: code complete cannot list the lua's function
« Reply #4 on: April 20, 2012, 01:57:52 pm »
Code
int (bar_not_visible)();
int bar_visible();

void foo()
{
    ba|Ctrl+Space
}

code completion (for ba ) suggests only bar_visible, and not bar_not_visible.

Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 6077
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: code complete cannot list the lua's function
« Reply #5 on: April 20, 2012, 02:04:33 pm »
Ok, does it a .c file?
Another question is:
Code
int (bar_not_visible)();
Do you think this is a valid C function declaration? I don't.
If some piece of memory should be reused, turn them to variables (or const variables).
If some piece of operations should be reused, turn them to functions.
If they happened together, then turn them to classes.

Offline Freem

  • Almost regular
  • **
  • Posts: 218
Re: code complete cannot list the lua's function
« Reply #6 on: April 20, 2012, 02:22:01 pm »
It is an uncommon style, but I think it is valid.

In short, when you declare a callback, you declare a function pointer. So, a pointer which know the address of a function (I know that you perfectly know that, I am just going step by step to make things clear as best as I can).

For a classic variable, we use this:
Code
int foo;
For a classic pointer:
Code
int *pfoo;[code]

For function pointers:
[code]int (*pbar)(void);
So there are no reasons to think removing the pointer operand is not legal.
In fact, we could probably say that removing parenthesis is just a shortcut for easier read, and the parenthesis write is the good one.

To conclude, I have tried a very little program (which do nothing) and compiled it with "gcc foo.c -ansi" and it gaves me no error or warning.
Here it is:
Code
int (bar_not_v)();
int (bar_v)();

void main()
{
bar_v();
bar_not_v();
}

int bar_not_v()
{
}

int (bar_v)()
{
}
[/code][/code]

Offline momocc

  • Single posting newcomer
  • *
  • Posts: 3
Re: code complete cannot list the lua's function
« Reply #7 on: April 20, 2012, 06:51:18 pm »
Oh, the way i expressed has some wrong, i mean the code completion cannot list the functions of lua's C API.
i am doing a lua binding library for c++, so i often need to call the lua's C API to achieve some features :P
Still not clear about your idea. If you would like to show C API, should should have C code parsed by the CC's parser. Where is you C API declaration? Please give more details.

the C API declarations are in the Lua's header files
for example:
Code
// in lua.h
LUA_API lua_State *(lua_newstate) (lua_Alloc f, void *ud);