Anton Golov avatar Anton Golov committed 04d81d2

Made clReflectUtil compile.

Comments (0)

Files changed (14)

inc/clcpp/Containers.h

 	private:
 		bool m_Initialised;
 	};
-}
+}

inc/clcpp/PlatformSpecificHacks.h

 #endif
 
 #ifdef _WIN32
+#define WITH_CDECL __cdecl
+#else
+#define WITH_CDECL __attribute__((cdecl))
+#endif
+
+#ifdef _WIN32
 #define DECLARE_NAKED __declspec(naked)
 #else
 	// GCC provides a naked attribute, but it is ignored on many platforms.

inc/clcpp/clcpp.h

 
 //
 // Export function signature
+// Don't export on anything but Windows.
 //
+#ifdef _WIN32
 #define clcpp_export __declspec(dllexport)
+#else
+#define clcpp_export
+#endif
 
 
 

inc/clutl/Module.h

 
 #pragma once
 
+#include <clcpp/clcpp.h>
+
 
 namespace clcpp
 {
 		// Module database
 		const clcpp::Database* m_ReflectionDB;
 	};
-}
+}

inc/clutl/Serialise.h

 
 
 #include <clcpp/clcpp.h>
+#include <clcpp/PlatformSpecificHacks.h>
 
 
 clcpp_reflect_part(clutl)
 			union
 			{
 				const char* string;
-				__int64 integer;
+				clcpp::Int64 integer;
 				double decimal;
 			};
 		} val;
 	// JSON serialisation
 	JSONError LoadJSON(ReadBuffer& in, void* object, const clcpp::Type* type);
 	void SaveJSON(WriteBuffer& out, const void* object, const clcpp::Type* type, unsigned int flags = 0);
-}
+}

src/CMakeLists.txt

 add_subdirectory(clReflectExport)
 add_subdirectory(clReflectMerge)
 add_subdirectory(clReflectScan)
-add_subdirectory(clReflectTest)
+add_subdirectory(clReflectUtil)
+add_subdirectory(clReflectTest)

src/clReflectCpp/CMakeLists.txt

 project(clReflectCpp)
 add_clreflect_library(clReflectCpp
   Core.cpp
+  Containers.cpp
   Database.cpp
   DatabaseLoader.cpp
   )

src/clReflectTest/CMakeLists.txt

 add_clreflect_executable(clReflectTest
   Main.cpp
   Test.cpp
+  TestArrays.cpp
   TestAttributes.cpp
   TestClassImpl.cpp
   TestCollections.cpp
   TestReflectionSpecs.cpp
+  TestSerialise.cpp
+  TestSerialiseJSON.cpp
   TestTemplates.cpp
+  TestTypedefs.cpp
+  TestOffsets.cpp
   )
 
 target_link_libraries(clReflectTest
   clReflectCore
   clReflectCpp
-  )
+  clReflectUtil
+  )

src/clReflectTest/TestArrays.cpp

 	{
 		const clcpp::Field* field = type->fields[i];
 
-		clcpp::WriteIterator writer(field, (char*)&s + field->offset);
+		clcpp::WriteIterator writer;
+		writer.Initialise(field, (char*)&s + field->offset);
 		for (unsigned int j = 0; j < writer.m_Count; j++)
 		{
 			void* value_ptr = writer.AddEmpty();
 			reader.MoveNext();
 		}
 	}
-}
+}

src/clReflectTest/TestOffsets.cpp

 
 #include <clcpp/clcpp.h>
+#include <clcpp/PlatformSpecificHacks.h>
 #include <string.h>
 #include <stdio.h>
 
 
 // Different from the classic offsetoff macro in that it produces reproduceable behaviour per platform/compiler
 // This allows me to measure offsets with virtual inheritance without the compiler crashing!
+// Can't be called offsetof because that's a macro name.
 template <typename CLASS_TYPE, typename FIELD_TYPE>
-int offsetof(FIELD_TYPE (CLASS_TYPE::*field))
+int offsetof_func(FIELD_TYPE (CLASS_TYPE::*field))
 {
 	CLASS_TYPE object;
 	return (char*)&(object.*field) - (char*)&object;
 	void Test(const char* field_name, FIELD_TYPE (CLASS_TYPE::*field_data))
 	{
 		//int native_offset = (int)&(((CLASS_TYPE*)0)->*field_data);
-		int native_offset = offsetof(field_data);
+		int native_offset = offsetof_func(field_data);
 		if (m_Class)
 		{
 			// Compare offsets and print the results
 	{
 		virtual void Empty() { }
 		int a;
-		__int64 b;
+		clcpp::Int64 b;
 		TESTS(Int64InPolymorphicStruct, a, b)
 	};
 
 	Offsets::I::Test(db);
 	Offsets::J::Test(db);
 	Offsets::K::Test(db);
-}
+}

src/clReflectTest/TestSerialise.cpp

 
 #include <clcpp/clcpp.h>
+#include <clcpp/PlatformSpecificHacks.h>
 #include <clutl/Serialise.h>
 
 

src/clReflectTest/TestSerialiseJSON.cpp

 
 #include <clcpp/clcpp.h>
+#include <clcpp/PlatformSpecificHacks.h>
 #include <clutl/Serialise.h>
 
 #include <stdio.h>
 		long f11;
 		long f12;
 
-		__int64 f13;
-		__int64 f14;
-		__int64 f15;
+		clcpp::Int64 f13;
+		clcpp::Int64 f14;
+		clcpp::Int64 f15;
 
 		float f16;
 		float f17;
 		unsigned short f27;
 		unsigned int f28;
 		unsigned long f29;
-		unsigned __int64 f30;
+		clcpp::UInt64 f30;
 
 		Value e0;
 		Value e1;
 		printf("STRUCT PASS!\n");
 	else
 		printf("STRUCT FAIL!\n");
-}
+}

src/clReflectUtil/Serialise.cpp

 //
 
 #include <clutl/Serialise.h>
+#include <clcpp/PlatformSpecificHacks.h>
 
 
 // Explicit dependency
 // TODO: Some how remove the need for this or provide a means of locating it on the target platform
-extern "C" void* __cdecl memcpy(void* dst, const void* src, unsigned int size);
+extern "C" void* WITH_CDECL memcpy(void* dst, const void* src, unsigned int size);
 
 
 clutl::WriteBuffer::WriteBuffer()

src/clReflectUtil/SerialiseJSON.cpp

 #include <clutl/Objects.h>
 #include <clcpp/Containers.h>
 #include <clcpp/FunctionCall.h>
+#include <clcpp/PlatformSpecificHacks.h>
 
 
 // Pointers are serialised in hash values in hexadecimal format, which isn't compliant with
 	//
 	// This will return an integer in the range [-9,223,372,036,854,775,808:9,223,372,036,854,775,807]
 	//
-	bool LexerInteger(Context& ctx, unsigned __int64& uintval)
+	bool LexerInteger(Context& ctx, clcpp::UInt64& uintval)
 	{
 		// Consume the first digit
 		if (ctx.ReadOverflows(0))
 
 	clutl::JSONToken LexerHexInteger(Context& ctx, clutl::JSONToken& token)
 	{
-		unsigned __int64& uintval = (unsigned __int64&)token.val.integer;
+		clcpp::UInt64& uintval = (clcpp::UInt64&)token.val.integer;
 
 		// Consume the first digit
 		if (ctx.ReadOverflows(0))
 		{
 			// Consume and accumulate the digit
 			ctx.ConsumeChar();
-			unsigned __int64 digit = 0;
+			clcpp::UInt64 digit = 0;
 			if (c < 'A')
 				digit = c - '0';
 			else
 		clutl::JSONToken token(clutl::JSON_TOKEN_INTEGER, 0);
 
 		// Is this a hex integer?
-		unsigned __int64 uintval;
+		clcpp::UInt64 uintval;
 		if (ctx.PeekChar() == '0')
 		{
 			if (ctx.ReadOverflows(1))
 
 
 	typedef void (*SaveNumberFunc)(clutl::WriteBuffer&, const char*, unsigned int flags);
-	typedef void (*LoadIntegerFunc)(char*, __int64);
+	typedef void (*LoadIntegerFunc)(char*, clcpp::Int64);
 	typedef void (*LoadDecimalFunc)(char*, double);
 
 
 
 
 	template <typename TYPE>
-	void LoadIntegerWithCast(char* dest, __int64 integer)
+	void LoadIntegerWithCast(char* dest, clcpp::Int64 integer)
 	{
 		*(TYPE*)dest = (TYPE)integer;
 	}
-	void LoadIntegerBool(char* dest, __int64 integer)
+	void LoadIntegerBool(char* dest, clcpp::Int64 integer)
 	{
 		*(bool*)dest = integer != 0;
 	}
 	}
 
 
-	void LoadInteger(Context& ctx, __int64 integer, char* object, const clcpp::Type* type, clcpp::Qualifier::Operator op)
+	void LoadInteger(Context& ctx, clcpp::Int64 integer, char* object, const clcpp::Type* type, clcpp::Qualifier::Operator op)
 	{
 		if (type == 0)
 			return;
 	}
 
 
-	void SaveInteger(clutl::WriteBuffer& out, __int64 integer)
+	void SaveInteger(clutl::WriteBuffer& out, clcpp::Int64 integer)
 	{
 		// Enough to store a 64-bit int
 		static const int MAX_SZ = 20;
 		// Loop through the value with radix 10
 		do 
 		{
-			__int64 next_integer = integer / 10;
+			clcpp::Int64 next_integer = integer / 10;
 			*--tptr = char('0' + (integer - next_integer * 10));
 			integer = next_integer;
 		} while (integer);
 	}
 
 
-	void SaveUnsignedInteger(clutl::WriteBuffer& out, unsigned __int64 integer)
+	void SaveUnsignedInteger(clutl::WriteBuffer& out, clcpp::UInt64 integer)
 	{
 		// Enough to store a 64-bit int + null
 		static const int MAX_SZ = 21;
 		// Loop through the value with radix 10
 		do 
 		{
-			unsigned __int64 next_integer = integer / 10;
+			clcpp::UInt64 next_integer = integer / 10;
 			*--tptr = char('0' + (integer - next_integer * 10));
 			integer = next_integer;
 		} while (integer);
 	}
 
 
-	void SaveHexInteger(clutl::WriteBuffer& out, unsigned __int64 integer)
+	void SaveHexInteger(clutl::WriteBuffer& out, clcpp::UInt64 integer)
 	{
 		// Enough to store a 64-bit int + null
 		static const int MAX_SZ = 21;
 		// Loop through the value with radix 16
 		do 
 		{
-			unsigned __int64 next_integer = integer / 16;
+			clcpp::UInt64 next_integer = integer / 16;
 			*--tptr = "0123456789ABCDEF"[integer - next_integer * 16];
 			integer = next_integer;
 		} while (integer);
 		{
 			// Use a specific prefix to inform the lexer to alias as a decimal
 			out.WriteStr("0d");
-			SaveHexInteger(out, (unsigned __int64&)decimal);
+			SaveHexInteger(out, (clcpp::UInt64&)decimal);
 			return;
 		}
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.