sergey.pozhidaev Posted December 7, 2014 Posted December 7, 2014 hi, how do subj? ExternClass<Logic> *a_logic = MakeExternClass<Logic>(); a_logic->addConstructor(); a_logic->addFunction("getVariable", &Logic::getVariable); Interpreter::addExternClass("Anandamide::Logic", a_logic); getVariable(const char *) getVariable(int) renaming functions is not beautiful solution
ulf.schroeter Posted December 7, 2014 Posted December 7, 2014 I think this is not possible as Unigine does not support function overloading with different types. Same background as here https://developer.unigine.com/forum/topic/2939-solved-constructor-overloading/?p=15802
unclebob Posted December 10, 2014 Posted December 10, 2014 Hi there, Sergey! It's possible to create static function which will check variable type inside it and call proper C++ methods. Like here: /* */ static int get_variable(Logic *logic,const Variable &v) { Interpreter *interpreter = Interpreter::get(); if(v.isInt()) { /* do your Logic::getVariable(int) call */ } else if(v.isString()) { /* do your Logic::getVariable(const char *) call */ } else Interpreter::error("Logic::getVariable(): unknown type of argument (%s)\n",v.getTypeName().get()); } ExternClass<Logic> *a_logic = MakeExternClass<Logic>(); a_logic->addConstructor(); a_logic->addFunction("getVariable", &get_variable); Interpreter::addExternClass("Anandamide::Logic", a_logic);
Recommended Posts