Open llm96 opened 1 year ago
Is it possible to bind multiple constructors with this library? I've tried doing it with the following sample code without success.
class test { public: test(const std::string& arg1) { std::cout << std::format("{}\n", arg1); } test(const std::string& arg1, const std::string& arg2) { std::cout << std::format("{}, {}\n", arg1, arg2); } }; int main(int argc, char* argv[]) { auto vm = wren::VM(); auto& example = vm.module("example"); auto& lib = example.klass<test>("test"); lib.ctor<const std::string&>(); lib.ctor<const std::string&, const std::string&>(); try { vm.runFromSource("main", R"( import "example" for test var test1 = test.new("1") var test2 = test.new("1", "2") )"); } catch (const std::exception& e) { std::cerr << e.what() << std::endl; } return 0; }
Runtime error: test metaclass does not implement 'new(_)'. at: main:4
Unfortunately only one constructor can be specified at the moment.
Some alternatives that I can suggest:
Is it possible to bind multiple constructors with this library? I've tried doing it with the following sample code without success.