jeremyong / Selene

Simple C++11 friendly header-only bindings to Lua
zlib License
813 stars 117 forks source link

It seems that more than two objects cannot be registered(Will be overwritten) #185

Open AndThenYou opened 2 years ago

AndThenYou commented 2 years ago

//cpp class A { public: void showA(){std::cout << "aaa";} }; class B { public: void showB(){ std::cout << "bbb"; } }; class c1 { public: A newA() { return new A; } }; class c2 { public: B newB() { return new B; } }; int main() { c1 c; c2 cc; sel::State state(true); state["A"].SetClass("showA", &A::showA); state["B"].SetClass("showB", &B::showB); state["c"].SetObj(c, "newA", &c1::newA); state["cc"].SetObj(cc, "newB", &c2::newB); state.Load("test.lua"); return 0; }

//test.lua a = c:newA() b = cc:newB() a:showA() b:showB()