나는 Lua를위한 D2
바인딩을 쓰고있다. 이것은 Lua 헤더 파일 중 하나에 있습니다.C 함수의 D 콜백
void lua_pushcfunction(lua_State* L, string name, lua_CFunction func);
나는 그것이해야 않는 D2
기능을 밀어하려면 :
extern(C) alias int function(lua_State* L) lua_CFunction;
루아는 또한 API 기능을 제공합니다 :
typedef int (*lua_CFunction) (lua_State *L);
나는 동등한
D2
문이 될 것입니다 가정 extern (C) 또는 함수를 사용할 수 있습니까?
int dfunc(lua_State* L)
{
std.stdio.writeln("dfunc");
}
extern(C) int cfunc(lua_State* L)
{
std.stdio.writeln("cfunc");
}
lua_State* L = lua_newstate();
lua_pushcfunction(L, "cfunc", &cfunc); //This will definitely work.
lua_pushcfunction(L, "dfunc", &dfunc); //Will this work?
cfunc
만 사용할 수있는 이유는 무엇입니까? 나는 C++
에서 그런 것을 할 필요가 없습니다. C++
함수의 주소를 C
에 전달하면 모든 것이 올바르게 작동합니다.
현재 존재하지 않는 바인딩이 있습니다. 얼마나 좋은지 잘 모르겠습니다. http://code.google.com/p/dlua/ –