|
|
|
|
@ -15,7 +15,7 @@
|
|
|
|
|
|
|
|
|
|
namespace lunarium
|
|
|
|
|
{
|
|
|
|
|
std::vector<FMBinder*> WrenState::mFMBinders;
|
|
|
|
|
std::vector<WrenState::ForeignMethodDesc> WrenState::mForeignMethods;
|
|
|
|
|
|
|
|
|
|
WrenState::~WrenState()
|
|
|
|
|
{
|
|
|
|
|
@ -49,9 +49,9 @@ namespace lunarium
|
|
|
|
|
return mLogCat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void WrenState::RegisterForeignMethodBinder(FMBinder* binder_method)
|
|
|
|
|
void WrenState::RegisterForeignMethod(ForeignMethodDesc method_desc)
|
|
|
|
|
{
|
|
|
|
|
mFMBinders.push_back(binder_method);
|
|
|
|
|
mForeignMethods.push_back(method_desc);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
@ -177,21 +177,19 @@ namespace lunarium
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
WrenForeignMethodFn WrenState::BindForeignMethodFN(WrenVM* vm, const char* module, const char* className, bool isStatic, const char* signature)
|
|
|
|
|
WrenForeignMethodFn WrenState::BindForeignMethodFN(WrenVM* vm, const char* module, const char* class_name, bool isStatic, const char* signature)
|
|
|
|
|
{
|
|
|
|
|
// Bind methods
|
|
|
|
|
ForeignMethodDesc FMID = { module, class_name, isStatic, signature };
|
|
|
|
|
|
|
|
|
|
// If method not recognized, call any registered FMBinder methods
|
|
|
|
|
for (auto iter = mFMBinders.begin(); iter != mFMBinders.end(); iter++)
|
|
|
|
|
for (auto iter = mForeignMethods.begin(); iter != mForeignMethods.end(); iter++)
|
|
|
|
|
{
|
|
|
|
|
auto FN = ((FMBinder)(*iter))(vm, module, className, isStatic, signature);
|
|
|
|
|
if (FN)
|
|
|
|
|
if (FMID == (*iter))
|
|
|
|
|
{
|
|
|
|
|
return FN;
|
|
|
|
|
return iter->FM;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Logger::Error(mLogCat, "Failed to bind foreign method: %s::%s", className, signature);
|
|
|
|
|
Logger::Error(mLogCat, "Failed to bind foreign method: %s::%s", class_name, signature);
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
}
|