没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > apollo11 |
apollo11
|
0 | 0 | 0 |
贡献者 | 讨论 | 代码提交 |
I needed a scripting language for an iPhone game. Lua was the obvious choice, because it is easy to embed and is efficient.
I then found that while Lua is a nice little language, all the C++ bindings I was able to find for it leave something to be desired. Some of them require an external compilation phase. Some of them require every exposed method, function and class to be declared separately from their C++ declaration and implementation. All of them just seem to require a lot of extra programmer work.
So, here's another one.
Here's how you use it to bind a class to Lua:
class ClassName
{
ScriptMethodDecl( methodName, returnType, N, ArgType1, argName1, ArgType2, argName2, ... ArgTypeN, argNameN)
// OR
ScriptMethodDecl(methodName);
returnType methodName(ArgType1 argName1, ArgType2 argName2, ArgTypeN argNameN );
};
ScriptMethodImpl(ClassName, methodName, returnType, N, ArgType1, argName1, ArgType2, argName2, /*...*/ ArgTypeN, argNameN)
{
// implementation for ClassName::methodName(...)
return returnType();
}And here's how you use it to bind a single function to Lua:
ScriptFunction( funcName, returnType, ArgType1, argName1, ArgType2, argName2, ArgTypeN, argNameN )
{
// profit
return returnType();
}