00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __ASHASEVENTS_H__
00017 #define __ASHASEVENTS_H__
00018
00019
00020 #include "../../dependencies.h"
00021
00022 #ifdef __COMPILE_WITH_ANGELSCRIPT__
00023
00024 #include "../../core/HasEvents.h"
00025 #include "../ScriptHelper.h"
00026
00027
00030 extern bool connectEventSignal(const std::string &slotName, asIScriptObject *object,
00031 const std::string &function, HasEvents *container);
00032
00035 extern void disconnectEventSignal(const std::string &slotName, asIScriptObject *object,
00036 const std::string &function, HasEvents *container);
00037
00038
00041 template<typename T>
00042 void bindHasEventsBase(asIScriptEngine *engine, const char *type)
00043 {
00044
00045 int r;
00046 std::string sType = type;
00047
00048
00049 r = engine->RegisterObjectMethod(type, "bool createEventSlot(const string &in)",
00050 asMETHODPR(T, createEventSlot, (const std::string&), bool), asCALL_THISCALL); assert(r >= 0);
00051
00052 r = engine->RegisterObjectMethod(type, "bool connectEventSignal(const string &in, IHasSlots@, " \
00053 "const string &in)", asFUNCTION(connectEventSignal), asCALL_CDECL_OBJLAST);
00054 assert(r >= 0);
00055 r = engine->RegisterObjectMethod(type, "bool disconnectEventSignal(const string &in, IHasSlots@, " \
00056 "const string &in)", asFUNCTION(disconnectEventSignal), asCALL_CDECL_OBJLAST);
00057 assert(r>= 0);
00058
00059 r = engine->RegisterObjectMethod(type, "bool emitEvent(const string &in)",
00060 asMETHODPR(T, emitEvent, (const std::string&, void*), bool), asCALL_THISCALL);
00061 assert(r >= 0);
00062
00063 r = engine->RegisterObjectMethod(type, "bool emitEvent(const string &in, ? &in)",
00064 asMETHODPR(T, emitEvent, (const std::string&, void*), bool), asCALL_THISCALL);
00065 assert(r >= 0);
00066
00067 r = engine->RegisterObjectMethod(type, "void removeEventSlots()",
00068 asMETHOD(T, removeEventSlots), asCALL_THISCALL);
00069 assert(r >= 0);
00070
00071 r = engine->RegisterObjectMethod(type, "bool removeEventSlot(const string &in)",
00072 asMETHODPR(T, removeEventSlot, (const std::string&), bool), asCALL_THISCALL);
00073 assert(r >= 0);
00074 }
00075
00076 #endif // __COMPILE_WITH_ANGELSCRIPT__
00077
00078 #endif