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

All classes now subclass PolyBase to faciliate casting in Lua bindings

Ivan Safrin 13 лет назад
Родитель
Сommit
a503864244
47 измененных файлов с 86 добавлено и 82 удалено
  1. 20 20
      Bindings/Scripts/create_lua_library/create_lua_library.py
  2. 3 3
      Core/Contents/Include/OSBasics.h
  3. 2 2
      Core/Contents/Include/PolyBezierCurve.h
  4. 1 1
      Core/Contents/Include/PolyColor.h
  5. 2 2
      Core/Contents/Include/PolyConfig.h
  6. 3 3
      Core/Contents/Include/PolyCore.h
  7. 1 1
      Core/Contents/Include/PolyCoreInput.h
  8. 1 1
      Core/Contents/Include/PolyData.h
  9. 2 1
      Core/Contents/Include/PolyEntity.h
  10. 1 1
      Core/Contents/Include/PolyEvent.h
  11. 1 1
      Core/Contents/Include/PolyEventHandler.h
  12. 1 1
      Core/Contents/Include/PolyFont.h
  13. 1 1
      Core/Contents/Include/PolyFontManager.h
  14. 2 0
      Core/Contents/Include/PolyGlobals.h
  15. 1 1
      Core/Contents/Include/PolyImage.h
  16. 1 1
      Core/Contents/Include/PolyLogger.h
  17. 1 1
      Core/Contents/Include/PolyMaterialManager.h
  18. 1 1
      Core/Contents/Include/PolyMatrix4.h
  19. 4 4
      Core/Contents/Include/PolyMesh.h
  20. 1 1
      Core/Contents/Include/PolyModule.h
  21. 4 4
      Core/Contents/Include/PolyObject.h
  22. 1 1
      Core/Contents/Include/PolyParticle.h
  23. 1 1
      Core/Contents/Include/PolyPerlin.h
  24. 1 1
      Core/Contents/Include/PolyPolygon.h
  25. 1 1
      Core/Contents/Include/PolyQuaternion.h
  26. 1 1
      Core/Contents/Include/PolyQuaternionCurve.h
  27. 1 1
      Core/Contents/Include/PolyRectangle.h
  28. 3 3
      Core/Contents/Include/PolyRenderer.h
  29. 1 1
      Core/Contents/Include/PolyResource.h
  30. 1 1
      Core/Contents/Include/PolyResourceManager.h
  31. 1 1
      Core/Contents/Include/PolySceneEntity.h
  32. 1 1
      Core/Contents/Include/PolySceneManager.h
  33. 1 1
      Core/Contents/Include/PolySceneRenderTexture.h
  34. 1 1
      Core/Contents/Include/PolyScreenEntity.h
  35. 4 4
      Core/Contents/Include/PolyShader.h
  36. 2 2
      Core/Contents/Include/PolySkeleton.h
  37. 1 1
      Core/Contents/Include/PolySound.h
  38. 1 1
      Core/Contents/Include/PolySoundManager.h
  39. 1 1
      Core/Contents/Include/PolyString.h
  40. 1 1
      Core/Contents/Include/PolyTimerManager.h
  41. 1 1
      Core/Contents/Include/PolyTweenManager.h
  42. 1 1
      Core/Contents/Include/PolyVector2.h
  43. 1 1
      Core/Contents/Include/PolyVector3.h
  44. 1 0
      Core/Contents/Include/Polycode.h
  45. 1 1
      Core/Contents/Source/PolyEntity.cpp
  46. 1 1
      Core/Contents/Source/PolySceneEntity.cpp
  47. 1 1
      Core/Contents/Source/PolyScreenEntity.cpp

+ 20 - 20
Bindings/Scripts/create_lua_library/create_lua_library.py

@@ -118,8 +118,8 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 		wrappersHeaderOut += "		lua_getfield(L, LUA_GLOBALSINDEX, \"EventHandler\" );\n"
 		wrappersHeaderOut += "		lua_getfield(L, -1, \"__handleEvent\");\n"
 		wrappersHeaderOut += "		lua_rawgeti( L, LUA_REGISTRYINDEX, wrapperIndex );\n"
-		wrappersHeaderOut += "		void **userdataPtr = (void**)lua_newuserdata(L, sizeof(void*));\n"
-		wrappersHeaderOut += "		*userdataPtr = (void*)e;\n"
+		wrappersHeaderOut += "		PolyBase **userdataPtr = (PolyBase**)lua_newuserdata(L, sizeof(PolyBase*));\n"
+		wrappersHeaderOut += "		*userdataPtr = (PolyBase*)e;\n"
 #		wrappersHeaderOut += "		lua_getfield (L, LUA_GLOBALSINDEX, \"__customError\");\n"
 #		wrappersHeaderOut += "		int errH = lua_gettop(L);\n"
 #		wrappersHeaderOut += "		lua_pcall(L, 2, 0, errH);\n"
@@ -148,7 +148,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 			f = open(fileName) # Def: Input file handle
 			contents = f.read().replace("_PolyExport", "") # Def: Input file contents, strip out "_PolyExport"
 			cppHeader = CppHeaderParser.CppHeader(contents, "string") # Def: Input file contents, parsed structure
-			ignore_classes = ["PolycodeShaderModule", "Object", "Threaded", "OpenGLCubemap"]
+			ignore_classes = ["PolycodeShaderModule", "Object", "Threaded", "OpenGLCubemap", "PolyBase"]
 
 			# Iterate, check each class in this file.
 			for ckey in cppHeader.classes: 
@@ -238,7 +238,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							cppRegisterOut += "\t\t{\"%s_get_%s\", %s_%s_get_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
 							wrappersHeaderOut += "static int %s_%s_get_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
+							wrappersHeaderOut += "\t%s *inst = (%s*) *((PolyBase**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 
 							outfunc = "this_shouldnt_happen"
 							retFunc = ""
@@ -255,8 +255,8 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							if pp["type"] == "Number" or  pp["type"] == "String" or pp["type"] == "int" or pp["type"] == "bool":
 								wrappersHeaderOut += "\t%s(L, inst->%s%s);\n" % (outfunc, pp["name"], retFunc)
 							else:
-								wrappersHeaderOut += "\tvoid **userdataPtr = (void**)lua_newuserdata(L, sizeof(void*));\n"
-								wrappersHeaderOut += "\t*userdataPtr = (void*)&inst->%s%s;\n" % (pp["name"], retFunc)
+								wrappersHeaderOut += "\tPolyBase **userdataPtr = (PolyBase**)lua_newuserdata(L, sizeof(PolyBase*));\n"
+								wrappersHeaderOut += "\t*userdataPtr = (PolyBase*)&inst->%s%s;\n" % (pp["name"], retFunc)
 							wrappersHeaderOut += "\treturn 1;\n"
 							wrappersHeaderOut += "}\n\n"
 						
@@ -291,7 +291,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							cppRegisterOut += "\t\t{\"%s_set_%s\", %s_%s_set_%s},\n" % (ckey, pp["name"], libName, ckey, pp["name"])
 							wrappersHeaderOut += "static int %s_%s_set_%s(lua_State *L) {\n" % (libName, ckey, pp["name"])
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
+							wrappersHeaderOut += "\t%s *inst = (%s*) *((PolyBase**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 
 							outfunc = "this_shouldnt_happen"
 							if pp["type"] == "Number":
@@ -356,7 +356,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 						# Skip static methods (TODO: Figure out, why is this being done here?). # FIXME
 						if pm["rtnType"].find("static ") == -1:
 							wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-							wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
+							wrappersHeaderOut += "\t%s *inst = (%s*) *((PolyBase**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 							idx = 2
 						else:
 							idx = 1
@@ -380,11 +380,11 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 								luatype = "LUA_TUSERDATA"
 								checkfunc = "lua_isuserdata"
 								if param["type"].find("*") > -1:
-									luafunc = "(%s) *((void**)lua_touserdata" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+									luafunc = "(%s) *((PolyBase**)lua_touserdata" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								elif param["type"].find("&") > -1:
-									luafunc = "*(%s*) *((void**)lua_touserdata" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+									luafunc = "*(%s*) *((PolyBase**)lua_touserdata" % (param["type"].replace("const", "").replace("&", "").replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								else:
-									luafunc = "*(%s*) *((void**)lua_touserdata" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
+									luafunc = "*(%s*) *((PolyBase**)lua_touserdata" % (param["type"].replace("Polygon", "Polycode::Polygon").replace("Rectangle", "Polycode::Rectangle"))
 								lend = ".__ptr"
 								luafuncsuffix = ")"
 								if param["type"] == "int" or param["type"] == "unsigned int" or param["type"] == "short":
@@ -453,8 +453,8 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 							else:
 								wrappersHeaderOut += "\t%s *inst = new %s(%s);\n" % (ckey, ckey, ", ".join(paramlist))
 							
-							wrappersHeaderOut += "\t%s **userdataPtr = (%s**)lua_newuserdata(L, sizeof(%s*));\n" % (ckey, ckey, ckey)
-							wrappersHeaderOut += "\t*userdataPtr = inst;\n"
+							wrappersHeaderOut += "\tPolyBase **userdataPtr = (PolyBase**)lua_newuserdata(L, sizeof(PolyBase*));\n"
+							wrappersHeaderOut += "\t*userdataPtr = (PolyBase*)inst;\n"
 							wrappersHeaderOut += "\tluaL_getmetatable(L, \"%s.%s\");\n" % (libName, ckey)
 							wrappersHeaderOut += "\tlua_setmetatable(L, -2);\n"
 							wrappersHeaderOut += "\treturn 1;\n"
@@ -474,8 +474,8 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 										wrappersHeaderOut += "\tstd::vector<%s> retVector = %s;\n" % (vectorReturnClass,call)
 										wrappersHeaderOut += "\tlua_newtable(L);\n"
 										wrappersHeaderOut += "\tfor(int i=0; i < retVector.size(); i++) {\n"
-										wrappersHeaderOut += "\t\tvoid **userdataPtr = (void**)lua_newuserdata(L, sizeof(void*));\n"
-										wrappersHeaderOut += "\t\t*userdataPtr = (void*)retVector[i];\n"
+										wrappersHeaderOut += "\t\tPolyBase **userdataPtr = (PolyBase**)lua_newuserdata(L, sizeof(PolyBase*));\n"
+										wrappersHeaderOut += "\t\t*userdataPtr = (PolyBase*)retVector[i];\n"
 										wrappersHeaderOut += "\t\tlua_rawseti(L, -2, i+1);\n"
 										wrappersHeaderOut += "\t}\n"
 										wrappersHeaderOut += "\treturn 1;\n"
@@ -507,11 +507,11 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 									basicType = True
 
 								if pm["rtnType"].find("*") > -1: # Returned var is definitely a pointer.
-									wrappersHeaderOut += "\tvoid *ptrRetVal = (void*)%s%s;\n" % (call, retFunc)
+									wrappersHeaderOut += "\tPolyBase *ptrRetVal = (PolyBase*)%s%s;\n" % (call, retFunc)
 									wrappersHeaderOut += "\tif(ptrRetVal == NULL) {\n"
 									wrappersHeaderOut += "\t\tlua_pushnil(L);\n"
 									wrappersHeaderOut += "\t} else {\n"
-									wrappersHeaderOut += "\t\tvoid **userdataPtr = (void**)lua_newuserdata(L, sizeof(void*));\n"
+									wrappersHeaderOut += "\t\tPolyBase **userdataPtr = (PolyBase**)lua_newuserdata(L, sizeof(PolyBase*));\n"
 									wrappersHeaderOut += "\t\t*userdataPtr = ptrRetVal;\n"
 									wrappersHeaderOut += "\t}\n"
 								elif basicType == True: # Returned var has been flagged as a recognized primitive type
@@ -526,10 +526,10 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 										className = "Polycode::Rectangle"
 									wrappersHeaderOut += "\t%s *retInst = new %s();\n" % (className, className)
 									wrappersHeaderOut += "\t*retInst = %s;\n" % (call)
-									wrappersHeaderOut += "\tvoid **userdataPtr = (void**)lua_newuserdata(L, sizeof(void*));\n"
+									wrappersHeaderOut += "\tPolyBase **userdataPtr = (PolyBase**)lua_newuserdata(L, sizeof(PolyBase*));\n"
 									wrappersHeaderOut += "\tluaL_getmetatable(L, \"%s.%s\");\n" % (libName, className)
 									wrappersHeaderOut += "\tlua_setmetatable(L, -2);\n"
-									wrappersHeaderOut += "\t*userdataPtr = (void*)retInst;\n"
+									wrappersHeaderOut += "\t*userdataPtr = (PolyBase*)retInst;\n"
 								wrappersHeaderOut += "\treturn 1;\n"
 					wrappersHeaderOut += "}\n\n" # Close out C++ generation
 
@@ -606,7 +606,7 @@ def createLUABindings(inputPath, prefix, mainInclude, libSmallName, libName, api
 				cppRegisterOut += "\t\t{\"delete_%s\", %s_delete_%s},\n" % (ckey, libName, ckey)
 				wrappersHeaderOut += "static int %s_delete_%s(lua_State *L) {\n" % (libName, ckey)
 				wrappersHeaderOut += "\tluaL_checktype(L, 1, LUA_TUSERDATA);\n"
-				wrappersHeaderOut += "\t%s *inst = (%s*) *((void**)lua_touserdata(L, 1));\n" % (ckey, ckey)
+				wrappersHeaderOut += "\t%s *inst = (%s*) *((PolyBase**)lua_touserdata(L, 1));\n" % (ckey, ckey)
 				wrappersHeaderOut += "\tdelete inst;\n"
 				wrappersHeaderOut += "\treturn 0;\n"
 				wrappersHeaderOut += "}\n\n"

+ 3 - 3
Core/Contents/Include/OSBasics.h

@@ -27,7 +27,7 @@
 
 struct PHYSFS_File;
 
-class _PolyExport OSFileEntry {
+class _PolyExport OSFileEntry : public PolyBase {
 
 	public:
 		OSFileEntry() {};
@@ -47,7 +47,7 @@ class _PolyExport OSFileEntry {
 		static const int TYPE_FOLDER = 1;
 };
 
-class _PolyExport OSFILE {
+class _PolyExport OSFILE : public PolyBase {
 public:
 	OSFILE(){}
 	
@@ -60,7 +60,7 @@ public:
 	static const int TYPE_ARCHIVE_FILE = 1;	
 };
 
-class _PolyExport OSBasics {
+class _PolyExport OSBasics : public PolyBase {
 	public:
 	
 		static OSFILE *open(const Polycode::String& filename, const Polycode::String& opts);

+ 2 - 2
Core/Contents/Include/PolyBezierCurve.h

@@ -36,7 +36,7 @@ namespace Polycode {
 	* A curve point defined by 3 positions.
 	* @see BezierCurve
 	*/
-	class _PolyExport BezierPoint {
+	class _PolyExport BezierPoint : public PolyBase {
 		public:
 		
 		/**
@@ -75,7 +75,7 @@ namespace Polycode {
 		A bezier curve consists of control points, each having 3 points: one middle point and two 'handles'. The middle point is the actual position of the control point and the two side points serve as vectors defining how the curve curves towards the next control points.
 		
 	*/																																									
-	class _PolyExport BezierCurve {
+	class _PolyExport BezierCurve : public PolyBase {
 		public:
 			/** 
 			* Default constructor.

+ 1 - 1
Core/Contents/Include/PolyColor.h

@@ -29,7 +29,7 @@ namespace Polycode {
 	/**
 	* Stores and manipulates color information. Color is always RGBA in Polycode.
 	*/						
-	class _PolyExport Color {
+	class _PolyExport Color : public PolyBase {
 		public:
 
 			/**

+ 2 - 2
Core/Contents/Include/PolyConfig.h

@@ -26,7 +26,7 @@ THE SOFTWARE.
 
 namespace Polycode {
 
-	class ConfigEntry {
+	class ConfigEntry : public PolyBase {
 	public:
 		String key;
 		String configNamespace;
@@ -38,7 +38,7 @@ namespace Polycode {
 	/**
 	* Saves and loads simple config files. Config stores, loads and saves string and number values associated by string keys. You can use to easily save and load settings and preferences and other data. Configs are separated by namespaces, so you can have multiple configs with the same keys.
 	*/
-	class _PolyExport Config {
+	class _PolyExport Config : public PolyBase {
 	public:
 		/**
 		* Default constructor.

+ 3 - 3
Core/Contents/Include/PolyCore.h

@@ -44,18 +44,18 @@ namespace Polycode {
 
 	class Renderer;
 
-	class _PolyExport CoreMutex {
+	class _PolyExport CoreMutex : public PolyBase {
 	public:
 		int mutexID;
 	};
 	
-	class _PolyExport CoreFileExtension {
+	class _PolyExport CoreFileExtension : public PolyBase {
 	public:
 		String extension;
 		String description;
 	};
 	
-	class _PolyExport PolycodeViewBase {
+	class _PolyExport PolycodeViewBase : public PolyBase {
 	public:
 		PolycodeViewBase() { windowData = NULL; }
 		virtual ~PolycodeViewBase(){}

+ 1 - 1
Core/Contents/Include/PolyCoreInput.h

@@ -32,7 +32,7 @@ namespace Polycode {
 	/**
 	* Joystick info.
 	*/
-	class JoystickInfo {
+	class JoystickInfo : public PolyBase {
 		public:
 			JoystickInfo();
 			

+ 1 - 1
Core/Contents/Include/PolyData.h

@@ -29,7 +29,7 @@ namespace Polycode {
 	/**
 	* Stores, saves and loads data. This class can save and load arbitrary data to and from disk and convert it to strings.
 	*/	
-	class _PolyExport Data {
+	class _PolyExport Data : public PolyBase {
 		public:
 			/**
 			* Default constructor

+ 2 - 1
Core/Contents/Include/PolyEntity.h

@@ -27,6 +27,7 @@
 #include "PolyQuaternion.h"
 #include "PolyColor.h"
 #include "PolyRectangle.h"
+#include "PolyEventDispatcher.h"
 #include <vector>
 
 namespace Polycode {
@@ -60,7 +61,7 @@ namespace Polycode {
 	/**
 	* Base class for both 2D and 3D objects in Polycode. It provides position and color transformations as well as hierarchy for all Polycode objects.
 	*/
-	class _PolyExport Entity {
+	class _PolyExport Entity : public EventDispatcher {
 		public:
 			Entity();
 			virtual ~Entity();

+ 1 - 1
Core/Contents/Include/PolyEvent.h

@@ -31,7 +31,7 @@ namespace Polycode {
 	/**
 	* Event base class. Subclass this class to pass complex data through events.
 	*/
-	class _PolyExport Event {
+	class _PolyExport Event : public PolyBase {
 		public:
 			/**
 			* Default constructor.

+ 1 - 1
Core/Contents/Include/PolyEventHandler.h

@@ -29,7 +29,7 @@ namespace Polycode {
 	/**
 	* Can handle events from EventDispatcher classes.
 	*/
-	class _PolyExport EventHandler {
+	class _PolyExport EventHandler : public PolyBase {
 		public:
 			/**
 			* Default constructor

+ 1 - 1
Core/Contents/Include/PolyFont.h

@@ -31,7 +31,7 @@ namespace Polycode {
 	
 	class String;
 
-	class _PolyExport Font {
+	class _PolyExport Font : public PolyBase {
 		public:
 			Font(const String& fileName);
 			virtual ~Font();

+ 1 - 1
Core/Contents/Include/PolyFontManager.h

@@ -39,7 +39,7 @@ namespace Polycode {
 	/**
 	* Manages fonts. The font manager shoudl only be accessed via the CoreServices singleton.
 	*/
-	class _PolyExport FontManager {
+	class _PolyExport FontManager : public PolyBase {
 	public:
 		FontManager();
 		~FontManager();

+ 2 - 0
Core/Contents/Include/PolyGlobals.h

@@ -87,3 +87,5 @@ inline Number clampf(Number x, Number a, Number b)
 // Special flag read by create_lua_library parser, suppresses Lua bindings for item.
 #define POLYIGNORE
 
+class _PolyExport PolyBase {};
+

+ 1 - 1
Core/Contents/Include/PolyImage.h

@@ -31,7 +31,7 @@ namespace Polycode {
 	/**
 	* An image in memory. Basic RGB or RGBA images stored in memory. Can be loaded from PNG files, created into textures and written to file.
 	*/
-	class _PolyExport Image {
+	class _PolyExport Image : public PolyBase {
 		public:
 		
 			/**

+ 1 - 1
Core/Contents/Include/PolyLogger.h

@@ -25,7 +25,7 @@ THE SOFTWARE.
 
 namespace Polycode {
 
-	class _PolyExport Logger {
+	class _PolyExport Logger : public PolyBase {
 		public:
 			Logger(){}
 			~Logger(){}

+ 1 - 1
Core/Contents/Include/PolyMaterialManager.h

@@ -41,7 +41,7 @@ namespace Polycode {
 	/**
 	* Manages loading and reloading of materials, textures and shaders. This class should be only accessed from the CoreServices singleton.
 	*/
-	class _PolyExport MaterialManager {
+	class _PolyExport MaterialManager : public PolyBase {
 		public:
 			MaterialManager();
 			~MaterialManager();

+ 1 - 1
Core/Contents/Include/PolyMatrix4.h

@@ -32,7 +32,7 @@ namespace Polycode {
 	/**
 	* 4x4 Matrix.
 	*/
-	class _PolyExport Matrix4 {
+	class _PolyExport Matrix4 : public PolyBase {
 	
 		public:
 			Matrix4();

+ 4 - 4
Core/Contents/Include/PolyMesh.h

@@ -31,13 +31,13 @@ namespace Polycode {
 	
 	class String;
 
-	class _PolyExport VertexSorter {
+	class _PolyExport VertexSorter : public PolyBase {
 		public:
 			Vertex *target;
 			bool operator() (Vertex *v1,Vertex *v2) { return (v1->distance(*target)<v2->distance(*target));}
 	};	
 	
-	class _PolyExport VertexBuffer {
+	class _PolyExport VertexBuffer : public PolyBase {
 		public:	
 			VertexBuffer(){}
 			virtual ~VertexBuffer(){}
@@ -54,7 +54,7 @@ namespace Polycode {
 	/**
 	* Render data array.
 	*/
-	class _PolyExport RenderDataArray {
+	class _PolyExport RenderDataArray : public PolyBase {
 	public:		
 		int arrayType;
 		int stride;
@@ -113,7 +113,7 @@ namespace Polycode {
 	/**
 	* A polygonal mesh. The mesh is assembled from Polygon instances, which in turn contain Vertex instances. This structure is provided for convenience and when the mesh is rendered, it is cached into vertex arrays with no notions of separate polygons. When data in the mesh changes, arrayDirtyMap must be set to true for the appropriate array types (color, position, normal, etc). Available types are defined in RenderDataArray.
 	*/
-	class _PolyExport Mesh {
+	class _PolyExport Mesh : public PolyBase {
 		public:
 		
 			

+ 1 - 1
Core/Contents/Include/PolyModule.h

@@ -21,7 +21,7 @@ namespace Polycode {
 	class ShaderBinding;
 	class Resource;
 	
-	class _PolyExport PolycodeModule {
+	class _PolyExport PolycodeModule : public PolyBase {
 	public:
 		PolycodeModule();
 		virtual ~PolycodeModule();

+ 4 - 4
Core/Contents/Include/PolyObject.h

@@ -32,7 +32,7 @@ namespace Polycode {
 	/**
 	* Single entry in an Object. Object entries can be accessed as dictionaries or arrays.
 	*/
-	class _PolyExport ObjectEntry {
+	class _PolyExport ObjectEntry : public PolyBase {
 	public:
 		
 		/**
@@ -211,7 +211,7 @@ namespace Polycode {
 	* Basic dictionary data object. Objects can store organized data and save and load it from disk. An object contains a hierarchy of ObjectEntry classes which hold the actual data.
 	*/
 	
-	class _PolyExport Object {
+	class _PolyExport Object : public PolyBase {
 	public:
 		/**
 		* Default constructor
@@ -263,7 +263,7 @@ namespace Polycode {
 		
 	};
 
-	class _PolyExport BinaryObjectReader {
+	class _PolyExport BinaryObjectReader : public PolyBase {
 		public:
 			BinaryObjectReader(const String& fileName, Object *object);
 			~BinaryObjectReader();			
@@ -282,7 +282,7 @@ namespace Polycode {
 
 	};
 		
-	class _PolyExport BinaryObjectWriter {
+	class _PolyExport BinaryObjectWriter : public PolyBase {
 		public:
 			BinaryObjectWriter(Object *object);
 			~BinaryObjectWriter();

+ 1 - 1
Core/Contents/Include/PolyParticle.h

@@ -31,7 +31,7 @@ namespace Polycode {
 	class Mesh;
 	class Texture;
 
-	class _PolyExport Particle {
+	class _PolyExport Particle : public PolyBase {
 		public:
 			Particle(int particleType, bool isScreenParticle, Material *material, Texture *texture, Mesh *particleMesh);
 			~Particle();

+ 1 - 1
Core/Contents/Include/PolyPerlin.h

@@ -31,7 +31,7 @@ namespace Polycode {
 /**
 * 2D Perlin noise.
 */ 
-class _PolyExport Perlin
+class _PolyExport Perlin : public PolyBase 
 {
 public:
 

+ 1 - 1
Core/Contents/Include/PolyPolygon.h

@@ -33,7 +33,7 @@ namespace Polycode {
 	/**
 	* A polygon structure.
 	*/ 
-	class _PolyExport Polygon {
+	class _PolyExport Polygon : public PolyBase {
 	
 		public:
 			/**

+ 1 - 1
Core/Contents/Include/PolyQuaternion.h

@@ -30,7 +30,7 @@ namespace Polycode {
 	/**
 	* Rotation quaternion.
 	*/
-	class _PolyExport Quaternion {
+	class _PolyExport Quaternion : public PolyBase {
 		public:
 		
 			/**

+ 1 - 1
Core/Contents/Include/PolyQuaternionCurve.h

@@ -36,7 +36,7 @@ namespace Polycode {
 		Quaternion q3;		
 	};	
 
-	class _PolyExport QuaternionCurve {
+	class _PolyExport QuaternionCurve : public PolyBase {
 		public:
 			QuaternionCurve(BezierCurve *wCurve, BezierCurve *xCurve, BezierCurve *yCurve, BezierCurve *zCurve);
 			virtual ~QuaternionCurve();

+ 1 - 1
Core/Contents/Include/PolyRectangle.h

@@ -28,7 +28,7 @@ namespace Polycode {
 	/**
 	* Basic rectangle.
 	*/
-	class _PolyExport Rectangle {
+	class _PolyExport Rectangle : public PolyBase {
 		public:
 			/**
 			* Default constructor.

+ 3 - 3
Core/Contents/Include/PolyRenderer.h

@@ -42,7 +42,7 @@ namespace Polycode {
 	class Texture;
 	class VertexBuffer;
 
-	class _PolyExport LightInfo {
+	class _PolyExport LightInfo : public PolyBase {
 		public:
 			Vector3 position;
 			Vector3 color;
@@ -61,7 +61,7 @@ namespace Polycode {
 			int lightImportance;
 	};
 
-	class _PolyExport LightSorter {
+	class _PolyExport LightSorter : public PolyBase {
 		public:
 			Vector3 basePosition;
 			Matrix4 cameraMatrix;
@@ -77,7 +77,7 @@ namespace Polycode {
 	/**
 	* Main renderer. The renderer should only be accessed from the CoreServices singleton. Renderer operations should only be called from within Render methods of entities so that they can be properly managed.
 	*/
-	class _PolyExport Renderer {
+	class _PolyExport Renderer : public PolyBase {
 	public:
 		Renderer();
 		virtual ~Renderer();

+ 1 - 1
Core/Contents/Include/PolyResource.h

@@ -30,7 +30,7 @@ namespace Polycode {
 	/**
 	* Base class for resources. All resources that are managed by the ResourceManager subclass this.
 	*/
-	class _PolyExport Resource {
+	class _PolyExport Resource : public PolyBase {
 		public:
 					
 			// ----------------------------------------------------------------------------------------------------------------

+ 1 - 1
Core/Contents/Include/PolyResourceManager.h

@@ -34,7 +34,7 @@ namespace Polycode {
 	/**
 	* Manages loading and unloading of resources from directories and archives. Should only be accessed via the CoreServices singleton. 
 	*/ 
-	class _PolyExport ResourceManager {
+	class _PolyExport ResourceManager : public PolyBase {
 		public:
 			ResourceManager();
 			~ResourceManager();

+ 1 - 1
Core/Contents/Include/PolySceneEntity.h

@@ -30,7 +30,7 @@ namespace Polycode {
 	* 3D base entity. SceneEntities are the base class for all 3D entities in Polycode. A thin wrapper around Entity, it inherits most of its functionality.
 	@see Entity
 	*/
-	class _PolyExport SceneEntity : public Entity, public EventDispatcher {
+	class _PolyExport SceneEntity : public Entity {
 		public:
 			SceneEntity();
 			virtual ~SceneEntity();

+ 1 - 1
Core/Contents/Include/PolySceneManager.h

@@ -30,7 +30,7 @@ namespace Polycode {
 	class Scene;
 	class SceneRenderTexture;
 	
-	class _PolyExport SceneManager {
+	class _PolyExport SceneManager : public PolyBase {
 		public:
 		SceneManager();
 		~SceneManager();

+ 1 - 1
Core/Contents/Include/PolySceneRenderTexture.h

@@ -32,7 +32,7 @@ namespace Polycode {
 	/**
 	* Renders scenes to texture. This class automatically renders a scene to a texture every frame that you can use to texture anything else. You can set a scene to virtual (see Scene for details) to only render a scene to a texture if you need to. This class automatically adds itself to the render cycle, so you do not need to do anything manual every frame.
 	*/
-	class _PolyExport SceneRenderTexture {
+	class _PolyExport SceneRenderTexture : public PolyBase {
 		public:
 			/**
 			* Construct a new render texture with parameters.

+ 1 - 1
Core/Contents/Include/PolyScreenEntity.h

@@ -42,7 +42,7 @@ namespace Polycode {
 /**
 * 2D Entity base. The ScreenEntity is the base class for all 2D elements in Polycode. They can be added to a screen or to other ScreenEntities and are rendered automatically. If you want to create custom screen objects, subclass this. ScreenEntity subclasses Entity, which use 3d positioning and tranformation, but provides some 2d-only versions of the transformation functions for convenience.
 */
-class _PolyExport ScreenEntity : public Entity, public EventDispatcher {
+class _PolyExport ScreenEntity : public Entity {
 		
 	public:
 		using Entity::setPosition;		

+ 4 - 4
Core/Contents/Include/PolyShader.h

@@ -85,7 +85,7 @@ namespace Polycode {
 			int type;
 	};
 	
-	class _PolyExport ShaderRenderTarget {
+	class _PolyExport ShaderRenderTarget : public PolyBase {
 		public:
 			String id;
 			Number width;
@@ -98,13 +98,13 @@ namespace Polycode {
 			static const int SIZE_MODE_NORMALIZED = 1;
 	};
 	
-	class LocalShaderParam {
+	class LocalShaderParam : public PolyBase {
 		public:	
 			String name;
 			void *data;
 	};	
 	
-	class RenderTargetBinding {
+	class RenderTargetBinding : public PolyBase {
 		public:
 			String id;
 			String name;
@@ -116,7 +116,7 @@ namespace Polycode {
 			static const int MODE_OUT = 1;
 	};
 
-	class _PolyExport ShaderBinding {
+	class _PolyExport ShaderBinding : public PolyBase {
 		public:
 			ShaderBinding(Shader *shader);
 			virtual ~ShaderBinding();

+ 2 - 2
Core/Contents/Include/PolySkeleton.h

@@ -37,7 +37,7 @@ namespace Polycode {
 	class QuaternionTween;
 	class BezierPathTween;
 	
-	class _PolyExport BoneTrack {
+	class _PolyExport BoneTrack : public PolyBase {
 		public:
 			BoneTrack(Bone *bone, Number length);
 			~BoneTrack();
@@ -90,7 +90,7 @@ namespace Polycode {
 	/**
 	* Skeleton animation.
 	*/ 
-	class _PolyExport SkeletonAnimation {
+	class _PolyExport SkeletonAnimation : public PolyBase {
 		public:
 		
 			SkeletonAnimation(const String& name, Number duration);

+ 1 - 1
Core/Contents/Include/PolySound.h

@@ -45,7 +45,7 @@ namespace Polycode {
 	/**
 	* Loads and plays a sound. This class can load and play an OGG or WAV sound file.
 	*/
-	class _PolyExport Sound {
+	class _PolyExport Sound : public PolyBase {
 	public:
 	
 		/**

+ 1 - 1
Core/Contents/Include/PolySoundManager.h

@@ -32,7 +32,7 @@ namespace Polycode {
 	/**
 	* Controls global sound settings.
 	*/
-	class _PolyExport SoundManager {
+	class _PolyExport SoundManager : public PolyBase{
 	public:
 		SoundManager();
 		~SoundManager();

+ 1 - 1
Core/Contents/Include/PolyString.h

@@ -39,7 +39,7 @@ namespace Polycode {
 	/**
 	* Unicode-friendly string. The Polycode String class wraps around STL wstring to support Unicode text in the engine. You can request data from it in different encodings (currently only UTF-8) or plain char data. It is mostly just a wrapper around STL created for easier Unicode support, LUA bindings and convenience methods.
 	*/
-	class _PolyExport String {
+	class _PolyExport String : public PolyBase {
 		public:
 		
 			/**

+ 1 - 1
Core/Contents/Include/PolyTimerManager.h

@@ -28,7 +28,7 @@ namespace Polycode {
 
 	class Timer;
 
-	class _PolyExport TimerManager {
+	class _PolyExport TimerManager : public PolyBase{
 		public:
 		TimerManager();
 		~TimerManager();

+ 1 - 1
Core/Contents/Include/PolyTweenManager.h

@@ -28,7 +28,7 @@ namespace Polycode {
 
 	class Tween;
 
-	class _PolyExport TweenManager {
+	class _PolyExport TweenManager : public PolyBase {
 		public:
 			TweenManager();
 			~TweenManager();

+ 1 - 1
Core/Contents/Include/PolyVector2.h

@@ -30,7 +30,7 @@ namespace Polycode {
 	/**
 	* 2D Vector (convenience wrapper around Vector3). 
 	*/
-	class _PolyExport Vector2 {
+	class _PolyExport Vector2 : public PolyBase {
 		public:
 				
 			/**

+ 1 - 1
Core/Contents/Include/PolyVector3.h

@@ -33,7 +33,7 @@ namespace Polycode {
 	/**
 	* 3D Vector class. 
 	*/
-	class _PolyExport Vector3 {
+	class _PolyExport Vector3 : public PolyBase {
 		public:
 		
 			/**

+ 1 - 0
Core/Contents/Include/Polycode.h

@@ -94,6 +94,7 @@
 #include "PolyServer.h"
 #include "PolyServerWorld.h"
 #include "PolySocket.h"
+#include "PolyGlobals.h"
 
 #ifdef _WINDOWS
 #include "PolyWinCore.h"

+ 1 - 1
Core/Contents/Source/PolyEntity.cpp

@@ -30,7 +30,7 @@ Rotation::Rotation() {
 	roll = 0;		
 }
 
-Entity::Entity() {
+Entity::Entity() : EventDispatcher() {
 	userData = NULL;
 	scale.set(1,1,1);
 	renderer = NULL;

+ 1 - 1
Core/Contents/Source/PolySceneEntity.cpp

@@ -24,7 +24,7 @@
 
 using namespace Polycode;
 
-SceneEntity::SceneEntity() : EventDispatcher(), Entity() {
+SceneEntity::SceneEntity() : Entity() {
 	castShadows = true;
 }
 

+ 1 - 1
Core/Contents/Source/PolyScreenEntity.cpp

@@ -33,7 +33,7 @@ inline double round(double x) { return floor(x + 0.5); }
 
 using namespace Polycode;
 
-ScreenEntity::ScreenEntity() : Entity(), EventDispatcher() {
+ScreenEntity::ScreenEntity() : Entity() {
 	color = Color(1.0f,1.0f,1.0f,1.0f);
 	width = 1;
 	height = 1;