Browse Source

Started work on scripting

Marko Pintera 12 years ago
parent
commit
e51cbce52c

+ 42 - 0
BansheeEngine.sln

@@ -42,9 +42,11 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
 		Dependencies.txt = Dependencies.txt
 		DrawHelper.txt = DrawHelper.txt
 		EditorWindowDock.txt = EditorWindowDock.txt
+		MonoIntegrationGuide.txt = MonoIntegrationGuide.txt
 		Notes.txt = Notes.txt
 		Opts.txt = Opts.txt
 		RenderOperation.txt = RenderOperation.txt
+		ResourceBundles.txt = ResourceBundles.txt
 		TODO.txt = TODO.txt
 		TODODoc.txt = TODODoc.txt
 		TODOEditor.txt = TODOEditor.txt
@@ -108,6 +110,10 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "BansheeOctreeSM", "BansheeO
 EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Plugins", "Plugins", "{32E4E2B7-1B4D-4B06-AD87-57CEE00BC247}"
 EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBansheeEngine", "MBansheeEngine\MBansheeEngine.csproj", "{876EB338-489E-4727-84DA-8CBBF0DA5B5E}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MBansheeEditor", "MBansheeEditor\MBansheeEditor.csproj", "{ABC62E37-342E-4345-A374-E37CA06C036E}"
+EndProject
 Global
 	GlobalSection(SubversionScc) = preSolution
 		Svn-Managed = True
@@ -422,6 +428,42 @@ Global
 		{41CC18CE-139E-45A5-A9AA-336CBA2E1521}.Release|Win32.Build.0 = Release|Win32
 		{41CC18CE-139E-45A5-A9AA-336CBA2E1521}.Release|x64.ActiveCfg = Release|x64
 		{41CC18CE-139E-45A5-A9AA-336CBA2E1521}.Release|x64.Build.0 = Release|x64
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.DebugRelease|Any CPU.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.DebugRelease|Any CPU.Build.0 = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.DebugRelease|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.DebugRelease|Mixed Platforms.Build.0 = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.DebugRelease|Win32.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.DebugRelease|x64.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Release|Win32.ActiveCfg = Release|Any CPU
+		{876EB338-489E-4727-84DA-8CBBF0DA5B5E}.Release|x64.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Debug|Any CPU.Build.0 = Debug|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Debug|Win32.ActiveCfg = Debug|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Debug|x64.ActiveCfg = Debug|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.DebugRelease|Any CPU.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.DebugRelease|Any CPU.Build.0 = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.DebugRelease|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.DebugRelease|Mixed Platforms.Build.0 = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.DebugRelease|Win32.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.DebugRelease|x64.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Release|Any CPU.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Release|Any CPU.Build.0 = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Release|Mixed Platforms.Build.0 = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Release|Win32.ActiveCfg = Release|Any CPU
+		{ABC62E37-342E-4345-A374-E37CA06C036E}.Release|x64.ActiveCfg = Release|Any CPU
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 1 - 1
BansheeEngine/BansheeEngine.vcxproj

@@ -127,7 +127,7 @@
     <Link>
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <AdditionalLibraryDirectories>..\lib\x86\$(Configuration);..\Dependencies\lib\x86\Debug;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
-      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotCore.lib;CamelotUtility.lib;libmonosgen-2.0.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
   </ItemDefinitionGroup>

+ 50 - 0
CSharpWrap.txt

@@ -48,6 +48,52 @@ Systems:
 
  -----------------
 
+ ScriptManager
+ - loadAssembly
+ - compileAssembly
+
+ScriptAssembly
+ - GetClass(namespace, name)
+
+ScriptClass
+ - GetField(name)
+ - GetMethod(name)
+ - InvokeMethod(name, void** params)
+ - AddInternalCall
+ - CreateInstance()
+
+ScriptMethod
+ - Invoke(void** params)
+
+ retval = mono_jit_exec (domain, assembly, argc - 1, argv + 1);
+to call a Main function in the assembly
+
+ -----------------
+
+ VERY IMPORTANT:
+  - Attempt to compile mono runtime as 64bit
+
+Make sure to add /etc and /lib folders in CamelotDependencies. Plus all of the x64 files.
+ - lib/bin files only exist in x86 Debug. And projects are only set up for that single configuration as well
+
+ -----------------
+
+ add BansheeEditor class
+ Add C++ EditorApplication and have it start up Application and create a main window
+Then in C# class just call EditorApplication to create a main window
+
+Create another .exe class called BansheeEd, which loads up MBansheeEditor assembly and calls EditorApplication to start everything up.
+ - I might need to add Mono loading code to BansheeEngine first?
+ - ScriptManager
+  - InvokeMethod
+
+For EditorWindow, add a new class in BansheeEditor, which pretty much does the job of  EditorWidget::open
+ - Except it creates an empty widget. (It will also create a window, but in C++ code)
+ - All the window docking/undocking moving/resizing is done in C++
+ - EditorWindow only has a reference to EditorWidget
+
+ -----------------
+
  But which ones will I need initially?
   - [EditorApplication] - Entry point. Creates a MainEditorWindow
   - [EditorWindow] (Scene, Project, Hierarchy, etc.)
@@ -78,7 +124,11 @@ Systems:
 	  - [GUILabel], [GUIButton], etc.
 	- TODO: GUISkin? - Will I need to create interface for textures and resource loading/importing as well? Probably
   
+  ----------------
+
+  I want my .exe to be native. Internally it will call MBansheeEngine and MBansheeEditor.
 
+This will allow me to debug and start C++ as usual.
 
  -----------------
 

+ 15 - 6
CamelotCore/CamelotCore.vcxproj

@@ -150,7 +150,7 @@
     <Link>
       <SubSystem>NotSet</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>CamelotUtility.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotUtility.lib;mono-2.0.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Debug</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
@@ -168,7 +168,7 @@
     <Link>
       <SubSystem>NotSet</SubSystem>
       <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>CamelotUtility.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotUtility.lib;mono-2.0.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Debug</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
@@ -192,7 +192,7 @@
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotUtility.lib;mono-2.0.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/Release</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
@@ -217,7 +217,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotUtility.lib;mono-2.0.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/x86/$(Configuration);../Dependencies/lib/x86/DebugRelease</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\x86\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
@@ -241,7 +241,7 @@
       <GenerateDebugInformation>false</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotUtility.lib;mono-2.0.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/Release</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
@@ -266,7 +266,7 @@
       <GenerateDebugInformation>true</GenerateDebugInformation>
       <EnableCOMDATFolding>true</EnableCOMDATFolding>
       <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>CamelotUtility.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
+      <AdditionalDependencies>CamelotUtility.lib;mono-2.0.lib;cg.lib;%(AdditionalDependencies)</AdditionalDependencies>
       <AdditionalLibraryDirectories>../lib/$(Platform)/$(Configuration);../Dependencies/lib/x64/DebugRelease</AdditionalLibraryDirectories>
       <ImportLibrary>..\lib\$(Platform)\$(Configuration)\$(TargetName).lib</ImportLibrary>
     </Link>
@@ -346,6 +346,11 @@
     <ClInclude Include="Include\CmOcclusionQuery.h" />
     <ClInclude Include="Include\CmPixelBuffer.h" />
     <ClInclude Include="Include\CmGpuProgIncludeImporter.h" />
+    <ClInclude Include="Include\CmScriptAssembly.h" />
+    <ClInclude Include="Include\CmScriptClass.h" />
+    <ClInclude Include="Include\CmScriptManager.h" />
+    <ClInclude Include="Include\CmScriptMethod.h" />
+    <ClInclude Include="Include\CmScriptObject.h" />
     <ClInclude Include="Include\CmSubMesh.h" />
     <ClInclude Include="Include\CmTextureView.h" />
     <ClInclude Include="Include\CmTextData.h" />
@@ -471,6 +476,10 @@
     <ClCompile Include="Source\CmQueryManager.cpp" />
     <ClCompile Include="Source\CmRenderer.cpp" />
     <ClCompile Include="Source\CmRenderQueue.cpp" />
+    <ClCompile Include="Source\CmScriptAssembly.cpp" />
+    <ClCompile Include="Source\CmScriptClass.cpp" />
+    <ClCompile Include="Source\CmScriptManager.cpp" />
+    <ClCompile Include="Source\CmScriptMethod.cpp" />
     <ClCompile Include="Source\CmTextureView.cpp" />
     <ClCompile Include="Source\CmTextData.cpp" />
     <ClCompile Include="Source\CmTimerQuery.cpp" />

+ 33 - 0
CamelotCore/CamelotCore.vcxproj.filters

@@ -94,6 +94,12 @@
     <Filter Include="Header Files\Platform">
       <UniqueIdentifier>{d53f502a-b966-4162-a828-af2654f0408f}</UniqueIdentifier>
     </Filter>
+    <Filter Include="Header Files\Script">
+      <UniqueIdentifier>{85a691b2-e208-4b3f-83e0-d6b7bedb8367}</UniqueIdentifier>
+    </Filter>
+    <Filter Include="Source Files\Script">
+      <UniqueIdentifier>{8e102909-a27d-4961-a4a1-43cb89721afc}</UniqueIdentifier>
+    </Filter>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="Include\CmApplication.h">
@@ -522,6 +528,21 @@
     <ClInclude Include="Include\CmMeshBaseRTTI.h">
       <Filter>Header Files\RTTI</Filter>
     </ClInclude>
+    <ClInclude Include="Include\CmScriptManager.h">
+      <Filter>Header Files\Script</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmScriptObject.h">
+      <Filter>Header Files\Script</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmScriptAssembly.h">
+      <Filter>Header Files\Script</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmScriptClass.h">
+      <Filter>Header Files\Script</Filter>
+    </ClInclude>
+    <ClInclude Include="Include\CmScriptMethod.h">
+      <Filter>Header Files\Script</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <ClCompile Include="Source\CmApplication.cpp">
@@ -818,5 +839,17 @@
     <ClCompile Include="Source\CmMeshBase.cpp">
       <Filter>Source Files\Resources</Filter>
     </ClCompile>
+    <ClCompile Include="Source\CmScriptMethod.cpp">
+      <Filter>Source Files\Script</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmScriptClass.cpp">
+      <Filter>Source Files\Script</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmScriptAssembly.cpp">
+      <Filter>Source Files\Script</Filter>
+    </ClCompile>
+    <ClCompile Include="Source\CmScriptManager.cpp">
+      <Filter>Source Files\Script</Filter>
+    </ClCompile>
   </ItemGroup>
 </Project>

+ 5 - 0
CamelotCore/Include/CmPrerequisites.h

@@ -132,6 +132,11 @@ namespace CamelotFramework
 	class EventQuery;
 	class TimerQuery;
 	class FrameAlloc;
+	class ScriptManager;
+	class ScriptObject;
+	class ScriptAssembly;
+	class ScriptClass;
+	class ScriptMethod;
 	// Asset import
 	class SpecificImporter;
 	class Importer;

+ 43 - 0
CamelotCore/Include/CmScriptAssembly.h

@@ -0,0 +1,43 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include <mono/jit/jit.h>
+#include <mono/metadata/assembly.h>
+
+namespace CamelotFramework
+{
+	class CM_EXPORT ScriptAssembly
+	{
+		struct ClassId
+		{
+			struct Hash
+			{
+				inline size_t operator()(const ClassId& v) const;
+			};
+
+			struct Equals
+			{
+				inline bool operator()(const ClassId &a, const ClassId &b) const;
+			};
+
+			ClassId(const String& namespaceName, String name);
+
+			String namespaceName;
+			String name;
+		};
+
+	public:
+		~ScriptAssembly();
+
+		ScriptClass& getClass(const String& namespaceName, const String& name);
+
+	private:
+		friend class ScriptManager;
+
+		ScriptAssembly(MonoAssembly* assembly);
+
+		MonoImage* mMonoImage;
+		MonoAssembly* mMonoAssembly;
+		UnorderedMap<ClassId, ScriptClass*, ClassId::Hash, ClassId::Equals>::type mClasses;
+	};
+}

+ 45 - 0
CamelotCore/Include/CmScriptClass.h

@@ -0,0 +1,45 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include <mono/jit/jit.h>
+
+namespace CamelotFramework
+{
+	class CM_EXPORT ScriptClass
+	{
+		struct MethodId
+		{
+			struct Hash
+			{
+				inline size_t operator()(const MethodId& v) const;
+			};
+			
+			struct Equals
+			{
+				inline bool operator()(const MethodId &a, const MethodId &b) const;
+			};
+
+			MethodId(const String& name, UINT32 numParams);
+
+			String name;
+			UINT32 numParams;
+		};
+
+	public:
+		~ScriptClass();
+
+		ScriptMethod& getMethod(const String& name, UINT32 numParams = 0);
+		
+		MonoObject* invokeMethod(const String& name, ScriptObject* instance = nullptr, void** params = nullptr, UINT32 numParams = 0);
+		void addInternalCall(const String& name, const void* method);
+	private:
+		friend class ScriptAssembly;
+
+		ScriptClass(const String& fullName, MonoClass* monoClass);
+
+		MonoClass* mClass;
+		String mFullName;
+
+		UnorderedMap<MethodId, ScriptMethod*, MethodId::Hash, MethodId::Equals>::type mMethods; 
+	};
+}

+ 30 - 0
CamelotCore/Include/CmScriptManager.h

@@ -0,0 +1,30 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include "CmModule.h"
+#include <mono/jit/jit.h>
+
+namespace CamelotFramework
+{
+	/**
+	 * @brief	Loads Mono script assemblies and manages script objects.
+	 */
+	class CM_EXPORT ScriptManager : public Module<ScriptManager>
+	{
+	public:
+		ScriptManager();
+		~ScriptManager();
+
+		ScriptAssembly& loadAssembly(const String& name);
+
+		MonoDomain* getDomain() const { return mDomain; }
+
+	private:
+		static const String DOMAIN_NAME;
+		static const String MONO_LIB_DIR;
+		static const String MONO_ETC_DIR;
+
+		MonoDomain* mDomain;
+		UnorderedMap<String, ScriptAssembly*>::type mAssemblies;
+	};
+}

+ 29 - 0
CamelotCore/Include/CmScriptMethod.h

@@ -0,0 +1,29 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include <mono/jit/jit.h>
+
+namespace CamelotFramework
+{
+	class CM_EXPORT ScriptMethod
+	{
+	public:
+		MonoObject* invoke(ScriptObject* instance, void** params);
+
+		/**
+		 * @brief	Gets a thunk for this method. A thunk is a C++ like function
+		 * 			pointer that you can use for calling the method.
+		 *
+		 * @note	This is the fastest way of calling managed code.
+		 */
+		void* getThunk();
+
+	private:
+		friend class ScriptClass;
+
+		ScriptMethod(MonoMethod* method);
+
+		MonoMethod* mMethod;
+		void* mThunk;
+	};
+}

+ 32 - 0
CamelotCore/Include/CmScriptObject.h

@@ -0,0 +1,32 @@
+#pragma once
+
+#include "CmPrerequisites.h"
+#include <mono/jit/jit.h>
+
+namespace CamelotFramework
+{
+	/**
+	 * @brief	 Base class for objects that can be extended using Mono scripting
+	 */
+	class CM_EXPORT ScriptObject
+	{
+	public:
+		class CM_EXPORT Meta
+		{
+			const char* Namespace;								
+			const char* Name;									
+			MonoClass* Class;									
+			MonoDomain* Domain;									
+			MonoClassField* ThisPtr;	
+
+			virtual void init() = 0;
+		};
+
+		virtual void script_create(MonoObject* scriptObj) = 0;
+		virtual void script_destroy() = 0;
+
+		MonoObject* getMonoObject() const { return mScriptObject; }
+	private:
+		MonoObject* mScriptObject;	
+	};
+}

+ 65 - 0
CamelotCore/Source/CmScriptAssembly.cpp

@@ -0,0 +1,65 @@
+#include "CmScriptAssembly.h"
+#include "CmScriptClass.h"
+#include "CmUtil.h"
+#include "CmException.h"
+
+namespace CamelotFramework
+{
+	inline size_t ScriptAssembly::ClassId::Hash::operator()(const ScriptAssembly::ClassId& v) const
+	{
+		size_t seed = 0;
+		hash_combine(seed, v.namespaceName);
+		hash_combine(seed, v.name);
+		return seed;
+	}
+
+	inline bool ScriptAssembly::ClassId::Equals::operator()(const ScriptAssembly::ClassId &a, const ScriptAssembly::ClassId &b) const
+	{
+		return a.name == b.name && a.namespaceName == b.namespaceName;
+	}
+
+	ScriptAssembly::ClassId::ClassId(const String& namespaceName, String name)
+		:namespaceName(namespaceName), name(name)
+	{
+
+	}
+
+	ScriptAssembly::ScriptAssembly(MonoAssembly* assembly)
+		:mMonoAssembly(assembly)
+	{
+		mMonoImage = mono_assembly_get_image(mMonoAssembly);
+		if(mMonoImage == nullptr)
+		{
+			CM_EXCEPT(InvalidParametersException, "Cannot get script assembly image.");
+		}
+	}
+
+	ScriptAssembly::~ScriptAssembly()
+	{
+		for(auto& entry : mClasses)
+			cm_delete(entry.second);
+
+		mClasses.clear();
+	}
+
+	ScriptClass& ScriptAssembly::getClass(const String& namespaceName, const String& name)
+	{
+		ClassId classId(namespaceName, name);
+		auto iterFind = mClasses.find(classId);
+
+		if(iterFind != mClasses.end())
+			return *iterFind->second;
+
+		MonoClass* monoClass = mono_class_from_name(mMonoImage, namespaceName.c_str(), name.c_str());
+		if(monoClass == nullptr)
+		{
+			CM_EXCEPT(InvalidParametersException, "Cannot get Mono class: " + namespaceName + "." + name);
+		}
+
+		String fullClassName = namespaceName + "::" + name;
+		ScriptClass* newClass = new (cm_alloc<ScriptClass>()) ScriptClass(fullClassName, monoClass);
+		mClasses[classId] = newClass;
+
+		return *newClass;
+	}
+}

+ 73 - 0
CamelotCore/Source/CmScriptClass.cpp

@@ -0,0 +1,73 @@
+#include "CmScriptClass.h"
+#include "CmScriptMethod.h"
+#include "CmUtil.h"
+#include "CmException.h"
+
+namespace CamelotFramework
+{
+	inline size_t ScriptClass::MethodId::Hash::operator()(const ScriptClass::MethodId& v) const
+	{
+		size_t seed = 0;
+		hash_combine(seed, v.name);
+		hash_combine(seed, v.numParams);
+		return seed;
+	}
+
+	inline bool ScriptClass::MethodId::Equals::operator()(const ScriptClass::MethodId &a, const ScriptClass::MethodId &b) const
+	{
+		return a.name == b.name && a.numParams == b.numParams;
+	}
+
+	ScriptClass::MethodId::MethodId(const String& name, UINT32 numParams)
+		:name(name), numParams(numParams)
+	{
+
+	}
+
+	ScriptClass::ScriptClass(const String& fullName, MonoClass* monoClass)
+		:mFullName(fullName), mClass(monoClass)
+	{
+
+	}
+
+	ScriptClass::~ScriptClass()
+	{
+		for(auto& mapEntry : mMethods)
+		{
+			cm_delete(mapEntry.second);
+		}
+
+		mMethods.clear();
+	}
+
+	ScriptMethod& ScriptClass::getMethod(const String& name, UINT32 numParams)
+	{
+		MethodId mehodId(name, numParams);
+		auto iterFind = mMethods.find(mehodId);
+		if(iterFind != mMethods.end())
+			return *iterFind->second;
+
+		MonoMethod* method = mono_class_get_method_from_name(mClass, name.c_str(), (int)numParams);
+		if(method == nullptr)
+		{
+			String fullMethodName = mFullName + "::" + name;
+			CM_EXCEPT(InvalidParametersException, "Cannot get Mono method: " + fullMethodName);
+		}
+
+		ScriptMethod* newMethod = new (cm_alloc<ScriptMethod>()) ScriptMethod(method);
+		mMethods[mehodId] = newMethod;
+
+		return *newMethod;
+	}
+
+	MonoObject* ScriptClass::invokeMethod(const String& name, ScriptObject* instance, void** params, UINT32 numParams)
+	{
+		return getMethod(name, numParams).invoke(instance, params);
+	}
+
+	void ScriptClass::addInternalCall(const String& name, const void* method)
+	{
+		String fullMethodName = mFullName + "::" + name;
+		mono_add_internal_call(fullMethodName.c_str(), method);
+	}
+}

+ 58 - 0
CamelotCore/Source/CmScriptManager.cpp

@@ -0,0 +1,58 @@
+#include "CmScriptManager.h"
+#include "CmException.h"
+#include "CmScriptAssembly.h"
+
+#include <mono/metadata/assembly.h>
+#include <mono/metadata/mono-config.h>
+
+namespace CamelotFramework
+{
+	const String ScriptManager::DOMAIN_NAME = "BansheeEngine";
+	const String ScriptManager::MONO_LIB_DIR = "..\\..\\Mono\\lib";
+	const String ScriptManager::MONO_ETC_DIR = "..\\..\\Mono\\etc";
+
+	ScriptManager::ScriptManager()
+	{
+		mono_set_dirs(MONO_LIB_DIR.c_str(), MONO_ETC_DIR.c_str()); 
+		mono_config_parse(nullptr);
+
+		mDomain = mono_jit_init (DOMAIN_NAME.c_str());
+		if(mDomain == nullptr)
+		{
+			CM_EXCEPT(InternalErrorException, "Cannot initialize Mono runtime.");
+		}
+	}
+
+	ScriptManager::~ScriptManager()
+	{
+		for(auto& entry : mAssemblies)
+		{
+			cm_delete(entry.second);
+		}
+
+		mAssemblies.clear();
+
+		if(mDomain != nullptr)
+			mono_jit_cleanup(mDomain);
+	}
+
+	ScriptAssembly& ScriptManager::loadAssembly(const String& name)
+	{
+		auto iterFind = mAssemblies.find(name);
+		if(iterFind != mAssemblies.end())
+		{
+			return *iterFind->second;
+		}
+
+		MonoAssembly* monoAssembly = mono_domain_assembly_open (mDomain, name.c_str());
+		if(monoAssembly == nullptr)
+		{
+			CM_EXCEPT(InvalidParametersException, "Cannot load Mono assembly: " + name);
+		}
+
+		ScriptAssembly* assembly = new (cm_alloc<ScriptAssembly>()) ScriptAssembly(monoAssembly);
+		mAssemblies[name] = assembly;
+
+		return *assembly;
+	}
+}

+ 21 - 0
CamelotCore/Source/CmScriptMethod.cpp

@@ -0,0 +1,21 @@
+#include "CmScriptMethod.h"
+#include "CmScriptObject.h"
+
+namespace CamelotFramework
+{
+	ScriptMethod::ScriptMethod(MonoMethod* method)
+		:mMethod(method)
+	{
+		mThunk = mono_method_get_unmanaged_thunk(mMethod);
+	}
+
+	MonoObject* ScriptMethod::invoke(ScriptObject* instance, void** params)
+	{
+		return mono_runtime_invoke(mMethod, instance->getMonoObject(), params, nullptr);
+	}		
+
+	void* ScriptMethod::getThunk()
+	{
+		return mThunk;
+	}
+}

+ 5 - 5
CamelotGLRenderer/Source/CmGLRenderSystem.cpp

@@ -1363,11 +1363,11 @@ namespace CamelotFramework
 
 		// TODO - Replace with OpenGL 4.3 built-in functionality (GL_DEBUG_OUTPUT_SYNCHRONOUS)
 #if CM_DEBUG_MODE
-		if (mGLSupport->checkExtension("GL_ARB_debug_output"))
-		{
-			glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
-			glDebugMessageCallbackARB(&openGlErrorCallback, 0);
-		}
+		//if (mGLSupport->checkExtension("GL_ARB_debug_output"))
+		//{
+		//	glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
+		//	glDebugMessageCallbackARB(&openGlErrorCallback, 0);
+		//}
 #endif
 	}
 	//---------------------------------------------------------------------

+ 0 - 26
CamelotUtility/Include/CmStdHeaders.h

@@ -120,32 +120,6 @@ extern "C" {
 
 namespace CamelotFramework
 {
-#if CM_COMPILER == CM_COMPILER_GNUC && CM_COMP_VER >= 310
-#   if CM_COMP_VER >= 430
-#       define HashMap ::std::tr1::UnorderedMap
-#		define HashSet ::std::tr1::UnorderedSet
-#    else
-#       define HashMap ::__gnu_cxx::hash_map
-#       define HashSet ::__gnu_cxx::hash_set
-#    endif
-#else
-#   if CM_COMPILER == CM_COMPILER_MSVC
-#       if CM_COMP_VER >= 1600 // VC++ 10.0
-#			define HashMap ::std::tr1::UnorderedMap
-#           define HashSet ::std::tr1::UnorderedSet
-#		elif CM_COMP_VER > 1300 && !defined(_STLP_MSVC)
-#           define HashMap ::stdext::hash_map
-#           define HashSet ::stdext::hash_set
-#       else
-#           define HashMap ::std::hash_map
-#           define HashSet ::std::hash_set
-#       endif
-#   else
-#       define HashMap ::std::hash_map
-#       define HashSet ::std::hash_set
-#   endif
-#endif
-
 	// Standard containers, for easier access in my own namespace
 	template <typename T, typename A = StdAlloc<T>> 
 	struct Deque 

+ 26 - 36
CamelotUtility/Include/CmString.h

@@ -25,43 +25,10 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 THE SOFTWARE.
 -----------------------------------------------------------------------------
 */
-#ifndef _String_H__
-#define _String_H__
+#pragma once
 
 #include "CmPrerequisitesUtil.h"
 
-// If we're using the GCC 3.1 C++ Std lib
-#if CM_COMPILER == CM_COMPILER_GNUC && CM_COMP_VER >= 310 && !defined(STLPORT)
-
-// For gcc 4.3 see http://gcc.gnu.org/gcc-4.3/changes.html
-#   if CM_COMP_VER >= 430
-#       include <tr1/unordered_map> 
-#   else
-#       include <ext/hash_map>
-namespace __gnu_cxx
-{
-    template <> struct hash< CamelotFramework::_StringBase >
-    {
-        size_t operator()( const CamelotFramework::_StringBase _stringBase ) const
-        {
-            /* This is the PRO-STL way, but it seems to cause problems with VC7.1
-               and in some other cases (although I can't recreate it)
-            hash<const char*> H;
-            return H(_stringBase.c_str());
-            */
-            /** This is our custom way */
-            register size_t ret = 0;
-            for( CamelotFramework::_StringBase::const_iterator it = _stringBase.begin(); it != _stringBase.end(); ++it )
-                ret = 5 * ret + *it;
-
-            return ret;
-        }
-    };
-}
-#   endif
-
-#endif
-
 namespace CamelotFramework 
 {
 	template <typename T>
@@ -869,6 +836,29 @@ namespace CamelotFramework
 
 } // namespace CamelotFramework
 
-#include "CmHString.h"
+template<> 
+struct std::hash<CamelotFramework::String>
+{
+	size_t operator()(const CamelotFramework::String& string) const
+	{
+		size_t hash = 0;
+		for(size_t i = 0; i < string.size(); i++) 
+			hash = 65599 * hash + string[i];
+		return hash ^ (hash >> 16);
+	}
+};
+
+template<> 
+struct std::hash<CamelotFramework::WString>
+{
+	size_t operator()(const CamelotFramework::WString& string) const
+	{
+		size_t hash = 0;
+		for(size_t i = 0; i < string.size(); i++) 
+			hash = 65599 * hash + string[i];
+		return hash ^ (hash >> 16);
+	}
+};
+
 
-#endif // _String_H__
+#include "CmHString.h"

+ 3 - 0
Dependencies.txt

@@ -3,6 +3,9 @@ Camelot relies on the following 3rd party libraries:
     - http://www.boost.org
  - Cg 3.1
     - http://developer.nvidia.com/cg-toolkit
+ - Mono 3.2.3
+    - http://www.mono-project.com
+	- See MonoIntegrationGuide.txt on how to compile & integrate Mono
 
 Place dependency files in:
  - Library include files in (BansheeRootDir)/Dependencies/Include

+ 9 - 0
MBansheeEditor/EditorApplication.cs

@@ -0,0 +1,9 @@
+using System;
+using System.Collections.Generic;
+
+namespace BansheeEditor
+{
+    public class EditorApplication
+    {
+    }
+}

+ 54 - 0
MBansheeEditor/MBansheeEditor.csproj

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{ABC62E37-342E-4345-A374-E37CA06C036E}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MBansheeEditor</RootNamespace>
+    <AssemblyName>MBansheeEditor</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="EditorApplication.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 13 - 0
MBansheeEditor/Program.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace MBansheeEditor
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+
+        }
+    }
+}

+ 36 - 0
MBansheeEditor/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MBansheeEditor")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MBansheeEditor")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("ebcdd4b7-909a-4800-be5a-bbc34ba2b49e")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 10 - 0
MBansheeEngine/Application.cs

@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+
+namespace BansheeEngine
+{
+    public class Application
+    {
+
+    }
+}

+ 54 - 0
MBansheeEngine/MBansheeEngine.csproj

@@ -0,0 +1,54 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
+  <PropertyGroup>
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+    <ProjectGuid>{876EB338-489E-4727-84DA-8CBBF0DA5B5E}</ProjectGuid>
+    <OutputType>Library</OutputType>
+    <AppDesignerFolder>Properties</AppDesignerFolder>
+    <RootNamespace>MBansheeEngine</RootNamespace>
+    <AssemblyName>MBansheeEngine</AssemblyName>
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
+    <FileAlignment>512</FileAlignment>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+    <DebugSymbols>true</DebugSymbols>
+    <DebugType>full</DebugType>
+    <Optimize>false</Optimize>
+    <OutputPath>bin\Debug\</OutputPath>
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+    <DebugType>pdbonly</DebugType>
+    <Optimize>true</Optimize>
+    <OutputPath>bin\Release\</OutputPath>
+    <DefineConstants>TRACE</DefineConstants>
+    <ErrorReport>prompt</ErrorReport>
+    <WarningLevel>4</WarningLevel>
+  </PropertyGroup>
+  <ItemGroup>
+    <Reference Include="System" />
+    <Reference Include="System.Core" />
+    <Reference Include="System.Xml.Linq" />
+    <Reference Include="System.Data.DataSetExtensions" />
+    <Reference Include="Microsoft.CSharp" />
+    <Reference Include="System.Data" />
+    <Reference Include="System.Xml" />
+  </ItemGroup>
+  <ItemGroup>
+    <Compile Include="Application.cs" />
+    <Compile Include="Program.cs" />
+    <Compile Include="Properties\AssemblyInfo.cs" />
+  </ItemGroup>
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
+  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
+       Other similar extension points exist, see Microsoft.Common.targets.
+  <Target Name="BeforeBuild">
+  </Target>
+  <Target Name="AfterBuild">
+  </Target>
+  -->
+</Project>

+ 13 - 0
MBansheeEngine/Program.cs

@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+
+namespace MBansheeEngine
+{
+    class Program
+    {
+        static void Main(string[] args)
+        {
+
+        }
+    }
+}

+ 36 - 0
MBansheeEngine/Properties/AssemblyInfo.cs

@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following 
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("MBansheeEngine")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("MBansheeEngine")]
+[assembly: AssemblyCopyright("Copyright ©  2013")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible 
+// to COM components.  If you need to access a type in this assembly from 
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("094f8fea-b123-4e94-9600-1a5daf903b22")]
+
+// Version information for an assembly consists of the following four values:
+//
+//      Major Version
+//      Minor Version 
+//      Build Number
+//      Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers 
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 95 - 0
MonoIntegrationGuide.txt

@@ -0,0 +1,95 @@
+Download mono 3.2.3 source from http://download.mono-project.com/sources/.
+
+Mono can be a bit problematic to compile on Windows as MSVC solution is not maintained very often. 
+Cygwin option that is provided doesn't come with a 64bit configuration, plus it also has errors.
+
+--------------------------------------Compiling with Visual Studio 2012 on Windows 7 x64--------------------------------------------------
+ - 3.2.3 version is missing "mono.props" file and without it Visual Studio will fail to open some project files. To fix download the .props file 
+   from https://raw.github.com/mono/mono/master/msvc/mono.props and put it in mono-3.2.3\msvc folder before opening any projects or solution
+ - Even though solution is VS2010, it will only compile with VS2012 unless you change platform toolkit to 
+   v10 for all projects. (Haven't actually tested with VS2010)
+ - If compiler complains it cannot find pthreads.h make sure to define "HAS_64BITS_ATOMIC" in libmonoutils project (for all configurations)
+ - In dlmalloc.c change #include <dlmalloc.h> to #include "dlmalloc.h" if compiler complains it cannot find that file
+ - In "mono-proclib.c" add this bit of code somewhere near the start of the file:
+
+#ifdef HOST_WIN32
+#define strtoll _strtoi64
+#define strtoull _strtoui64
+#endif
+
+  - In "threads.c" replace a line in ves_icall_System_Threading_Interlocked_CompareExchange_Long method, from:
+
+return InterlockedCompareExchange64 (location, value, comparand);
+
+    to
+
+#ifdef HOST_WIN32
+	return _InterlockedCompareExchange64 (location, value, comparand);
+#else
+	return InterlockedCompareExchange64 (location, value, comparand); 
+#endif
+
+    InterlockedCompareExchange64 is just a typedef for _InterlockedCompareExchange64 on Windows and for some
+	reason compiler doesn't realize it (typedefs to intrinstics don't work?). Anyway, so we just reference the intrinsic
+	directly.
+
+  - In "threads.c" replace a line in ves_icall_System_Threading_Thread_VolatileRead8 method, from:
+
+return InterlockedCompareExchange64 (ptr, 0, 0);
+     
+	to
+
+#ifdef HOST_WIN32
+	return _InterlockedCompareExchange64 (ptr, 0, 0);
+#else
+	return InterlockedCompareExchange64 (ptr, 0, 0);    
+#endif
+
+    Same problem as previous.
+
+  - For all projects and configurations update their property pages under "C/C++->Optimization" and set "Enable Intrinsic Functions" to "Yes"
+    - You might be able to skip this step.
+  - In "exceptions-amd64.c" replace line 121:
+
+if (win32_chained_exception_needs_run) { 
+    
+   with
+
+if (mono_win_chained_exception_needs_run) {
+
+  - In "exceptions-amd64.c" delete lines 167 and 168:
+
+if (old_win32_toplevel_exception_filter)
+	SetUnhandledExceptionFilter(mono_old_win_toplevel_exception_filter);
+
+  - In "exceptions-amd64.c" move line 166 (line # after previous changes) to start of the function:
+
+guint32 ret = 0;
+
+  - in threads.c in mono_thread_get_stack_bounds method replace the bit of code under "#if defined(HOST_WIN32)" from:
+
+void* tib = (void*)__readfsdword(0x18);
+guint8 *stackTop = (guint8*)*(int*)((char*)tib + 4);
+guint8 *stackBottom = (guint8*)*(int*)((char*)tib + 8);
+
+    to:
+
+NT_TIB* tib = (NT_TIB*)NtCurrentTeb();
+guint8 *stackTop = (guint8*)tib->StackBase;
+guint8 *stackBottom = (guint8*)tib->StackLimit;
+
+    __readfsdword doesn't exist when building 64bit. Use may use __readgsqword instead but then you need
+	to double all your offsets. NtCurrentTeb works equally for both 32 and 64 bit builds.
+
+  - Build "mono" project. 
+  - You should end up with mono-2.0.dll, mono-2.0.lib, MonoPosixHelper.dll and mono.exe and we are done compiling
+
+
+--------------------------------Integrating Mono into Banshee----------------------------------------------
+ - Add mono-2.0.dll to (BansheeRootDir)/bin/(Platform)/(Configuration)
+ - Add mono-2.0.lib to (BansheeRootDir)/Dependencies/lib/(Platform)/(Configuration)
+ - Install mono 3.2.3 prebuilt binaries
+   - Copy contents of (PrebuiltMonoFolder)/include/mono/mono-2.0/mono to (BansheeRootDir)/Dependencies/Include/Mono
+   - Copy folders (PrebuiltMonoFolder)/etc and (PrebuiltMonoFolder)/lib folders into (BansheeRootDir)/bin/Mono
+     - TODO - Not all files from /lib are needed, but I haven't yet determined which are
+ - TODO - mono.exe and mono compiler are not used at the moment. Update docs once they are.

+ 18 - 0
ResourceBundles.txt

@@ -0,0 +1,18 @@
+Resource packing
+ - Add support for zlib compression/decompression
+    - There should be a generic comp/decomp class, and it can get assigned to ResourceManager
+    - When loading a file ResourceManager will check if it is compressed and uncompress if needed
+    - When saving user can specify if the file should be compressed
+    - Audio, image or video compression can be handled per file basis and their comp/decomp is done in their special managers and shouldn't be handled by resource manager
+       - But this means they will decompress on core thread? Not if I do it in "initialize()" method.
+ - Add support for ResourceBundle-s. They contain multiple resources and are natively supported by ResourceManager
+   - They have RTTI and can easily be serialized/deserialized
+   - ResourceManager must be able to load/unload individual files from the ResourcePack
+ - Resource bundle manager - Editor window
+   - Allows you to create resource bundles by dragging in resources
+     - Each dragged in resource also includes all of its dependencies
+       - Including a level will include all resources needed for that level (Think Unity Build manager but more customizable)
+     - Normally you only need one resource pack but if you want a streaming game where stuff gets downloaded from the web (for example) you can split it
+       into smaller packs.
+  - Displays detailed information for all included resources, including file sizes and dependencies
+  - Allows you to select compression settings per bundle