Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
AndThenYou opened this issue Dec 17, 2021 · 1 comment

Comments

@AndThenYou
Copy link

No description provided.

@AndThenYou
Copy link
Author

AndThenYou commented Dec 17, 2021

//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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant