We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
class Base { public: virtual void print() { std::cout << "base print:" << x << endl; } private: int x; };
class A: public Base { public: void print() override { std::cout << "A print:" << y << endl; } private: int y; };
class C { public: void print() { std::cout << "B print:" << z << endl; } private: int z; }; void funcBase(Base* base) { return base->print(); }
A a; C c; Base base; sol::state lua; luaL_openlibs(lua); lua.new_usertype<Base>( "Base"); lua.new_usertype<A>( "A", sol::base_classes, sol::bases<Base>()); lua["base"] = &base; lua["a"] = &a; lua["c"] = &c; lua.safe_script("function startup() return funcBase(b) end"); // set funcBase lua.set_function("funcBase", funcBase); **//An error parameter &c was passed** lua["funcBase"](&c);
The text was updated successfully, but these errors were encountered:
The call to lua["funcBase"](&c); returns a sol::protected_function_result. You can then check if this result was valid yourself like:
lua["funcBase"](&c);
sol::protected_function_result
auto res = lua["funcBase"](&c); if (!res.valid()) { std::cout << "error occured!" << std::endl; }
To make this call automatically print the error result you can call it from a protected function:
sol::protected_function protected_function( lua["funcBase"], [](std::string message) { std::cout << "error occurred : " << message << std::endl; }); protected_function(&c);
Sorry, something went wrong.
No branches or pull requests
class Base
{
public:
virtual void print()
{
std::cout << "base print:" << x << endl;
}
private:
int x;
};
class A: public Base
{
public:
void print() override
{
std::cout << "A print:" << y << endl;
}
private:
int y;
};
class C
{
public:
void print()
{
std::cout << "B print:" << z << endl;
}
private:
int z;
};
void funcBase(Base* base)
{
return base->print();
}
The text was updated successfully, but these errors were encountered: