From: Patrick <patrick@spellingbeewinnars.org>
Subject: Please help with my lua binding
Date: Wed, 2 Jan 2013 10:46:13 -0800 (PST)
Date: 2013-01-02T10:46:13-08:00 [thread overview]
Message-ID: <38857635-8ab5-4ff6-b547-f40ac31720a2@googlegroups.com> (raw)
Hello Everyone
I am trying to make a binding to Lua.
Although I had to comment out a couple of functions, I have three compiling spec files for the three lua headers that are needed to form a binding.
I have a great free pascal binding to use as an example
I used fdump-ada-spec-slim and it helped a lot. I was able to sort out most of the types and macros by hand.
In lua, lua_State holds the instance of lua. It is an empty struct in the header and fdump skips it.
I don't really know how to represent this structure in lua.
I tried to define it as:
type lua_State is access lua_State;
pragma Import (C, lua_State, "lua_State");
but when I call it in this piece of code:
with lauxlib_h ; use lauxlib_h ;
with lualib_h ; use lualib_h ;
with lua_h ; use lua_h ;
procedure test is
result : Integer ;
type L is access lua_State ;
begin
L := luaL_newstate ;
end test ;
I get this:
test.adb:27:01: invalid use of subtype mark in expression or call
lua_h.ads:149:26: type "lua_State" cannot be used before end of its declaration
lua_h.ads:150:19: second argument of pragma "import" must be object or subprogram
gnatmake: "test.adb" compilation error
In the pascal biding lua_State is:
Plua_State = Pointer;
They put a P at the start to show it is a pointer.
An example of it's use in C is:
int main(void)
{
lua_State *L;
L = luaL_newstate(); /* Create Lua state variable */
luaL_openlibs(L); /* Load Lua libraries */
continues....
interfaces.C helps me a lot but outside of it I get mixed up working with C. Does anyone have any hints on how I could define lua_State in my spec file?
Thanks for reading.
next reply other threads:[~2013-01-02 18:46 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-02 18:46 Patrick [this message]
2013-01-02 19:03 ` Please help with my lua binding Patrick
2013-01-02 19:31 ` Florian Weimer
2013-01-02 19:46 ` Florian Weimer
2013-01-02 19:55 ` Patrick
2013-01-02 20:08 ` Simon Wright
2013-01-03 5:51 ` Jeffrey Carter
2013-01-03 9:03 ` Simon Wright
2013-01-03 9:45 ` Florian Weimer
2013-01-02 20:08 ` Florian Weimer
2013-01-02 22:37 ` Patrick
2013-01-02 23:17 ` Patrick
2013-01-03 7:08 ` Patrick
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox