Просмотр исходного кода

All thunk calls now use MonoUtil::invokeThunk

Marko Pintera 10 лет назад
Родитель
Сommit
97422accdc
32 измененных файлов с 76 добавлено и 264 удалено
  1. 0 1
      BansheeMono/Include/BsMonoField.h
  2. 9 0
      BansheeMono/Include/BsMonoUtil.h
  3. 3 15
      SBansheeEditor/Source/BsScriptDropDownWindow.cpp
  4. 3 15
      SBansheeEditor/Source/BsScriptEditorWindow.cpp
  5. 4 19
      SBansheeEditor/Source/BsScriptFolderMonitor.cpp
  6. 1 4
      SBansheeEditor/Source/BsScriptGUIColorField.cpp
  7. 1 4
      SBansheeEditor/Source/BsScriptGUIComponentFoldout.cpp
  8. 1 4
      SBansheeEditor/Source/BsScriptGUIFloatField.cpp
  9. 1 4
      SBansheeEditor/Source/BsScriptGUIFoldout.cpp
  10. 1 5
      SBansheeEditor/Source/BsScriptGUIGameObjectField.cpp
  11. 1 4
      SBansheeEditor/Source/BsScriptGUIIntField.cpp
  12. 1 5
      SBansheeEditor/Source/BsScriptGUIResourceField.cpp
  13. 1 5
      SBansheeEditor/Source/BsScriptGUITextField.cpp
  14. 1 4
      SBansheeEditor/Source/BsScriptGUIToggleField.cpp
  15. 1 4
      SBansheeEditor/Source/BsScriptGUIVector2Field.cpp
  16. 1 4
      SBansheeEditor/Source/BsScriptGUIVector3Field.cpp
  17. 1 4
      SBansheeEditor/Source/BsScriptGUIVector4Field.cpp
  18. 1 4
      SBansheeEditor/Source/BsScriptHandleManager.cpp
  19. 3 15
      SBansheeEditor/Source/BsScriptModalWindow.cpp
  20. 7 16
      SBansheeEditor/Source/BsScriptOSDropTarget.cpp
  21. 2 10
      SBansheeEditor/Source/BsScriptProjectLibrary.cpp
  22. 4 20
      SBansheeEngine/Source/BsManagedComponent.cpp
  23. 1 4
      SBansheeEngine/Source/BsScriptContextMenu.cpp
  24. 4 16
      SBansheeEngine/Source/BsScriptGUIButton.cpp
  25. 1 4
      SBansheeEngine/Source/BsScriptGUIElement.cpp
  26. 1 5
      SBansheeEngine/Source/BsScriptGUIInputBox.cpp
  27. 1 4
      SBansheeEngine/Source/BsScriptGUIListBox.cpp
  28. 2 8
      SBansheeEngine/Source/BsScriptGUISlider.cpp
  29. 4 16
      SBansheeEngine/Source/BsScriptGUIToggle.cpp
  30. 11 28
      SBansheeEngine/Source/BsScriptInput.cpp
  31. 3 12
      SBansheeEngine/Source/BsScriptVirtualInput.cpp
  32. 0 1
      TODO.txt

+ 0 - 1
BansheeMono/Include/BsMonoField.h

@@ -90,6 +90,5 @@ namespace BansheeEngine
 		String mName;
 		MonoClassField* mField;
 		MonoClass* mFieldType;
-		void* mThunk;
 	};
 }

+ 9 - 0
BansheeMono/Include/BsMonoUtil.h

@@ -146,5 +146,14 @@ namespace BansheeEngine
 				BS_EXCEPT(InternalErrorException, msg);
 			}
 		}
+
+		template<class T, class... Args>
+		static void invokeThunk(T* thunk, Args... args)
+		{
+			MonoException* exception = nullptr;
+			thunk(std::forward<Args>(args)..., &exception);
+
+			throwIfException(exception);
+		}
 	};
 }

+ 3 - 15
SBansheeEditor/Source/BsScriptDropDownWindow.cpp

@@ -165,13 +165,9 @@ namespace BansheeEngine
 	{
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnInitializeThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnInitializeThunk, mManagedInstance);
 		}
 	}
 
@@ -179,13 +175,9 @@ namespace BansheeEngine
 	{
 		if (mOnDestroyThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnDestroyThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnDestroyThunk, mManagedInstance);
 		}
 	}
 
@@ -193,13 +185,9 @@ namespace BansheeEngine
 	{
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mUpdateThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mUpdateThunk, mManagedInstance);
 		}
 	}
 

+ 3 - 15
SBansheeEditor/Source/BsScriptEditorWindow.cpp

@@ -335,13 +335,9 @@ namespace BansheeEngine
 	{
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnInitializeThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnInitializeThunk, mManagedInstance);
 		}
 	}
 
@@ -349,13 +345,9 @@ namespace BansheeEngine
 	{
 		if (mOnDestroyThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnDestroyThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnDestroyThunk, mManagedInstance);
 		}
 	}
 
@@ -363,13 +355,9 @@ namespace BansheeEngine
 	{
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mUpdateThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mUpdateThunk, mManagedInstance);
 		}
 	}
 

+ 4 - 19
SBansheeEditor/Source/BsScriptFolderMonitor.cpp

@@ -70,31 +70,19 @@ namespace BansheeEngine
 	void ScriptFolderMonitor::onMonitorFileModified(const Path& path)
 	{
 		MonoString* monoPath = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), path.toWString());
-
-		MonoException* exception = nullptr;
-		OnModifiedThunk(getManagedInstance(), monoPath, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnModifiedThunk, getManagedInstance(), monoPath);
 	}
 
 	void ScriptFolderMonitor::onMonitorFileAdded(const Path& path)
 	{
 		MonoString* monoPath = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), path.toWString());
-
-		MonoException* exception = nullptr;
-		OnAddedThunk(getManagedInstance(), monoPath, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnAddedThunk, getManagedInstance(), monoPath);
 	}
 
 	void ScriptFolderMonitor::onMonitorFileRemoved(const Path& path)
 	{
 		MonoString* monoPath = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), path.toWString());
-
-		MonoException* exception = nullptr;
-		OnRemovedThunk(getManagedInstance(), monoPath, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnRemovedThunk, getManagedInstance(), monoPath);
 	}
 
 	void ScriptFolderMonitor::onMonitorFileRenamed(const Path& from, const Path& to)
@@ -102,10 +90,7 @@ namespace BansheeEngine
 		MonoString* monoPathFrom = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), from.toWString());
 		MonoString* monoPathTo = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), to.toWString());
 
-		MonoException* exception = nullptr;
-		OnRenamedThunk(getManagedInstance(), monoPathFrom, monoPathTo, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnRenamedThunk, getManagedInstance(), monoPathFrom, monoPathTo);
 	}
 
 	void ScriptFolderMonitor::update()

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIColorField.cpp

@@ -84,9 +84,6 @@ namespace BansheeEngine
 
 	void ScriptGUIColorField::onChanged(MonoObject* instance, Color newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIComponentFoldout.cpp

@@ -82,9 +82,6 @@ namespace BansheeEngine
 
 	void ScriptGUIComponentFoldout::onToggled(MonoObject* instance, bool expanded)
 	{
-		MonoException* exception = nullptr;
-		onToggledThunk(instance, expanded, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onToggledThunk, instance, expanded);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIFloatField.cpp

@@ -91,9 +91,6 @@ namespace BansheeEngine
 
 	void ScriptGUIFloatField::onChanged(MonoObject* instance, float newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIFoldout.cpp

@@ -82,9 +82,6 @@ namespace BansheeEngine
 
 	void ScriptGUIFoldout::onToggled(MonoObject* instance, bool expanded)
 	{
-		MonoException* exception = nullptr;
-		onToggledThunk(instance, expanded, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onToggledThunk, instance, expanded);
 	}
 }

+ 1 - 5
SBansheeEditor/Source/BsScriptGUIGameObjectField.cpp

@@ -103,12 +103,8 @@ namespace BansheeEngine
 
 	void ScriptGUIGameObjectField::onChanged(MonoObject* instance, const HGameObject& newValue)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* managedObj = nativeToManagedGO(newValue);
-
-		onChangedThunk(instance, managedObj, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, managedObj);
 	}
 
 	MonoObject* ScriptGUIGameObjectField::nativeToManagedGO(const HGameObject& instance)

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIIntField.cpp

@@ -98,9 +98,6 @@ namespace BansheeEngine
 
 	void ScriptGUIIntField::onChanged(MonoObject* instance, INT32 newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 5
SBansheeEditor/Source/BsScriptGUIResourceField.cpp

@@ -102,12 +102,8 @@ namespace BansheeEngine
 
 	void ScriptGUIResourceField::onChanged(MonoObject* instance, const HResource& newValue)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* managedObj = nativeToManagedResource(newValue);
-
-		onChangedThunk(instance, managedObj, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, managedObj);
 	}
 
 	MonoObject* ScriptGUIResourceField::nativeToManagedResource(const HResource& instance)

+ 1 - 5
SBansheeEditor/Source/BsScriptGUITextField.cpp

@@ -91,11 +91,7 @@ namespace BansheeEngine
 
 	void ScriptGUITextField::onChanged(MonoObject* instance, const WString& newValue)
 	{
-		MonoException* exception = nullptr;
 		MonoString* monoNewValue = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), newValue);
-
-		onChangedThunk(instance, monoNewValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, monoNewValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIToggleField.cpp

@@ -84,9 +84,6 @@ namespace BansheeEngine
 
 	void ScriptGUIToggleField::onChanged(MonoObject* instance, bool newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIVector2Field.cpp

@@ -91,9 +91,6 @@ namespace BansheeEngine
 
 	void ScriptGUIVector2Field::onChanged(MonoObject* instance, Vector2 newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIVector3Field.cpp

@@ -91,9 +91,6 @@ namespace BansheeEngine
 
 	void ScriptGUIVector3Field::onChanged(MonoObject* instance, Vector3 newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptGUIVector4Field.cpp

@@ -91,9 +91,6 @@ namespace BansheeEngine
 
 	void ScriptGUIVector4Field::onChanged(MonoObject* instance, Vector4 newValue)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, newValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, newValue);
 	}
 }

+ 1 - 4
SBansheeEditor/Source/BsScriptHandleManager.cpp

@@ -238,9 +238,6 @@ namespace BansheeEngine
 
 	void ScriptHandleManager::callDestroy(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		mDestroyThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(mDestroyThunk, instance);
 	}
 }

+ 3 - 15
SBansheeEditor/Source/BsScriptModalWindow.cpp

@@ -240,13 +240,9 @@ namespace BansheeEngine
 	{
 		if (mOnInitializeThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnInitializeThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnInitializeThunk, mManagedInstance);
 		}
 	}
 
@@ -254,13 +250,9 @@ namespace BansheeEngine
 	{
 		if (mOnDestroyThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnDestroyThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnDestroyThunk, mManagedInstance);
 		}
 	}
 
@@ -273,13 +265,9 @@ namespace BansheeEngine
 	{
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mUpdateThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mUpdateThunk, mManagedInstance);
 		}
 	}
 

+ 7 - 16
SBansheeEditor/Source/BsScriptOSDropTarget.cpp

@@ -172,10 +172,8 @@ namespace BansheeEngine
 		if (thisPtr->mIsDestroyed)
 			return;
 
-		MonoException* exception = nullptr;
-		onEnterThunk(thisPtr->getManagedInstance(), x - thisPtr->mParentArea.x, y - thisPtr->mParentArea.y, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onEnterThunk, thisPtr->getManagedInstance(), 
+			x - thisPtr->mParentArea.x, y - thisPtr->mParentArea.y);
 	}
 
 	void ScriptOSDropTarget::dropTargetDragMove(ScriptOSDropTarget* thisPtr, INT32 x, INT32 y)
@@ -183,10 +181,8 @@ namespace BansheeEngine
 		if (thisPtr->mIsDestroyed)
 			return;
 
-		MonoException* exception = nullptr;
-		onMoveThunk(thisPtr->getManagedInstance(), x - thisPtr->mParentArea.x, y - thisPtr->mParentArea.y, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onMoveThunk, thisPtr->getManagedInstance(), 
+			x - thisPtr->mParentArea.x, y - thisPtr->mParentArea.y);
 	}
 
 	void ScriptOSDropTarget::dropTargetDragLeave(ScriptOSDropTarget* thisPtr)
@@ -194,10 +190,7 @@ namespace BansheeEngine
 		if (thisPtr->mIsDestroyed)
 			return;
 
-		MonoException* exception = nullptr;
-		onLeaveThunk(thisPtr->getManagedInstance(), &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onLeaveThunk, thisPtr->getManagedInstance());
 	}
 
 	void ScriptOSDropTarget::dropTargetDragDropped(ScriptOSDropTarget* thisPtr, INT32 x, INT32 y)
@@ -205,10 +198,8 @@ namespace BansheeEngine
 		if (thisPtr->mIsDestroyed)
 			return;
 
-		MonoException* exception = nullptr;
-		onDropThunk(thisPtr->getManagedInstance(), x - thisPtr->mParentArea.x, y - thisPtr->mParentArea.y, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onDropThunk, thisPtr->getManagedInstance(), 
+			x - thisPtr->mParentArea.x, y - thisPtr->mParentArea.y);
 	}
 
 	void ScriptOSDropTarget::widgetParentChanged(EditorWidgetContainer* parent)

+ 2 - 10
SBansheeEditor/Source/BsScriptProjectLibrary.cpp

@@ -246,21 +246,13 @@ namespace BansheeEngine
 	void ScriptProjectLibrary::onEntryAdded(const Path& path)
 	{
 		MonoString* pathStr = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), path.toWString());
-
-		MonoException* exception = nullptr;
-		OnEntryAddedThunk(pathStr, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnEntryAddedThunk, pathStr);
 	}
 
 	void ScriptProjectLibrary::onEntryRemoved(const Path& path)
 	{
 		MonoString* pathStr = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), path.toWString());
-
-		MonoException* exception = nullptr;
-		OnEntryRemovedThunk(pathStr, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnEntryRemovedThunk, pathStr);
 	}
 
 	ScriptLibraryEntryBase::ScriptLibraryEntryBase(MonoObject* instance)

+ 4 - 20
SBansheeEngine/Source/BsManagedComponent.cpp

@@ -193,13 +193,9 @@ namespace BansheeEngine
 	{
 		if (mUpdateThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mUpdateThunk(mManagedInstance, &exception); 
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mUpdateThunk, mManagedInstance);
 		}
 	}
 
@@ -207,13 +203,9 @@ namespace BansheeEngine
 	{
 		if (mRequiresReset && mOnResetThunk != nullptr && mManagedInstance != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnResetThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnResetThunk, mManagedInstance);
 		}
 
 		mRequiresReset = false;
@@ -243,13 +235,9 @@ namespace BansheeEngine
 
 		if (mOnInitializedThunk != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnInitializedThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnInitializedThunk, mManagedInstance);
 		}
 
 		triggerOnReset();
@@ -261,13 +249,9 @@ namespace BansheeEngine
 
 		if (mOnDestroyThunk != nullptr)
 		{
-			MonoException* exception = nullptr;
-
 			// Note: Not calling virtual methods. Can be easily done if needed but for now doing this
 			// for some extra speed.
-			mOnDestroyThunk(mManagedInstance, &exception);
-
-			MonoUtil::throwIfException(exception);
+			MonoUtil::invokeThunk(mOnDestroyThunk, mManagedInstance);
 		}
 
 		if (mManagedInstance != nullptr)

+ 1 - 4
SBansheeEngine/Source/BsScriptContextMenu.cpp

@@ -65,9 +65,6 @@ namespace BansheeEngine
 
 	void ScriptContextMenu::onContextMenuItemTriggered(UINT32 idx)
 	{
-		MonoException* exception = nullptr;
-		onEntryTriggered(getManagedInstance(), idx, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onEntryTriggered, getManagedInstance(), idx);
 	}
 }

+ 4 - 16
SBansheeEngine/Source/BsScriptGUIButton.cpp

@@ -74,33 +74,21 @@ namespace BansheeEngine
 
 	void ScriptGUIButton::onClick(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onClickThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onClickThunk, instance);
 	}
 
 	void ScriptGUIButton::onDoubleClick(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onDoubleClickThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onDoubleClickThunk, instance);
 	}
 
 	void ScriptGUIButton::onHover(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onHoverThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onHoverThunk, instance);
 	}
 
 	void ScriptGUIButton::onOut(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onOutThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onOutThunk, instance);
 	}
 }

+ 1 - 4
SBansheeEngine/Source/BsScriptGUIElement.cpp

@@ -31,10 +31,7 @@ namespace BansheeEngine
 
 	void ScriptGUIElementBaseTBase::onFocusChanged(MonoObject* instance, bool focus)
 	{
-		MonoException* exception = nullptr;
-		ScriptGUIElement::onFocusChangedThunk(instance, focus, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(ScriptGUIElement::onFocusChangedThunk, instance, focus);
 	}
 
 	void ScriptGUIElementBaseTBase::_onManagedInstanceDeleted()

+ 1 - 5
SBansheeEngine/Source/BsScriptGUIInputBox.cpp

@@ -65,10 +65,6 @@ namespace BansheeEngine
 	void ScriptGUIInputBox::onChanged(MonoObject* instance, const WString& newValue)
 	{
 		MonoString* monoValue = MonoUtil::wstringToMono(MonoManager::instance().getDomain(), newValue);
-
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, monoValue, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, monoValue);
 	}
 }

+ 1 - 4
SBansheeEngine/Source/BsScriptGUIListBox.cpp

@@ -92,9 +92,6 @@ namespace BansheeEngine
 
 	void ScriptGUIListBox::onSelectionChanged(MonoObject* instance, UINT32 index)
 	{
-		MonoException* exception = nullptr;
-		onSelectionChangedThunk(instance, index, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onSelectionChangedThunk, instance, index);
 	}
 }

+ 2 - 8
SBansheeEngine/Source/BsScriptGUISlider.cpp

@@ -70,10 +70,7 @@ namespace BansheeEngine
 
 	void ScriptGUISliderH::onChanged(MonoObject* instance, float percent)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, percent, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, percent);
 	}
 
 	ScriptGUISliderV::OnChangedThunkDef ScriptGUISliderV::onChangedThunk;
@@ -128,9 +125,6 @@ namespace BansheeEngine
 
 	void ScriptGUISliderV::onChanged(MonoObject* instance, float percent)
 	{
-		MonoException* exception = nullptr;
-		onChangedThunk(instance, percent, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onChangedThunk, instance, percent);
 	}
 }

+ 4 - 16
SBansheeEngine/Source/BsScriptGUIToggle.cpp

@@ -101,33 +101,21 @@ namespace BansheeEngine
 
 	void ScriptGUIToggle::onClick(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onClickThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onClickThunk, instance);
 	}
 
 	void ScriptGUIToggle::onHover(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onHoverThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onHoverThunk, instance);
 	}
 
 	void ScriptGUIToggle::onOut(MonoObject* instance)
 	{
-		MonoException* exception = nullptr;
-		onOutThunk(instance, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onOutThunk, instance);
 	}
 
 	void ScriptGUIToggle::onToggled(MonoObject* instance, bool toggled)
 	{
-		MonoException* exception = nullptr;
-		onToggledThunk(instance, toggled, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(onToggledThunk, instance, toggled);
 	}
 }

+ 11 - 28
SBansheeEngine/Source/BsScriptInput.cpp

@@ -77,70 +77,53 @@ namespace BansheeEngine
 
 	void ScriptInput::onButtonDown(const ButtonEvent& ev)
 	{
-		MonoException* exception = nullptr;
-		OnButtonPressedThunk(ev.buttonCode, ev.deviceIdx, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnButtonPressedThunk, ev.buttonCode, ev.deviceIdx);
 	}
 
 	void ScriptInput::onButtonUp(const ButtonEvent& ev)
 	{
-		MonoException* exception = nullptr;
-		OnButtonReleasedThunk(ev.buttonCode, ev.deviceIdx, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnButtonReleasedThunk, ev.buttonCode, ev.deviceIdx);
 	}
 
 	void ScriptInput::onCharInput(const TextInputEvent& ev)
 	{
-		MonoException* exception = nullptr;
-		OnCharInputThunk(ev.textChar, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnCharInputThunk, ev.textChar);
 	}
 
 	void ScriptInput::onPointerMoved(const PointerEvent& ev)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* screenPos = ScriptVector2I::box(ev.screenPos);
 		MonoObject* delta = ScriptVector2I::box(ev.delta);
 
-		OnPointerMovedThunk(screenPos, delta, ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnPointerMovedThunk, screenPos, delta, 
+			ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount);
 	}
 
 	void ScriptInput::onPointerPressed(const PointerEvent& ev)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* screenPos = ScriptVector2I::box(ev.screenPos);
 		MonoObject* delta = ScriptVector2I::box(ev.delta);
 
-		OnPointerPressedThunk(screenPos, delta, ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnPointerPressedThunk, screenPos, delta, 
+			ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount);
 	}
 
 	void ScriptInput::onPointerReleased(const PointerEvent& ev)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* screenPos = ScriptVector2I::box(ev.screenPos);
 		MonoObject* delta = ScriptVector2I::box(ev.delta);
 
-		OnPointerReleasedThunk(screenPos, delta, ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnPointerReleasedThunk, screenPos, delta, 
+			ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount);
 	}
 
 	void ScriptInput::onPointerDoubleClick(const PointerEvent& ev)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* screenPos = ScriptVector2I::box(ev.screenPos);
 		MonoObject* delta = ScriptVector2I::box(ev.delta);
 
-		OnPointerDoubleClickThunk(screenPos, delta, ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnPointerDoubleClickThunk, screenPos, delta, 
+			ev.button, ev.shift, ev.control, ev.alt, ev.mouseWheelScrollAmount);
 	}
 
 	bool ScriptInput::internal_isButtonHeld(ButtonCode code, UINT32 deviceIdx)

+ 3 - 12
SBansheeEngine/Source/BsScriptVirtualInput.cpp

@@ -54,29 +54,20 @@ namespace BansheeEngine
 
 	void ScriptVirtualInput::onButtonDown(const VirtualButton& btn, UINT32 deviceIdx)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* virtualButton = ScriptVirtualButton::box(btn);
-		OnButtonDownThunk(virtualButton, deviceIdx, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnButtonDownThunk, virtualButton, deviceIdx);
 	}
 
 	void ScriptVirtualInput::onButtonUp(const VirtualButton& btn, UINT32 deviceIdx)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* virtualButton = ScriptVirtualButton::box(btn);
-		OnButtonUpThunk(virtualButton, deviceIdx, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnButtonUpThunk, virtualButton, deviceIdx);
 	}
 
 	void ScriptVirtualInput::onButtonHeld(const VirtualButton& btn, UINT32 deviceIdx)
 	{
-		MonoException* exception = nullptr;
 		MonoObject* virtualButton = ScriptVirtualButton::box(btn);
-		OnButtonHeldThunk(virtualButton, deviceIdx, &exception);
-
-		MonoUtil::throwIfException(exception);
+		MonoUtil::invokeThunk(OnButtonHeldThunk, virtualButton, deviceIdx);
 	}
 
 	MonoObject* ScriptVirtualInput::internal_getKeyConfig()

+ 0 - 1
TODO.txt

@@ -59,7 +59,6 @@ Simple stuff
  - Move all the code files into subfolders so their hierarchy is similar to VS filters
  - Font doesn't have a C# interface
  - Get rid of PoolAlloc and other unused allocators (plus fix bs_new and others which have weird overloads)
- - Call stack from C# to use in Debug.Log calls
  - Get rid of event callback from HString and figure out a better way
  - GUI TextureField similar to ResourceField but it displays the texture it has assigned
  - Better handle and gizmo shaders