Skip to content
This repository was archived by the owner on Apr 21, 2025. It is now read-only.
This repository was archived by the owner on Apr 21, 2025. It is now read-only.

Execute function of class by class name as string #128

Description

@paulocoutinhox

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions