Foo
単純なクラスを公開するための非常に単純なソース コードがいくつかあります。
main.cpp:
#include <iostream>
#include <lua.hpp>
#include <LuaBridge.h>
class Foo
{
private:
int number = 0;
public:
void setNumber(const int& newNumber) {number = newNumber;}
int getNumber() {return number;}
};
int main()
{
//Expose the API:
lua_State* L = luaL_newstate();
luaL_openlibs(L);
luabridge::getGlobalNamespace(L)
.beginClass<Foo>("Foo")
.addConstructor<void(*)(void)>()
.addProperty("number", &Foo::getNumber, &Foo::setNumber)
.endClass();
}
残念ながら、次のエラーが表示されます。
24 error: no matching function for call to ‘luabridge::Namespace::Class<Foo>::addProperty(const char [7], int (Foo::*)(), void (Foo::*)(const int&))’
何が問題なのかわかりませんが、使用する必要がありますaddProperty
。そうしないと、コードが正しく見えません