Eluna登録Luaバインド
1952 ワード
使用するhttps://github.com/radiotail/eluna提供されるヘッダファイルは、クラスと関数を登録することができます.このヘッダファイルは、バインドされたオブジェクトを解放するためのゴミ収集器を提供しています.そのループは書くのに少し問題があります.
オリジナル
に改心
オリジナル
struct CPPGarbage
{
inline static void pushMethod(GenericMethod* method) { m_CPPMethods.push_back(method);};
inline static void pushFunction(GenericFunction* function) { m_CPPFunctions.push_back(function);};
inline static void release() {
for (Function_Vector::iterator itr = m_CPPFunctions.begin(); itr != m_CPPFunctions.end(); ++itr) {
delete *itr;
}
for (Method_Vector::iterator itr = m_CPPMethods.begin(); itr != m_CPPMethods.end(); ++itr) {
delete *itr;
}
}
private:
static Function_Vector m_CPPFunctions;
static Method_Vector m_CPPMethods;
};
Function_Vector CPPGarbage::m_CPPFunctions;
Method_Vector CPPGarbage::m_CPPMethods;
に改心
struct CPPGarbage
{
inline static void pushMethod(GenericMethod* method) { m_CPPMethods.push_back(method);};
inline static void pushFunction(GenericFunction* function) { m_CPPFunctions.push_back(function);};
inline static void release() {
for (Function_Vector::iterator itr = m_CPPFunctions.begin(); itr != m_CPPFunctions.end(); ++itr) {
if (*itr) {
delete *itr;
*itr = NULL;
}
}
for (Method_Vector::iterator itr = m_CPPMethods.begin(); itr != m_CPPMethods.end(); ++itr) {
if (*itr) {
delete *itr;
*itr = NULL;
}
}
}
private:
static Function_Vector m_CPPFunctions;
static Method_Vector m_CPPMethods;
};
//Function_Vector CPPGarbage::m_CPPFunctions;
//Method_Vector CPPGarbage::m_CPPMethods;
__declspec(selectany) Function_Vector CPPGarbage::m_CPPFunctions;
__declspec(selectany) Method_Vector CPPGarbage::m_CPPMethods;