Browse Source

Switched void* interface handles to uintptr_t for better cross platform compatibility.
Fixed 64bit support on MacOSX

Lloyd Weehuizen 15 years ago
parent
commit
9f0c9c9906

+ 3 - 3
Include/Rocket/Core/Types.h

@@ -81,10 +81,10 @@ class Element;
 class Dictionary;
 class Dictionary;
 
 
 // Types for external interfaces.
 // Types for external interfaces.
-typedef void* FileHandle;
+typedef uintptr_t FileHandle;
 typedef uintptr_t TextureHandle;
 typedef uintptr_t TextureHandle;
-typedef void* CompiledGeometryHandle;
-typedef void* DecoratorDataHandle;
+typedef uintptr_t CompiledGeometryHandle;
+typedef uintptr_t DecoratorDataHandle;
 
 
 // List of elements.
 // List of elements.
 typedef std::vector< Element* > ElementList;
 typedef std::vector< Element* > ElementList;

+ 1 - 1
Include/Rocket/Core/Variant.h

@@ -151,7 +151,7 @@ private:
 		Type type;
 		Type type;
 
 
 #ifdef ROCKET_ARCH_64
 #ifdef ROCKET_ARCH_64
-		static const int BUFFER_SIZE = 32;
+		static const int BUFFER_SIZE = 24; // Required for Strings
 #else
 #else
 		static const int BUFFER_SIZE = 16;
 		static const int BUFFER_SIZE = 16;
 #endif
 #endif

+ 3 - 3
Source/Core/DecoratorTiledBox.cpp

@@ -278,20 +278,20 @@ DecoratorDataHandle DecoratorTiledBox::GenerateElementData(Element* element)
 	while ((texture = GetTexture(texture_index)) != NULL)
 	while ((texture = GetTexture(texture_index)) != NULL)
 		data->geometry[texture_index++]->SetTexture(texture);
 		data->geometry[texture_index++]->SetTexture(texture);
 
 
-	return data;
+	return reinterpret_cast<DecoratorDataHandle>(data);
 }
 }
 
 
 // Called to release element data generated by this decorator.
 // Called to release element data generated by this decorator.
 void DecoratorTiledBox::ReleaseElementData(DecoratorDataHandle element_data)
 void DecoratorTiledBox::ReleaseElementData(DecoratorDataHandle element_data)
 {
 {
-	delete static_cast< DecoratorTiledBoxData* >(element_data);
+	delete reinterpret_cast< DecoratorTiledBoxData* >(element_data);
 }
 }
 
 
 // Called to render the decorator on an element.
 // Called to render the decorator on an element.
 void DecoratorTiledBox::RenderElement(Element* element, DecoratorDataHandle element_data)
 void DecoratorTiledBox::RenderElement(Element* element, DecoratorDataHandle element_data)
 {
 {
 	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
 	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
-	DecoratorTiledBoxData* data = static_cast< DecoratorTiledBoxData* >(element_data);
+	DecoratorTiledBoxData* data = reinterpret_cast< DecoratorTiledBoxData* >(element_data);
 
 
 	for (int i = 0; i < 9; i++)
 	for (int i = 0; i < 9; i++)
 		data->geometry[i]->Render(translation);
 		data->geometry[i]->Render(translation);

+ 3 - 3
Source/Core/DecoratorTiledHorizontal.cpp

@@ -137,20 +137,20 @@ DecoratorDataHandle DecoratorTiledHorizontal::GenerateElementData(Element* eleme
 	while ((texture = GetTexture(texture_index)) != NULL)
 	while ((texture = GetTexture(texture_index)) != NULL)
 		data->geometry[texture_index++]->SetTexture(texture);
 		data->geometry[texture_index++]->SetTexture(texture);
 
 
-	return data;
+	return reinterpret_cast<DecoratorDataHandle>(data);
 }
 }
 
 
 // Called to release element data generated by this decorator.
 // Called to release element data generated by this decorator.
 void DecoratorTiledHorizontal::ReleaseElementData(DecoratorDataHandle element_data)
 void DecoratorTiledHorizontal::ReleaseElementData(DecoratorDataHandle element_data)
 {
 {
-	delete static_cast< DecoratorTiledHorizontalData* >(element_data);
+	delete reinterpret_cast< DecoratorTiledHorizontalData* >(element_data);
 }
 }
 
 
 // Called to render the decorator on an element.
 // Called to render the decorator on an element.
 void DecoratorTiledHorizontal::RenderElement(Element* element, DecoratorDataHandle element_data)
 void DecoratorTiledHorizontal::RenderElement(Element* element, DecoratorDataHandle element_data)
 {
 {
 	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
 	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
-	DecoratorTiledHorizontalData* data = static_cast< DecoratorTiledHorizontalData* >(element_data);
+	DecoratorTiledHorizontalData* data = reinterpret_cast< DecoratorTiledHorizontalData* >(element_data);
 
 
 	for (int i = 0; i < 3; i++)
 	for (int i = 0; i < 3; i++)
 		data->geometry[i]->Render(translation);
 		data->geometry[i]->Render(translation);

+ 3 - 3
Source/Core/DecoratorTiledImage.cpp

@@ -66,19 +66,19 @@ DecoratorDataHandle DecoratorTiledImage::GenerateElementData(Element* element)
 	// Generate the geometry for the tile.
 	// Generate the geometry for the tile.
 	tile.GenerateGeometry(data->GetVertices(), data->GetIndices(), element, Vector2f(0, 0), element->GetBox().GetSize(Box::PADDING), tile.GetDimensions(element));
 	tile.GenerateGeometry(data->GetVertices(), data->GetIndices(), element, Vector2f(0, 0), element->GetBox().GetSize(Box::PADDING), tile.GetDimensions(element));
 
 
-	return data;
+	return reinterpret_cast<DecoratorDataHandle>(data);
 }
 }
 
 
 // Called to release element data generated by this decorator.
 // Called to release element data generated by this decorator.
 void DecoratorTiledImage::ReleaseElementData(DecoratorDataHandle element_data)
 void DecoratorTiledImage::ReleaseElementData(DecoratorDataHandle element_data)
 {
 {
-	delete static_cast< Geometry* >(element_data);
+	delete reinterpret_cast< Geometry* >(element_data);
 }
 }
 
 
 // Called to render the decorator on an element.
 // Called to render the decorator on an element.
 void DecoratorTiledImage::RenderElement(Element* element, DecoratorDataHandle element_data)
 void DecoratorTiledImage::RenderElement(Element* element, DecoratorDataHandle element_data)
 {
 {
-	Geometry* data = static_cast< Geometry* >(element_data);
+	Geometry* data = reinterpret_cast< Geometry* >(element_data);
 	data->Render(element->GetAbsoluteOffset(Box::PADDING));
 	data->Render(element->GetAbsoluteOffset(Box::PADDING));
 }
 }
 
 

+ 3 - 3
Source/Core/DecoratorTiledVertical.cpp

@@ -138,20 +138,20 @@ DecoratorDataHandle DecoratorTiledVertical::GenerateElementData(Element* element
 	while ((texture = GetTexture(texture_index)) != NULL)
 	while ((texture = GetTexture(texture_index)) != NULL)
 		data->geometry[texture_index++]->SetTexture(texture);
 		data->geometry[texture_index++]->SetTexture(texture);
 
 
-	return data;
+	return reinterpret_cast<DecoratorDataHandle>(data);
 }
 }
 
 
 // Called to release element data generated by this decorator.
 // Called to release element data generated by this decorator.
 void DecoratorTiledVertical::ReleaseElementData(DecoratorDataHandle element_data)
 void DecoratorTiledVertical::ReleaseElementData(DecoratorDataHandle element_data)
 {
 {
-	delete static_cast< DecoratorTiledVerticalData* >(element_data);
+	delete reinterpret_cast< DecoratorTiledVerticalData* >(element_data);
 }
 }
 
 
 // Called to render the decorator on an element.
 // Called to render the decorator on an element.
 void DecoratorTiledVertical::RenderElement(Element* element, DecoratorDataHandle element_data)
 void DecoratorTiledVertical::RenderElement(Element* element, DecoratorDataHandle element_data)
 {
 {
 	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
 	Vector2f translation = element->GetAbsoluteOffset(Box::PADDING);
-	DecoratorTiledVerticalData* data = static_cast< DecoratorTiledVerticalData* >(element_data);
+	DecoratorTiledVerticalData* data = reinterpret_cast< DecoratorTiledVerticalData* >(element_data);
 
 
 	for (int i = 0; i < 3; i++)
 	for (int i = 0; i < 3; i++)
 		data->geometry[i]->Render(translation);
 		data->geometry[i]->Render(translation);

+ 1 - 1
Source/Core/ElementDecoration.cpp

@@ -118,7 +118,7 @@ void ElementDecoration::ReleaseDecorators()
 {
 {
 	for (size_t i = 0; i < decorators.size(); i++)
 	for (size_t i = 0; i < decorators.size(); i++)
 	{
 	{
-		if (decorators[i].decorator_data != NULL)
+		if (decorators[i].decorator_data)
 			decorators[i].decorator->ReleaseElementData(decorators[i].decorator_data);
 			decorators[i].decorator->ReleaseElementData(decorators[i].decorator_data);
 
 
 		decorators[i].decorator->RemoveReference();
 		decorators[i].decorator->RemoveReference();

+ 2 - 2
Source/Core/FontFaceHandle.cpp

@@ -237,9 +237,9 @@ int FontFaceHandle::GenerateLayerConfiguration(FontEffectMap& font_effects)
 }
 }
 
 
 // Generates the texture data for a layer (for the texture database).
 // Generates the texture data for a layer (for the texture database).
-bool FontFaceHandle::GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, int layer_id, int texture_id)
+bool FontFaceHandle::GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id)
 {
 {
-	FontLayerMap::iterator layer_iterator = layers.find((const FontEffect*) layer_id);
+	FontLayerMap::iterator layer_iterator = layers.find(layer_id);
 	if (layer_iterator == layers.end())
 	if (layer_iterator == layers.end())
 		return false;
 		return false;
 
 

+ 1 - 1
Source/Core/FontFaceHandle.h

@@ -98,7 +98,7 @@ public:
 	/// @param[out] texture_dimensions The dimensions of the texture.
 	/// @param[out] texture_dimensions The dimensions of the texture.
 	/// @param[in] layer_id The id of the layer to request the texture data from.
 	/// @param[in] layer_id The id of the layer to request the texture data from.
 	/// @param[in] texture_id The index of the texture within the layer to generate.
 	/// @param[in] texture_id The index of the texture within the layer to generate.
-	bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, int layer_id, int texture_id);
+	bool GenerateLayerTexture(const byte*& texture_data, Vector2i& texture_dimensions, FontEffect* layer_id, int texture_id);
 
 
 	/// Generates the geometry required to render a single line of text.
 	/// Generates the geometry required to render a single line of text.
 	/// @param[out] geometry An array of geometries to generate the geometry into.
 	/// @param[out] geometry An array of geometries to generate the geometry into.

+ 1 - 1
Source/Core/FontFaceLayer.cpp

@@ -150,7 +150,7 @@ bool FontFaceLayer::Initialise(const FontFaceHandle* _handle, FontEffect* _effec
 		for (int i = 0; i < texture_layout.GetNumTextures(); ++i)
 		for (int i = 0; i < texture_layout.GetNumTextures(); ++i)
 		{
 		{
 			Texture texture;
 			Texture texture;
-			if (!texture.Load(String(64, "?font::%x/%x/%d", handle, effect, i)))
+			if (!texture.Load(String(64, "?font::%p/%p/%d", handle, effect, i)))
 				return false;
 				return false;
 
 
 			textures.push_back(texture);
 			textures.push_back(texture);

+ 3 - 8
Source/Core/Geometry.cpp

@@ -93,7 +93,7 @@ void Geometry::Render(const Vector2f& translation)
 		return;
 		return;
 
 
 	// Render our compiled geometry if possible.
 	// Render our compiled geometry if possible.
-	if (compiled_geometry != NULL)
+	if (compiled_geometry)
 	{
 	{
 		render_interface->RenderCompiledGeometry(compiled_geometry, translation);
 		render_interface->RenderCompiledGeometry(compiled_geometry, translation);
 	}
 	}
@@ -132,13 +132,8 @@ void Geometry::Render(const Vector2f& translation)
 
 
 			// If we managed to compile the geometry, we can clear the local copy of vertices and indices and
 			// If we managed to compile the geometry, we can clear the local copy of vertices and indices and
 			// immediately render the compiled version.
 			// immediately render the compiled version.
-			if (compiled_geometry != NULL)
+			if (compiled_geometry)
 			{	
 			{	
-/*				std::vector< Vertex > new_vertices;
-				std::vector< int > new_indices;
-				vertices.swap(new_vertices);
-				indices.swap(new_indices);*/
-
 				render_interface->RenderCompiledGeometry(compiled_geometry, translation);
 				render_interface->RenderCompiledGeometry(compiled_geometry, translation);
 				return;
 				return;
 			}
 			}
@@ -177,7 +172,7 @@ void Geometry::SetTexture(const Texture* _texture)
 
 
 void Geometry::Release(bool clear_buffers)
 void Geometry::Release(bool clear_buffers)
 {
 {
-	if (compiled_geometry != NULL)
+	if (compiled_geometry)
 	{
 	{
 		GetRenderInterface()->ReleaseCompiledGeometry(compiled_geometry);
 		GetRenderInterface()->ReleaseCompiledGeometry(compiled_geometry);
 		compiled_geometry = NULL;
 		compiled_geometry = NULL;

+ 3 - 3
Source/Core/StreamFile.cpp

@@ -41,7 +41,7 @@ StreamFile::StreamFile()
 
 
 StreamFile::~StreamFile()
 StreamFile::~StreamFile()
 {
 {
-	if (file_handle != NULL)
+	if (file_handle)
 		Close();
 		Close();
 }
 }
 
 
@@ -51,7 +51,7 @@ bool StreamFile::Open(const String& path)
 	String url_safe_path = path.Replace(":", "|");
 	String url_safe_path = path.Replace(":", "|");
 	SetStreamDetails(URL(url_safe_path), Stream::MODE_READ);
 	SetStreamDetails(URL(url_safe_path), Stream::MODE_READ);
 
 
-	if (file_handle != NULL)
+	if (file_handle)
 		Close();
 		Close();
 
 
 	// Fix the path if a leading colon has been replaced with a pipe.
 	// Fix the path if a leading colon has been replaced with a pipe.
@@ -71,7 +71,7 @@ bool StreamFile::Open(const String& path)
 // Closes the stream.
 // Closes the stream.
 void StreamFile::Close()
 void StreamFile::Close()
 {
 {
-	if (file_handle != NULL)
+	if (file_handle)
 	{
 	{
 		GetFileInterface()->Close(file_handle);
 		GetFileInterface()->Close(file_handle);
 		file_handle = NULL;
 		file_handle = NULL;

+ 8 - 7
Source/Core/TextureResource.cpp

@@ -130,16 +130,17 @@ bool TextureResource::Load(RenderInterface* render_interface) const
 		{
 		{
 			// The requested texture is a font layer.
 			// The requested texture is a font layer.
 			delete_data = true;
 			delete_data = true;
-
-			StringList parameters;
-			StringUtilities::ExpandString(parameters, source.Substring(source.Find("::") + 2), '/');
-			if (parameters.size() == 3)
+			
+			FontFaceHandle* handle;
+			FontEffect* layer_id;
+			int texture_id;
+			
+			if (sscanf(source.CString(), "?font::%p/%p/%d", &handle, &layer_id, &texture_id) == 3)
 			{
 			{
-				FontFaceHandle* handle = (FontFaceHandle*) strtol(parameters[0].CString(), NULL, 16);
 				handle->GenerateLayerTexture(data,
 				handle->GenerateLayerTexture(data,
 											 dimensions,
 											 dimensions,
-											 strtol(parameters[1].CString(), NULL, 16),
-											 atoi(parameters[2].CString()));
+											 layer_id,
+											 texture_id);
 			}
 			}
 		}
 		}
 
 

+ 5 - 14
Source/Core/Variant.cpp

@@ -36,11 +36,9 @@ Variant::Variant()
 	data_block = NULL;
 	data_block = NULL;
 	
 	
 	// Make sure our object size assumptions fit inside the static buffer
 	// Make sure our object size assumptions fit inside the static buffer
-	//ROCKET_STATIC_ASSERT(sizeof(Quaternion) <= 16, Invalid_Size_Quaternion);
-	//ROCKET_STATIC_ASSERT(sizeof(Vector4f) <= 16, Invalid_Size_Vector4f);
-	//ROCKET_STATIC_ASSERT(sizeof(Vector4i) <= 16, Invalid_Size_Vector4i);
-	ROCKET_STATIC_ASSERT(sizeof(Colourb) <= 16, Invalid_Size_Colourb);
-	ROCKET_STATIC_ASSERT(sizeof(Colourf) <= 16, Invalid_Size_Colourf);
+	ROCKET_STATIC_ASSERT(sizeof(String) <= DataBlock::BUFFER_SIZE, Invalid_Size_String);
+	ROCKET_STATIC_ASSERT(sizeof(Colourb) <= DataBlock::BUFFER_SIZE, Invalid_Size_Colourb);
+	ROCKET_STATIC_ASSERT(sizeof(Colourf) <= DataBlock::BUFFER_SIZE, Invalid_Size_Colourf);
 }
 }
 
 
 Variant::Variant( const Variant& copy )
 Variant::Variant( const Variant& copy )
@@ -105,12 +103,6 @@ void Variant::Set(const int value)
 	SET_VARIANT(int);
 	SET_VARIANT(int);
 }
 }
 
 
-/*void Variant::Set(const Quaternion& value) 
-{
-	NewDataBlock(QUATERNION);
-	SET_VARIANT(Quaternion);  
-}*/
-
 void Variant::Set(const String& value) {
 void Variant::Set(const String& value) {
 	NewDataBlock(STRING);
 	NewDataBlock(STRING);
 	((String*) data_block->data_ptr)->Assign( value );
 	((String*) data_block->data_ptr)->Assign( value );
@@ -177,10 +169,9 @@ void Variant::NewDataBlock(Type type)
 	{
 	{
 		ReleaseDataBlock();
 		ReleaseDataBlock();
 		data_block = new DataBlock();
 		data_block = new DataBlock();
-
-		if (type == STRING)
-			new(data_block->data_ptr) String();
 	}
 	}
+	if (data_block->type != STRING || type == STRING)
+		new(data_block->data_ptr) String();
 
 
 	data_block->type = type;
 	data_block->type = type;
 }
 }