2018-02-25 06:19:16 +08:00
|
|
|
#define SOL_CHECK_ARGUMENTS 1
|
|
|
|
|
2018-09-28 13:27:38 +08:00
|
|
|
#include <sol/sol.hpp>
|
2018-03-02 11:08:27 +08:00
|
|
|
#include "../assert.hpp"
|
2018-02-25 06:19:16 +08:00
|
|
|
|
|
|
|
struct vars {
|
|
|
|
int boop = 0;
|
|
|
|
|
|
|
|
int bop () const {
|
|
|
|
return boop + 1;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
int main() {
|
|
|
|
sol::state lua;
|
|
|
|
lua.new_usertype<vars>("vars",
|
|
|
|
"boop", &vars::boop,
|
|
|
|
"bop", &vars::bop);
|
|
|
|
lua.script("beep = vars.new()\n"
|
|
|
|
"beep.boop = 1\n"
|
|
|
|
"bopvalue = beep:bop()");
|
|
|
|
|
|
|
|
vars& beep = lua["beep"];
|
|
|
|
int bopvalue = lua["bopvalue"];
|
|
|
|
|
2018-03-02 11:08:27 +08:00
|
|
|
c_assert(beep.boop == 1);
|
|
|
|
c_assert(lua.get<vars>("beep").boop == 1);
|
|
|
|
c_assert(beep.bop() == 2);
|
|
|
|
c_assert(bopvalue == 2);
|
2018-02-25 06:19:16 +08:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|