[Date Prev][Date Next][Thread Prev][Thread Next][Thread Index]

[XaraXtreme-commits] Commit Complete



Commit by  : phil
Repository : xara
Revision   : 1670
Date       : Fri Aug  4 15:46:48 BST 2006

Changed paths:
   M /Trunk/XaraLX/Kernel/cxfile.cpp
   M /Trunk/XaraLX/Kernel/cxfrec.cpp
   M /Trunk/XaraLX/wxOil/hardwaremanager.h

Commented out stab at dealing with byte order issues when importing and exporting floats and doubles in XAR format - placeholder code for further development


Diff:
Index: Trunk/XaraLX/Kernel/cxfile.cpp
===================================================================
--- Trunk/XaraLX/Kernel/cxfile.cpp	(revision 1669)
+++ Trunk/XaraLX/Kernel/cxfile.cpp	(revision 1670)
@@ -889,12 +889,16 @@
 
 BOOL CXaraFile::Read(FLOAT* pf)
 {
-	return (Read((BYTE*)pf,sizeof(FLOAT)));
+	BOOL ok = (Read((BYTE*)pf,sizeof(FLOAT)));
+	*pf = LEtoNative(*pf);
+	return ok;
 }
 
 BOOL CXaraFile::Read(double* pd)
 {
-	return (Read((BYTE*)pd,sizeof(double)));
+	BOOL ok = (Read((BYTE*)pd,sizeof(double)));
+	*pd = LEtoNative(*pd);
+	return ok;
 }
 
 BOOL CXaraFile::ReadWCHAR(WCHAR *pw)
Index: Trunk/XaraLX/Kernel/cxfrec.cpp
===================================================================
--- Trunk/XaraLX/Kernel/cxfrec.cpp	(revision 1669)
+++ Trunk/XaraLX/Kernel/cxfrec.cpp	(revision 1670)
@@ -1321,17 +1321,23 @@
 
 BOOL CXaraFileRecord::ReadFLOAT(FLOAT* pf)
 {
-	return ReadBuffer((BYTE*)pf,sizeof(FLOAT));
+	BOOL ok = ReadBuffer((BYTE*)pf,sizeof(FLOAT));
+	*pf = LEtoNative(*pf);
+	return ok;
 }
 
 BOOL CXaraFileRecord::ReadDOUBLE(double* pd)
 {
-	return ReadBuffer((BYTE*)pd,sizeof(double));
+	BOOL ok = ReadBuffer((BYTE*)pd,sizeof(double));
+	*pd = LEtoNative(*pd);
+	return ok;
 }
 
 BOOL CXaraFileRecord::ReadDOUBLEnoError(double* pd)
 {
-	return ReadBuffernoError((BYTE*)pd,sizeof(double));
+	BOOL ok = ReadBuffernoError((BYTE*)pd,sizeof(double));
+	*pd = LEtoNative(*pd);
+	return ok;
 }
 
 BOOL CXaraFileRecord::ReadWCHAR(WCHAR *pw)
Index: Trunk/XaraLX/wxOil/hardwaremanager.h
===================================================================
--- Trunk/XaraLX/wxOil/hardwaremanager.h	(revision 1669)
+++ Trunk/XaraLX/wxOil/hardwaremanager.h	(revision 1670)
@@ -158,6 +158,16 @@
 	static inline FIXED16 NativetoBE(FIXED16 n) {return n;}
 	static inline FIXED16 NativetoLE(FIXED16 n) {return FIXED16::FromRawLong(wxINT32_SWAP_ALWAYS(n.GetRawLong()));}
 
+	static inline float BEtoNative(float n) {return n;}
+	static inline float LEtoNative(float n) {return n;} //{return reinterpret_cast<float>(wxINT32_SWAP_ALWAYS(reinterpret_cast<INT32>(n)));}
+	static inline float NativetoBE(float n) {return n;}
+	static inline float NativetoLE(float n) {return n;} //{return reinterpret_cast<float>(wxINT32_SWAP_ALWAYS(reinterpret_cast<INT32>(n)));}
+
+	static inline double BEtoNative(double n) {return n;}
+	static inline double LEtoNative(double n) {return n;} //{return reinterpret_cast<double>(wxINT64_SWAP_ALWAYS(reinterpret_cast<INT64>(n)));}
+	static inline double NativetoBE(double n) {return n;}
+	static inline double NativetoLE(double n) {return n;} //{return reinterpret_cast<double>(wxINT64_SWAP_ALWAYS(reinterpret_cast<INT64>(n)));}
+
 #else
 	// __LITTLE_ENDIAN__
 	// Little-Endian, signed
@@ -200,6 +210,16 @@
 	static inline FIXED16 NativetoBE(FIXED16 n) {return FIXED16::FromRawLong(wxINT32_SWAP_ALWAYS(n.GetRawLong()));}
 	static inline FIXED16 NativetoLE(FIXED16 n) {return n;}
 
+	static inline float BEtoNative(float n) {return n;} //{return reinterpret_cast<float>(wxINT32_SWAP_ALWAYS(reinterpret_cast<INT32>(n)));}
+	static inline float LEtoNative(float n) {return n;}
+	static inline float NativetoBE(float n) {return n;} //{return reinterpret_cast<float>(wxINT32_SWAP_ALWAYS(reinterpret_cast<INT32>(n)));}
+	static inline float NativetoLE(float n) {return n;}
+
+	static inline double BEtoNative(double n) {return n;} //{return reinterpret_cast<double>(wxINT64_SWAP_ALWAYS(reinterpret_cast<INT64>(n)));}
+	static inline double LEtoNative(double n) {return n;}
+	static inline double NativetoBE(double n) {return n;} //{return reinterpret_cast<double>(wxINT64_SWAP_ALWAYS(reinterpret_cast<INT64>(n)));}
+	static inline double NativetoLE(double n) {return n;}
+
 #endif
 
 // -------------------------------------------------------------------------------


Xara