Open AndThenYou opened 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()
//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()