#pragma once #include #include using namespace std; extern "C" { #include "Lua.h" #include "LuaLib.h" #include "lauxlib.h" }; #define LUA_GLUE extern "C" int extern "C" { typedef int (*LuaFunctionType)(struct lua_State* pLuaState); }; // ½Ì±ÛÅæ ÆíÇÏ°Ô ¾²ÀÚ~ #define LUA_DELEGATE LuaDelegate_Singleton() //--------------------------------------------------------------------------// // Class Name: CLuaDelegate // // Author : Á¤Çѱâ // // Desc: ·ç¾Æ ÀÎÅÍÆäÀ̽º ´ë¸®ÀÚ~~ //--------------------------------------------------------------------------// class CLuaDelegate { private: lua_State* m_pLuaState; void (*m_pErrorHandler)( const char* pError ); // ½Ì±ÛÅæÀÌ´Ù. CLuaDelegate(void); // ÅØ½ºÆ® ÆÄÀÏÀ» ¸ø ãÀ» °æ¿ì¿£ ¹ÙÀ̳ʸ® ÆÄÀÏ(lub)·Î ã¾Æº»´Ù. void _ConvertProperFileExt( IN OUT string& strFileName ); public: ~CLuaDelegate(void); // µð¹ö±×ÀÏ ¶§¸¸ Çã¿ë. //#if defined (_DEBUG) | (DEBUG) #if defined (_DEBUG) void StartDebugConsole( HINSTANCE hInst ); #endif bool RunScript( const char* pFileName ); bool RunString( const char* pCommand ); const char* GetErrorString( void ); bool AddFunction( const char* pFunctionName, LuaFunctionType pFunc ); const char* GetStringArgument( int iNum, const char* pDefault = NULL ); double GetNumberArgument( int iNum, double dDefault = 0.0 ); void PushString( const char* pString ); void PushNumber( double dValue ); // ±Û·Î¹ú º¯¼ö¸¦ ¾ò¾î¿À±â double GetNumber( const char* pVarName ); const char* GetString( const char* pVarName ); // ±Û·Î¹ú º¯¼ö¸¦ ¼ÂÆÃ void SetNumber( const char* pVarName, double dNumber ); void SetString( const char* pVarName, const char* pString ); // Å×ÀÌºí ¾ò¾î¿À±â. int GetTable( const char* pTableName ); // Å×ÀÌºí¿¡ Ű&°ª Æä¾î¸¦ ³Ö´Â´Ù. void AddToTable( int iTableIndex, const char* pStrKey, const char* pStrValue ); void AddToTable( int iTableIndex, const char* pStrKey, lua_Number NumericValue ); // Å×À̺íÀº ½ºÅÃÀÇ Top ¿¡ ÀÖ´Ù°í °¡Á¤ÇÑ´Ù. void GetField( const char* pStrKey, /*IN OUT*/ string& strValue ); lua_Number GetField( const char* pStrKey ); void SetErrorHandler( void(*pErrorHandler)(const char* pError) ); lua_State* GetLuaState( void ); friend CLuaDelegate& LuaDelegate_Singleton( void ); };