00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef _CEGUILua_h_
00031 #define _CEGUILua_h_
00032
00033
00034
00035
00036
00037 #if (defined( __WIN32__ ) || defined( _WIN32 )) && !defined(CEGUI_STATIC)
00038 # ifdef CEGUILUA_EXPORTS
00039 # define CEGUILUA_API __declspec(dllexport)
00040 # else
00041 # define CEGUILUA_API __declspec(dllimport)
00042 # endif
00043 #else
00044 # define CEGUILUA_API
00045 #endif
00046
00047
00048 #include "../../CEGUIScriptModule.h"
00049
00050 struct lua_State;
00051
00052
00053 namespace CEGUI
00054 {
00055
00060 class CEGUILUA_API LuaScriptModule : public CEGUI::ScriptModule
00061 {
00062 public:
00063
00064
00065
00074 static LuaScriptModule& create(lua_State* state = 0);
00075
00077 static void destroy(LuaScriptModule& mod);
00078
00079
00080
00081
00082
00095 void executeScriptFile(const String& filename, const String& resourceGroup);
00096
00114 void executeScriptFile(const String& filename,
00115 const String& resourceGroup,
00116 const String& error_handler);
00117
00135 void executeScriptFile(const String& filename,
00136 const String& resourceGroup,
00137 const int error_handler);
00138
00151 int executeScriptGlobal(const String& function_name);
00152
00170 int executeScriptGlobal(const String& function_name,
00171 const String& error_handler);
00172
00190 int executeScriptGlobal(const String& function_name,
00191 const int error_handler);
00192
00193
00212 bool executeScriptedEventHandler(const String& handler_name,
00213 const EventArgs& e);
00214
00238 bool executeScriptedEventHandler(const String& handler_name,
00239 const EventArgs& e,
00240 const String& error_handler);
00241
00265 bool executeScriptedEventHandler(const String& handler_name,
00266 const EventArgs& e,
00267 const int error_handler);
00268
00279 void executeString(const String& str);
00280
00296 void executeString(const String& str, const String& error_handler);
00297
00313 void executeString(const String& str, const int error_handler);
00314
00315
00316
00317
00336 Event::Connection subscribeEvent(EventSet* target, const String& name,
00337 const String& subscriber_name);
00338
00362 Event::Connection subscribeEvent(EventSet* target, const String& name,
00363 const String& subscriber_name,
00364 const String& error_handler);
00365
00389 Event::Connection subscribeEvent(EventSet* target, const String& name,
00390 const String& subscriber_name,
00391 const int error_handler);
00392
00415 Event::Connection subscribeEvent(EventSet* target, const String& name,
00416 Event::Group group,
00417 const String& subscriber_name);
00418
00446 Event::Connection subscribeEvent(EventSet* target, const String& name,
00447 Event::Group group,
00448 const String& subscriber_name,
00449 const String& error_handler);
00450
00478 Event::Connection subscribeEvent(EventSet* target, const String& name,
00479 Event::Group group,
00480 const String& subscriber_name,
00481 const int error_handler);
00482
00483
00484
00485
00496 void createBindings(void);
00497
00508 void destroyBindings(void);
00509
00510
00511
00512
00521 lua_State* getLuaState(void) const {return d_state;}
00522
00523
00524
00525
00536 void setDefaultPCallErrorHandler(const String& error_handler_function);
00537
00547 void setDefaultPCallErrorHandler(int function_reference);
00548
00563 const String& getActivePCallErrorHandlerString() const;
00564
00587 int getActivePCallErrorHandlerReference() const;
00588
00589 private:
00590
00591
00592
00601 LuaScriptModule(lua_State* state);
00602
00604 ~LuaScriptModule();
00605
00606
00607 void setModuleIdentifierString();
00612 int initErrorHandlerFunc();
00617 int initErrorHandlerFunc(const String func_name);
00622 int initErrorHandlerFunc(int func);
00623
00629 void cleanupErrorHandlerFunc();
00630
00632 void unrefErrorFunc();
00633
00635 void executeScriptFile_impl(const String& filename,
00636 const String& resourceGroup,
00637 const int err_idx, const int top);
00638
00640 int executeScriptGlobal_impl(const String& function_name,
00641 const int err_idx, const int top);
00642
00644 bool executeScriptedEventHandler_impl(const String& handler_name,
00645 const EventArgs& e,
00646 const int err_idx, const int top);
00647
00649 void executeString_impl(const String& str, const int err_idx, const int top);
00650
00651
00652
00653
00655 bool d_ownsState;
00657 lua_State* d_state;
00659 String d_errFuncName;
00661 int d_errFuncIndex;
00665 String d_activeErrFuncName;
00669 int d_activeErrFuncIndex;
00670 };
00671
00672 }
00673
00674 #endif // end of guard _CEGUILua_h_