lua-users home
lua-l archive

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


And here is another example - this time extracting the symbols in C
code into a Lua table.

local somecode = [[
extern int adder(int a, int b);

int adder(int a, int b)
{
return a+b;
}
]]

local symbols = dmrc.getsymbols(somecode)

table_print(symbols)

The output goes like this:

[1] => table
    (
       [1] => table
           (
              [startcol] => 17
              [endline] => 1
              [file] => buffer
              [type] => function
              [id] => 1
              [endcol] => 31
              [builtintype] => int
              [arguments] => table
                  (
                     [1] => table
                         (
                            [startcol] => 18
                            [endline] => 1
                            [file] => buffer
                            [ident] => a
                            [id] => 2
                            [endcol] => 23
                            [builtintype] => int
                            [startline] => 1
                            [alignment] => 4
                            [offset] => 0
                            [bitsize] => 32
                            [type] => node
                         )
                     [2] => table
                         (
                            [startcol] => 25
                            [endline] => 1
                            [file] => buffer
                            [ident] => b
                            [id] => 3
                            [endcol] => 30
                            [builtintype] => int
                            [startline] => 1
                            [alignment] => 4
                            [offset] => 0
                            [bitsize] => 32
                            [type] => node
                         )
                  )
              [alignment] => 4
              [offset] => 0
              [bitsize] => 32
              [startline] => 1
           )
       [startline] => 1
       [basetype] => 1
       [extern] => 1
       [toplevel] => 1
       [offset] => 0
       [bitsize] => 32
       [signed] => 1
       [endline] => 1
       [file] => buffer
       [ident] => adder
       [id] => 0
       [endcol] => 31
       [prototype] => 1
       [type] => node
       [startcol] => 12
       [addressable] => 1
       [alignment] => 4
    )

<truncated>