Jump to content

[SOLVED] Export Overloaded Functions


photo

Recommended Posts

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

Link to comment

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);
Link to comment
×
×
  • Create New...