Explorar o código

Merge branch 'lua-event-handler'

aster2013 %!s(int64=11) %!d(string=hai) anos
pai
achega
ec839a8e39

+ 1 - 1
Source/Samples/22_LuaIntegration/LuaIntegration.cpp

@@ -118,7 +118,7 @@ void LuaIntegration::CreateScene()
         instance->CreateObject(scriptFile, "Rotator");
         
         // Call the script object's "SetRotationSpeed" function.
-        WeakPtr<LuaFunction> function = instance->GetScriptObjectFunction("SetRotationSpeed");
+        LuaFunction* function = instance->GetScriptObjectFunction("SetRotationSpeed");
         if (function && function->BeginCall(instance))
         {
             function->PushUserType(Vector3(10.0f, 20.0f, 30.0f), "Vector3");

+ 20 - 54
Source/Urho3D/LuaScript/LuaScript.cpp

@@ -150,14 +150,14 @@ LuaScript::~LuaScript()
 
 void LuaScript::AddEventHandler(const String& eventName, int functionIndex)
 {
-    WeakPtr<LuaFunction> function = GetFunction(functionIndex);
+    LuaFunction* function = GetFunction(functionIndex);
     if (function)
         eventInvoker_->AddEventHandler(0, eventName, function);
 }
 
 void LuaScript::AddEventHandler(const String& eventName, const String& functionName)
 {
-    WeakPtr<LuaFunction> function = GetFunction(functionName);
+    LuaFunction* function = GetFunction(functionName);
     if (function)
         eventInvoker_->AddEventHandler(0, eventName, function);
 }
@@ -167,7 +167,7 @@ void LuaScript::AddEventHandler(Object* sender, const String& eventName, int fun
     if (!sender)
         return;
 
-    WeakPtr<LuaFunction> function = GetFunction(functionIndex);
+    LuaFunction* function = GetFunction(functionIndex);
     if (function)
         eventInvoker_->AddEventHandler(sender, eventName, function);
 }
@@ -177,48 +177,14 @@ void LuaScript::AddEventHandler(Object* sender, const String& eventName, const S
     if (!sender)
         return;
 
-    WeakPtr<LuaFunction> function = GetFunction(functionName);
+    LuaFunction* function = GetFunction(functionName);
     if (function)
         eventInvoker_->AddEventHandler(sender, eventName, function);
 }
 
-void LuaScript::RemoveEventHandler(const String& eventName, int functionIndex)
-{
-    WeakPtr<LuaFunction> function = GetFunction(functionIndex);
-    if (function)
-        eventInvoker_->RemoveEventHandler(0, eventName, function);
-}
-
-void LuaScript::RemoveEventHandler(const String& eventName, const String& functionName)
-{
-    WeakPtr<LuaFunction> function = GetFunction(functionName);
-    if (function)
-        eventInvoker_->RemoveEventHandler(0, eventName, function);
-}
-
 void LuaScript::RemoveEventHandler(const String& eventName)
 {
-    eventInvoker_->RemoveEventHandler(0, eventName, WeakPtr<LuaFunction>());
-}
-
-void LuaScript::RemoveEventHandler(Object* sender, const String& eventName, int functionIndex)
-{
-    if (!sender)
-        return;
-
-    WeakPtr<LuaFunction> function = GetFunction(functionIndex);
-    if (function)
-        eventInvoker_->RemoveEventHandler(sender, eventName, function);
-}
-
-void LuaScript::RemoveEventHandler(Object* sender, const String& eventName, const String& functionName)
-{
-    if (!sender)
-        return;
-
-    WeakPtr<LuaFunction> function = GetFunction(functionName);
-    if (function)
-        eventInvoker_->RemoveEventHandler(sender, eventName, function);
+    eventInvoker_->UnsubscribeFromEvent(eventName);
 }
 
 void LuaScript::RemoveEventHandler(Object* sender, const String& eventName)
@@ -226,7 +192,7 @@ void LuaScript::RemoveEventHandler(Object* sender, const String& eventName)
     if (!sender)
         return;
 
-    eventInvoker_->RemoveEventHandler(sender, eventName, WeakPtr<LuaFunction>());
+    eventInvoker_->UnsubscribeFromEvent(sender, eventName);
 }
 
 void LuaScript::RemoveEventHandlers(Object* sender)
@@ -234,12 +200,12 @@ void LuaScript::RemoveEventHandlers(Object* sender)
     if (!sender)
         return;
 
-    eventInvoker_->RemoveAllEventHandlers(sender);
+    eventInvoker_->UnsubscribeFromEvents(sender);
 }
 
 void LuaScript::RemoveAllEventHandlers()
 {
-    eventInvoker_->RemoveAllEventHandlers(0);
+    eventInvoker_->UnsubscribeFromAllEvents();
 }
 
 void LuaScript::RemoveEventHandlersExcept(const Vector<String>& exceptionNames)
@@ -248,7 +214,7 @@ void LuaScript::RemoveEventHandlersExcept(const Vector<String>& exceptionNames)
     for (unsigned i = 0; i < exceptionTypes.Size(); ++i)
         exceptionTypes[i] = StringHash(exceptionNames[i]);
 
-    eventInvoker_->RemoveEventHandlersExcept(exceptionTypes);
+    eventInvoker_->UnsubscribeFromAllEventsExcept(exceptionTypes, true);
 }
 
 bool LuaScript::ExecuteFile(const String& fileName)
@@ -279,7 +245,7 @@ bool LuaScript::ExecuteString(const String& string)
 
 bool LuaScript::ExecuteFunction(const String& functionName)
 {
-    WeakPtr<LuaFunction> function = GetFunction(functionName);
+    LuaFunction* function = GetFunction(functionName);
     return function && function->BeginCall() && function->EndCall();
 }
 
@@ -387,18 +353,18 @@ int LuaScript::Print(lua_State *L)
     return 0;
 }
 
-WeakPtr<LuaFunction> LuaScript::GetFunction(int functionIndex)
+LuaFunction* LuaScript::GetFunction(int functionIndex)
 {
     if (!lua_isfunction(luaState_, functionIndex))
-        return WeakPtr<LuaFunction>();
+        return 0;
 
     const void* functionPointer = lua_topointer(luaState_, functionIndex);
     if (!functionPointer)
-        return WeakPtr<LuaFunction>();
+        return 0;
 
     HashMap<const void*, SharedPtr<LuaFunction> >::Iterator i = functionPointerToFunctionMap_.Find(functionPointer);
     if (i != functionPointerToFunctionMap_.End())
-        return WeakPtr<LuaFunction>(i->second_);
+        return i->second_;
 
     lua_pushvalue(luaState_, functionIndex);
     int functionRef = luaL_ref(luaState_, LUA_REGISTRYINDEX);
@@ -406,17 +372,17 @@ WeakPtr<LuaFunction> LuaScript::GetFunction(int functionIndex)
     SharedPtr<LuaFunction> function(new LuaFunction(luaState_, functionRef, false));
     functionPointerToFunctionMap_[functionPointer] = function;
 
-    return WeakPtr<LuaFunction>(function);
+    return function;
 }
 
-WeakPtr<LuaFunction> LuaScript::GetFunction(const String& functionName, bool silentIfNotFound)
+LuaFunction* LuaScript::GetFunction(const String& functionName, bool silentIfNotFound)
 {
     if (!luaState_)
-        return WeakPtr<LuaFunction>();
+        return 0;
 
     HashMap<String, SharedPtr<LuaFunction> >::Iterator i = functionNameToFunctionMap_.Find(functionName);
     if (i != functionNameToFunctionMap_.End())
-        return WeakPtr<LuaFunction>(i->second_);
+        return i->second_;
 
     int top = lua_gettop(luaState_);
 
@@ -427,7 +393,7 @@ WeakPtr<LuaFunction> LuaScript::GetFunction(const String& functionName, bool sil
     lua_settop(luaState_, top);
 
     functionNameToFunctionMap_[functionName] = function;
-    return WeakPtr<LuaFunction>(function);
+    return function;
 }
 
 void LuaScript::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
@@ -442,7 +408,7 @@ void LuaScript::HandlePostUpdate(StringHash eventType, VariantMap& eventData)
 
     // Collect garbage
     {
-        PROFILE(CollectLuaGarbage);
+        PROFILE(LuaCollectGarbage);
         lua_gc(luaState_, LUA_GCCOLLECT, 0);
     }
 }

+ 3 - 11
Source/Urho3D/LuaScript/LuaScript.h

@@ -56,16 +56,8 @@ public:
     virtual void AddEventHandler(Object* sender, const String& eventName, int functionIndex);
     /// Add a scripted event handler by function name for a specific sender.
     virtual void AddEventHandler(Object* sender, const String& eventName, const String& functionName);
-    /// Remove a scripted event handler by function.
-    virtual void RemoveEventHandler(const String& eventName, int functionIndex);
-    /// Remove a scripted event handler by function name.
-    virtual void RemoveEventHandler(const String& eventName, const String& functionName);
     /// Remove a scripted event handler.
     virtual void RemoveEventHandler(const String& eventName);
-    /// Remove a scripted event handler for a specific sender by function.
-    virtual void RemoveEventHandler(Object* sender, const String& eventName, int functionIndex);
-    /// Remove a scripted event handler for a specific sender by function name.
-    virtual void RemoveEventHandler(Object* sender, const String& eventName, const String& functionName);
     /// Remove a scripted event handler for a specific sender.
     virtual void RemoveEventHandler(Object* sender, const String& eventName);
     /// Remove all scripted event handlers for a specific sender.
@@ -89,9 +81,9 @@ public:
     /// Return Lua state.
     lua_State* GetState() const { return luaState_; }
     /// Return Lua function by function stack index.
-    WeakPtr<LuaFunction> GetFunction(int functionIndex);
+    LuaFunction* GetFunction(int functionIndex);
     /// Return Lua function by function name.
-    WeakPtr<LuaFunction> GetFunction(const String& functionName, bool silentIfNotfound = false);
+    LuaFunction* GetFunction(const String& functionName, bool silentIfNotfound = false);
     /// Return whether is executing engine console commands as script code.
     bool GetExecuteConsoleCommands() const { return executeConsoleCommands_; }
 
@@ -119,7 +111,7 @@ private:
     /// Event invoker.
     SharedPtr<LuaScriptEventInvoker> eventInvoker_;
     /// Coroutine update function.
-    WeakPtr<LuaFunction> coroutineUpdate_;
+    LuaFunction* coroutineUpdate_;
     /// Flag for executing engine console commands as script code. Default to true.
     bool executeConsoleCommands_;
     /// Function pointer to function map.

+ 18 - 201
Source/Urho3D/LuaScript/LuaScriptEventInvoker.cpp

@@ -29,59 +29,14 @@
 namespace Urho3D
 {
 
-class EventHandlerCommand
-{
-public:
-    EventHandlerCommand(int type) : type_(type) { }
-    virtual ~EventHandlerCommand() { }
-    int type_;
-};
-
-struct AddOrRemoveEventHandlerCommand : public EventHandlerCommand
-{
-    enum { Type = 1 };
-    AddOrRemoveEventHandlerCommand(bool add, Object* sender, const StringHash& eventType, WeakPtr<LuaFunction> function) : 
-        EventHandlerCommand(Type), add_(add), sender_(sender), eventType_(eventType), function_(function)
-    {
-    }
-
-    bool add_;
-    Object* sender_;
-    StringHash eventType_;
-    WeakPtr<LuaFunction> function_;
-};
-
-struct RemoveAllEventHandlersCommand : public EventHandlerCommand
-{    
-    enum { Type = 2 };
-    RemoveAllEventHandlersCommand(Object* sender) : EventHandlerCommand(Type), sender_(sender)
-    {
-    }
-
-    Object* sender_;
-};
-
-struct RemoveEventHandlersExceptCommand : public EventHandlerCommand
-{
-
-    enum { Type = 3 };
-    RemoveEventHandlersExceptCommand(const PODVector<StringHash>& exceptionTypes) : EventHandlerCommand(Type), exceptionTypes_(exceptionTypes)
-    {
-    }
-    PODVector<StringHash> exceptionTypes_;
-};
-
 LuaScriptEventInvoker::LuaScriptEventInvoker(Context* context) : 
-    Object(context), 
-    instance_(0),
-    invoking_(false)
+    Object(context)
 {
 }
 
 LuaScriptEventInvoker::LuaScriptEventInvoker(LuaScriptInstance* instance) : 
     Object(instance->GetContext()), 
-    instance_(instance),
-    invoking_(false)
+    instance_(instance)
 {
 }
 
@@ -89,181 +44,43 @@ LuaScriptEventInvoker::~LuaScriptEventInvoker()
 {
 }
 
-void LuaScriptEventInvoker::AddEventHandler(Object* sender, const StringHash& eventType, WeakPtr<LuaFunction> function)
+void LuaScriptEventInvoker::AddEventHandler(Object* sender, const StringHash& eventType, LuaFunction* function)
 {
-    if (invoking_)
-    {
-        eventHandlerCommands_.Push(new AddOrRemoveEventHandlerCommand(true, sender, eventType, function));
+    if (!function)
         return;
-    }
 
-    EventTypeToLuaFunctionVectorMap& eventTypeToFunctionVectorMap = GetEventTypeToLuaFunctionVectorMap(sender);
-    EventTypeToLuaFunctionVectorMap::Iterator i = eventTypeToFunctionVectorMap.Find(eventType);
-
-    if (i == eventTypeToFunctionVectorMap.End())
-    {
-        eventTypeToFunctionVectorMap[eventType].Push(function);
-        
-        if (!sender)
-            SubscribeToEvent(eventType, HANDLER(LuaScriptEventInvoker, HandleLuaScriptEvent));
-        else
-            SubscribeToEvent(sender, eventType, HANDLER(LuaScriptEventInvoker, HandleLuaScriptEvent));
-    }
+    if (sender)
+        SubscribeToEvent(sender, eventType, HANDLER_USERDATA(LuaScriptEventInvoker, HandleLuaScriptEvent, function));
     else
-    {
-        if (!i->second_.Contains(function))
-            i->second_.Push(function);
-    }
-}
-
-void LuaScriptEventInvoker::RemoveEventHandler(Object* sender, const StringHash& eventType, WeakPtr<LuaFunction> function)
-{
-    if (invoking_)
-    {
-        eventHandlerCommands_.Push(new AddOrRemoveEventHandlerCommand(false, sender, eventType, function));
-        return;
-    }
-
-    EventTypeToLuaFunctionVectorMap& eventTypeToLuaFunctionVectorMap = GetEventTypeToLuaFunctionVectorMap(sender);
-    EventTypeToLuaFunctionVectorMap::Iterator i = eventTypeToLuaFunctionVectorMap.Find(eventType);
-    if (i == eventTypeToLuaFunctionVectorMap.End())
-        return;
-
-    if (function)
-        i->second_.Remove(function);
-    else
-        i->second_.Clear();
-    
-    if (i->second_.Empty())
-    {
-        eventTypeToLuaFunctionVectorMap.Erase(i);
-
-        if (!sender)
-            UnsubscribeFromEvent(eventType);
-        else
-            UnsubscribeFromEvent(sender, eventType);
-    }
-}
-
-void LuaScriptEventInvoker::RemoveAllEventHandlers(Object* sender)
-{
-    if (invoking_)
-    {
-        eventHandlerCommands_.Push(new RemoveAllEventHandlersCommand(sender));
-        return;
-    }
-
-    if (!sender)
-    {
-        UnsubscribeFromAllEvents();
-        eventTypeToLuaFunctionVectorMap.Clear();
-        senderEventTypeToLuaFunctionVectorMap.Clear();
-    }
-    else
-    {
-        UnsubscribeFromEvents(sender);
-        senderEventTypeToLuaFunctionVectorMap.Erase(sender);
-    }
-}
-
-void LuaScriptEventInvoker::RemoveEventHandlersExcept(const PODVector<StringHash>& exceptionTypes)
-{
-    if (invoking_)
-    {
-        eventHandlerCommands_.Push(new RemoveEventHandlersExceptCommand(exceptionTypes));
-        return;
-    }
-
-    for (unsigned i = 0; i < exceptionTypes.Size(); ++i)
-        eventTypeToLuaFunctionVectorMap.Erase(exceptionTypes[i]);
-
-    UnsubscribeFromAllEventsExcept(exceptionTypes, false);
+        SubscribeToEvent(eventType, HANDLER_USERDATA(LuaScriptEventInvoker, HandleLuaScriptEvent, function));
 }
 
 void LuaScriptEventInvoker::HandleLuaScriptEvent(StringHash eventType, VariantMap& eventData)
 {
-    Object* sender = GetEventHandler()->GetSender();
-    EventTypeToLuaFunctionVectorMap& eventTypeToLuaFunctionVectorMap = GetEventTypeToLuaFunctionVectorMap(sender);
-    EventTypeToLuaFunctionVectorMap::Iterator i = eventTypeToLuaFunctionVectorMap.Find(eventType);
-    if (i == eventTypeToLuaFunctionVectorMap.End())
+    LuaFunction* function = static_cast<LuaFunction*>(GetEventHandler()->GetUserData());
+    if (!function)
         return;
 
+    // Keep instance alive during invoking
     SharedPtr<LuaScriptInstance> instance(instance_);
-    
-    invoking_ = true;
-    
-    LuaFunctionVector& luaFunctionVector = i->second_;
     if (instance)
     {
-        for (unsigned i = 0; i < luaFunctionVector.Size(); ++i)
+        if (function->BeginCall(instance))
         {
-            WeakPtr<LuaFunction>& function = luaFunctionVector[i];
-            if (function && function->BeginCall(instance))
-            {
-                function->PushUserType(eventType, "StringHash");
-                function->PushUserType(eventData, "VariantMap");
-                function->EndCall();
-            }
+            function->PushUserType(eventType, "StringHash");
+            function->PushUserType(eventData, "VariantMap");
+            function->EndCall();
         }
     }
     else
     {
-        for (unsigned i = 0; i < luaFunctionVector.Size(); ++i)
-        {
-            WeakPtr<LuaFunction>& function = luaFunctionVector[i];
-            if (function && function->BeginCall())
-            {
-                function->PushUserType(eventType, "StringHash");
-                function->PushUserType(eventData, "VariantMap");
-                function->EndCall();
-            }
-        }
-    }
-
-    invoking_ = false;
-
-    if (!eventHandlerCommands_.Empty())
-    {
-        for (unsigned i = 0; i < eventHandlerCommands_.Size(); ++i)
-            ExecuteThenDestroyCommand(eventHandlerCommands_[i]);
-
-        eventHandlerCommands_.Clear();
-    }
-}
-
-void LuaScriptEventInvoker::ExecuteThenDestroyCommand(EventHandlerCommand* command)
-{
-    if (!command)
-        return;
-
-    switch (command->type_)
-    {
-    case AddOrRemoveEventHandlerCommand::Type:
-        {
-            AddOrRemoveEventHandlerCommand* theCommand = (AddOrRemoveEventHandlerCommand*)command;
-            if (theCommand->add_)
-                AddEventHandler(theCommand->sender_, theCommand->eventType_, theCommand->function_);
-            else
-                RemoveEventHandler(theCommand->sender_, theCommand->eventType_, theCommand->function_);
-        }
-        break;
-
-    case RemoveAllEventHandlersCommand::Type:
+        if (function->BeginCall())
         {
-            RemoveAllEventHandlersCommand* theCommand = (RemoveAllEventHandlersCommand*)command;
-            RemoveAllEventHandlers(theCommand->sender_);
+            function->PushUserType(eventType, "StringHash");
+            function->PushUserType(eventData, "VariantMap");
+            function->EndCall();
         }
-        break;
-
-    case RemoveEventHandlersExceptCommand::Type:
-        {
-            RemoveEventHandlersExceptCommand* theCommand = (RemoveEventHandlersExceptCommand*)command;
-            RemoveEventHandlersExcept(theCommand->exceptionTypes_);
-        }
-        break;
     }
-
-    delete command;
 }
 
 }

+ 3 - 30
Source/Urho3D/LuaScript/LuaScriptEventInvoker.h

@@ -27,7 +27,6 @@
 namespace Urho3D
 {
 
-class EventHandlerCommand;
 class LuaFunction;
 class LuaScriptInstance;
 
@@ -44,40 +43,14 @@ public:
     virtual ~LuaScriptEventInvoker();
 
     /// Add a scripted event handler.
-    void AddEventHandler(Object* sender, const StringHash& eventType, WeakPtr<LuaFunction> function);
-    /// Remove a scripted event handler.
-    void RemoveEventHandler(Object* sender, const StringHash& eventType, WeakPtr<LuaFunction> function);
-    /// Remove all scripted event handlers.
-    void RemoveAllEventHandlers(Object* sender);
-    /// Remove all scripted event handlers, except those listed.
-    void RemoveEventHandlersExcept(const PODVector<StringHash>& exceptionTypes);
+    void AddEventHandler(Object* sender, const StringHash& eventType, LuaFunction* function);
 
 private:
     /// Handle script event in Lua script.
     void HandleLuaScriptEvent(StringHash eventType, VariantMap& eventData);
-    typedef Vector<WeakPtr<LuaFunction> > LuaFunctionVector;
-    typedef HashMap<StringHash, LuaFunctionVector> EventTypeToLuaFunctionVectorMap;
-    /// Return event type to Lua function vector map.
-    EventTypeToLuaFunctionVectorMap& GetEventTypeToLuaFunctionVectorMap(Object* sender)
-    {
-        if (!sender)
-            return eventTypeToLuaFunctionVectorMap;
-
-        return senderEventTypeToLuaFunctionVectorMap[sender];
-    }
-    /// Execute then destory command.
-    void ExecuteThenDestroyCommand(EventHandlerCommand* command);
-
+    
     /// Lua script instance.
-    LuaScriptInstance* instance_;
-    /// Invoking.
-    bool invoking_;
-    /// Event handler commands.
-    PODVector<EventHandlerCommand*> eventHandlerCommands_;
-    /// Event type to Lua function vector map.
-    EventTypeToLuaFunctionVectorMap eventTypeToLuaFunctionVectorMap;
-    /// Event type to Lua function vector map for specific sender.
-    HashMap<Object*, EventTypeToLuaFunctionVectorMap> senderEventTypeToLuaFunctionVectorMap;
+    WeakPtr<LuaScriptInstance> instance_;
 };
 
 }

+ 1 - 9
Source/Urho3D/LuaScript/LuaScriptEventListener.h

@@ -31,7 +31,7 @@ namespace Urho3D
 class URHO3D_API LuaScriptEventListener
 {
 public:
-    /// Destruct
+    /// Destruct.
     virtual ~LuaScriptEventListener() {};
 
     /// Add a scripted event handler by function.
@@ -42,16 +42,8 @@ public:
     virtual void AddEventHandler(Object* sender, const String& eventName, int functionIndex) = 0;
     /// Add a scripted event handler by function name for a specific sender.
     virtual void AddEventHandler(Object* sender, const String& eventName, const String& functionName) = 0;
-    /// Remove a scripted event handler by function.
-    virtual void RemoveEventHandler(const String& eventName, int functionIndex) = 0;
-    /// Remove a scripted event handler by function name.
-    virtual void RemoveEventHandler(const String& eventName, const String& functionName) = 0;
     /// Remove a scripted event handler.
     virtual void RemoveEventHandler(const String& eventName) = 0;
-    /// Remove a scripted event handler for a specific sender by function.
-    virtual void RemoveEventHandler(Object* sender, const String& eventName, int functionIndex) = 0;
-    /// Remove a scripted event handler for a specific sender by function name.
-    virtual void RemoveEventHandler(Object* sender, const String& eventName, const String& functionName) = 0;
     /// Remove a scripted event handler for a specific sender.
     virtual void RemoveEventHandler(Object* sender, const String& eventName) = 0;
     /// Remove all scripted event handlers for a specific sender.

+ 28 - 62
Source/Urho3D/LuaScript/LuaScriptInstance.cpp

@@ -71,6 +71,9 @@ LuaScriptInstance::LuaScriptInstance(Context* context) :
     attributeInfos_ = *context_->GetAttributes(GetTypeStatic());
 
     eventInvoker_ =  new LuaScriptEventInvoker(this);
+
+    for (int i = 0; i < MAX_LUA_SCRIPT_OBJECT_METHODS; ++i)
+        scriptObjectMethods_[i] = 0;
 }
 
 LuaScriptInstance::~LuaScriptInstance()
@@ -108,7 +111,7 @@ void LuaScriptInstance::OnSetAttribute(const AttributeInfo& attr, const Variant&
     int top = lua_gettop(luaState_);
 
     String functionName = String("Set") + name.Substring(0, 1).ToUpper() + name.Substring(1, length - 1);
-    WeakPtr<LuaFunction> function = GetScriptObjectFunction(functionName);
+    LuaFunction* function = GetScriptObjectFunction(functionName);
     // If set function exist
     if (function)
     {
@@ -215,7 +218,7 @@ void LuaScriptInstance::OnGetAttribute(const AttributeInfo& attr, Variant& dest)
     int top = lua_gettop(luaState_);
 
     String functionName = String("Get") + name.Substring(0, 1).ToUpper() + name.Substring(1, length - 1);
-    WeakPtr<LuaFunction> function = GetScriptObjectFunction(functionName);
+    LuaFunction* function = GetScriptObjectFunction(functionName);
     // If get function exist
     if (function)
     {
@@ -271,7 +274,7 @@ void LuaScriptInstance::OnGetAttribute(const AttributeInfo& attr, Variant& dest)
 
 void LuaScriptInstance::ApplyAttributes()
 {
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_APPLYATTRIBUTES];
+    LuaFunction* function = scriptObjectMethods_[LSOM_APPLYATTRIBUTES];
     if (function && function->BeginCall(this))
     {
         function->EndCall();
@@ -286,11 +289,9 @@ void LuaScriptInstance::OnSetEnabled()
         UnsubscribeFromScriptMethodEvents();
 }
 
-
-
 void LuaScriptInstance::AddEventHandler(const String& eventName, int functionIndex)
 {
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(functionIndex);
+    LuaFunction* function = luaScript_->GetFunction(functionIndex);
     if (function)
         eventInvoker_->AddEventHandler(0, eventName, function);
 }
@@ -298,7 +299,7 @@ void LuaScriptInstance::AddEventHandler(const String& eventName, int functionInd
 void LuaScriptInstance::AddEventHandler(const String& eventName, const String& functionName)
 {
     String realFunctionName = functionName.Replaced(":", ".");
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(realFunctionName);
+    LuaFunction* function = luaScript_->GetFunction(realFunctionName);
     if (function)
         eventInvoker_->AddEventHandler(0, eventName, function);
 }
@@ -308,7 +309,7 @@ void LuaScriptInstance::AddEventHandler(Object* sender, const String& eventName,
     if (!sender)
         return;
 
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(functionIndex);
+    LuaFunction* function = luaScript_->GetFunction(functionIndex);
     if (function)
         eventInvoker_->AddEventHandler(sender, eventName, function);
 }
@@ -319,50 +320,14 @@ void LuaScriptInstance::AddEventHandler(Object* sender, const String& eventName,
         return;
 
     String realFunctionName = functionName.Replaced(":", ".");
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(realFunctionName);
+    LuaFunction* function = luaScript_->GetFunction(realFunctionName);
     if (function)
         eventInvoker_->AddEventHandler(sender, eventName, function);
 }
 
-void LuaScriptInstance::RemoveEventHandler(const String& eventName, int functionIndex)
-{
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(functionIndex);
-    if (function)
-        eventInvoker_->RemoveEventHandler(0, eventName, function);
-}
-
-void LuaScriptInstance::RemoveEventHandler(const String& eventName, const String& functionName)
-{
-    String realFunctionName = functionName.Replaced(":", ".");
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(realFunctionName);
-    if (function)
-        eventInvoker_->RemoveEventHandler(0, eventName, function);
-}
-
 void LuaScriptInstance::RemoveEventHandler(const String& eventName)
 {
-    eventInvoker_->RemoveEventHandler(0, eventName, WeakPtr<LuaFunction>());
-}
-
-void LuaScriptInstance::RemoveEventHandler(Object* sender, const String& eventName, int functionIndex)
-{
-    if (!sender)
-        return;
-
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(functionIndex);
-    if (function)
-        eventInvoker_->RemoveEventHandler(sender, eventName, function);
-}
-
-void LuaScriptInstance::RemoveEventHandler(Object* sender, const String& eventName, const String& functionName)
-{
-    if (!sender)
-        return;
-
-    String realFunctionName = functionName.Replaced(":", ".");
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction(realFunctionName);
-    if (function)
-        eventInvoker_->RemoveEventHandler(sender, eventName, function);
+    eventInvoker_->UnsubscribeFromEvent(eventName);
 }
 
 void LuaScriptInstance::RemoveEventHandler(Object* sender, const String& eventName)
@@ -370,19 +335,20 @@ void LuaScriptInstance::RemoveEventHandler(Object* sender, const String& eventNa
     if (!sender)
         return;
 
-    eventInvoker_->RemoveEventHandler(sender, eventName, WeakPtr<LuaFunction>());
+    eventInvoker_->UnsubscribeFromEvent(sender, eventName);
 }
+
 void LuaScriptInstance::RemoveEventHandlers(Object* sender)
 {
     if (!sender)
         return;
 
-    eventInvoker_->RemoveAllEventHandlers(sender);
+    eventInvoker_->UnsubscribeFromEvents(sender);
 }
 
 void LuaScriptInstance::RemoveAllEventHandlers()
 {
-    eventInvoker_->RemoveAllEventHandlers(0);
+    eventInvoker_->UnsubscribeFromAllEvents();
 }
 
 void LuaScriptInstance::RemoveEventHandlersExcept(const Vector<String>& exceptionNames)
@@ -391,7 +357,7 @@ void LuaScriptInstance::RemoveEventHandlersExcept(const Vector<String>& exceptio
     for (unsigned i = 0; i < exceptionTypes.Size(); ++i)
         exceptionTypes[i] = StringHash(exceptionNames[i]);
 
-    eventInvoker_->RemoveEventHandlersExcept(exceptionTypes);
+    eventInvoker_->UnsubscribeFromAllEventsExcept(exceptionTypes, true);
 }
 
 bool LuaScriptInstance::CreateObject(const String& scriptObjectType)
@@ -429,7 +395,7 @@ void LuaScriptInstance::SetScriptObjectType(const String& scriptObjectType)
 
     ReleaseObject();
 
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction("CreateScriptObjectInstance");
+    LuaFunction* function = luaScript_->GetFunction("CreateScriptObjectInstance");
     if (!function || !function->BeginCall())
         return;
 
@@ -453,7 +419,7 @@ void LuaScriptInstance::SetScriptDataAttr(const PODVector<unsigned char>& data)
     if (scriptObjectRef_ == LUA_REFNIL)
         return;
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_LOAD];
+    LuaFunction* function = scriptObjectMethods_[LSOM_LOAD];
     if (function && function->BeginCall(this))
     {
         MemoryBuffer buf(data);
@@ -467,7 +433,7 @@ void LuaScriptInstance::SetScriptNetworkDataAttr(const PODVector<unsigned char>&
     if (scriptObjectRef_ == LUA_REFNIL)
         return;
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_READNETWORKUPDATE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_READNETWORKUPDATE];
     if (function && function->BeginCall(this))
     {
         MemoryBuffer buf(data);
@@ -488,7 +454,7 @@ PODVector<unsigned char> LuaScriptInstance::GetScriptDataAttr() const
 
     VectorBuffer buf;
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_SAVE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_SAVE];
     if (function && function->BeginCall(this))
     {
         function->PushUserType((Serializer&)buf, "Serializer");
@@ -505,7 +471,7 @@ PODVector<unsigned char> LuaScriptInstance::GetScriptNetworkDataAttr() const
 
     VectorBuffer buf;
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_WRITENETWORKUPDATE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_WRITENETWORKUPDATE];
     if (function && function->BeginCall(this))
     {
         function->PushUserType((Serializer&)buf, "Serializer");
@@ -525,7 +491,7 @@ void LuaScriptInstance::OnMarkedDirty(Node* node)
         return;
     }
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_TRANSFORMCHANGED];
+    LuaFunction* function = scriptObjectMethods_[LSOM_TRANSFORMCHANGED];
     if (function && function->BeginCall(this))
     {
         function->EndCall();
@@ -676,7 +642,7 @@ void LuaScriptInstance::HandleUpdate(StringHash eventType, VariantMap& eventData
     using namespace Update;
     float timeStep = eventData[P_TIMESTEP].GetFloat();
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_UPDATE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_UPDATE];
     if (function && function->BeginCall(this))
     {
         function->PushFloat(timeStep);
@@ -689,7 +655,7 @@ void LuaScriptInstance::HandlePostUpdate(StringHash eventType, VariantMap& event
     using namespace PostUpdate;
     float timeStep = eventData[P_TIMESTEP].GetFloat();
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_POSTUPDATE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_POSTUPDATE];
     if (function && function->BeginCall(this))
     {
         function->PushFloat(timeStep);
@@ -703,7 +669,7 @@ void LuaScriptInstance::HandleFixedUpdate(StringHash eventType, VariantMap& even
     using namespace PhysicsPreStep;
     float timeStep = eventData[P_TIMESTEP].GetFloat();
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_FIXEDUPDATE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_FIXEDUPDATE];
     if (function && function->BeginCall(this))
     {
         function->PushFloat(timeStep);
@@ -716,7 +682,7 @@ void LuaScriptInstance::HandlePostFixedUpdate(StringHash eventType, VariantMap&
     using namespace PhysicsPostStep;
     float timeStep = eventData[P_TIMESTEP].GetFloat();
 
-    WeakPtr<LuaFunction> function = scriptObjectMethods_[LSOM_FIXEDPOSTUPDATE];
+    LuaFunction* function = scriptObjectMethods_[LSOM_FIXEDPOSTUPDATE];
     if (function && function->BeginCall(this))
     {
         function->PushFloat(timeStep);
@@ -739,7 +705,7 @@ void LuaScriptInstance::ReleaseObject()
     luaL_unref(luaState_, LUA_REGISTRYINDEX, scriptObjectRef_);
     scriptObjectRef_ = LUA_REFNIL;
 
-    WeakPtr<LuaFunction> function = luaScript_->GetFunction("DestroyScriptObjectInstance");
+    LuaFunction* function = luaScript_->GetFunction("DestroyScriptObjectInstance");
     if (function && function->BeginCall())
     {
         function->PushUserType((void*)this, "LuaScriptInstance");
@@ -747,7 +713,7 @@ void LuaScriptInstance::ReleaseObject()
     }
 }
 
-WeakPtr<LuaFunction> LuaScriptInstance::GetScriptObjectFunction(const String& functionName) const
+LuaFunction* LuaScriptInstance::GetScriptObjectFunction(const String& functionName) const
 {
     return luaScript_->GetFunction(scriptObjectType_ + "." + functionName, true);
 }

+ 2 - 10
Source/Urho3D/LuaScript/LuaScriptInstance.h

@@ -85,16 +85,8 @@ public:
     virtual void AddEventHandler(Object* sender, const String& eventName, int functionIndex);
     /// Add a scripted event handler by function name for a specific sender.
     virtual void AddEventHandler(Object* sender, const String& eventName, const String& functionName);
-    /// Remove a scripted event handler by function.
-    virtual void RemoveEventHandler(const String& eventName, int functionIndex);
-    /// Remove a scripted event handler by function name.
-    virtual void RemoveEventHandler(const String& eventName, const String& functionName);
     /// Remove a scripted event handler.
     virtual void RemoveEventHandler(const String& eventName);
-    /// Remove a scripted event handler for a specific sender by function.
-    virtual void RemoveEventHandler(Object* sender, const String& eventName, int functionIndex);
-    /// Remove a scripted event handler for a specific sender by function name.
-    virtual void RemoveEventHandler(Object* sender, const String& eventName, const String& functionName);
     /// Remove a scripted event handler for a specific sender.
     virtual void RemoveEventHandler(Object* sender, const String& eventName);
     /// Remove all scripted event handlers for a specific sender.
@@ -128,7 +120,7 @@ public:
     /// Get script network serialization attribute by calling a script function.
     PODVector<unsigned char> GetScriptNetworkDataAttr() const;
     /// Return script object's funcition.
-    WeakPtr<LuaFunction> GetScriptObjectFunction(const String& functionName) const;
+    LuaFunction* GetScriptObjectFunction(const String& functionName) const;
 
     /// Set script file attribute.
     void SetScriptFileAttr(const ResourceRef& value);
@@ -176,7 +168,7 @@ private:
     /// Script object ref.
     int scriptObjectRef_;
     /// Script object method.
-    WeakPtr<LuaFunction> scriptObjectMethods_[MAX_LUA_SCRIPT_OBJECT_METHODS];
+    LuaFunction* scriptObjectMethods_[MAX_LUA_SCRIPT_OBJECT_METHODS];
 };
 
 }

+ 3 - 63
Source/Urho3D/LuaScript/pkgs/LuaScript/LuaScript.pkg

@@ -3,10 +3,7 @@ $#include "LuaScript/LuaScript.h"
 void LuaScriptAddEventHandler @ SubscribeToEvent(const String eventName, void* functionOrFunctionName);
 void LuaScriptAddEventHandler @ SubscribeToEvent(void* sender, const String eventName, void* functionOrFunctionName);
 
-void LuaScriptRemoveEventHandler @ UnsubscribeFromEvent(const String eventName, void* functionOrFunctionName);
 void LuaScriptRemoveEventHandler @ UnsubscribeFromEvent(const String eventName);
-
-void LuaScriptRemoveEventHandler @ UnsubscribeFromEvent(Object* sender, const String eventName, void* functionOrFunctionName);
 void LuaScriptRemoveEventHandler @ UnsubscribeFromEvent(Object* sender, const String eventName);
 
 void LuaScriptRemoveEventHandlers @ UnsubscribeFromEvents(Object* sender);
@@ -123,28 +120,10 @@ static int tolua_LuaScriptLuaAPI_UnsubscribeFromEvent(lua_State* tolua_S)
     }
     else if (args == 2)
     {
-        // UnsubscribeFromEvent(const String eventName, void* functionOrFunctionName);
-        if (tolua_isurho3dstring(tolua_S,1,0,&tolua_err))
-        {
-            if (!tolua_isfunctionorurho3dstring(tolua_S,2,0,&tolua_err))
-                goto tolua_lerror;
-        }
         // UnsubscribeFromEvent(Object* sender, const String eventName);
-        else if (tolua_isuserdata(tolua_S,1,0,&tolua_err))
-        {
-            if (!tolua_isurho3dstring(tolua_S,2,0,&tolua_err))
-                goto tolua_lerror;
-        }
-        else
-            goto tolua_lerror;
-    }
-    else if (args == 3)
-    {
-        // UnsubscribeFromEvent(Object* sender, const String eventName, void* functionOrFunctionName);
         if (!tolua_isuserdata(tolua_S,1,0,&tolua_err) ||
-            !tolua_isurho3dstring(tolua_S,2,0,&tolua_err) ||
-            !tolua_isfunctionorurho3dstring(tolua_S,3,0,&tolua_err))
-            goto tolua_lerror;
+            !tolua_isurho3dstring(tolua_S,2,0,&tolua_err))
+                goto tolua_lerror;
     }
     else
         goto tolua_lerror;
@@ -158,38 +137,10 @@ static int tolua_LuaScriptLuaAPI_UnsubscribeFromEvent(lua_State* tolua_S)
     }
     else if (args == 2)
     {
-        // UnsubscribeFromEvent(const String eventName, void* functionOrFunctionName);
-        if (tolua_isurho3dstring(tolua_S,1,0,&tolua_err))
-        {
-            const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,1,0));
-            if (lua_isfunction(tolua_S, 2))
-                LuaScriptRemoveEventHandler(eventName, 2);
-            else
-            {
-                const String functionName = (const String)tolua_tourho3dstring(tolua_S,2,0);
-                LuaScriptRemoveEventHandler(eventName, functionName);
-            }
-        }
         // UnsubscribeFromEvent(Object* sender, const String eventName);
-        else if (tolua_isuserdata(tolua_S,1,0,&tolua_err))
-        {
-            Object* sender = ((Object*)  tolua_touserdata(tolua_S,1,0));
-            const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,2,0));
-            LuaScriptRemoveEventHandler(sender, eventName);
-        }
-    }
-    else if (args == 3)
-    {
-        // UnsubscribeFromEvent(Object* sender, const String eventName, void* functionOrFunctionName);
         Object* sender = ((Object*)  tolua_touserdata(tolua_S,1,0));
         const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,2,0));
-        if (lua_isfunction(tolua_S,3))
-            LuaScriptRemoveEventHandler(sender,eventName,3);
-        else
-        {
-            const String functionName = (const String)tolua_tourho3dstring(tolua_S,3,0);
-            LuaScriptRemoveEventHandler(sender,eventName,functionName);
-        }
+        LuaScriptRemoveEventHandler(sender, eventName);
     }
 
     return 0;
@@ -213,15 +164,4 @@ static int tolua_LuaScriptLuaAPI_UnsubscribeFromEvent01(lua_State* tolua_S)
     return tolua_LuaScriptLuaAPI_UnsubscribeFromEvent(tolua_S);
 }
 
-#define TOLUA_DISABLE_tolua_LuaScriptLuaAPI_UnsubscribeFromEvent02
-static int tolua_LuaScriptLuaAPI_UnsubscribeFromEvent02(lua_State* tolua_S)
-{
-    return tolua_LuaScriptLuaAPI_UnsubscribeFromEvent(tolua_S);
-}
-
-#define TOLUA_DISABLE_tolua_LuaScriptLuaAPI_UnsubscribeFromEvent03
-static int tolua_LuaScriptLuaAPI_UnsubscribeFromEvent03(lua_State* tolua_S)
-{
-    return tolua_LuaScriptLuaAPI_UnsubscribeFromEvent(tolua_S);
-}
 $}

+ 7 - 72
Source/Urho3D/LuaScript/pkgs/LuaScript/LuaScriptInstance.pkg

@@ -9,9 +9,7 @@ class LuaScriptInstance : public Component
 
     void AddEventHandler @ SubscribeToEvent(const String eventName, void* functionOrFunctionName);
     void AddEventHandler @ SubscribeToEvent(void* sender, const String eventName, void* functionOrFunctionName);
-    void RemoveEventHandler @ UnsubscribeFromEvent(const String eventName, void* functionOrFunctionName);
     void RemoveEventHandler @ UnsubscribeFromEvent(const String eventName);
-    void RemoveEventHandler @ UnsubscribeFromEvent(Object* sender, const String eventName, void* functionOrFunctionName);
     void RemoveEventHandler @ UnsubscribeFromEvent(Object* sender, const String eventName);
     void RemoveEventHandlers @ UnsubscribeFromEvents(Object* sender);
     void RemoveAllEventHandlers @ UnsubscribeFromAllEvents();
@@ -50,7 +48,7 @@ function LuaScriptObject:SubscribeToEvent(param1, param2, param3)
     end
 end
 
-function LuaScriptObject:UnsubscribeFromEvent(param1, param2, param3)
+function LuaScriptObject:UnsubscribeFromEvent(param1, param2)
     local instance = self.instance
     if instance == nil then
         return
@@ -58,10 +56,8 @@ function LuaScriptObject:UnsubscribeFromEvent(param1, param2, param3)
 
     if param2 == nil then
         instance:UnsubscribeFromEvent(param1)
-    elseif param3 == nil then
-        instance:UnsubscribeFromEvent(param1, param2)
     else
-        instance:UnsubscribeFromEvent(param1, param2, param3)
+        instance:UnsubscribeFromEvent(param1, param2)
     end
 end
 
@@ -230,32 +226,11 @@ static int tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent(lua_Stat
     }
     else if (args == 3)
     {
-        // LuaScriptInstance::RemoveEventHandler(const String eventName, void* functionOrFunctionName);
-        if (!tolua_isusertype(tolua_S,1,"LuaScriptInstance",0,&tolua_err))
-            goto tolua_lerror;
-
-        if (tolua_isurho3dstring(tolua_S,2,0,&tolua_err))
-        {
-            if (!tolua_isfunctionorurho3dstring(tolua_S,3,0,&tolua_err))
-                goto tolua_lerror;
-        }
-        // LuaScriptInstance::RemoveEventHandler(Object* sender, const String eventName);
-        else if (tolua_isuserdata(tolua_S,2,0,&tolua_err))
-        {
-            if (!tolua_isurho3dstring(tolua_S,3,0,&tolua_err))
-                goto tolua_lerror;
-        }
-        else
-            goto tolua_lerror;
-    }
-    else if (args == 4)
-    {
-        // LuaScriptInstance::RemoveEventHandler(Object* sender, const String eventName, void* functionOrFunctionName);
+       // LuaScriptInstance::RemoveEventHandler(Object* sender, const String eventName);
         if (!tolua_isusertype(tolua_S,1,"LuaScriptInstance",0,&tolua_err) ||
             !tolua_isuserdata(tolua_S,2,0,&tolua_err) ||
-            !tolua_isurho3dstring(tolua_S,3,0,&tolua_err) ||
-            !tolua_isfunctionorurho3dstring(tolua_S,4,0,&tolua_err))
-            goto tolua_lerror;
+            !tolua_isurho3dstring(tolua_S,3,0,&tolua_err))
+                goto tolua_lerror;
     }
     else
         goto tolua_lerror;
@@ -269,40 +244,12 @@ static int tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent(lua_Stat
         const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,2,0));
         self->RemoveEventHandler(eventName);
     }
-    else if (args == 2)
+    else if (args == 3)
     {
-        // LuaScriptInstance::RemoveEventHandler(const String eventName, void* functionOrFunctionName);
-        if (tolua_isurho3dstring(tolua_S,2,0,&tolua_err))
-        {
-            const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,2,0));
-            if (lua_isfunction(tolua_S, 3))
-                self->RemoveEventHandler(eventName, 3);
-            else
-            {
-                const String functionName = (const String)tolua_tourho3dstring(tolua_S,3,0);
-                self->RemoveEventHandler(eventName, functionName);
-            }
-        }
         // LuaScriptInstance::RemoveEventHandler(Object* sender, const String eventName);
-        else if (tolua_isuserdata(tolua_S,2,0,&tolua_err))
-        {
-            Object* sender = ((Object*)  tolua_touserdata(tolua_S,2,0));
-            const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,3,0));
-            self->RemoveEventHandler(sender, eventName);
-        }
-    }
-    else if (args == 4)
-    {
-        // LuaScriptInstance::RemoveEventHandler(Object* sender, const String eventName, void* functionOrFunctionName);
         Object* sender = ((Object*)  tolua_touserdata(tolua_S,2,0));
         const String eventName = ((const String)  tolua_tourho3dstring(tolua_S,3,0));
-        if (lua_isfunction(tolua_S,4))
-            self->RemoveEventHandler(sender,eventName,4);
-        else
-        {
-            const String functionName = (const String)tolua_tourho3dstring(tolua_S,4,0);
-            self->RemoveEventHandler(sender,eventName,functionName);
-        }
+        self->RemoveEventHandler(sender, eventName);
     }
 
     return 0;
@@ -326,16 +273,4 @@ static int tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent01(lua_St
     return tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent(tolua_S);
 }
 
-#define TOLUA_DISABLE_tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent02
-static int tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent02(lua_State* tolua_S)
-{
-    return tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent(tolua_S);
-}
-
-#define TOLUA_DISABLE_tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent03
-static int tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent03(lua_State* tolua_S)
-{
-    return tolua_LuaScriptLuaAPI_LuaScriptInstance_UnsubscribeFromEvent(tolua_S);
-}
-
 $}

+ 13 - 13
Source/Urho3D/Urho2D/ParticleEffect2D.cpp

@@ -284,7 +284,7 @@ bool ParticleEffect2D::Save(Serializer& dest) const
     WriteFloat(rootElem, "rotationEnd", rotationEnd_);
     WriteFloat(rootElem, "rotationEndVariance", rotationEndVariance_);
 
-	return xmlFile.Save(dest);
+    return xmlFile.Save(dest);
 }
 
 void ParticleEffect2D::SetSprite(Sprite2D* sprite)
@@ -486,30 +486,30 @@ Vector2 ParticleEffect2D::ReadVector2(const XMLElement& element, const String& n
 
 void ParticleEffect2D::WriteInt(XMLElement& element, const String& name, int value) const
 {
-	XMLElement child = element.CreateChild(name);
-	child.SetInt("value", value);
+    XMLElement child = element.CreateChild(name);
+    child.SetInt("value", value);
 }
 
 void ParticleEffect2D::WriteFloat(XMLElement& element, const String& name, float value) const
 {
-	XMLElement child = element.CreateChild(name);
-	child.SetFloat("value", value);
+    XMLElement child = element.CreateChild(name);
+    child.SetFloat("value", value);
 }
 
 void ParticleEffect2D::WriteColor(XMLElement& element, const String& name, const Color& color) const
 {
-	XMLElement child = element.CreateChild(name);
-	child.SetFloat("red", color.r_);
-	child.SetFloat("green", color.g_);
-	child.SetFloat("blue", color.b_);
-	child.SetFloat("alpha", color.a_);
+    XMLElement child = element.CreateChild(name);
+    child.SetFloat("red", color.r_);
+    child.SetFloat("green", color.g_);
+    child.SetFloat("blue", color.b_);
+    child.SetFloat("alpha", color.a_);
 }
 
 void ParticleEffect2D::WriteVector2(XMLElement& element,const String& name,const Vector2& value) const
 {
-	XMLElement child = element.CreateChild(name);
-	child.SetFloat("x", value.x_);
-	child.SetFloat("y", value.y_);
+    XMLElement child = element.CreateChild(name);
+    child.SetFloat("x", value.x_);
+    child.SetFloat("y", value.y_);
 }
 
 }