Author Topic: using lua api with C::B,but Some functions do not complete automatically  (Read 3252 times)

Offline omgfish

  • Multiple posting newcomer
  • *
  • Posts: 13
I've compiled the lua lib library and it works, however some functions do not complete automatically
such as lua_pushnumber
LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);
if i change it like this
LUA_API void        lua_pushnumber (lua_State *L, lua_Number n);
C::B's code complete works
so i think , the C::B code complete plugin don't works on the functions which name with ()
this is a bug?



Offline ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: using lua api with C::B,but Some functions do not complete automatically
« Reply #1 on: October 29, 2020, 04:15:52 pm »
Code
LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);

I think C::B's code completion parser failed to parse this above line as a function declaration.
So, it is a bug.
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 ollydbg

  • Developer
  • Lives here!
  • *****
  • Posts: 5910
  • OpenCV and Robotics
    • Chinese OpenCV forum moderator
Re: using lua api with C::B,but Some functions do not complete automatically
« Reply #2 on: October 29, 2020, 04:26:48 pm »
FYI

I see the parser in https://github.com/JoshDreamland/JustDefineIt can parse those code:

Code
// my_class.h
#define LUA_API
typedef int lua_State;
typedef int lua_Number;
namespace N
{
    class my_class
    {
    public:
        void do_something();
        LUA_API void        (lua_pushnumber) (lua_State *L, lua_Number n);
    };

}

Here is the log of the result when running the demo project of JustDefineIt.

Quote
Created blank file for preprocessing.
Polling GCC for include directories for c++03...
 - Command: gcc -E -x c++ --std=c++03 -v C:\Users\someuser\AppData\Local\Temp\jdi\bla
nk > C:\Users\someuser\AppData\Local\Temp\jdi\search_dirs.txt 2>&1
 - Command succeeded. System include paths:
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../
../../include/c++/10.2.0
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../
../../include/c++/10.2.0/x86_64-w64-mingw32
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../
../../include/c++/10.2.0/backward
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/includ
e
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../
../../include
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/includ
e-fixed
    - F:/msys64-20200924/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/10.2.0/../../
../../x86_64-w64-mingw32/include
Obtaining GCC defines list via command line: cpp -dM -x c++ --std=c++03 -E C:\Us
ers\someuser\AppData\Local\Temp\jdi\blank > C:\Users\someuser\AppData\Local\Temp\jdi\defin
es.cc
Command succeeded. Reading in GCC definitions.Beginning parse of file `"test.h"`
...

====[++++++++++++++++++++++++++++++ SUCCESS! ++++++++++++++++++++++++++++++]====


Parse completed with 0 errors and 0 warnings.
Commands are single-letter; 'h' for help.
Follow commands with ENTER on non-unix.
> d ::
Enter the item to define:
>> {
  typedef int lua_State;
  typedef int lua_Number;
  namespace N {
    class my_class
    {
      void do_something();
      void lua_pushnumber(lua_State *L, lua_Number n);
    }
  }
}
>


Note that when I run the command "d ::", it can print the tree correctly.
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.