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
00070 LuaScriptModule();
00071
00072
00080 LuaScriptModule(lua_State* state);
00081
00082
00087 ~LuaScriptModule();
00088
00089
00090
00091
00092
00105 void executeScriptFile(const String& filename, const String& resourceGroup);
00106
00124 void executeScriptFile(const String& filename,
00125 const String& resourceGroup,
00126 const String& error_handler);
00127
00145 void executeScriptFile(const String& filename,
00146 const String& resourceGroup,
00147 const int error_handler);
00148
00161 int executeScriptGlobal(const String& function_name);
00162
00180 int executeScriptGlobal(const String& function_name,
00181 const String& error_handler);
00182
00200 int executeScriptGlobal(const String& function_name,
00201 const int error_handler);
00202
00203
00222 bool executeScriptedEventHandler(const String& handler_name,
00223 const EventArgs& e);
00224
00248 bool executeScriptedEventHandler(const String& handler_name,
00249 const EventArgs& e,
00250 const String& error_handler);
00251
00275 bool executeScriptedEventHandler(const String& handler_name,
00276 const EventArgs& e,
00277 const int error_handler);
00278
00289 void executeString(const String& str);
00290
00306 void executeString(const String& str, const String& error_handler);
00307
00323 void executeString(const String& str, const int error_handler);
00324
00325
00326
00327
00346 Event::Connection subscribeEvent(EventSet* target, const String& name,
00347 const String& subscriber_name);
00348
00372 Event::Connection subscribeEvent(EventSet* target, const String& name,
00373 const String& subscriber_name,
00374 const String& error_handler);
00375
00399 Event::Connection subscribeEvent(EventSet* target, const String& name,
00400 const String& subscriber_name,
00401 const int error_handler);
00402
00425 Event::Connection subscribeEvent(EventSet* target, const String& name,
00426 Event::Group group,
00427 const String& subscriber_name);
00428
00456 Event::Connection subscribeEvent(EventSet* target, const String& name,
00457 Event::Group group,
00458 const String& subscriber_name,
00459 const String& error_handler);
00460
00488 Event::Connection subscribeEvent(EventSet* target, const String& name,
00489 Event::Group group,
00490 const String& subscriber_name,
00491 const int error_handler);
00492
00493
00494
00495
00506 void createBindings(void);
00507
00518 void destroyBindings(void);
00519
00520
00521
00522
00531 lua_State* getLuaState(void) const {return d_state;}
00532
00533
00534
00535
00546 void setDefaultPCallErrorHandler(const String& error_handler_function);
00547
00557 void setDefaultPCallErrorHandler(int function_reference);
00558
00573 const String& getActivePCallErrorHandlerString() const;
00574
00597 int getActivePCallErrorHandlerReference() const;
00598
00599 private:
00600
00601
00602
00603 void setModuleIdentifierString();
00608 int initErrorHandlerFunc();
00613 int initErrorHandlerFunc(const String func_name);
00618 int initErrorHandlerFunc(int func);
00619
00625 void cleanupErrorHandlerFunc();
00626
00628 void unrefErrorFunc();
00629
00631 void executeScriptFile_impl(const String& filename,
00632 const String& resourceGroup,
00633 const int err_idx, const int top);
00634
00636 int executeScriptGlobal_impl(const String& function_name,
00637 const int err_idx, const int top);
00638
00640 bool executeScriptedEventHandler_impl(const String& handler_name,
00641 const EventArgs& e,
00642 const int err_idx, const int top);
00643
00645 void executeString_impl(const String& str, const int err_idx, const int top);
00646
00647
00648
00649
00651 bool d_ownsState;
00653 lua_State* d_state;
00655 String d_errFuncName;
00657 int d_errFuncIndex;
00661 String d_activeErrFuncName;
00665 int d_activeErrFuncIndex;
00666 };
00667
00668 }
00669
00670 #endif // end of guard _CEGUILua_h_