私は C++ アプリケーションを持っており、このアプリケーション用の Lua API を設計して提供したいと考えています。そのために役立つツールはありますか? いくつかのメソッドをマークして Lua API レイヤーに公開する方法はあるのでしょうか? コードを解析した後に API を生成できるツールを見た他の言語では、Lua にこれに似たものがありますか?
2 に答える
4
アプリケーションにインクルードする 1 つ (1 つ!) のヘッダー ファイルで構成される LuaBridge の非常に軽量なアプローチに本当に感謝しています。
https://github.com/vinniefalco/LuaBridge
https://github.com/vinniefalco/LuaBridgeDemo
/** Declare LUA binding for this class
*
* @param global_lua
*/
void c_entity::lua_bind(lua_State* L) {
getGlobalNamespace(L)
.beginClass<c_entity>("c_entity")
.addFunction("getSpeed",&c_entity::get_linear_speed)
.addFunction("getName",&c_entity::get_name)
.addFunction("getMaxSpeed",&c_entity::get_max_linear_speed)
.addFunction("getAcceleration",&c_entity::get_max_linear_acceleration)
.addFunction("getHull",&c_entity::get_hull)
.addFunction("getArmor",&c_entity::get_armor)
.addFunction("getShield",&c_entity::get_shield)
.addCFunction("getStatus",&c_entity::getStatus)
.addFunction("logTrace",&c_entity::log_trace)
.addFunction("logInfo",&c_entity::log_info)
.addFunction("logDebug",&c_entity::log_debug)
.addFunction("logError",&c_entity::log_error)
.endClass();
}
于 2013-01-04T10:04:59.140 に答える