Bläddra i källkod

Seperated CoreLua and ControlsLua in to different .dll files.

There is still some cleanup, like removing commented out code, left to do.

I have also not checked if the sample still works. My guess is that it doesn't.
Nate Starkey 13 år sedan
förälder
incheckning
0c27600374
73 ändrade filer med 1123 tillägg och 1025 borttagningar
  1. 346 0
      Build/RocketControlsLua.vcproj
  2. 2 126
      Build/RocketCoreLua.vcproj
  3. 7 1
      Build/RocketLua.sln
  4. 45 0
      Include/Rocket/Controls/Lua/Controls.h
  5. 0 5
      Include/Rocket/Core/Lua/Interpreter.h
  6. 38 13
      Include/Rocket/Core/Lua/LuaType.h
  7. 7 1
      Include/Rocket/Core/Lua/Utilities.h
  8. 73 0
      Source/Controls/Lua/Controls.cpp
  9. 12 4
      Source/Controls/Lua/DataFormatter.cpp
  10. 8 7
      Source/Controls/Lua/DataFormatter.h
  11. 8 3
      Source/Controls/Lua/DataSource.cpp
  12. 10 4
      Source/Controls/Lua/DataSource.h
  13. 13 10
      Source/Controls/Lua/ElementDataGrid.cpp
  14. 9 14
      Source/Controls/Lua/ElementDataGrid.h
  15. 14 10
      Source/Controls/Lua/ElementDataGridRow.cpp
  16. 10 14
      Source/Controls/Lua/ElementDataGridRow.h
  17. 13 3
      Source/Controls/Lua/ElementForm.cpp
  18. 10 14
      Source/Controls/Lua/ElementForm.h
  19. 13 4
      Source/Controls/Lua/ElementFormControl.cpp
  20. 7 13
      Source/Controls/Lua/ElementFormControl.h
  21. 15 13
      Source/Controls/Lua/ElementFormControlDataSelect.cpp
  22. 8 15
      Source/Controls/Lua/ElementFormControlDataSelect.h
  23. 14 10
      Source/Controls/Lua/ElementFormControlInput.cpp
  24. 8 15
      Source/Controls/Lua/ElementFormControlInput.h
  25. 18 14
      Source/Controls/Lua/ElementFormControlSelect.cpp
  26. 8 14
      Source/Controls/Lua/ElementFormControlSelect.h
  27. 12 12
      Source/Controls/Lua/ElementFormControlTextArea.cpp
  28. 8 14
      Source/Controls/Lua/ElementFormControlTextArea.h
  29. 12 10
      Source/Controls/Lua/ElementTabSet.cpp
  30. 9 14
      Source/Controls/Lua/ElementTabSet.h
  31. 5 4
      Source/Controls/Lua/LuaDataFormatter.cpp
  32. 5 5
      Source/Controls/Lua/LuaDataFormatter.h
  33. 7 3
      Source/Controls/Lua/LuaDataSource.cpp
  34. 5 5
      Source/Controls/Lua/LuaDataSource.h
  35. 18 6
      Source/Controls/Lua/SelectOptionsProxy.cpp
  36. 8 5
      Source/Controls/Lua/SelectOptionsProxy.h
  37. 19 0
      Source/Core/Lua/Colourb.cpp
  38. 2 7
      Source/Core/Lua/Colourb.h
  39. 11 2
      Source/Core/Lua/Colourf.cpp
  40. 2 7
      Source/Core/Lua/Colourf.h
  41. 1 6
      Source/Core/Lua/Context.cpp
  42. 1 7
      Source/Core/Lua/Context.h
  43. 8 0
      Source/Core/Lua/ContextDocumentsProxy.cpp
  44. 3 1
      Source/Core/Lua/ContextDocumentsProxy.h
  45. 9 6
      Source/Core/Lua/Document.cpp
  46. 2 8
      Source/Core/Lua/Document.h
  47. 31 7
      Source/Core/Lua/Element.cpp
  48. 4 8
      Source/Core/Lua/Element.h
  49. 9 1
      Source/Core/Lua/ElementAttributesProxy.cpp
  50. 3 1
      Source/Core/Lua/ElementAttributesProxy.h
  51. 8 6
      Source/Core/Lua/ElementStyle.cpp
  52. 2 7
      Source/Core/Lua/ElementStyle.h
  53. 8 1
      Source/Core/Lua/ElementText.cpp
  54. 2 2
      Source/Core/Lua/ElementText.h
  55. 1 6
      Source/Core/Lua/Event.cpp
  56. 1 7
      Source/Core/Lua/Event.h
  57. 10 1
      Source/Core/Lua/EventParametersProxy.cpp
  58. 3 1
      Source/Core/Lua/EventParametersProxy.h
  59. 27 25
      Source/Core/Lua/Interpreter.cpp
  60. 34 6
      Source/Core/Lua/Log.cpp
  61. 2 7
      Source/Core/Lua/Log.h
  62. 2 1
      Source/Core/Lua/LuaEventListener.cpp
  63. 1 0
      Source/Core/Lua/LuaEventListener.h
  64. 7 21
      Source/Core/Lua/LuaType.inl
  65. 0 440
      Source/Core/Lua/LuaTypeTemplateSpec.inl
  66. 25 6
      Source/Core/Lua/Rocket.cpp
  67. 2 7
      Source/Core/Lua/Rocket.h
  68. 18 1
      Source/Core/Lua/Utilities.cpp
  69. 24 0
      Source/Core/Lua/Vector2f.cpp
  70. 3 7
      Source/Core/Lua/Vector2f.h
  71. 24 0
      Source/Core/Lua/Vector2i.cpp
  72. 2 7
      Source/Core/Lua/Vector2i.h
  73. 7 0
      Source/Core/Lua/precompiled.h

+ 346 - 0
Build/RocketControlsLua.vcproj

@@ -0,0 +1,346 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+	ProjectType="Visual C++"
+	Version="9.00"
+	Name="RocketControlsLua"
+	ProjectGUID="{45C9CB50-E22C-465E-AB17-CA81D2372DEF}"
+	RootNamespace="RocketLua"
+	TargetFrameworkVersion="196613"
+	>
+	<Platforms>
+		<Platform
+			Name="Win32"
+		/>
+	</Platforms>
+	<ToolFiles>
+	</ToolFiles>
+	<Configurations>
+		<Configuration
+			Name="Debug|Win32"
+			OutputDirectory="$(IntDir)"
+			IntermediateDirectory="build\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			DeleteExtensionsOnClean="*.pch;*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="0"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)..\Include&quot;;&quot;$(SolutionDir)..\Source\Core&quot;;&quot;$(SolutionDir)..\Dependencies\lua\src&quot;;&quot;$(SolutionDir)..\Source\Controls\Lua&quot;"
+				PreprocessorDefinitions="_WIN32,_DEBUG,RocketLua_EXPORTS"
+				MinimalRebuild="true"
+				BasicRuntimeChecks="3"
+				RuntimeLibrary="3"
+				UsePrecompiledHeader="2"
+				PrecompiledHeaderThrough="precompiled.h"
+				WarningLevel="3"
+				DebugInformationFormat="4"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkLibraryDependencies="false"
+				AdditionalDependencies="lua51.lib RocketCore_d.lib RocketControls_d.lib RocketCoreLua_d.lib"
+				ShowProgress="0"
+				OutputFile="..\bin\$(ProjectName)_d.dll"
+				AdditionalLibraryDirectories="$(SolutionDir)..\bin"
+				GenerateManifest="false"
+				EnableUAC="false"
+				GenerateDebugInformation="true"
+				ImportLibrary="$(TargetDir)$(TargetName).lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+		<Configuration
+			Name="Release|Win32"
+			OutputDirectory="$(IntDir)"
+			IntermediateDirectory="build\$(ProjectName)\$(ConfigurationName)"
+			ConfigurationType="2"
+			CharacterSet="2"
+			WholeProgramOptimization="1"
+			>
+			<Tool
+				Name="VCPreBuildEventTool"
+			/>
+			<Tool
+				Name="VCCustomBuildTool"
+			/>
+			<Tool
+				Name="VCXMLDataGeneratorTool"
+			/>
+			<Tool
+				Name="VCWebServiceProxyGeneratorTool"
+			/>
+			<Tool
+				Name="VCMIDLTool"
+			/>
+			<Tool
+				Name="VCCLCompilerTool"
+				Optimization="3"
+				InlineFunctionExpansion="0"
+				EnableIntrinsicFunctions="true"
+				WholeProgramOptimization="true"
+				AdditionalIncludeDirectories="&quot;$(SolutionDir)..\Include&quot;;&quot;$(SolutionDir)..\Source\Core&quot;;&quot;$(SolutionDir)..\Dependencies\lua\src&quot;;&quot;$(SolutionDir)..\Source\Controls\Lua&quot;"
+				PreprocessorDefinitions="_WIN32,NDEBUG,RocketLua_EXPORTS"
+				RuntimeLibrary="2"
+				EnableFunctionLevelLinking="true"
+				UsePrecompiledHeader="2"
+				PrecompiledHeaderThrough="precompiled.h"
+				WarningLevel="3"
+				DebugInformationFormat="3"
+			/>
+			<Tool
+				Name="VCManagedResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCResourceCompilerTool"
+			/>
+			<Tool
+				Name="VCPreLinkEventTool"
+			/>
+			<Tool
+				Name="VCLinkerTool"
+				LinkLibraryDependencies="true"
+				AdditionalDependencies="lua51.lib RocketCore.lib RocketControls.lib RocketCoreLua.lib"
+				ShowProgress="0"
+				OutputFile="..\bin\$(ProjectName).dll"
+				AdditionalLibraryDirectories="$(SolutionDir)..\bin"
+				GenerateManifest="false"
+				EnableUAC="true"
+				GenerateDebugInformation="false"
+				OptimizeReferences="2"
+				EnableCOMDATFolding="2"
+				LinkTimeCodeGeneration="1"
+				ImportLibrary="$(TargetDir)$(TargetName).lib"
+				TargetMachine="1"
+			/>
+			<Tool
+				Name="VCALinkTool"
+			/>
+			<Tool
+				Name="VCManifestTool"
+			/>
+			<Tool
+				Name="VCXDCMakeTool"
+			/>
+			<Tool
+				Name="VCBscMakeTool"
+			/>
+			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
+				Name="VCAppVerifierTool"
+			/>
+			<Tool
+				Name="VCPostBuildEventTool"
+			/>
+		</Configuration>
+	</Configurations>
+	<References>
+	</References>
+	<Files>
+		<Filter
+			Name="Controls"
+			>
+			<File
+				RelativePath="..\Source\Controls\Lua\DataFormatter.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\DataFormatter.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\DataSource.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\DataSource.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\ElementDataGrid.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\ElementDataGrid.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\ElementDataGridRow.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\ElementDataGridRow.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\ElementTabSet.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\ElementTabSet.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\LuaDataFormatter.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\LuaDataFormatter.h"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\LuaDataSource.cpp"
+				>
+			</File>
+			<File
+				RelativePath="..\Source\Controls\Lua\LuaDataSource.h"
+				>
+			</File>
+			<Filter
+				Name="Forms"
+				>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementForm.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementForm.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControl.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControl.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlDataSelect.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlDataSelect.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlInput.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlInput.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlSelect.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlSelect.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlTextArea.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlTextArea.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\SelectOptionsProxy.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\SelectOptionsProxy.h"
+					>
+				</File>
+			</Filter>
+		</Filter>
+		<File
+			RelativePath="..\Source\Controls\Lua\Controls.cpp"
+			>
+		</File>
+		<File
+			RelativePath="..\Include\Rocket\Controls\Lua\Controls.h"
+			>
+		</File>
+		<File
+			RelativePath="..\Include\Rocket\Core\Lua\Header.h"
+			>
+		</File>
+		<File
+			RelativePath="..\Source\Core\Lua\precompiled.cpp"
+			>
+			<FileConfiguration
+				Name="Debug|Win32"
+				>
+				<Tool
+					Name="VCCLCompilerTool"
+					UsePrecompiledHeader="1"
+				/>
+			</FileConfiguration>
+			<FileConfiguration
+				Name="Release|Win32"
+				>
+				<Tool
+					Name="VCCLCompilerTool"
+					UsePrecompiledHeader="1"
+				/>
+			</FileConfiguration>
+		</File>
+		<File
+			RelativePath="..\Source\Core\Lua\precompiled.h"
+			>
+		</File>
+	</Files>
+	<Globals>
+	</Globals>
+</VisualStudioProject>

+ 2 - 126
Build/RocketLua.vcproj → Build/RocketCoreLua.vcproj

@@ -2,7 +2,7 @@
 <VisualStudioProject
 	ProjectType="Visual C++"
 	Version="9.00"
-	Name="RocketLua"
+	Name="RocketCoreLua"
 	ProjectGUID="{FC02901C-3CE4-4625-856A-F180DC45A855}"
 	RootNamespace="RocketLua"
 	TargetFrameworkVersion="196613"
@@ -184,126 +184,6 @@
 	<References>
 	</References>
 	<Files>
-		<Filter
-			Name="Controls"
-			>
-			<File
-				RelativePath="..\Source\Controls\Lua\DataFormatter.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\DataFormatter.h"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\DataSource.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\DataSource.h"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\ElementDataGrid.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\ElementDataGrid.h"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\ElementDataGridRow.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\ElementDataGridRow.h"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\ElementTabSet.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\ElementTabSet.h"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\LuaDataFormatter.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\LuaDataFormatter.h"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\LuaDataSource.cpp"
-				>
-			</File>
-			<File
-				RelativePath="..\Source\Controls\Lua\LuaDataSource.h"
-				>
-			</File>
-			<Filter
-				Name="Forms"
-				>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementForm.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementForm.h"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControl.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControl.h"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlDataSelect.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlDataSelect.h"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlInput.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlInput.h"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlSelect.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlSelect.h"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlTextArea.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\ElementFormControlTextArea.h"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\SelectOptionsProxy.cpp"
-					>
-				</File>
-				<File
-					RelativePath="..\Source\Controls\Lua\SelectOptionsProxy.h"
-					>
-				</File>
-			</Filter>
-		</Filter>
 		<Filter
 			Name="Core"
 			>
@@ -343,10 +223,6 @@
 					/>
 				</FileConfiguration>
 			</File>
-			<File
-				RelativePath="..\Source\Core\Lua\LuaTypeTemplateSpec.inl"
-				>
-			</File>
 			<File
 				RelativePath="..\Source\Core\Lua\Rocket.cpp"
 				>
@@ -368,7 +244,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\Source\Core\Lua\Utilities.h"
+				RelativePath="..\Include\Rocket\Core\Lua\Utilities.h"
 				>
 			</File>
 			<Filter

+ 7 - 1
Build/RocketLua.sln

@@ -13,7 +13,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RocketDebugger", "RocketDeb
 		{1AAC0B29-AEB9-4E3F-8EDF-B46F8949C41B} = {1AAC0B29-AEB9-4E3F-8EDF-B46F8949C41B}
 	EndProjectSection
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RocketLua", "RocketLua.vcproj", "{FC02901C-3CE4-4625-856A-F180DC45A855}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RocketCoreLua", "RocketCoreLua.vcproj", "{FC02901C-3CE4-4625-856A-F180DC45A855}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RocketControlsLua", "RocketControlsLua.vcproj", "{45C9CB50-E22C-465E-AB17-CA81D2372DEF}"
 EndProject
 Global
 	GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -37,6 +39,10 @@ Global
 		{FC02901C-3CE4-4625-856A-F180DC45A855}.Debug|Win32.Build.0 = Debug|Win32
 		{FC02901C-3CE4-4625-856A-F180DC45A855}.Release|Win32.ActiveCfg = Release|Win32
 		{FC02901C-3CE4-4625-856A-F180DC45A855}.Release|Win32.Build.0 = Release|Win32
+		{45C9CB50-E22C-465E-AB17-CA81D2372DEF}.Debug|Win32.ActiveCfg = Debug|Win32
+		{45C9CB50-E22C-465E-AB17-CA81D2372DEF}.Debug|Win32.Build.0 = Debug|Win32
+		{45C9CB50-E22C-465E-AB17-CA81D2372DEF}.Release|Win32.ActiveCfg = Release|Win32
+		{45C9CB50-E22C-465E-AB17-CA81D2372DEF}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 45 - 0
Include/Rocket/Controls/Lua/Controls.h

@@ -0,0 +1,45 @@
+/*
+ * This source file is part of libRocket, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://www.librocket.com
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#ifndef ROCKETCONTROLSLUACONTROLS_H
+#define ROCKETCONTROLSLUACONTROLS_H
+
+#include <Rocket/Core/Lua/Header.h>
+
+namespace Rocket {
+namespace Controls {
+namespace Lua {
+
+//This will define all of the types from RocketControls for Lua. There is not a
+//corresponding function for types of RocketCore, because they are defined automatically
+//when the Interpreter starts.
+ROCKETLUA_API void RegisterTypes(lua_State* L);
+}
+}
+}
+
+#endif

+ 0 - 5
Include/Rocket/Core/Lua/Interpreter.h

@@ -51,11 +51,6 @@ public:
     //Same as DoString, except does NOT call pcall on it. It will leave the compiled (but not executed) string
     //on top of the stack. It is just like luaL_loadstring, but you get to specify the name
     static void LoadString(const Rocket::Core::String& code, const Rocket::Core::String& name = "");
-    //If there are errors on the top of the stack, this will print those out to the log.
-    //L is a Lua state, and if not passed in, will use the Interpreter's state
-    //place is a string that will be printed to the log right before the error message seperated by a space. Set
-    //this when you would get no information about where the error happens.
-    static void Report(lua_State* L = NULL, const Rocket::Core::String& place = "");
 
     //clears all of the items on the stack, and pushes the function from funRef on top of the stack. Only use
     //this if you used lua_ref instead of luaL_ref

+ 38 - 13
Include/Rocket/Core/Lua/LuaType.h

@@ -35,9 +35,6 @@
 #include <Rocket/Core/Lua/Header.h>
 #include <Rocket/Core/Lua/lua.hpp>
 
-namespace Rocket {
-namespace Core {
-namespace Lua {
 
 //As an example, if you used this macro like
 //LUAMETHOD(Unit,GetId)
@@ -57,23 +54,43 @@ namespace Lua {
 #define LUASETTER(type,varname) { #varname, type##SetAttr##varname },
 
 #define CHECK_BOOL(L,narg) (lua_toboolean((L),(narg)) > 0 ? true : false )
-#define LUACHECKOBJ(obj) if(obj == NULL) { lua_pushnil(L); return 1; }
+#define LUACHECKOBJ(obj) if((obj) == NULL) { lua_pushnil(L); return 1; }
 
 //put this in the type.cpp file
+    /*
 #define LUATYPEDEFINE(type) \
     template<> inline const char* GetTClassName<type>() { return #type; } \
     template<> inline RegType<type>* GetMethodTable<type>() { return type##Methods; } \
     template<> inline luaL_reg* GetAttrTable<type>() { return type##Getters; } \
     template<> inline luaL_reg* SetAttrTable<type>() { return type##Setters; } \
-
-//put this in the type.h file
+*/
+ //put this in the type.cpp file
+#define LUATYPEDEFINE(type,is_ref_counted) \
+    template<> const char* Rocket::Core::Lua::GetTClassName<type>() { return #type; } \
+    template<> Rocket::Core::Lua::RegType<type>* Rocket::Core::Lua::GetMethodTable<type>() { return type##Methods; } \
+    template<> luaL_reg* Rocket::Core::Lua::GetAttrTable<type>() { return type##Getters; } \
+    template<> luaL_reg* Rocket::Core::Lua::SetAttrTable<type>() { return type##Setters; } \
+    template<> bool Rocket::Core::Lua::IsReferenceCounted<type>() { return (is_ref_counted); } \
+
+//put this in the type.h file. Not used at the moment
+    /*
 #define LUATYPEDECLARE(type) \
     template<> const char* GetTClassName<type>(); \
     template<> RegType<type>* GetMethodTable<type>(); \
     template<> luaL_reg* GetAttrTable<type>(); \
     template<> luaL_reg* SetAttrTable<type>(); \
+*/
+//put this in the type.h file
+#define LUATYPEDECLARE(type) \
+    template<> ROCKETLUA_API const char* Rocket::Core::Lua::GetTClassName<type>(); \
+    template<> ROCKETLUA_API Rocket::Core::Lua::RegType<type>* Rocket::Core::Lua::GetMethodTable<type>(); \
+    template<> ROCKETLUA_API luaL_reg* Rocket::Core::Lua::GetAttrTable<type>(); \
+    template<> ROCKETLUA_API luaL_reg* Rocket::Core::Lua::SetAttrTable<type>(); \
+    template<> ROCKETLUA_API bool Rocket::Core::Lua::IsReferenceCounted<type>(); \
 
-
+namespace Rocket {
+namespace Core {
+namespace Lua {
 //replacement for luaL_reg that uses a different function pointer signature, but similar syntax
 template<typename T>
 struct ROCKETLUA_API RegType
@@ -83,13 +100,21 @@ struct ROCKETLUA_API RegType
 };
 
 //this is for all of the methods available from Lua that call to the C functions
-template<typename T> ROCKETLUA_API inline RegType<T>* GetMethodTable();
+template<typename T> ROCKETLUA_API RegType<T>* GetMethodTable();
 //this is for all of the function that 'get' an attribute/property
-template<typename T> ROCKETLUA_API inline luaL_reg* GetAttrTable();
+template<typename T> ROCKETLUA_API luaL_reg* GetAttrTable();
 //this is for all of the functions that 'set' an attribute/property
-template<typename T> ROCKETLUA_API inline luaL_reg* SetAttrTable();
+template<typename T> ROCKETLUA_API luaL_reg* SetAttrTable();
 //String representation of the class
-template<typename T> ROCKETLUA_API inline const char* GetTClassName();
+template<typename T> ROCKETLUA_API const char* GetTClassName();
+//bool for if it is reference counted
+template<typename T> ROCKETLUA_API bool IsReferenceCounted();
+//gets called from the LuaType<T>::Register function, right before _regfunctions.
+//If you want to inherit from another class, in the function you would want
+//to call _regfunctions<superclass>, where method is metatable_index - 1. Anything
+//that has the same name in the subclass will be overwrite whatever had the 
+//same name in the superclass.
+template<typename T> ROCKETLUA_API void ExtraInit(lua_State* L, int metatable_index) { return; }
 
 template<typename T>
 class ROCKETLUA_API LuaType
@@ -121,13 +146,13 @@ public:
     //to call _regfunctions<superclass>, where method is metatable_index - 1. Anything
     //that has the same name in the subclass will be overwrite whatever had the 
     //same name in the superclass.
-    static inline  void extra_init(lua_State* L, int metatable_index);
+    //static inline void extra_init(lua_State* L, int metatable_index);
     //Registers methods,getters,and setters to the type
     static inline void _regfunctions(lua_State* L, int meta, int method);
     //Says if it is a reference counted type. If so, then on push and __gc, do reference counting things
     //rather than regular new/delete. Note that it is still up to the user to pass "true" to the push function's
     //third parameter to be able to decrease the reference when Lua garbage collects an object
-    static inline bool is_reference_counted();
+    //static inline bool is_reference_counted();
 private:
     LuaType(); //hide constructor
 

+ 7 - 1
Source/Core/Lua/Utilities.h → Include/Rocket/Core/Lua/Utilities.h

@@ -30,6 +30,7 @@
 /*
     This file is for free-floating functions that are used across more than one file.
 */
+#include <Rocket/Core/Lua/Header.h>
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Core/Variant.h>
@@ -39,8 +40,13 @@ namespace Core {
 namespace Lua {
 
 //casts the variant to its specific type before pushing it to the stack
-void PushVariant(lua_State* L, Variant* var);
+void ROCKETLUA_API PushVariant(lua_State* L, Variant* var);
 
+//If there are errors on the top of the stack, this will print those out to the log.
+//L is a Lua state, and if not passed in, will use the Interpreter's state
+//place is a string that will be printed to the log right before the error message seperated by a space. Set
+//this when you would get no information about where the error happens.
+void ROCKETLUA_API Report(lua_State* L = NULL, const Rocket::Core::String& place = "");
 }
 }
 }

+ 73 - 0
Source/Controls/Lua/Controls.cpp

@@ -0,0 +1,73 @@
+/*
+ * This source file is part of libRocket, the HTML/CSS Interface Middleware
+ *
+ * For the latest information, see http://www.librocket.com
+ *
+ * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ */
+
+#include "precompiled.h"
+#include <Rocket/Controls/Lua/Controls.h>
+#include <Rocket/Core/Lua/LuaType.h>
+#include <Rocket/Core/Lua/lua.hpp>
+#include "SelectOptionsProxy.h"
+#include "DataFormatter.h"
+#include "DataSource.h"
+#include "ElementForm.h"
+#include "ElementFormControl.h"
+#include "ElementFormControlSelect.h"
+#include "ElementFormControlDataSelect.h"
+#include "ElementFormControlInput.h"
+#include "ElementFormControlTextArea.h"
+#include "ElementDataGrid.h"
+#include "ElementDataGridRow.h"
+#include "ElementTabSet.h"
+
+using Rocket::Core::Lua::LuaType;
+namespace Rocket {
+namespace Controls {
+namespace Lua {
+
+//This will define all of the types from RocketControls for Lua. There is not a
+//corresponding function for types of RocketCore, because they are defined automatically
+//when the Interpreter starts.
+void RegisterTypes(lua_State* L)
+{
+    LuaType<ElementForm>::Register(L);
+    LuaType<ElementFormControl>::Register(L);
+        //Inherits from ElementFormControl
+        LuaType<ElementFormControlSelect>::Register(L);
+            LuaType<ElementFormControlDataSelect>::Register(L);
+        LuaType<ElementFormControlInput>::Register(L);
+        LuaType<ElementFormControlTextArea>::Register(L);
+    //proxy tables
+    LuaType<SelectOptionsProxy>::Register(L);
+    LuaType<DataFormatter>::Register(L);
+    LuaType<DataSource>::Register(L);
+    LuaType<ElementDataGrid>::Register(L);
+    LuaType<ElementDataGridRow>::Register(L);
+    LuaType<ElementTabSet>::Register(L);
+}
+
+}
+}
+}

+ 12 - 4
Source/Controls/Lua/DataFormatter.cpp

@@ -28,10 +28,16 @@
 #include "precompiled.h"
 #include "DataFormatter.h"
 
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::Lua::DataFormatter>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,Rocket::Controls::Lua::DataFormatternew);
+    lua_setfield(L,metatable_index-1,"new");
+    return;
+}
+using Rocket::Core::Log;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-
 //method
 int DataFormatternew(lua_State* L)
 {
@@ -84,7 +90,7 @@ int DataFormatterSetAttrFormatData(lua_State* L)
     return 0;
 }
 
-RegType<DataFormatter> DataFormatterMethods[] =
+Rocket::Core::Lua::RegType<DataFormatter> DataFormatterMethods[] =
 {
     { NULL, NULL },
 };
@@ -102,4 +108,6 @@ luaL_reg DataFormatterSetters[] =
 
 }
 }
-}
+}
+using Rocket::Controls::Lua::DataFormatter;
+LUACONTROLSTYPEDEFINE(DataFormatter,false)

+ 8 - 7
Source/Controls/Lua/DataFormatter.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUADATAFORMATTER_H
-#define ROCKETCORELUADATAFORMATTER_H
+#ifndef ROCKETCONTROLSLUADATAFORMATTER_H
+#define ROCKETCONTROLSLUADATAFORMATTER_H
 /*
     This defines the DataFormatter type in the Lua global namespace
 
@@ -46,23 +46,24 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include "LuaDataFormatter.h"
 
+using Rocket::Core::Lua::LuaType;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 typedef LuaDataFormatter DataFormatter;
-//for DataFormatter.new
-template<> void LuaType<DataFormatter>::extra_init(lua_State* L, int metatable_index);
-
 //method
 int DataFormatternew(lua_State* L);
 
 //setter
 int DataFormatterSetAttrFormatData(lua_State* L);
 
-RegType<DataFormatter> DataFormatterMethods[];
+Rocket::Core::Lua::RegType<DataFormatter> DataFormatterMethods[];
 luaL_reg DataFormatterGetters[];
 luaL_reg DataFormatterSetters[];
 }
 }
 }
+//for DataFormatter.new
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::Lua::DataFormatter>(lua_State* L, int metatable_index);
+LUATYPEDECLARE(Rocket::Controls::Lua::DataFormatter)
 #endif

+ 8 - 3
Source/Controls/Lua/DataSource.cpp

@@ -29,8 +29,9 @@
 #include "DataSource.h"
 #include <Rocket/Core/Log.h>
 
+using Rocket::Core::Log;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 typedef LuaDataSource DataSource;
 
@@ -100,7 +101,7 @@ int DataSourceSetAttrGetRow(lua_State* L)
 }
 
 
-RegType<DataSource> DataSourceMethods[] =
+Rocket::Core::Lua::RegType<DataSource> DataSourceMethods[] =
 {
     LUAMETHOD(DataSource,NotifyRowAdd)
     LUAMETHOD(DataSource,NotifyRowRemove)
@@ -120,6 +121,10 @@ luaL_reg DataSourceSetters[] =
     { NULL, NULL },
 };
 
+
+
+}
 }
 }
-}
+using Rocket::Controls::Lua::DataSource;
+LUACONTROLSTYPEDEFINE(DataSource,false)

+ 10 - 4
Source/Controls/Lua/DataSource.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUADATASOURCE_H
-#define ROCKETCORELUADATASOURCE_H
+#ifndef ROCKETCONTROLSLUADATASOURCE_H
+#define ROCKETCONTROLSLUADATASOURCE_H
 
 /*
     This defines the DataSource type in the Lua global namespace
@@ -48,8 +48,10 @@
 #include <Rocket/Core/Lua/lua.hpp>
 #include "LuaDataSource.h"
 
+using Rocket::Core::Lua::LuaType;
+
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 typedef LuaDataSource DataSource;
 
@@ -60,11 +62,15 @@ int DataSourceNotifyRowChange(lua_State* L, DataSource* obj);
 int DataSourceSetAttrGetNumRows(lua_State* L);
 int DataSourceSetAttrGetRow(lua_State* L);
 
-RegType<DataSource> DataSourceMethods[];
+Rocket::Core::Lua::RegType<DataSource> DataSourceMethods[];
 luaL_reg DataSourceGetters[];
 luaL_reg DataSourceSetters[];
 
+
+
 }
 }
 }
+
+LUATYPEDECLARE(Rocket::Controls::Lua::DataSource)
 #endif

+ 13 - 10
Source/Controls/Lua/ElementDataGrid.cpp

@@ -30,10 +30,16 @@
 #include <Rocket/Core/Element.h>
 #include <Rocket/Controls/ElementDataGridRow.h>
 
-using Rocket::Controls::ElementDataGridRow;
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementDataGrid>(lua_State* L, int metatable_index)
+{
+    Rocket::Core::Lua::ExtraInit<Rocket::Core::Element>(L,metatable_index);
+    LuaType<Rocket::Core::Element>::_regfunctions(L,metatable_index,metatable_index-1);
+}
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
+
+
 //methods
 int ElementDataGridAddColumn(lua_State* L, ElementDataGrid* obj)
 {
@@ -78,7 +84,7 @@ int ElementDataGridGetAttrrows(lua_State* L)
 
 
 
-RegType<ElementDataGrid> ElementDataGridMethods[] =
+Rocket::Core::Lua::RegType<ElementDataGrid> ElementDataGridMethods[] =
 {
     LUAMETHOD(ElementDataGrid,AddColumn)
     LUAMETHOD(ElementDataGrid,SetDataSource)
@@ -96,12 +102,9 @@ luaL_reg ElementDataGridSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<ElementDataGrid>() { return "ElementDataGrid"; }
-template<> RegType<ElementDataGrid>* GetMethodTable<ElementDataGrid>() { return ElementDataGridMethods; }
-template<> luaL_reg* GetAttrTable<ElementDataGrid>() { return ElementDataGridGetters; }
-template<> luaL_reg* SetAttrTable<ElementDataGrid>() { return ElementDataGridSetters; }
-*/
+
+}
 }
 }
-}
+using Rocket::Controls::ElementDataGrid;
+LUACONTROLSTYPEDEFINE(ElementDataGrid,true)

+ 9 - 14
Source/Controls/Lua/ElementDataGrid.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTDATAGRID_H
-#define ROCKETCORELUAELEMENTDATAGRID_H
+#ifndef ROCKETCONTROLSLUAELEMENTDATAGRID_H
+#define ROCKETCONTROLSLUAELEMENTDATAGRID_H
 /*
     This defines the ElementDataGrid type in the Lua global namespace
     
@@ -45,13 +45,12 @@
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Controls/ElementDataGrid.h>
 
-using Rocket::Controls::ElementDataGrid;
+using Rocket::Core::Lua::LuaType;
+//this will be used to "inherit" from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementDataGrid>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//this will be used to "inherit" from Element
-template<> void LuaType<ElementDataGrid>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementDataGrid>::is_reference_counted();
 
 //methods
 int ElementDataGridAddColumn(lua_State* L, ElementDataGrid* obj);
@@ -61,17 +60,13 @@ int ElementDataGridSetDataSource(lua_State* L, ElementDataGrid* obj);
 int ElementDataGridGetAttrrows(lua_State* L);
 
 
-RegType<ElementDataGrid> ElementDataGridMethods[];
+Rocket::Core::Lua::RegType<ElementDataGrid> ElementDataGridMethods[];
 luaL_reg ElementDataGridGetters[];
 luaL_reg ElementDataGridSetters[];
 
-/*
-template<> const char* GetTClassName<ElementDataGrid>();
-template<> RegType<ElementDataGrid>* GetMethodTable<ElementDataGrid>();
-template<> luaL_reg* GetAttrTable<ElementDataGrid>();
-template<> luaL_reg* SetAttrTable<ElementDataGrid>();
-*/
+
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementDataGrid)
 #endif

+ 14 - 10
Source/Controls/Lua/ElementDataGridRow.cpp

@@ -29,10 +29,17 @@
 #include "ElementDataGridRow.h"
 #include <Rocket/Controls/ElementDataGrid.h>
 
-using Rocket::Controls::ElementDataGrid;
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementDataGridRow>(lua_State* L, int metatable_index)
+{
+    Rocket::Core::Lua::ExtraInit<Rocket::Core::Element>(L,metatable_index);
+    LuaType<Rocket::Core::Element>::_regfunctions(L,metatable_index,metatable_index-1);
+}
+
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
+
+
 //getters
 int ElementDataGridRowGetAttrrow_expanded(lua_State* L)
 {
@@ -90,7 +97,7 @@ int ElementDataGridRowSetAttrrow_expanded(lua_State* L)
 
 
 
-RegType<ElementDataGridRow> ElementDataGridRowMethods[] =
+Rocket::Core::Lua::RegType<ElementDataGridRow> ElementDataGridRowMethods[] =
 {
     { NULL, NULL },
 };
@@ -110,12 +117,9 @@ luaL_reg ElementDataGridRowSetters[] =
     LUASETTER(ElementDataGridRow,row_expanded)
     { NULL, NULL },
 };
-/*
-template<> const char* GetTClassName<ElementDataGridRow>() { return "ElementDataGridRow"; }
-template<> RegType<ElementDataGridRow>* GetMethodTable<ElementDataGridRow>() { return ElementDataGridRowMethods; }
-template<> luaL_reg* GetAttrTable<ElementDataGridRow>() { return ElementDataGridRowGetters; }
-template<> luaL_reg* SetAttrTable<ElementDataGridRow>() { return ElementDataGridRowSetters; }
-*/
+
+}
 }
 }
-}
+using Rocket::Controls::ElementDataGridRow;
+LUACONTROLSTYPEDEFINE(ElementDataGridRow,true)

+ 10 - 14
Source/Controls/Lua/ElementDataGridRow.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTDATAGRIDROW_H
-#define ROCKETCORELUAELEMENTDATAGRIDROW_H
+#ifndef ROCKETCONTROLSLUAELEMENTDATAGRIDROW_H
+#define ROCKETCONTROLSLUAELEMENTDATAGRIDROW_H
 /*
     This defines the ElementDataGridRow type in the Lua global namespace
 
@@ -49,13 +49,13 @@
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Controls/ElementDataGridRow.h>
 
-using Rocket::Controls::ElementDataGridRow;
+using Rocket::Core::Lua::LuaType;
+//this will be used to "inherit" from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementDataGridRow>(lua_State* L, int metatable_index);
+
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//this will be used to "inherit" from Element
-template<> void LuaType<ElementDataGridRow>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementDataGridRow>::is_reference_counted();
 
 //getters
 int ElementDataGridRowGetAttrrow_expanded(lua_State* L);
@@ -68,18 +68,14 @@ int ElementDataGridRowGetAttrparent_grid(lua_State* L);
 int ElementDataGridRowSetAttrrow_expanded(lua_State* L);
 
 
-RegType<ElementDataGridRow> ElementDataGridRowMethods[];
+Rocket::Core::Lua::RegType<ElementDataGridRow> ElementDataGridRowMethods[];
 luaL_reg ElementDataGridRowGetters[];
 luaL_reg ElementDataGridRowSetters[];
 
-/*
-template<> const char* GetTClassName<ElementDataGridRow>();
-template<> RegType<ElementDataGridRow>* GetMethodTable<ElementDataGridRow>();
-template<> luaL_reg* GetAttrTable<ElementDataGridRow>();
-template<> luaL_reg* SetAttrTable<ElementDataGridRow>();
-*/
+
 
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementDataGridRow)
 #endif

+ 13 - 3
Source/Controls/Lua/ElementForm.cpp

@@ -30,9 +30,17 @@
 #include <Rocket/Core/Element.h>
 #include <Rocket/Controls/ElementForm.h>
 
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementForm>(lua_State* L, int metatable_index)
+{
+    //inherit from Element
+    Rocket::Core::Lua::ExtraInit<Rocket::Core::Element>(L,metatable_index);
+    LuaType<Rocket::Core::Element>::_regfunctions(L,metatable_index,metatable_index-1);
+}
+
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
+
 //method
 int ElementFormSubmit(lua_State* L, ElementForm* obj)
 {
@@ -42,7 +50,7 @@ int ElementFormSubmit(lua_State* L, ElementForm* obj)
     return 0;
 }
 
-RegType<ElementForm> ElementFormMethods[] =
+Rocket::Core::Lua::RegType<ElementForm> ElementFormMethods[] =
 {
     LUAMETHOD(ElementForm,Submit)
     { NULL, NULL },
@@ -61,4 +69,6 @@ luaL_reg ElementFormSetters[] =
 
 }
 }
-}
+}
+using Rocket::Controls::ElementForm;
+LUACONTROLSTYPEDEFINE(ElementForm,true)

+ 10 - 14
Source/Controls/Lua/ElementForm.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTFORM_H
-#define ROCKETCORELUAELEMENTFORM_H
+#ifndef ROCKETCONTROLSLUAELEMENTFORM_H
+#define ROCKETCONTROLSLUAELEMENTFORM_H
 /*
     This defines the ElementForm type in the Lua global namespace
 
@@ -40,30 +40,26 @@
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Controls/ElementForm.h>
 
-using Rocket::Controls::ElementForm;
+using Rocket::Core::Lua::LuaType;
+//this will be used to "inherit" from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementForm>(lua_State* L, int metatable_index);
+
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//this will be used to "inherit" from Element
-template<> void LuaType<ElementForm>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementForm>::is_reference_counted();
+
 
 //method
 int ElementFormSubmit(lua_State* L, ElementForm* obj);
 
-RegType<ElementForm> ElementFormMethods[];
+Rocket::Core::Lua::RegType<ElementForm> ElementFormMethods[];
 luaL_reg ElementFormGetters[];
 luaL_reg ElementFormSetters[];
 
 
-/*
-template<> const char* GetTClassName<ElementForm>() { return "ElementForm"; }
-template<> RegType<ElementForm>* GetMethodTable<ElementForm>() { return ElementFormMethods; }
-template<> luaL_reg* GetAttrTable<ElementForm>() { return ElementFormGetters; }
-template<> luaL_reg* SetAttrTable<ElementForm>() { return ElementFormSetters; }
 
-*/
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementForm)
 #endif

+ 13 - 4
Source/Controls/Lua/ElementFormControl.cpp

@@ -29,10 +29,18 @@
 #include "ElementFormControl.h"
 #include <Rocket/Controls/ElementFormControl.h>
 #include <Rocket/Core/Element.h>
+#include "Lua/Element.h"
+
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(lua_State* L, int metatable_index)
+{
+    Rocket::Core::Lua::ExtraInit<Rocket::Core::Element>(L,metatable_index);
+    LuaType<Rocket::Core::Element>::_regfunctions(L,metatable_index,metatable_index-1);
+}
 
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
+
 //getters
 int ElementFormControlGetAttrdisabled(lua_State* L)
 {
@@ -87,7 +95,7 @@ int ElementFormControlSetAttrvalue(lua_State* L)
 }
 
 
-RegType<ElementFormControl> ElementFormControlMethods[] = 
+Rocket::Core::Lua::RegType<ElementFormControl> ElementFormControlMethods[] = 
 {
     { NULL, NULL },
 };
@@ -108,7 +116,8 @@ luaL_reg ElementFormControlSetters[] =
     { NULL, NULL },
 };
 
-
 }
 }
-}
+}
+using Rocket::Controls::ElementFormControl;
+LUACONTROLSTYPEDEFINE(ElementFormControl,true)

+ 7 - 13
Source/Controls/Lua/ElementFormControl.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTFORMCONTROL_H
-#define ROCKETCORELUAELEMENTFORMCONTROL_H
+#ifndef ROCKETCONTROLSLUAELEMENTFORMCONTROL_H
+#define ROCKETCONTROLSLUAELEMENTFORMCONTROL_H
 /*
     This defines the ElementFormControl type in the Lua global namespace
 
@@ -40,12 +40,11 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Controls/ElementFormControl.h>
 
-using Rocket::Controls::ElementFormControl;
+using Rocket::Core::Lua::LuaType;
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-template<> void LuaType<ElementFormControl>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementFormControl>::is_reference_counted();
 
 //getters
 int ElementFormControlGetAttrdisabled(lua_State* L);
@@ -57,18 +56,13 @@ int ElementFormControlSetAttrdisabled(lua_State* L);
 int ElementFormControlSetAttrname(lua_State* L);
 int ElementFormControlSetAttrvalue(lua_State* L);
 
-RegType<ElementFormControl> ElementFormControlMethods[];
+Rocket::Core::Lua::RegType<ElementFormControl> ElementFormControlMethods[];
 luaL_reg ElementFormControlGetters[];
 luaL_reg ElementFormControlSetters[];
 
-/*
-template<> const char* GetTClassName<ElementFormControl>() { return "ElementFormControl"; }
-template<> RegType<ElementFormControl>* GetMethodTable<ElementFormControl>() { return ElementFormControlMethods; }
-template<> luaL_reg* GetAttrTable<ElementFormControl>() { return ElementFormControlGetters; }
-template<> luaL_reg* SetAttrTable<ElementFormControl>() { return ElementFormControlSetters; }
-*/
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementFormControl)
 #endif
 

+ 15 - 13
Source/Controls/Lua/ElementFormControlDataSelect.cpp

@@ -28,13 +28,20 @@
 #include "precompiled.h"
 #include "ElementFormControlDataSelect.h"
 #include <Rocket/Controls/ElementFormControlSelect.h>
+#include "ElementFormControlSelect.h"
 
-using Rocket::Controls::ElementFormControlSelect;
-namespace Rocket {
-namespace Core {
-namespace Lua {
 //inherits from ElementFormControl which inherits from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlDataSelect>(lua_State* L, int metatable_index)
+{
+    //do whatever ElementFormControlSelect did as far as inheritance
+    Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlSelect>(L,metatable_index);
+    //then inherit from ElementFromControlSelect
+    LuaType<Rocket::Controls::ElementFormControlSelect>::_regfunctions(L,metatable_index,metatable_index-1);
+}
 
+namespace Rocket {
+namespace Controls {
+namespace Lua {
 
 //method
 int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDataSelect* obj)
@@ -44,7 +51,7 @@ int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDa
     return 0;
 }
 
-RegType<ElementFormControlDataSelect> ElementFormControlDataSelectMethods[] =
+Rocket::Core::Lua::RegType<ElementFormControlDataSelect> ElementFormControlDataSelectMethods[] =
 {
     LUAMETHOD(ElementFormControlDataSelect,SetDataSource)
     { NULL, NULL },
@@ -60,13 +67,8 @@ luaL_reg ElementFormControlDataSelectSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<ElementFormControlDataSelect>() { return "ElementFormControlDataSelect"; }
-template<> RegType<ElementFormControlDataSelect>* GetMethodTable<ElementFormControlDataSelect>() { return ElementFormControlDataSelectMethods; }
-template<> luaL_reg* GetAttrTable<ElementFormControlDataSelect>() { return ElementFormControlDataSelectGetters; }
-template<> luaL_reg* SetAttrTable<ElementFormControlDataSelect>() { return ElementFormControlDataSelectSetters; }
-*/
-
 }
 }
-}
+}
+using Rocket::Controls::ElementFormControlDataSelect;
+LUACONTROLSTYPEDEFINE(ElementFormControlDataSelect,true)

+ 8 - 15
Source/Controls/Lua/ElementFormControlDataSelect.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTFORMCONTROLDATASELECT_H
-#define ROCKETCORELUAELEMENTFORMCONTROLDATASELECT_H
+#ifndef ROCKETCONTROLSLUAELEMENTFORMCONTROLDATASELECT_H
+#define ROCKETCONTROLSLUAELEMENTFORMCONTROLDATASELECT_H
 /*
     This defines the ElementFormControlDataSelect type in the Lua global namespace. I think it is the longest
     type name.
@@ -42,29 +42,22 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Controls/ElementFormControlDataSelect.h>
 
-using Rocket::Controls::ElementFormControlDataSelect;
+using Rocket::Core::Lua::LuaType;
+//inherits from ElementFormControl which inherits from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlDataSelect>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//inherits from ElementFormControl which inherits from Element
-template<> void LuaType<ElementFormControlDataSelect>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementFormControlDataSelect>::is_reference_counted();
 
 //method
 int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDataSelect* obj);
 
-RegType<ElementFormControlDataSelect> ElementFormControlDataSelectMethods[];
+Rocket::Core::Lua::RegType<ElementFormControlDataSelect> ElementFormControlDataSelectMethods[];
 luaL_reg ElementFormControlDataSelectGetters[];
 luaL_reg ElementFormControlDataSelectSetters[];
 
-/*
-template<> const char* GetTClassName<ElementFormControlDataSelect>();
-template<> RegType<ElementFormControlDataSelect>* GetMethodTable<ElementFormControlDataSelect>();
-template<> luaL_reg* GetAttrTable<ElementFormControlDataSelect>();
-template<> luaL_reg* SetAttrTable<ElementFormControlDataSelect>();
-*/
-
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementFormControlDataSelect)
 #endif

+ 14 - 10
Source/Controls/Lua/ElementFormControlInput.cpp

@@ -28,11 +28,19 @@
 #include "precompiled.h"
 #include "ElementFormControlInput.h"
 #include <Rocket/Controls/ElementFormControl.h>
+#include "ElementFormControl.h"
 
-using Rocket::Controls::ElementFormControl;
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlInput>(lua_State* L, int metatable_index)
+{
+    Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(L,metatable_index);
+    LuaType<Rocket::Controls::ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
+
+}
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
+
+
 //getters
 int ElementFormControlInputGetAttrchecked(lua_State* L)
 {
@@ -142,7 +150,7 @@ int ElementFormControlInputSetAttrstep(lua_State* L)
 }
 
 
-RegType<ElementFormControlInput> ElementFormControlInputMethods[] = 
+Rocket::Core::Lua::RegType<ElementFormControlInput> ElementFormControlInputMethods[] = 
 {
     {NULL,NULL},
 };
@@ -169,12 +177,8 @@ luaL_reg ElementFormControlInputSetters[] =
     {NULL,NULL},
 };
 
-/*
-template<> const char* GetTClassName<ElementFormControlInput>() { return "ElementFormControlInput"; }
-template<> RegType<ElementFormControlInput>* GetMethodTable<ElementFormControlInput>() { return ElementFormControlInputMethods; }
-template<> luaL_reg* GetAttrTable<ElementFormControlInput>() { return ElementFormControlInputGetters; }
-template<> luaL_reg* SetAttrTable<ElementFormControlInput>() { return ElementFormControlInputSetters; }
-*/
 }
 }
-}
+}
+using Rocket::Controls::ElementFormControlInput;
+LUACONTROLSTYPEDEFINE(ElementFormControlInput,true)

+ 8 - 15
Source/Controls/Lua/ElementFormControlInput.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTFORMCONTROLINPUT_H
-#define ROCKETCORELUAELEMENTFORMCONTROLINPUT_H
+#ifndef ROCKETCONTROLSLUAELEMENTFORMCONTROLINPUT_H
+#define ROCKETCONTROLSLUAELEMENTFORMCONTROLINPUT_H
 /*
     This defines the type ElementFormControlInput in the Lua globla namespace, refered to in this documentation by EFCInput
 
@@ -45,13 +45,12 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Controls/ElementFormControlInput.h>
 
-using Rocket::Controls::ElementFormControlInput;
+using Rocket::Core::Lua::LuaType;
+//inherits from ElementFormControl which inherits from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlInput>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//inherits from ElementFormControl which inherits from Element
-template<> void LuaType<ElementFormControlInput>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementFormControlInput>::is_reference_counted();
 
 //getters
 int ElementFormControlInputGetAttrchecked(lua_State* L);
@@ -69,18 +68,12 @@ int ElementFormControlInputSetAttrmax(lua_State* L);
 int ElementFormControlInputSetAttrmin(lua_State* L);
 int ElementFormControlInputSetAttrstep(lua_State* L);
 
-RegType<ElementFormControlInput> ElementFormControlInputMethods[];
+Rocket::Core::Lua::RegType<ElementFormControlInput> ElementFormControlInputMethods[];
 luaL_reg ElementFormControlInputGetters[];
 luaL_reg ElementFormControlInputSetters[];
 
-/*
-template<> const char* GetTClassName<ElementFormControlInput>();
-template<> RegType<ElementFormControlInput>* GetMethodTable<ElementFormControlInput>();
-template<> luaL_reg* GetAttrTable<ElementFormControlInput>();
-template<> luaL_reg* SetAttrTable<ElementFormControlInput>();
-*/
-
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementFormControlInput)
 #endif

+ 18 - 14
Source/Controls/Lua/ElementFormControlSelect.cpp

@@ -31,14 +31,22 @@
 #include <Rocket/Controls/ElementFormControlSelect.h>
 #include <Rocket/Controls/ElementFormControl.h>
 #include <Rocket/Core/Element.h>
+#include "ElementFormControl.h"
+
 
-using Rocket::Controls::ElementFormControlSelect;
-using Rocket::Controls::ElementFormControl;
-namespace Rocket {
-namespace Core {
-namespace Lua {
 //inherits from ElementFormControl which inherits from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlSelect>(lua_State* L, int metatable_index)
+{
+    //init whatever elementformcontrol did extra, like inheritance
+    Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(L,metatable_index);
+    //then inherit from elementformcontrol
+    LuaType<Rocket::Controls::ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
+
+}
 
+namespace Rocket {
+namespace Controls {
+namespace Lua {
 
 //methods
 int ElementFormControlSelectAdd(lua_State* L, ElementFormControlSelect* obj)
@@ -66,7 +74,7 @@ int ElementFormControlSelectGetOption(lua_State* L, ElementFormControlSelect* ob
     int index = luaL_checkint(L,1);
     Rocket::Controls::SelectOption* opt = obj->GetOption(index);
     lua_newtable(L);
-    LuaType<Element>::push(L,opt->GetElement(),false);
+    LuaType<Rocket::Core::Element>::push(L,opt->GetElement(),false);
     lua_setfield(L,-2,"element");
     lua_pushstring(L,opt->GetValue().CString());
     lua_setfield(L,-2,"value");
@@ -107,7 +115,7 @@ int ElementFormControlSelectSetAttrselection(lua_State* L)
 }
 
 
-RegType<ElementFormControlSelect> ElementFormControlSelectMethods[] =
+Rocket::Core::Lua::RegType<ElementFormControlSelect> ElementFormControlSelectMethods[] =
 {
     LUAMETHOD(ElementFormControlSelect,Add)
     LUAMETHOD(ElementFormControlSelect,Remove)
@@ -128,12 +136,8 @@ luaL_reg ElementFormControlSelectSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<ElementFormControlSelect>() { return "ElementFormControlSelect"; }
-template<> RegType<ElementFormControlSelect>* GetMethodTable<ElementFormControlSelect>() { return ElementFormControlSelectMethods; }
-template<> luaL_reg* GetAttrTable<ElementFormControlSelect>() { return ElementFormControlSelectGetters; }
-template<> luaL_reg* SetAttrTable<ElementFormControlSelect>() { return ElementFormControlSelectSetters; }
-*/
 }
 }
-}
+}
+using Rocket::Controls::ElementFormControlSelect;
+LUACONTROLSTYPEDEFINE(ElementFormControlSelect,true)

+ 8 - 14
Source/Controls/Lua/ElementFormControlSelect.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTFORMCONTROLSELECT_H
-#define ROCKETCORELUAELEMENTFORMCONTROLSELECT_H
+#ifndef ROCKETCONTROLSLUAELEMENTFORMCONTROLSELECT_H
+#define ROCKETCONTROLSLUAELEMENTFORMCONTROLSELECT_H
 
 /*
     This defines the ElementFormControlSelect type in the Lua global namespace, for this documentation will be
@@ -51,13 +51,12 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Controls/ElementFormControlSelect.h>
 
-using Rocket::Controls::ElementFormControlSelect;
+using Rocket::Core::Lua::LuaType;
+//inherits from ElementFormControl which inherits from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlSelect>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//inherits from ElementFormControl which inherits from Element
-template<> void LuaType<ElementFormControlSelect>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementFormControlSelect>::is_reference_counted();
 
 //methods
 int ElementFormControlSelectAdd(lua_State* L, ElementFormControlSelect* obj);
@@ -71,17 +70,12 @@ int ElementFormControlSelectGetAttrselection(lua_State* L);
 //setter
 int ElementFormControlSelectSetAttrselection(lua_State* L);
 
-RegType<ElementFormControlSelect> ElementFormControlSelectMethods[];
+Rocket::Core::Lua::RegType<ElementFormControlSelect> ElementFormControlSelectMethods[];
 luaL_reg ElementFormControlSelectGetters[];
 luaL_reg ElementFormControlSelectSetters[];
 
-/*
-template<> const char* GetTClassName<ElementFormControlSelect>();
-template<> RegType<ElementFormControlSelect>* GetMethodTable<ElementFormControlSelect>();
-template<> luaL_reg* GetAttrTable<ElementFormControlSelect>();
-template<> luaL_reg* SetAttrTable<ElementFormControlSelect>();
-*/
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementFormControlSelect)
 #endif

+ 12 - 12
Source/Controls/Lua/ElementFormControlTextArea.cpp

@@ -28,13 +28,18 @@
 #include "precompiled.h"
 #include "ElementFormControlTextArea.h"
 #include <Rocket/Controls/ElementFormControl.h>
+#include "ElementFormControl.h"
+
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlTextArea>(lua_State* L, int metatable_index)
+{
+    Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControl>(L,metatable_index);
+    LuaType<Rocket::Controls::ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
+}
 
-using Rocket::Controls::ElementFormControl;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 
-
 //getters
 int ElementFormControlTextAreaGetAttrcols(lua_State* L)
 {
@@ -107,7 +112,7 @@ int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L)
 }
 
 
-RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[] =
+Rocket::Core::Lua::RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[] =
 {
     { NULL, NULL },
 };
@@ -130,13 +135,8 @@ luaL_reg ElementFormControlTextAreaSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<ElementFormControlTextArea>() { return "ElementFormControlTextArea"; }
-template<> RegType<ElementFormControlTextArea>* GetMethodTable<ElementFormControlTextArea>() { return ElementFormControlTextAreaMethods; }
-template<> luaL_reg* GetAttrTable<ElementFormControlTextArea>() { return ElementFormControlTextAreaGetters; }
-template<> luaL_reg* SetAttrTable<ElementFormControlTextArea>() { return ElementFormControlTextAreaSetters; }
-*/
-
 }
 }
-}
+}
+using Rocket::Controls::ElementFormControlTextArea;
+LUACONTROLSTYPEDEFINE(ElementFormControlTextArea,true)

+ 8 - 14
Source/Controls/Lua/ElementFormControlTextArea.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTFORMCONTROLTEXTAREA_H
-#define ROCKETCORELUAELEMENTFORMCONTROLTEXTAREA_H
+#ifndef ROCKETCONTROLSLUAELEMENTFORMCONTROLTEXTAREA_H
+#define ROCKETCONTROLSLUAELEMENTFORMCONTROLTEXTAREA_H
 /*
     This defines the ElementFormControlTextArea type in the Lua global namespace, refered in this documentation by EFCTextArea
 
@@ -42,13 +42,12 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Controls/ElementFormControlTextArea.h>
 
-using Rocket::Controls::ElementFormControlTextArea;
+using Rocket::Core::Lua::LuaType;
+//inherits from ElementFormControl which inherits from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementFormControlTextArea>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//inherits from ElementFormControl which inherits from Element
-template<> void LuaType<ElementFormControlTextArea>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementFormControlTextArea>::is_reference_counted();
 
 //getters
 int ElementFormControlTextAreaGetAttrcols(lua_State* L);
@@ -62,17 +61,12 @@ int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L);
 int ElementFormControlTextAreaSetAttrrows(lua_State* L);
 int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L);
 
-RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[];
+Rocket::Core::Lua::RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[];
 luaL_reg ElementFormControlTextAreaGetters[];
 luaL_reg ElementFormControlTextAreaSetters[];
 
-/*
-template<> const char* GetTClassName<ElementFormControlTextArea>();
-template<> RegType<ElementFormControlTextArea>* GetMethodTable<ElementFormControlTextArea>();
-template<> luaL_reg* GetAttrTable<ElementFormControlTextArea>();
-template<> luaL_reg* SetAttrTable<ElementFormControlTextArea>();
-*/
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementFormControlTextArea)
 #endif

+ 12 - 10
Source/Controls/Lua/ElementTabSet.cpp

@@ -29,11 +29,16 @@
 #include "ElementTabSet.h"
 #include <Rocket/Core/Element.h>
 
+//this will be used to "inherit" from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementTabSet>(lua_State* L, int metatable_index)
+{
+    Rocket::Core::Lua::ExtraInit<Rocket::Core::Element>(L,metatable_index);
+    LuaType<Rocket::Core::Element>::_regfunctions(L,metatable_index,metatable_index-1);
+}
 
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//this will be used to "inherit" from Element
 
 //methods
 int ElementTabSetSetPanel(lua_State* L, ElementTabSet* obj)
@@ -88,7 +93,7 @@ int ElementTabSetSetAttractive_tab(lua_State* L)
 }
 
 
-RegType<ElementTabSet> ElementTabSetMethods[] =
+Rocket::Core::Lua::RegType<ElementTabSet> ElementTabSetMethods[] =
 {
     LUAMETHOD(ElementTabSet,SetPanel)
     LUAMETHOD(ElementTabSet,SetTab)
@@ -108,13 +113,10 @@ luaL_reg ElementTabSetSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<ElementTabSet>() { return "ElementTabSet"; }
-template<> RegType<ElementTabSet>* GetMethodTable<ElementTabSet>() { return ElementTabSetMethods; }
-template<> luaL_reg* GetAttrTable<ElementTabSet>() { return ElementTabSetGetters; }
-template<> luaL_reg* SetAttrTable<ElementTabSet>() { return ElementTabSetSetters; }
-*/
 
+
+}
 }
 }
-}
+using Rocket::Controls::ElementTabSet;
+LUACONTROLSTYPEDEFINE(ElementTabSet,true)

+ 9 - 14
Source/Controls/Lua/ElementTabSet.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUAELEMENTTABSET_H
-#define ROCKETCORELUAELEMENTTABSET_H
+#ifndef ROCKETCONTROLSLUAELEMENTTABSET_H
+#define ROCKETCONTROLSLUAELEMENTTABSET_H
 /*
     This defines the ElementTabSet type in the Lua global namespace
 
@@ -48,13 +48,12 @@
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Controls/ElementTabSet.h>
 
-using Rocket::Controls::ElementTabSet;
+using Rocket::Core::Lua::LuaType;
+//this will be used to "inherit" from Element
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::ElementTabSet>(lua_State* L, int metatable_index);
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
-//this will be used to "inherit" from Element
-template<> void LuaType<ElementTabSet>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementTabSet>::is_reference_counted();
 
 //methods
 int ElementTabSetSetPanel(lua_State* L, ElementTabSet* obj);
@@ -67,17 +66,13 @@ int ElementTabSetGetAttrnum_tabs(lua_State* L);
 //setter
 int ElementTabSetSetAttractive_tab(lua_State* L);
 
-RegType<ElementTabSet> ElementTabSetMethods[];
+Rocket::Core::Lua::RegType<ElementTabSet> ElementTabSetMethods[];
 luaL_reg ElementTabSetGetters[];
 luaL_reg ElementTabSetSetters[];
 
-/*
-template<> const char* GetTClassName<ElementTabSet>();
-template<> RegType<ElementTabSet>* GetMethodTable<ElementTabSet>();
-template<> luaL_reg* GetAttrTable<ElementTabSet>();
-template<> luaL_reg* SetAttrTable<ElementTabSet>();
-*/
+
 }
 }
 }
+LUATYPEDECLARE(Rocket::Controls::ElementTabSet)
 #endif

+ 5 - 4
Source/Controls/Lua/LuaDataFormatter.cpp

@@ -30,12 +30,13 @@
 #include <Rocket/Core/Lua/Interpreter.h>
 #include <Rocket/Core/Log.h>
 
-
+using Rocket::Core::Lua::Interpreter;
+using Rocket::Core::Log;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 
-LuaDataFormatter::LuaDataFormatter(const String& name) : Rocket::Controls::DataFormatter(name), ref_FormatData(LUA_NOREF)
+LuaDataFormatter::LuaDataFormatter(const Rocket::Core::String& name) : Rocket::Controls::DataFormatter(name), ref_FormatData(LUA_NOREF)
 {
     
 }
@@ -75,7 +76,7 @@ void LuaDataFormatter::FormatData(Rocket::Core::String& formatted_data, const Ro
         Log::Message(Log::LT_ERROR, "In LuaDataFormatter: the return value of FormatData must be a string. You returned a %s.", lua_typename(L,lua_type(L,-1)));
         return;
     }
-    formatted_data = String(lua_tostring(L,-1));
+    formatted_data = Rocket::Core::String(lua_tostring(L,-1));
 }
 
 void LuaDataFormatter::PushDataFormatterFunctionTable(lua_State* L)

+ 5 - 5
Source/Controls/Lua/LuaDataFormatter.h

@@ -25,20 +25,20 @@
  *
  */
  
-#ifndef ROCKETCORELUALUADATAFORMATTER_H
-#define ROCKETCORELUALUADATAFORMATTER_H
+#ifndef ROCKETCONTROLSLUALUADATAFORMATTER_H
+#define ROCKETCONTROLSLUALUADATAFORMATTER_H
+
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Controls/DataFormatter.h>
 
-using Rocket::Controls::DataFormatter;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 
 class LuaDataFormatter : public Rocket::Controls::DataFormatter
 {
 public:
-    LuaDataFormatter(const String& name = "");
+    LuaDataFormatter(const Rocket::Core::String& name = "");
     ~LuaDataFormatter();
 
     virtual void FormatData(Rocket::Core::String& formatted_data, const Rocket::Core::StringList& raw_data);

+ 7 - 3
Source/Controls/Lua/LuaDataSource.cpp

@@ -29,12 +29,16 @@
 #include "LuaDataSource.h"
 #include <Rocket/Core/Lua/Interpreter.h>
 #include <Rocket/Core/Log.h>
+#include <Rocket/Core/String.h>
 
+using Rocket::Core::Lua::Interpreter;
+using Rocket::Core::Log;
+using Rocket::Core::Lua::LuaType;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 
-LuaDataSource::LuaDataSource(const String& name) : DataSource(name), getRowRef(LUA_NOREF), getNumRowsRef(LUA_NOREF)
+LuaDataSource::LuaDataSource(const Rocket::Core::String& name) : DataSource(name), getRowRef(LUA_NOREF), getNumRowsRef(LUA_NOREF)
 {
 }
 
@@ -54,7 +58,7 @@ void LuaDataSource::GetRow(Rocket::Core::StringList& row, const Rocket::Core::St
     lua_pushinteger(L,row_index);
     lua_newtable(L);
     int index = 0;
-    for(StringList::const_iterator itr = columns.begin(); itr != columns.end(); ++itr)
+    for(Rocket::Core::StringList::const_iterator itr = columns.begin(); itr != columns.end(); ++itr)
     {
         lua_pushstring(L,itr->CString());
         lua_rawseti(L,-2,index++);

+ 5 - 5
Source/Controls/Lua/LuaDataSource.h

@@ -25,23 +25,23 @@
  *
  */
  
-#ifndef ROCKETCORELUALUADATASOURCE_H
-#define ROCKETCORELUALUADATASOURCE_H
+#ifndef ROCKETCONTROLSLUALUADATASOURCE_H
+#define ROCKETCONTROLSLUALUADATASOURCE_H
 
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Core/Lua/lua.hpp>
 #include <Rocket/Controls/DataSource.h>
+#include <Rocket/Core/String.h>
 
-using Rocket::Controls::DataSource;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 
 class LuaDataSource : public Rocket::Controls::DataSource
 {
 public:
     //default initilialize the lua func references to -1
-    LuaDataSource(const String& name = "");
+    LuaDataSource(const Rocket::Core::String& name = "");
 
 	/// Fetches the contents of one row of a table within the data source.
 	/// @param[out] row The list of values in the table.

+ 18 - 6
Source/Controls/Lua/SelectOptionsProxy.cpp

@@ -29,9 +29,18 @@
 #include "SelectOptionsProxy.h"
 #include <Rocket/Core/Element.h>
 
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::Lua::SelectOptionsProxy>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,Rocket::Controls::Lua::SelectOptionsProxy__index);
+    lua_setfield(L,metatable_index,"__index");
+}
+
+
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
+
+
 int SelectOptionsProxy__index(lua_State* L)
 {
     /*the table obj and the missing key are currently on the stack(index 1 & 2) as defined by the Lua language*/
@@ -44,7 +53,7 @@ int SelectOptionsProxy__index(lua_State* L)
         Rocket::Controls::SelectOption* opt = proxy->owner->GetOption(index);
         LUACHECKOBJ(opt);
         lua_newtable(L);
-        LuaType<Element>::push(L,opt->GetElement(),false);
+        LuaType<Rocket::Core::Element>::push(L,opt->GetElement(),false);
         lua_setfield(L,-2,"element");
         lua_pushstring(L,opt->GetValue().CString());
         lua_setfield(L,-2,"value");
@@ -61,8 +70,8 @@ int SelectOptionsProxyGetTable(lua_State* L, SelectOptionsProxy* obj)
 
     //local variables for the loop
     Rocket::Controls::SelectOption* opt; 
-    Element* ele;
-    String value;
+    Rocket::Core::Element* ele;
+    Rocket::Core::String value;
     lua_newtable(L); //table to return
     int retindex = lua_gettop(L);
     for(int index = 0; index < numOptions; index++)
@@ -74,7 +83,7 @@ int SelectOptionsProxyGetTable(lua_State* L, SelectOptionsProxy* obj)
         value = opt->GetValue();
 
         lua_newtable(L);
-        LuaType<Element>::push(L,ele,false);
+        LuaType<Rocket::Core::Element>::push(L,ele,false);
         lua_setfield(L,-2,"element");
         lua_pushstring(L,value.CString());
         lua_setfield(L,-2,"value");
@@ -83,7 +92,7 @@ int SelectOptionsProxyGetTable(lua_State* L, SelectOptionsProxy* obj)
     return 1;
 }
 
-RegType<SelectOptionsProxy> SelectOptionsProxyMethods[] =
+Rocket::Core::Lua::RegType<SelectOptionsProxy> SelectOptionsProxyMethods[] =
 {
     LUAMETHOD(SelectOptionsProxy,GetTable)
     { NULL, NULL },
@@ -99,6 +108,9 @@ luaL_reg SelectOptionsProxySetters[] =
     { NULL, NULL },
 };
 
+
 }
 }
 }
+using Rocket::Controls::Lua::SelectOptionsProxy;
+LUACONTROLSTYPEDEFINE(SelectOptionsProxy,false);

+ 8 - 5
Source/Controls/Lua/SelectOptionsProxy.h

@@ -25,8 +25,8 @@
  *
  */
  
-#ifndef ROCKETCORELUASELECTOPTIONSPROXY_H
-#define ROCKETCORELUASELECTOPTIONSPROXY_H
+#ifndef ROCKETCONTROLSLUASELECTOPTIONSPROXY_H
+#define ROCKETCONTROLSLUASELECTOPTIONSPROXY_H
 /*
     Proxy table for ElementFormControlSelect.options
     read-only, key must be a number
@@ -45,22 +45,25 @@
 #include <Rocket/Core/Lua/LuaType.h>
 #include <Rocket/Controls/ElementFormControlSelect.h>
 
+using Rocket::Core::Lua::LuaType;
 namespace Rocket {
-namespace Core {
+namespace Controls {
 namespace Lua {
 //where owner is the ElementFormControlSelect that we should look up information from
 struct SelectOptionsProxy { Rocket::Controls::ElementFormControlSelect* owner;  };
 
-template<> void LuaType<SelectOptionsProxy>::extra_init(lua_State* L, int metatable_index);
 int SelectOptionsProxy__index(lua_State* L);
 
 //method
 int SelectOptionsProxyGetTable(lua_State* L, SelectOptionsProxy* obj);
 
-RegType<SelectOptionsProxy> SelectOptionsProxyMethods[];
+Rocket::Core::Lua::RegType<SelectOptionsProxy> SelectOptionsProxyMethods[];
 luaL_reg SelectOptionsProxyGetters[];
 luaL_reg SelectOptionsProxySetters[];
+
 }
 }
 }
+template<> void Rocket::Core::Lua::ExtraInit<Rocket::Controls::Lua::SelectOptionsProxy>(lua_State* L, int metatable_index);
+LUATYPEDECLARE(Rocket::Controls::Lua::SelectOptionsProxy)
 #endif

+ 19 - 0
Source/Core/Lua/Colourb.cpp

@@ -32,6 +32,23 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
+
+template<> void ExtraInit<Colourb>(lua_State* L, int metatable_index) 
+{
+    lua_pushcfunction(L,Colourbnew);
+    lua_setfield(L,metatable_index-1,"new");
+
+    lua_pushcfunction(L,Colourb__eq);
+    lua_setfield(L,metatable_index,"__eq");
+
+    lua_pushcfunction(L,Colourb__add);
+    lua_setfield(L,metatable_index,"__add");
+
+    lua_pushcfunction(L,Colourb__mul);
+    lua_setfield(L,metatable_index,"__mul");
+
+    return;
+}
 int Colourbnew(lua_State* L)
 {
     byte red = (byte)luaL_checkint(L,1);
@@ -189,6 +206,8 @@ luaL_reg ColourbSetters[] =
     LUASETTER(Colourb,alpha)
     { NULL, NULL },
 };
+
+LUATYPEDEFINE(Colourb,false)
 }
 }
 }

+ 2 - 7
Source/Core/Lua/Colourb.h

@@ -61,7 +61,7 @@ using Rocket::Core::Colourb;
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> void LuaType<Colourb>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<Colourb>(lua_State* L, int metatable_index);
 int Colourbnew(lua_State* L);
 int Colourb__eq(lua_State* L);
 int Colourb__add(lua_State* L);
@@ -85,12 +85,7 @@ RegType<Colourb> ColourbMethods[];
 luaL_reg ColourbGetters[];
 luaL_reg ColourbSetters[];
 
-/*
-template<> const char* GetTClassName<Colourb>() { return "Colourb"; }
-template<> RegType<Colourb>* GetMethodTable<Colourb>() { return ColourbMethods; }
-template<> luaL_reg* GetAttrTable<Colourb>() { return ColourbGetters; }
-template<> luaL_reg* SetAttrTable<Colourb>() { return ColourbSetters; }
-*/
+LUATYPEDECLARE(Colourb)
 }
 }
 }

+ 11 - 2
Source/Core/Lua/Colourf.cpp

@@ -33,9 +33,18 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 
-//metamethods
+template<> void ExtraInit<Colourf>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,Colourfnew);
+    lua_setfield(L,metatable_index-1,"new");
+
+    lua_pushcfunction(L,Colourf__eq);
+    lua_setfield(L,metatable_index,"__eq");
 
+    return;
+}
 
+//metamethods
 int Colourfnew(lua_State* L)
 {
     float red = (float)luaL_checknumber(L,1);
@@ -168,7 +177,7 @@ luaL_reg ColourfSetters[] =
     { NULL, NULL },
 };
 
-
+LUATYPEDEFINE(Colourf,false)
 
 
 }

+ 2 - 7
Source/Core/Lua/Colourf.h

@@ -59,7 +59,7 @@ using Rocket::Core::Colourf;
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> void LuaType<Colourf>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<Colourf>(lua_State* L, int metatable_index);
 //metamethods
 int Colourfnew(lua_State* L);
 int Colourf__eq(lua_State* L);
@@ -81,12 +81,7 @@ RegType<Colourf> ColourfMethods[];
 luaL_reg ColourfGetters[];
 luaL_reg ColourfSetters[];
 
-/*
-template<> const char* GetTClassName<Colourf>() { return "Colourf"; }
-template<> RegType<Colourf>* GetMethodTable<Colourf>() { return ColourfMethods; }
-template<> luaL_reg* GetAttrTable<Colourf>() { return ColourfGetters; }
-template<> luaL_reg* SetAttrTable<Colourf>() { return ColourfSetters; }
-*/
+LUATYPEDECLARE(Colourf)
 }
 }
 }

+ 1 - 6
Source/Core/Lua/Context.cpp

@@ -261,12 +261,7 @@ luaL_reg ContextSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<Context>() { return "Context"; }
-template<> RegType<Context>* GetMethodTable<Context>() { return ContextMethods; }
-template<> luaL_reg* GetAttrTable<Context>() { return ContextGetters; }
-template<> luaL_reg* SetAttrTable<Context>() { return ContextSetters; }
-*/
+LUATYPEDEFINE(Context,true)
 }
 }
 }

+ 1 - 7
Source/Core/Lua/Context.h

@@ -72,7 +72,6 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> bool LuaType<Context>::is_reference_counted();
 
 //methods
 int ContextAddEventListener(lua_State* L, Context* obj);
@@ -104,12 +103,7 @@ RegType<Context> ContextMethods[];
 luaL_reg ContextGetters[];
 luaL_reg ContextSetters[];
 
-/*
-template<> const char* GetTClassName<Context>();
-template<> RegType<Context>* GetMethodTable<Context>();
-template<> luaL_reg* GetAttrTable<Context>();
-template<> luaL_reg* SetAttrTable<Context>();
-*/
+LUATYPEDECLARE(Context)
 }
 }
 }

+ 8 - 0
Source/Core/Lua/ContextDocumentsProxy.cpp

@@ -33,6 +33,12 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 typedef Rocket::Core::ElementDocument Document;
+template<> void ExtraInit<ContextDocumentsProxy>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,ContextDocumentsProxy__index);
+    lua_setfield(L,metatable_index,"__index");
+}
+
 int ContextDocumentsProxy__index(lua_State* L)
 {
     /*the table obj and the missing key are currently on the stack(index 1 & 2) as defined by the Lua language*/
@@ -93,6 +99,8 @@ luaL_reg ContextDocumentsProxySetters[] =
     { NULL, NULL },
 };
 
+LUATYPEDEFINE(ContextDocumentsProxy,false)
+
 }
 }
 }

+ 3 - 1
Source/Core/Lua/ContextDocumentsProxy.h

@@ -41,7 +41,7 @@ namespace Lua {
 //where owner is the context that we should look information from
 struct ContextDocumentsProxy { Context* owner;  };
 
-template<> void LuaType<ContextDocumentsProxy>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<ContextDocumentsProxy>(lua_State* L, int metatable_index);
 int ContextDocumentsProxy__index(lua_State* L);
 
 //method
@@ -50,6 +50,8 @@ int ContextDocumentsProxyGetTable(lua_State* L, ContextDocumentsProxy* obj);
 RegType<ContextDocumentsProxy> ContextDocumentsProxyMethods[];
 luaL_reg ContextDocumentsProxyGetters[];
 luaL_reg ContextDocumentsProxySetters[];
+
+LUATYPEDECLARE(ContextDocumentsProxy)
 }
 }
 }

+ 9 - 6
Source/Core/Lua/Document.cpp

@@ -29,11 +29,19 @@
 #include "Document.h"
 #include <Rocket/Core/ElementDocument.h>
 #include <Rocket/Core/Context.h>
+#include "Element.h"
 
 namespace Rocket {
 namespace Core {
 namespace Lua {
 
+template<> void ExtraInit<Document>(lua_State* L, int metatable_index)
+{
+    //we will inherit from Element
+    ExtraInit<Element>(L,metatable_index);
+    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index - 1);
+}
+
 //methods
 int DocumentPullToFront(lua_State* L, Document* obj)
 {
@@ -144,12 +152,7 @@ luaL_reg DocumentSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<Document>() { return "Document"; }
-template<> RegType<Document>* GetMethodTable<Document>() { return DocumentMethods; }
-template<> luaL_reg* GetAttrTable<Document>() { return DocumentGetters; }
-template<> luaL_reg* SetAttrTable<Document>() { return DocumentSetters; }
-*/
+LUATYPEDEFINE(Document,true)
 }
 }
 }

+ 2 - 8
Source/Core/Lua/Document.h

@@ -60,8 +60,7 @@ namespace Core {
 namespace Lua {
 typedef ElementDocument Document;
 
-template<> void LuaType<Document>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<Document>::is_reference_counted();
+template<> void ExtraInit<Document>(lua_State* L, int metatable_index);
 
 //methods
 int DocumentPullToFront(lua_State* L, Document* obj);
@@ -83,12 +82,7 @@ RegType<Document> DocumentMethods[];
 luaL_reg DocumentGetters[];
 luaL_reg DocumentSetters[];
 
-/*
-template<> const char* GetTClassName<Document>();
-template<> RegType<Document>* GetMethodTable<Document>();
-template<> luaL_reg* GetAttrTable<Document>();
-template<> luaL_reg* SetAttrTable<Document>();
-*/
+LUATYPEDECLARE(Document)
 }
 }
 }

+ 31 - 7
Source/Core/Lua/Element.cpp

@@ -30,7 +30,7 @@
 #include <ElementStyle.h>
 #include "LuaEventListener.h"
 #include "ElementAttributesProxy.h"
-#include "Utilities.h"
+#include <Rocket/Core/Lua/Utilities.h>
 
 
 namespace Rocket {
@@ -38,6 +38,32 @@ namespace Core {
 namespace Lua {
 typedef ElementDocument Document;
 
+template<> void ExtraInit<Element>(lua_State* L, int metatable_index)
+{
+    int top = lua_gettop(L);
+    //build the Element.etype table
+    lua_newtable(L);
+    lua_pushinteger(L,TDATAGRID);
+    lua_setfield(L,-2,"datagrid");
+    lua_pushinteger(L,TDATASELECT);
+    lua_setfield(L,-2,"dataselect");
+    lua_pushinteger(L,TELEMENT);
+    lua_setfield(L,-2,"element");
+    lua_pushinteger(L,TFORM);
+    lua_setfield(L,-2,"form");
+    lua_pushinteger(L,TINPUT);
+    lua_setfield(L,-2,"input");
+    lua_pushinteger(L,TSELECT);
+    lua_setfield(L,-2,"select");
+    lua_pushinteger(L,TTABSET);
+    lua_setfield(L,-2,"tabset");
+    lua_pushinteger(L,TTEXTAREA);
+    lua_setfield(L,-2,"textarea");
+    
+    lua_setfield(L,metatable_index-1,"etype");
+    lua_settop(L,top);
+}
+
 //methods
 int ElementAddEventListener(lua_State* L, Element* obj)
 {
@@ -236,6 +262,7 @@ int ElementSetClass(lua_State* L, Element* obj)
 
 int ElementAsType(lua_State* L, Element* obj)
 {
+    /*
     Elementetype type = Elementetype(luaL_checkint(L,1));
     switch(type)
     {
@@ -264,6 +291,8 @@ int ElementAsType(lua_State* L, Element* obj)
         break;
     }
     return 1;
+    */
+    return 0;
 }
 
 
@@ -618,12 +647,7 @@ luaL_reg ElementSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<Element>() { return "Element"; }
-template<> RegType<Element>* GetMethodTable<Element>() { return ElementMethods; }
-template<> luaL_reg* GetAttrTable<Element>() { return ElementGetters; }
-template<> luaL_reg* SetAttrTable<Element>() { return ElementSetters; }
-*/
+LUATYPEDEFINE(Element,true)
 }
 }
 }

+ 4 - 8
Source/Core/Lua/Element.h

@@ -128,8 +128,8 @@ enum Elementetype
 {
     TDATAGRID = 0, TDATASELECT, TELEMENT, TFORM, TINPUT, TSELECT, TTABSET, TTEXTAREA
 };
-template<> bool LuaType<Element>::is_reference_counted();
-template<> void LuaType<Element>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<Element>(lua_State* L, int metatable_index);
+
 
 //methods
 int ElementAddEventListener(lua_State* L, Element* obj);
@@ -194,12 +194,8 @@ RegType<Element> ElementMethods[];
 luaL_reg ElementGetters[];
 luaL_reg ElementSetters[];
 
-/*
-template<> const char* GetTClassName<Element>();
-template<> RegType<Element>* GetMethodTable<Element>();
-template<> luaL_reg* GetAttrTable<Element>();
-template<> luaL_reg* SetAttrTable<Element>();
-*/
+LUATYPEDECLARE(Element)
+
 }
 }
 }

+ 9 - 1
Source/Core/Lua/ElementAttributesProxy.cpp

@@ -28,11 +28,17 @@
 #include "precompiled.h"
 #include "ElementAttributesProxy.h"
 #include <Rocket/Core/Variant.h>
-#include "Utilities.h"
+#include <Rocket/Core/Lua/Utilities.h>
 
 namespace Rocket {
 namespace Core {
 namespace Lua {
+template<> void ExtraInit<ElementAttributesProxy>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,ElementAttributesProxy__index);
+    lua_setfield(L,metatable_index,"__index");
+}
+
 int ElementAttributesProxy__index(lua_State* L)
 {
     /*the table obj and the missing key are currently on the stack(index 1 & 2) as defined by the Lua language*/
@@ -82,6 +88,8 @@ luaL_reg ElementAttributesProxySetters[] =
 {
     { NULL, NULL },
 };
+
+LUATYPEDEFINE(ElementAttributesProxy,false)
 }
 }
 }

+ 3 - 1
Source/Core/Lua/ElementAttributesProxy.h

@@ -41,7 +41,7 @@ namespace Lua {
 //where owner is the Element that we should look up information from
 struct ElementAttributesProxy { Element* owner;  };
 
-template<> void LuaType<ElementAttributesProxy>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<ElementAttributesProxy>(lua_State* L, int metatable_index);
 int ElementAttributesProxy__index(lua_State* L);
 
 //method
@@ -50,6 +50,8 @@ int ElementAttributesProxyGetTable(lua_State* L, ElementAttributesProxy* obj);
 RegType<ElementAttributesProxy> ElementAttributesProxyMethods[];
 luaL_reg ElementAttributesProxyGetters[];
 luaL_reg ElementAttributesProxySetters[];
+
+LUATYPEDECLARE(ElementAttributesProxy)
 }
 }
 }

+ 8 - 6
Source/Core/Lua/ElementStyle.cpp

@@ -34,7 +34,14 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
+template<> void ExtraInit<ElementStyle>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,ElementStyle__index);
+    lua_setfield(L,metatable_index,"__index");
 
+    lua_pushcfunction(L,ElementStyle__newindex);
+    lua_setfield(L,metatable_index,"__newindex");
+}
 
 int ElementStyle__index(lua_State* L)
 {
@@ -136,12 +143,7 @@ luaL_reg ElementStyleSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<ElementStyle>() { return "ElementStyle"; }
-template<> RegType<ElementStyle>* GetMethodTable<ElementStyle>() { return ElementStyleMethods; }
-template<> luaL_reg* GetAttrTable<ElementStyle>() { return ElementStyleGetters; }
-template<> luaL_reg* SetAttrTable<ElementStyle>() { return ElementStyleSetters; }
-*/
+LUATYPEDEFINE(ElementStyle,false)
 }
 }
 }

+ 2 - 7
Source/Core/Lua/ElementStyle.h

@@ -74,7 +74,7 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> void LuaType<ElementStyle>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<ElementStyle>(lua_State* L, int metatable_index);
 int ElementStyle__index(lua_State* L);
 int ElementStyle__newindex(lua_State* L);
 
@@ -85,12 +85,7 @@ RegType<ElementStyle> ElementStyleMethods[];
 luaL_reg ElementStyleGetters[];
 luaL_reg ElementStyleSetters[];
 
-/*
-template<> const char* GetTClassName<ElementStyle>();
-template<> RegType<ElementStyle>* GetMethodTable<ElementStyle>();
-template<> luaL_reg* GetAttrTable<ElementStyle>();
-template<> luaL_reg* SetAttrTable<ElementStyle>();
-*/
+LUATYPEDECLARE(ElementStyle)
 }
 }
 }

+ 8 - 1
Source/Core/Lua/ElementText.cpp

@@ -27,10 +27,17 @@
  
 #include "precompiled.h"
 #include "ElementText.h"
+#include "Element.h"
 
 namespace Rocket {
 namespace Core {
 namespace Lua {
+template<> void ExtraInit<ElementText>(lua_State* L, int metatable_index)
+{
+    //inherit from Element
+    ExtraInit<Element>(L,metatable_index);
+    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
+}
 
 int ElementTextGetAttrtext(lua_State* L)
 {
@@ -66,7 +73,7 @@ luaL_reg ElementTextSetters[] =
     { NULL, NULL },
 };
 
-
+LUATYPEDEFINE(ElementText,true)
 }
 }
 }

+ 2 - 2
Source/Core/Lua/ElementText.h

@@ -35,8 +35,7 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 //will inherit from Element
-template<> void LuaType<ElementText>::extra_init(lua_State* L, int metatable_index);
-template<> bool LuaType<ElementText>::is_reference_counted();
+template<> void ExtraInit<ElementText>(lua_State* L, int metatable_index);
 
 int ElementTextGetAttrtext(lua_State* L);
 int ElementTextSetAttrtext(lua_State* L);
@@ -45,6 +44,7 @@ RegType<ElementText> ElementTextMethods[];
 luaL_reg ElementTextGetters[];
 luaL_reg ElementTextSetters[];
 
+LUATYPEDECLARE(ElementText)
 }
 }
 }

+ 1 - 6
Source/Core/Lua/Event.cpp

@@ -103,12 +103,7 @@ luaL_reg EventSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<Event>() { return "Event"; }
-template<> RegType<Event>* GetMethodTable<Event>() { return EventMethods; }
-template<> luaL_reg* GetAttrTable<Event>() { return EventGetters; }
-template<> luaL_reg* SetAttrTable<Event>() { return EventSetters; }
-*/
+LUATYPEDEFINE(Event,true)
 }
 }
 }

+ 1 - 7
Source/Core/Lua/Event.h

@@ -48,7 +48,6 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> bool LuaType<Event>::is_reference_counted();
 
 //method
 int EventStopPropagation(lua_State* L, Event* obj);
@@ -63,12 +62,7 @@ RegType<Event> EventMethods[];
 luaL_reg EventGetters[];
 luaL_reg EventSetters[];
 
-/*
-template<> const char* GetTClassName<Event>();
-template<> RegType<Event>* GetMethodTable<Event>();
-template<> luaL_reg* GetAttrTable<Event>();
-template<> luaL_reg* SetAttrTable<Event>();
-*/
+LUATYPEDECLARE(Event)
 }
 }
 }

+ 10 - 1
Source/Core/Lua/EventParametersProxy.cpp

@@ -27,7 +27,7 @@
  
 #include "precompiled.h"
 #include "EventParametersProxy.h"
-#include "Utilities.h"
+#include <Rocket/Core/Lua/Utilities.h>
 #include <Rocket/Core/Variant.h>
 #include <Rocket/Core/Dictionary.h>
 
@@ -35,6 +35,13 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
+
+template<> void ExtraInit<EventParametersProxy>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,EventParametersProxy__index);
+    lua_setfield(L,metatable_index,"__index");
+}
+
 int EventParametersProxy__index(lua_State* L)
 {
     /*the table obj and the missing key are currently on the stack(index 1 & 2) as defined by the Lua language*/
@@ -84,6 +91,8 @@ luaL_reg EventParametersProxySetters[] =
 {
     { NULL, NULL },
 };
+
+LUATYPEDEFINE(EventParametersProxy,false)
 }
 }
 }

+ 3 - 1
Source/Core/Lua/EventParametersProxy.h

@@ -41,7 +41,7 @@ namespace Lua {
 //where owner is the Element that we should look up information from
 struct EventParametersProxy { Event* owner;  };
 
-template<> void LuaType<EventParametersProxy>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<EventParametersProxy>(lua_State* L, int metatable_index);
 int EventParametersProxy__index(lua_State* L);
 
 //method
@@ -50,6 +50,8 @@ int EventParametersProxyGetTable(lua_State* L, EventParametersProxy* obj);
 RegType<EventParametersProxy> EventParametersProxyMethods[];
 luaL_reg EventParametersProxyGetters[];
 luaL_reg EventParametersProxySetters[];
+
+LUATYPEDECLARE(EventParametersProxy)
 }
 }
 }

+ 27 - 25
Source/Core/Lua/Interpreter.cpp

@@ -27,21 +27,35 @@
  
 #include "precompiled.h"
 #include <Rocket/Core/Lua/Interpreter.h>
+#include <Rocket/Core/Lua/Utilities.h>
 #include <Rocket/Core/Log.h>
 #include <Rocket/Core/String.h>
 #include <Rocket/Core/Lua/LuaType.h>
 #include "LuaDocumentElementInstancer.h"
 #include <Rocket/Core/Factory.h>
 #include "LuaEventListenerInstancer.h"
-#include "LuaDataFormatter.h"
 #include "Rocket.h"
+#include <ElementStyle.h>
+//the types I made
+#include "ContextDocumentsProxy.h"
+#include "EventParametersProxy.h"
+#include "ElementAttributesProxy.h"
+#include "Log.h"
+#include "Element.h"
+#include "ElementStyle.h"
+#include "Document.h"
+#include "Colourb.h"
+#include "Colourf.h"
+#include "Vector2f.h"
+#include "Vector2i.h"
 
 namespace Rocket {
 namespace Core {
 namespace Lua {
 lua_State* Interpreter::_L = NULL;
+//typedefs for nicer Lua names
 typedef Rocket::Core::ElementDocument Document;
-typedef Rocket::Core::Lua::LuaDataFormatter DataFormatter;
+
 
 void Interpreter::Startup()
 {
@@ -64,6 +78,7 @@ void Interpreter::RegisterEverything(lua_State* L)
     LuaType<Element>::Register(L);
         //things that inherit from Element
         LuaType<Document>::Register(L);
+        /*
         //controls that inherit from Element
         LuaType<Rocket::Controls::ElementTabSet>::Register(L);
         LuaType<Rocket::Controls::ElementDataGrid>::Register(L);
@@ -75,10 +90,15 @@ void Interpreter::RegisterEverything(lua_State* L)
             LuaType<Rocket::Controls::ElementFormControlDataSelect>::Register(L);
             LuaType<Rocket::Controls::ElementFormControlInput>::Register(L);
             LuaType<Rocket::Controls::ElementFormControlTextArea>::Register(L);
+        */
     LuaType<Event>::Register(L);
     LuaType<Context>::Register(L);
-    LuaType<DataFormatter>::Register(L);
+    //LuaType<DataFormatter>::Register(L);
     LuaType<rocket>::Register(L);
+    //Proxy tables
+    LuaType<ContextDocumentsProxy>::Register(L);
+    LuaType<EventParametersProxy>::Register(L);
+    LuaType<ElementAttributesProxy>::Register(L);
 }
 
 
@@ -90,7 +110,7 @@ void Interpreter::LoadFile(const String& file)
     {
         msg.Append(" failed. Could not load. ").Append(file);
         Log::Message(Log::LT_ERROR, msg.CString());
-        Report();
+        Report(_L);
     }
     else
     {
@@ -98,7 +118,7 @@ void Interpreter::LoadFile(const String& file)
         {
             msg.Append(" failed. Could not run. ").Append(file);
             Log::Message(Log::LT_ERROR, msg.CString());
-            Report();
+            Report(_L);
         }
         else
         {
@@ -113,7 +133,7 @@ void Interpreter::DoString(const Rocket::Core::String& code, const Rocket::Core:
 {
     luaL_loadbuffer(_L,code.CString(),code.Length(), name.CString());
     if(lua_pcall(_L,0,0,0) != 0)
-        Report();
+        Report(_L);
 }
 
 void Interpreter::LoadString(const Rocket::Core::String& code, const Rocket::Core::String& name)
@@ -122,24 +142,6 @@ void Interpreter::LoadString(const Rocket::Core::String& code, const Rocket::Cor
 }
 
 
-void Interpreter::Report(lua_State* L, const Rocket::Core::String& place)
-{
-    if(L == NULL)
-        L = _L; //use the original state of Interpreter
-    const char * msg= lua_tostring(_L,-1);
-    String strmsg;
-    while(msg)
-    {
-        lua_pop(_L,1);
-        if(place == "")
-            strmsg = msg;
-        else
-            strmsg = String(place).Append(" ").Append(msg);
-        Log::Message(Log::LT_WARNING, strmsg.CString());
-        msg=lua_tostring(_L,-1);
-    }
-}
-
 void Interpreter::BeginCall(int funRef)
 {
     lua_settop(_L,0); //empty stack
@@ -171,7 +173,7 @@ bool Interpreter::ExecuteCall(int params, int res)
     {
         if(lua_pcall(_L,params,res,0) != 0)
         {
-            Report();
+            Report(_L);
             ret = false;
         }
     }

+ 34 - 6
Source/Core/Lua/Log.cpp

@@ -34,7 +34,40 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 
+template<> void ExtraInit<Log>(lua_State* L, int metatable_index)
+{
+    //due to they way that LuaType::Register is made, we know that the method table is at the index
+    //directly below the metatable
+    int method_index = metatable_index - 1;
+
+    lua_pushcfunction(L,LogMessage);
+    lua_setfield(L,method_index, "Message");
+
+    //construct the "logtype" table, so that we can use the Rocket::Core::Log::Type enum like Log.logtype.always in Lua for Log::LT_ALWAYS
+    lua_newtable(L);
+    int logtype = lua_gettop(L);
+    lua_pushvalue(L,-1); //copy of the new table, so that the logtype index will stay valid
+    lua_setfield(L,method_index,"logtype");
+
+    lua_pushinteger(L,(int)Log::LT_ALWAYS);
+    lua_setfield(L,logtype,"always");
+
+    lua_pushinteger(L,(int)Log::LT_ERROR);
+    lua_setfield(L,logtype,"error");
+
+    lua_pushinteger(L,(int)Log::LT_WARNING);
+    lua_setfield(L,logtype,"warning");
 
+    lua_pushinteger(L,(int)Log::LT_INFO);
+    lua_setfield(L,logtype,"info");
+
+    lua_pushinteger(L,(int)Log::LT_DEBUG);
+    lua_setfield(L,logtype,"debug");
+
+    lua_pop(L,1); //pop the logtype table
+
+    return;
+}
 
 int LogMessage(lua_State* L)
 {
@@ -61,12 +94,7 @@ luaL_reg LogSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<Log>() { return "Log"; }
-template<> RegType<Log>* GetMethodTable<Log>() { return LogMethods; }
-template<> luaL_reg* GetAttrTable<Log>() { return LogGetters; }
-template<> luaL_reg* SetAttrTable<Log>() { return LogSetters; }
-*/
+LUATYPEDEFINE(Log,false)
 }
 }
 }

+ 2 - 7
Source/Core/Lua/Log.h

@@ -47,19 +47,14 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 
-template<> void LuaType<Log>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<Log>(lua_State* L, int metatable_index);
 int LogMessage(lua_State* L);
 
 RegType<Log> LogMethods[];
 luaL_reg LogGetters[];
 luaL_reg LogSetters[];
 
-/*
-template<> const char* GetTClassName<Log>();
-template<> RegType<Log>* GetMethodTable<Log>();
-template<> luaL_reg* GetAttrTable<Log>();
-template<> luaL_reg* SetAttrTable<Log>();
-*/
+LUATYPEDECLARE(Log)
 }
 }
 }

+ 2 - 1
Source/Core/Lua/LuaEventListener.cpp

@@ -29,6 +29,7 @@
 #include "LuaEventListener.h"
 #include <Rocket/Core/Lua/Interpreter.h>
 #include <Rocket/Core/Lua/LuaType.h>
+#include <Rocket/Core/Lua/Utilities.h>
 
 namespace Rocket {
 namespace Core {
@@ -57,7 +58,7 @@ LuaEventListener::LuaEventListener(const String& code, Element* element) : Event
     //compile,execute,and save the function
     luaL_loadstring(L,function.CString());
     if(lua_pcall(L,0,1,0) != 0)
-        Interpreter::Report();
+        Report(L);
     luaFuncRef = luaL_ref(L,tbl); //creates a reference to the item at the top of the stack in to the table we just created
     lua_pop(L,1); //pop the EVENTLISTENERFUNCTIONS table
 

+ 1 - 0
Source/Core/Lua/LuaEventListener.h

@@ -27,6 +27,7 @@
  
 #ifndef ROCKETCORELUALUAEVENTLISTENER_H
 #define ROCKETCORELUALUAEVENTLISTENER_H
+
 #include <Rocket/Core/EventListener.h>
 #include <Rocket/Core/String.h>
 #include <Rocket/Core/Lua/lua.hpp>

+ 7 - 21
Source/Core/Lua/LuaType.inl

@@ -28,7 +28,7 @@
 #include "precompiled.h"
 #include <Rocket/Controls/Controls.h>
 #include <Rocket/Core/Core.h>
-#include <Rocket/Core/Lua/Interpreter.h>
+#include <Rocket/Core/Lua/Utilities.h>
 
 namespace Rocket {
 namespace Core {
@@ -66,7 +66,7 @@ void LuaType<T>::Register(lua_State* L)
     lua_pushcfunction(L, tostring_T);
     lua_setfield(L, metatable, "__tostring");
 
-    extra_init(L,metatable); //imlemented by individual types
+    ExtraInit<T>(L,metatable); //optionally implemented by individual types
 
     lua_newtable(L); //for method table -> [3] = this table
     lua_setmetatable(L, methods); //[methods = 1] -> metatable for [1] is [3]; [3] is popped off, top = [2]
@@ -109,7 +109,7 @@ int LuaType<T>::push(lua_State *L, T* obj, bool gc)
         }
         else
         {
-            if(is_reference_counted())
+            if(IsReferenceCounted<T>())
                 ((Rocket::Core::ReferenceCountable*)obj)->AddReference();
         }
         lua_pop(L,1); // -> pop [3]
@@ -175,7 +175,7 @@ int LuaType<T>::gc_T(lua_State* L)
         lua_getfield(L,-1, std::string(name).c_str()); //[-1 = 2] -> [3] = the value returned from if <ClassName> exists in the table to not gc
         if(lua_isnil(L,-1) ) //[-1 = 3] if it doesn't exist, then we are free to garbage collect c++ side
         {
-            if(is_reference_counted())
+            if(IsReferenceCounted<T>())
             {
                 ((Rocket::Core::ReferenceCountable*)obj)->RemoveReference();
             }
@@ -228,7 +228,7 @@ int LuaType<T>::index(lua_State* L)
             {
                 lua_pushvalue(L,1); //push the userdata to the stack [6]
                 if(lua_pcall(L,1,1,0) != 0) //remove one, result is at [6]
-                    Interpreter::Report(L, String(GetTClassName<T>()).Append(".__index for ").Append(lua_tostring(L,2)).Append(": "));
+                    Report(L, String(GetTClassName<T>()).Append(".__index for ").Append(lua_tostring(L,2)).Append(": "));
             }
             else
             {
@@ -242,7 +242,7 @@ int LuaType<T>::index(lua_State* L)
                         lua_pushvalue(L,1); //[1] = object -> [7] = object
                         lua_pushvalue(L,2); //[2] = key -> [8] = key
                         if(lua_pcall(L,2,1,0) != 0) //call function at top of stack (__index) -> pop top 2 as args; [7] = return value
-                            Interpreter::Report(L, String(GetTClassName<T>()).Append(".__index for ").Append(lua_tostring(L,2)).Append(": "));
+                            Report(L, String(GetTClassName<T>()).Append(".__index for ").Append(lua_tostring(L,2)).Append(": "));
                     }
                     else if(lua_istable(L,-1) )
                         lua_getfield(L,-1,key); //shorthand version of above -> [7] = return value
@@ -284,7 +284,7 @@ int LuaType<T>::newindex(lua_State* L)
         lua_pushvalue(L,1); //userdata at [7]
         lua_pushvalue(L,3); //[8] = copy of [3]
         if(lua_pcall(L,2,0,0) != 0) //call function, pop 2 off push 0 on
-            Interpreter::Report(L, String(GetTClassName<T>()).Append(".__newindex for ").Append(lua_tostring(L,2)).Append(": ")); 
+            Report(L, String(GetTClassName<T>()).Append(".__newindex for ").Append(lua_tostring(L,2)).Append(": ")); 
     }
     else
         lua_pop(L,1); //not a setter function.
@@ -292,12 +292,6 @@ int LuaType<T>::newindex(lua_State* L)
     return 0;
 }
 
-template<typename T>
-void LuaType<T>::extra_init(lua_State* L, int metatable_index)
-{
-    //empty, because it should be implemented by other types
-    return;
-}
 
 template<typename T>
 void LuaType<T>::_regfunctions(lua_State* L, int meta, int methods)
@@ -344,14 +338,6 @@ void LuaType<T>::_regfunctions(lua_State* L, int meta, int methods)
     lua_pop(L,1); //pop __setters
 }
 
-template<typename T>
-bool LuaType<T>::is_reference_counted()
-{
-    return false;
-}
-
 }
 }
 }
-
-#include "LuaTypeTemplateSpec.inl"

+ 0 - 440
Source/Core/Lua/LuaTypeTemplateSpec.inl

@@ -1,440 +0,0 @@
-/*
- * This source file is part of libRocket, the HTML/CSS Interface Middleware
- *
- * For the latest information, see http://www.librocket.com
- *
- * Copyright (c) 2008-2010 CodePoint Ltd, Shift Technology Ltd
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- * 
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- *
- */
- 
-/*
-    Because all of the template specializations have to be compiled in the same translation unit, they have to 
-    exist in this file. It is included by LuaType.cpp (or LuaType.inl right now)
-*/
-#include "precompiled.h"
-#include <Rocket/Core/Core.h>
-#include <Rocket/Controls/Controls.h>
-#include <Rocket/Core/Lua/LuaType.h>
-#include "Colourb.h"
-#include "Colourf.h"
-#include "Vector2f.h"
-#include "Vector2i.h"
-#include "ElementStyle.h"
-#include "Log.h"
-#include "Rocket.h"
-#include "Element.h"
-#include "ElementText.h"
-#include "Document.h"
-#include "Event.h"
-#include "Context.h"
-#include "ElementForm.h"
-#include "ElementFormControl.h"
-#include "ElementFormControlDataSelect.h"
-#include "ElementFormControlSelect.h"
-#include "ElementFormControlInput.h"
-#include "ElementFormControlTextArea.h"
-#include "ElementDataGrid.h"
-#include "ElementDataGridRow.h"
-#include "ElementTabSet.h"
-#include "DataSource.h"
-#include "DataFormatter.h"
-#include "ContextDocumentsProxy.h"
-#include "ElementAttributesProxy.h"
-#include "EventParametersProxy.h"
-#include "SelectOptionsProxy.h"
-
-
-
-namespace Rocket {
-namespace Core {
-namespace Lua {
-
-
-LUATYPEDEFINE(Colourb)
-LUATYPEDEFINE(Colourf)
-LUATYPEDEFINE(Vector2f)
-LUATYPEDEFINE(Vector2i)
-LUATYPEDEFINE(Log)
-LUATYPEDEFINE(rocket)
-LUATYPEDEFINE(Element)
-LUATYPEDEFINE(Document)
-LUATYPEDEFINE(ElementText)
-LUATYPEDEFINE(ElementStyle)
-LUATYPEDEFINE(Event)
-LUATYPEDEFINE(Context)
-LUATYPEDEFINE(ElementForm)
-LUATYPEDEFINE(ElementFormControl)
-LUATYPEDEFINE(ElementFormControlDataSelect)
-LUATYPEDEFINE(ElementFormControlSelect)
-LUATYPEDEFINE(ElementFormControlInput)
-LUATYPEDEFINE(ElementFormControlTextArea)
-LUATYPEDEFINE(ElementDataGrid)
-LUATYPEDEFINE(ElementDataGridRow)
-LUATYPEDEFINE(ElementTabSet)
-LUATYPEDEFINE(DataSource)
-LUATYPEDEFINE(DataFormatter)
-LUATYPEDEFINE(ContextDocumentsProxy)
-LUATYPEDEFINE(ElementAttributesProxy)
-LUATYPEDEFINE(EventParametersProxy)
-LUATYPEDEFINE(SelectOptionsProxy)
-
-
-template class LuaType<Colourb>;
-template class LuaType<Colourf>;
-template class LuaType<Vector2f>;
-template class LuaType<Vector2i>;
-template class LuaType<Log>;
-template class LuaType<rocket>;
-template class LuaType<Element>;
-template class LuaType<Document>;
-template class LuaType<ElementText>;
-template class LuaType<ElementStyle>;
-template class LuaType<Event>;
-template class LuaType<Context>;
-template class LuaType<ElementForm>;
-template class LuaType<ElementFormControl>;
-template class LuaType<ElementFormControlDataSelect>;
-template class LuaType<ElementFormControlSelect>;
-template class LuaType<ElementFormControlInput>;
-template class LuaType<ElementFormControlTextArea>;
-template class LuaType<ElementDataGrid>;
-template class LuaType<ElementDataGridRow>;
-template class LuaType<ElementTabSet>;
-template class LuaType<DataSource>;
-template class LuaType<DataFormatter>;
-template class LuaType<ContextDocumentsProxy>;
-template class LuaType<ElementAttributesProxy>;
-template class LuaType<EventParametersProxy>;
-template class LuaType<SelectOptionsProxy>;
-
-
-//reference counted types
-template<> bool LuaType<Element>::is_reference_counted() { return true; }
-template<> bool LuaType<Document>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementText>::is_reference_counted() { return true; }
-template<> bool LuaType<Event>::is_reference_counted() { return true; }
-template<> bool LuaType<Context>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementForm>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementFormControl>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementFormControlDataSelect>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementFormControlSelect>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementFormControlInput>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementFormControlTextArea>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementDataGrid>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementDataGridRow>::is_reference_counted() { return true; }
-template<> bool LuaType<ElementTabSet>::is_reference_counted() { return true; }
-/////////////////////////
-
-
-template<> void LuaType<rocket>::extra_init(lua_State* L, int metatable_index)
-{
-    //because of the way LuaType::Register is done, we know that the methods table is directly
-    //before the metatable 
-    int method_index = metatable_index - 1;
-
-    lua_pushcfunction(L,rocketCreateContext);
-    lua_setfield(L,method_index,"CreateContext");
-
-    lua_pushcfunction(L,rocketLoadFontFace);
-    lua_setfield(L,method_index,"LoadFontFace");
-
-    lua_pushcfunction(L,rocketRegisterTag);
-    lua_setfield(L,method_index,"RegisterTag");
-
-    rocketEnumkey_identifier(L);
-    lua_setfield(L,method_index,"key_identifier");
-
-    lua_pushcfunction(L,rocketGetAttrcontexts);
-    lua_setfield(L,method_index,"contexts");
-
-    return;
-}
-
-/*
-    
-        Basic Types
-
-*/
-
-template<> void LuaType<Colourb>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,Colourbnew);
-    lua_setfield(L,metatable_index-1,"new");
-
-    lua_pushcfunction(L,Colourb__eq);
-    lua_setfield(L,metatable_index,"__eq");
-
-    lua_pushcfunction(L,Colourb__add);
-    lua_setfield(L,metatable_index,"__add");
-
-    lua_pushcfunction(L,Colourb__mul);
-    lua_setfield(L,metatable_index,"__mul");
-
-    return;
-}
-
-
-template<> void LuaType<Colourf>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,Colourfnew);
-    lua_setfield(L,metatable_index-1,"new");
-
-    lua_pushcfunction(L,Colourf__eq);
-    lua_setfield(L,metatable_index,"__eq");
-
-    return;
-}
-
-
-template<> 
-void LuaType<Vector2f>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,Vector2fnew);
-    lua_setfield(L,metatable_index-1,"new");
-
-    lua_pushcfunction(L,Vector2f__mul);
-    lua_setfield(L,metatable_index,"__mul");
-
-    lua_pushcfunction(L,Vector2f__div);
-    lua_setfield(L,metatable_index,"__div");
-
-    lua_pushcfunction(L,Vector2f__add);
-    lua_setfield(L,metatable_index,"__add");
-
-    lua_pushcfunction(L,Vector2f__sub);
-    lua_setfield(L,metatable_index,"__sub");
-
-    lua_pushcfunction(L,Vector2f__eq);
-    lua_setfield(L,metatable_index,"__eq");
-
-    //stack is in the same state as it was before it entered this function
-    return;
-}
-
-template<> 
-void LuaType<Vector2i>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,Vector2inew);
-    lua_setfield(L,metatable_index-1,"new");
-
-    lua_pushcfunction(L,Vector2i__mul);
-    lua_setfield(L,metatable_index,"__mul");
-
-    lua_pushcfunction(L,Vector2i__div);
-    lua_setfield(L,metatable_index,"__div");
-
-    lua_pushcfunction(L,Vector2i__add);
-    lua_setfield(L,metatable_index,"__add");
-
-    lua_pushcfunction(L,Vector2i__sub);
-    lua_setfield(L,metatable_index,"__sub");
-
-    lua_pushcfunction(L,Vector2i__eq);
-    lua_setfield(L,metatable_index,"__eq");
-
-    //stack is in the same state as it was before it entered this function
-    return;
-}
-
-
-/*
-
-    Elements
-
-*/
-template<> void LuaType<Element>::extra_init(lua_State* L, int metatable_index)
-{
-    int top = lua_gettop(L);
-    //build the Element.etype table
-    lua_newtable(L);
-    lua_pushinteger(L,TDATAGRID);
-    lua_setfield(L,-2,"datagrid");
-    lua_pushinteger(L,TDATASELECT);
-    lua_setfield(L,-2,"dataselect");
-    lua_pushinteger(L,TELEMENT);
-    lua_setfield(L,-2,"element");
-    lua_pushinteger(L,TFORM);
-    lua_setfield(L,-2,"form");
-    lua_pushinteger(L,TINPUT);
-    lua_setfield(L,-2,"input");
-    lua_pushinteger(L,TSELECT);
-    lua_setfield(L,-2,"select");
-    lua_pushinteger(L,TTABSET);
-    lua_setfield(L,-2,"tabset");
-    lua_pushinteger(L,TTEXTAREA);
-    lua_setfield(L,-2,"textarea");
-    
-    lua_setfield(L,metatable_index-1,"etype");
-    lua_settop(L,top);
-}
-
-template<> void LuaType<Document>::extra_init(lua_State* L, int metatable_index)
-{
-    //we will inherit from Element
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index - 1);
-}
-
-template<> void LuaType<ElementText>::extra_init(lua_State* L, int metatable_index)
-{
-    //inherit from Element
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementStyle>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,ElementStyle__index);
-    lua_setfield(L,metatable_index,"__index");
-
-    lua_pushcfunction(L,ElementStyle__newindex);
-    lua_setfield(L,metatable_index,"__newindex");
-}
-
-
-template<> void LuaType<ElementForm>::extra_init(lua_State* L, int metatable_index)
-{
-    //inherit from Element
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementFormControl>::extra_init(lua_State* L, int metatable_index)
-{
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementFormControlDataSelect>::extra_init(lua_State* L, int metatable_index)
-{
-    //do whatever ElementFormControlSelect did as far as inheritance
-    LuaType<ElementFormControlSelect>::extra_init(L,metatable_index);
-    //then inherit from ElementFromControlSelect
-    LuaType<ElementFormControlSelect>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementFormControlInput>::extra_init(lua_State* L, int metatable_index)
-{
-    LuaType<ElementFormControl>::extra_init(L,metatable_index);
-    LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementFormControlSelect>::extra_init(lua_State* L, int metatable_index)
-{
-    //init whatever elementformcontrol did extra, like inheritance
-    LuaType<ElementFormControl>::extra_init(L,metatable_index);
-    //then inherit from elementformcontrol
-    LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementFormControlTextArea>::extra_init(lua_State* L, int metatable_index)
-{
-    LuaType<ElementFormControl>::extra_init(L,metatable_index);
-    LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementDataGrid>::extra_init(lua_State* L, int metatable_index)
-{
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementDataGridRow>::extra_init(lua_State* L, int metatable_index)
-{
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<ElementTabSet>::extra_init(lua_State* L, int metatable_index)
-{
-    LuaType<Element>::extra_init(L,metatable_index);
-    LuaType<Element>::_regfunctions(L,metatable_index,metatable_index-1);
-}
-
-template<> void LuaType<Log>::extra_init(lua_State* L, int metatable_index)
-{
-    //due to they way that LuaType::Register is made, we know that the method table is at the index
-    //directly below the metatable
-    int method_index = metatable_index - 1;
-
-    lua_pushcfunction(L,LogMessage);
-    lua_setfield(L,method_index, "Message");
-
-    //construct the "logtype" table, so that we can use the Rocket::Core::Log::Type enum like Log.logtype.always in Lua for Log::LT_ALWAYS
-    lua_newtable(L);
-    int logtype = lua_gettop(L);
-    lua_pushvalue(L,-1); //copy of the new table, so that the logtype index will stay valid
-    lua_setfield(L,method_index,"logtype");
-
-    lua_pushinteger(L,(int)Log::LT_ALWAYS);
-    lua_setfield(L,logtype,"always");
-
-    lua_pushinteger(L,(int)Log::LT_ERROR);
-    lua_setfield(L,logtype,"error");
-
-    lua_pushinteger(L,(int)Log::LT_WARNING);
-    lua_setfield(L,logtype,"warning");
-
-    lua_pushinteger(L,(int)Log::LT_INFO);
-    lua_setfield(L,logtype,"info");
-
-    lua_pushinteger(L,(int)Log::LT_DEBUG);
-    lua_setfield(L,logtype,"debug");
-
-    lua_pop(L,1); //pop the logtype table
-
-    return;
-}
-
-template<> void LuaType<DataFormatter>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,DataFormatternew);
-    lua_setfield(L,metatable_index-1,"new");
-    return;
-}
-
-template<> void LuaType<ContextDocumentsProxy>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,ContextDocumentsProxy__index);
-    lua_setfield(L,metatable_index,"__index");
-}
-
-template<> void LuaType<ElementAttributesProxy>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,ElementAttributesProxy__index);
-    lua_setfield(L,metatable_index,"__index");
-}
-
-template<> void LuaType<EventParametersProxy>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,EventParametersProxy__index);
-    lua_setfield(L,metatable_index,"__index");
-}
-
-template<> void LuaType<SelectOptionsProxy>::extra_init(lua_State* L, int metatable_index)
-{
-    lua_pushcfunction(L,SelectOptionsProxy__index);
-    lua_setfield(L,metatable_index,"__index");
-}
-
-}
-}
-}

+ 25 - 6
Source/Core/Lua/Rocket.cpp

@@ -34,6 +34,30 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 
+template<> void ExtraInit<rocket>(lua_State* L, int metatable_index)
+{
+    //because of the way LuaType::Register is done, we know that the methods table is directly
+    //before the metatable 
+    int method_index = metatable_index - 1;
+
+    lua_pushcfunction(L,rocketCreateContext);
+    lua_setfield(L,method_index,"CreateContext");
+
+    lua_pushcfunction(L,rocketLoadFontFace);
+    lua_setfield(L,method_index,"LoadFontFace");
+
+    lua_pushcfunction(L,rocketRegisterTag);
+    lua_setfield(L,method_index,"RegisterTag");
+
+    rocketEnumkey_identifier(L);
+    lua_setfield(L,method_index,"key_identifier");
+
+    lua_pushcfunction(L,rocketGetAttrcontexts);
+    lua_setfield(L,method_index,"contexts");
+
+    return;
+}
+
 int rocketCreateContext(lua_State* L)
 {
     const char* name = luaL_checkstring(L,1);
@@ -282,12 +306,7 @@ luaL_reg rocketSetters[] =
     { NULL, NULL },
 };
 
-/*
-template<> const char* GetTClassName<rocket>() { return "rocket"; }
-template<> RegType<rocket>* GetMethodTable<rocket>() { return rocketMethods; }
-template<> luaL_reg* GetAttrTable<rocket>() { return rocketGetters; }
-template<> luaL_reg* SetAttrTable<rocket>() { return rocketSetters; }
-*/
+LUATYPEDEFINE(rocket,false)
 }
 }
 }

+ 2 - 7
Source/Core/Lua/Rocket.h

@@ -54,7 +54,7 @@ namespace Lua {
 //just need a class to take up a type name
 class rocket { int to_remove_warning; };
 
-template<> void LuaType<rocket>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<rocket>(lua_State* L, int metatable_index);
 int rocketCreateContext(lua_State* L);
 int rocketLoadFontFace(lua_State* L);
 int rocketRegisterTag(lua_State* L);
@@ -66,12 +66,7 @@ RegType<rocket> rocketMethods[];
 luaL_reg rocketGetters[];
 luaL_reg rocketSetters[];
 
-/*
-template<> const char* GetTClassName<rocket>();
-template<> RegType<rocket>* GetMethodTable<rocket>();
-template<> luaL_reg* GetAttrTable<rocket>();
-template<> luaL_reg* SetAttrTable<rocket>();
-*/
+LUATYPEDECLARE(rocket)
 }
 }
 }

+ 18 - 1
Source/Core/Lua/Utilities.cpp

@@ -26,7 +26,7 @@
  */
  
 #include "precompiled.h"
-#include "Utilities.h"
+#include <Rocket/Core/Lua/Utilities.h>
 
 namespace Rocket {
 namespace Core {
@@ -72,6 +72,23 @@ void PushVariant(lua_State* L, Variant* var)
     }
 }
 
+
+void Report(lua_State* L, const Rocket::Core::String& place)
+{
+    const char * msg= lua_tostring(L,-1);
+    String strmsg;
+    while(msg)
+    {
+        lua_pop(L,1);
+        if(place == "")
+            strmsg = msg;
+        else
+            strmsg = String(place).Append(" ").Append(msg);
+        Log::Message(Log::LT_WARNING, strmsg.CString());
+        msg=lua_tostring(L,-1);
+    }
+}
+
 }
 }
 }

+ 24 - 0
Source/Core/Lua/Vector2f.cpp

@@ -33,7 +33,29 @@ namespace Rocket {
 namespace Core {
 namespace Lua {
 
+template<> void ExtraInit<Vector2f>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,Vector2fnew);
+    lua_setfield(L,metatable_index-1,"new");
+
+    lua_pushcfunction(L,Vector2f__mul);
+    lua_setfield(L,metatable_index,"__mul");
+
+    lua_pushcfunction(L,Vector2f__div);
+    lua_setfield(L,metatable_index,"__div");
+
+    lua_pushcfunction(L,Vector2f__add);
+    lua_setfield(L,metatable_index,"__add");
 
+    lua_pushcfunction(L,Vector2f__sub);
+    lua_setfield(L,metatable_index,"__sub");
+
+    lua_pushcfunction(L,Vector2f__eq);
+    lua_setfield(L,metatable_index,"__eq");
+
+    //stack is in the same state as it was before it entered this function
+    return;
+}
 
 int Vector2fnew(lua_State* L)
 {
@@ -215,6 +237,8 @@ luaL_reg Vector2fSetters[]=
     { NULL, NULL },
 };
 
+LUATYPEDEFINE(Vector2f,false)
+
 }
 }
 }

+ 3 - 7
Source/Core/Lua/Vector2f.h

@@ -62,7 +62,8 @@ using Rocket::Core::Vector2f;
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> void LuaType<Vector2f>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<Vector2f>(lua_State* L, int metatable_index);
+
 int Vector2fnew(lua_State* L);
 int Vector2f__mul(lua_State* L);
 int Vector2f__div(lua_State* L);
@@ -86,12 +87,7 @@ RegType<Vector2f> Vector2fMethods[];
 luaL_reg Vector2fGetters[];
 luaL_reg Vector2fSetters[];
 
-/*
-template<> const char* GetTClassName<Vector2f>() { return "Vector2f"; }
-template<> RegType<Vector2f>* GetMethodTable<Vector2f>() { return Vector2fMethods; }
-template<> luaL_reg* GetAttrTable<Vector2f>() { return Vector2fGetters; }
-template<> luaL_reg* SetAttrTable<Vector2f>() { return Vector2fSetters; }
-*/
+LUATYPEDECLARE(Vector2f)
 }
 }
 }

+ 24 - 0
Source/Core/Lua/Vector2i.cpp

@@ -32,7 +32,29 @@
 namespace Rocket {
 namespace Core {
 namespace Lua {
+template<> void ExtraInit<Vector2i>(lua_State* L, int metatable_index)
+{
+    lua_pushcfunction(L,Vector2inew);
+    lua_setfield(L,metatable_index-1,"new");
+
+    lua_pushcfunction(L,Vector2i__mul);
+    lua_setfield(L,metatable_index,"__mul");
+
+    lua_pushcfunction(L,Vector2i__div);
+    lua_setfield(L,metatable_index,"__div");
+
+    lua_pushcfunction(L,Vector2i__add);
+    lua_setfield(L,metatable_index,"__add");
 
+    lua_pushcfunction(L,Vector2i__sub);
+    lua_setfield(L,metatable_index,"__sub");
+
+    lua_pushcfunction(L,Vector2i__eq);
+    lua_setfield(L,metatable_index,"__eq");
+
+    //stack is in the same state as it was before it entered this function
+    return;
+}
 
 int Vector2inew(lua_State* L)
 {
@@ -179,6 +201,8 @@ luaL_reg Vector2iSetters[]=
     { NULL, NULL },
 };
 
+LUATYPEDEFINE(Vector2i,false)
+
 }
 }
 }

+ 2 - 7
Source/Core/Lua/Vector2i.h

@@ -55,7 +55,7 @@ using Rocket::Core::Vector2i;
 namespace Rocket {
 namespace Core {
 namespace Lua {
-template<> void LuaType<Vector2i>::extra_init(lua_State* L, int metatable_index);
+template<> void ExtraInit<Vector2i>(lua_State* L, int metatable_index);
 int Vector2inew(lua_State* L);
 int Vector2i__mul(lua_State* L);
 int Vector2i__div(lua_State* L);
@@ -77,12 +77,7 @@ RegType<Vector2i> Vector2iMethods[];
 luaL_reg Vector2iGetters[];
 luaL_reg Vector2iSetters[];
 
-/*
-template<> const char* GetTClassName<Vector2i>() { return "Vector2i"; }
-template<> RegType<Vector2i>* GetMethodTable<Vector2i>() { return Vector2iMethods; }
-template<> luaL_reg* GetAttrTable<Vector2i>() { return Vector2iGetters; }
-template<> luaL_reg* SetAttrTable<Vector2i>() { return Vector2iSetters; }
-*/
+LUATYPEDECLARE(Vector2i)
 }
 }
 }

+ 7 - 0
Source/Core/Lua/precompiled.h

@@ -32,5 +32,12 @@
 #include <Rocket/Core/Debug.h>
 #include <Rocket/Controls/Controls.h>
 #include <Rocket/Core/Lua/LuaType.h>
+//We can't use LUATYPEDEFINE from LuaType.h due to namespace issues
+#define LUACONTROLSTYPEDEFINE(type,is_ref_counted) \
+    template<> const char* Rocket::Core::Lua::GetTClassName<type>() { return #type; } \
+    template<> Rocket::Core::Lua::RegType<type>* Rocket::Core::Lua::GetMethodTable<type>() { return Rocket::Controls::Lua::type##Methods; } \
+    template<> luaL_reg* Rocket::Core::Lua::GetAttrTable<type>() { return Rocket::Controls::Lua::type##Getters; } \
+    template<> luaL_reg* Rocket::Core::Lua::SetAttrTable<type>() { return Rocket::Controls::Lua::type##Setters; } \
+    template<> bool Rocket::Core::Lua::IsReferenceCounted<type>() { return (is_ref_counted); } \
 
 #endif