#include #include //getch using namespace std; #include "..\ScriptEngine.h" void PrintInt( int n ) { cout << "Print( int ) ==> " << n << endl; } void PrintFloat( float f ) { cout << "Print( float ) ==> " << f << endl; } void PrintStr( const char * str ) { cout << "Print( const char * ) ==> " << str << endl; } void PrintBOOL( BOOL b ) { cout << "Print( bool ) ==> "; if( b ) cout << "true"; else cout << "false"; cout << endl; } void ScriptMessage( const char * msg ) { cout << "##" << msg << "##\n"; } void main( int argc, char *argv[] ) { //!!!!!!!!!!½Ã°£³ª¸é Å×½ºÆ®¸¦ Á» ´õ ÀÚµ¿È­ ÇÒ °Í!!!!!!!!!!!// //Áö±ÝÀº °¢ ºÎºÐÀÇ Å×½ºÆ®¸¦ Çϰí PrintÇØ¼­ Âïµµ·Ï ÇÑ ´ÙÀ½¿¡ //Á÷Á¢ È®ÀÎÇϰí ÀÖÁö¸¸... assert( test == °á°ú°ª ) °°Àº Çü½ÄÀ¸·Î Çϸé //assertÀÇ °á°ú°¡ okÀÎÁö ¾Æ´ÑÁö¸¸ È®ÀÎÇÏ¸é µÇ¹Ç·Î ÈξÀ È¿À²ÀûÀÓ. _SE_SetMessageFunction( ScriptMessage ); SCRIPT Script; if( argc != 2 ) { Script = _SE_Create( "TestCode.gsf" ); } else { Script = _SE_Create( argv[1] ); } if( Script == 0 ) cout << "usage : ScriptTest [gsf filename]" << endl; _SE_RegisterFunction( Script, PrintInt, T_VOID, "Print", T_INT, T_VOID ); _SE_RegisterFunction( Script, PrintFloat, T_VOID, "Print", T_FLOAT, T_VOID ); _SE_RegisterFunction( Script, PrintStr, T_VOID, "Print", T_STRING, T_VOID ); _SE_RegisterFunction( Script, PrintBOOL, T_VOID, "Print", T_BOOL, T_VOID ); _SE_Execute( Script ); SE_FUNC ScriptMain = _SE_GetScriptFunction( Script, T_VOID, "ScriptMain", 0 ); _SE_CallScriptFunction( Script, ScriptMain ); SE_FUNC getDoubleFunc = _SE_GetScriptFunction( Script, T_INT, "getDouble", T_INT, 0 ); AnyData result = _SE_CallScriptFunction( Script, getDoubleFunc, 1000 ); cout << "getDouble() ==> " << result.intValue << endl; SE_FUNC getDoubleFunc2 = _SE_GetScriptFunction( Script, T_FLOAT, "getDouble", T_FLOAT, 0 ); AnyData result2 = _SE_CallScriptFunction( Script, getDoubleFunc2, 0.534f ); cout << "getDouble(float) ==> " << result2.floatValue << endl; SE_FUNC TestFloat1 = _SE_GetScriptFunction( Script, T_FLOAT, "TestFloat", T_FLOAT, T_FLOAT, 0 ); result = _SE_CallScriptFunction( Script, TestFloat1, 0.325f, 13.535f ); //4.398875 cout << "TestFloat( float, float ) ==> " << result.floatValue << endl; SE_FUNC TestFloat2 = _SE_GetScriptFunction( Script, T_FLOAT, "TestFloat", T_FLOAT, T_FLOAT, T_FLOAT, 0 ); result = _SE_CallScriptFunction( Script, TestFloat2, 0.23415f, 8412.5325f, 212.53f ); //418640.4218 cout << "TestFloat( float, float, float ) ==> " << result.floatValue << endl; SE_FUNC TestFloat3 = _SE_GetScriptFunction( Script, T_FLOAT, "TestFloat", T_FLOAT, T_FLOAT, T_FLOAT, T_FLOAT, 0 ); result = _SE_CallScriptFunction( Script, TestFloat3, 32.3f, 35.2f, 8.2f, 93.66f ); cout << "TestFloat( float, float, float, float ) ==> " << result.floatValue << endl; //873198.92352 cout << "Press any key to continue...\n"; // getch(); _SE_Destroy( Script ); }