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

Execute function of class by class name as string #128

Open
paulocoutinhox opened this issue Sep 30, 2022 · 0 comments
Open

Execute function of class by class name as string #128

paulocoutinhox opened this issue Sep 30, 2022 · 0 comments

Comments

@paulocoutinhox
Copy link

Hi,

Im checking your example:

// retrieve the metaclass (containing the member data)
const ponder::Class& metaclass = ponder::classByType<Person>();

// construct a new person
ponder::UserObject person = ponder::runtime::create(metaclass, "Bozo");

// set attributes
person.set("height", 1.62f);
person.set("shoeSize", 28);

// retrieve a function we would like to call
const auto& func = metaclass.function("hasBigFeet");

// call the function and get the result
const bool bigFeet = ponder::runtime::call(func, person).to<bool>();

But in my case, i want something like this:

const ponder::Class& metaclass = ponder::classByString("Person");
ponder::UserObject person = ponder::runtime::create(metaclass, "Bozo");
const auto& func = metaclass.function("hasBigFeet");
const bool bigFeet = ponder::runtime::call(func, person).to<bool>();

And the second question is how to create using namespace, example:

namespace xyz {
    class Person {};
}

const ponder::Class& metaclass = ponder::classByString("xyz::Person");
ponder::UserObject person = ponder::runtime::create(metaclass, "Bozo");
const auto& func = metaclass.function("hasBigFeet");
const bool bigFeet = ponder::runtime::call(func, person).to<bool>();

Thanks.

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