summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorTycho <work.tycho+git@gmail.com>2014-06-14 18:19:28 +0200
committerTycho <work.tycho+git@gmail.com>2014-06-14 18:19:28 +0200
commit039c1a75f391b078f2b27a388e73bb203afed58e (patch)
treef4f213b794eb0c3a2713358c3d5bdd3f0b931486 /tests
parentFixed bad merge (diff)
parentMerge pull request #1093 from mc-server/BindingsFix (diff)
downloadcuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar
cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.gz
cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.bz2
cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.lz
cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.xz
cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.tar.zst
cuberite-039c1a75f391b078f2b27a388e73bb203afed58e.zip
Diffstat (limited to 'tests')
-rw-r--r--tests/ChunkData/ArraytoCoord.cpp79
-rw-r--r--tests/ChunkData/CMakeLists.txt5
-rw-r--r--tests/ChunkData/Coordinates.cpp10
-rw-r--r--tests/ChunkData/Copies.cpp68
-rw-r--r--tests/ChunkData/CopyBlocks.cpp76
-rw-r--r--tests/ChunkData/creatable.cpp2
-rw-r--r--tests/TestGlobals.h139
7 files changed, 161 insertions, 218 deletions
diff --git a/tests/ChunkData/ArraytoCoord.cpp b/tests/ChunkData/ArraytoCoord.cpp
index f800d8e05..80bcc5283 100644
--- a/tests/ChunkData/ArraytoCoord.cpp
+++ b/tests/ChunkData/ArraytoCoord.cpp
@@ -1,5 +1,5 @@
-#include "TestGlobals.h"
+#include "Globals.h"
#include "ChunkData.h"
@@ -20,26 +20,26 @@ int main(int argc, char** argv)
cChunkData buffer(Pool);
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
- memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- SrcBlockBuffer[7 + (4 * 16) + (5 * 16 * 16)] = 0xCD;
- buffer.SetBlocks(SrcBlockBuffer);
- testassert(buffer.GetBlock(7,5,4) == 0xCD);
+ memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer));
+ SrcBlockBuffer[7 + (4 * 16) + (5 * 16 * 16)] = 0xcd;
+ buffer.SetBlockTypes(SrcBlockBuffer);
+ testassert(buffer.GetBlock(7, 5, 4) == 0xcd);
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
- SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
- buffer.SetMeta(SrcNibbleBuffer);
- testassert(buffer.GetMeta(6, 2, 1) == 0xE);
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
+ SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xe;
+ buffer.SetMetas(SrcNibbleBuffer);
+ testassert(buffer.GetMeta(6, 2, 1) == 0xe);
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
- SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
+ SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xe;
buffer.SetBlockLight(SrcNibbleBuffer);
- testassert(buffer.GetBlockLight(6, 2, 1) == 0xE);
+ testassert(buffer.GetBlockLight(6, 2, 1) == 0xe);
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
- SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xE;
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
+ SrcNibbleBuffer[(6 + (1 * 16) + (2 * 16 * 16)) / 2] = 0xe;
buffer.SetSkyLight(SrcNibbleBuffer);
- testassert(buffer.GetSkyLight(6, 2, 1) == 0xE);
+ testassert(buffer.GetSkyLight(6, 2, 1) == 0xe);
}
{
@@ -47,26 +47,26 @@ int main(int argc, char** argv)
cChunkData buffer(Pool);
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
- memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- SrcBlockBuffer[7 + (4 * 16) + (24 * 16 * 16)] = 0xCD;
- buffer.SetBlocks(SrcBlockBuffer);
- testassert(buffer.GetBlock(7, 24, 4) == 0xCD);
+ memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer));
+ SrcBlockBuffer[7 + (4 * 16) + (24 * 16 * 16)] = 0xcd;
+ buffer.SetBlockTypes(SrcBlockBuffer);
+ testassert(buffer.GetBlock(7, 24, 4) == 0xcd);
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
- SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xE;
- buffer.SetMeta(SrcNibbleBuffer);
- testassert(buffer.GetMeta(6, 24, 1) == 0xE);
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
+ SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xe;
+ buffer.SetMetas(SrcNibbleBuffer);
+ testassert(buffer.GetMeta(6, 24, 1) == 0xe);
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- SrcNibbleBuffer[(6+1*16+24*16*16)/2] = 0xE;
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
+ SrcNibbleBuffer[(6 + 1 * 16 + 24 * 16 * 16) / 2] = 0xe;
buffer.SetBlockLight(SrcNibbleBuffer);
- testassert(buffer.GetBlockLight(6,24,1) == 0xE);
+ testassert(buffer.GetBlockLight(6, 24, 1) == 0xe);
- memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
- SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16))/2] = 0xE;
+ memset(SrcNibbleBuffer, 0xff, sizeof(SrcNibbleBuffer));
+ SrcNibbleBuffer[(6 + (1 * 16) + (24 * 16 * 16)) / 2] = 0xe;
buffer.SetSkyLight(SrcNibbleBuffer);
- testassert(buffer.GetSkyLight(6, 24, 1) == 0xE);
+ testassert(buffer.GetSkyLight(6, 24, 1) == 0xe);
}
{
@@ -74,22 +74,25 @@ int main(int argc, char** argv)
cChunkData buffer(Pool);
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
- memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- buffer.SetBlocks(SrcBlockBuffer);
+ memset(SrcBlockBuffer, 0x00, sizeof(SrcBlockBuffer));
+ buffer.SetBlockTypes(SrcBlockBuffer);
testassert(buffer.GetBlock(7, 24, 4) == 0x00);
- NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256/2];
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- buffer.SetMeta(SrcNibbleBuffer);
+ NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
+ buffer.SetMetas(SrcNibbleBuffer);
testassert(buffer.GetMeta(6, 24, 1) == 0x0);
- memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
+ memset(SrcNibbleBuffer, 0x00, sizeof(SrcNibbleBuffer));
buffer.SetBlockLight(SrcNibbleBuffer);
- testassert(buffer.GetBlockLight(6,24,1) == 0x0);
+ testassert(buffer.GetBlockLight(6, 24, 1) == 0x0);
- memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 /2);
+ memset(SrcNibbleBuffer, 0xff, sizeof(SrcNibbleBuffer));
buffer.SetSkyLight(SrcNibbleBuffer);
- testassert(buffer.GetSkyLight(6, 24, 1) == 0xF);
+ testassert(buffer.GetSkyLight(6, 24, 1) == 0xf);
}
+
+ // All tests passed:
+ return 0;
}
diff --git a/tests/ChunkData/CMakeLists.txt b/tests/ChunkData/CMakeLists.txt
index a2bd9fd22..381e11cc2 100644
--- a/tests/ChunkData/CMakeLists.txt
+++ b/tests/ChunkData/CMakeLists.txt
@@ -5,7 +5,7 @@ enable_testing()
include_directories(${CMAKE_SOURCE_DIR}/src/)
add_definitions(-DTEST_GLOBALS=1)
-add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp)
+add_library(ChunkBuffer ${CMAKE_SOURCE_DIR}/src/ChunkData.cpp ${CMAKE_SOURCE_DIR}/src/StringUtils.cpp)
add_executable(creatable-exe creatable.cpp)
@@ -24,3 +24,6 @@ add_executable(arraystocoords-exe ArraytoCoord.cpp)
target_link_libraries(arraystocoords-exe ChunkBuffer)
add_test(NAME arraystocoords-test COMMAND arraystocoords-exe)
+add_executable(copyblocks-exe CopyBlocks.cpp)
+target_link_libraries(copyblocks-exe ChunkBuffer)
+add_test(NAME copyblocks-test COMMAND copyblocks-exe)
diff --git a/tests/ChunkData/Coordinates.cpp b/tests/ChunkData/Coordinates.cpp
index 3a4477fd6..d5abbb143 100644
--- a/tests/ChunkData/Coordinates.cpp
+++ b/tests/ChunkData/Coordinates.cpp
@@ -1,5 +1,5 @@
-#include "TestGlobals.h"
+#include "Globals.h"
#include "ChunkData.h"
@@ -117,14 +117,14 @@ int main(int argc, char** argv)
// Zero's
buffer.SetBlock(0, 0, 0, 0x0);
- buffer.SetBlock(0, 0, 1, 0xAB);
+ buffer.SetBlock(0, 0, 1, 0xab);
testassert(buffer.GetBlock(0, 0, 0) == 0x0);
- testassert(buffer.GetBlock(0, 0, 1) == 0xAB);
+ testassert(buffer.GetBlock(0, 0, 1) == 0xab);
buffer.SetMeta(0, 16, 0, 0x0);
- buffer.SetMeta(0, 16, 1, 0xC);
+ buffer.SetMeta(0, 16, 1, 0xc);
testassert(buffer.GetMeta(0, 16, 0) == 0x0);
- testassert(buffer.GetMeta(0, 16, 1) == 0xC);
+ testassert(buffer.GetMeta(0, 16, 1) == 0xc);
}
diff --git a/tests/ChunkData/Copies.cpp b/tests/ChunkData/Copies.cpp
index 502a969e8..6f5d40792 100644
--- a/tests/ChunkData/Copies.cpp
+++ b/tests/ChunkData/Copies.cpp
@@ -1,5 +1,5 @@
-#include "TestGlobals.h"
+#include "Globals.h"
#include "ChunkData.h"
@@ -27,57 +27,56 @@ int main(int argc, char** argv)
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
for (int i = 0; i < 16 * 16 * 256; i += 4)
{
- SrcBlockBuffer[i+0] = 0xDE;
- SrcBlockBuffer[i+1] = 0xAD;
- SrcBlockBuffer[i+2] = 0xBE;
- SrcBlockBuffer[i+3] = 0xEF;
+ SrcBlockBuffer[i + 0] = 0xde;
+ SrcBlockBuffer[i + 1] = 0xad;
+ SrcBlockBuffer[i + 2] = 0xbe;
+ SrcBlockBuffer[i + 3] = 0xef;
}
- buffer.SetBlocks(SrcBlockBuffer);
+ buffer.SetBlockTypes(SrcBlockBuffer);
BLOCKTYPE DstBlockBuffer[16 * 16 * 256];
- buffer.CopyBlocks(DstBlockBuffer);
+ buffer.CopyBlockTypes(DstBlockBuffer);
testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
- buffer.SetBlocks(SrcBlockBuffer);
- buffer.CopyBlocks(DstBlockBuffer);
+ buffer.SetBlockTypes(SrcBlockBuffer);
+ buffer.CopyBlockTypes(DstBlockBuffer);
testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
-
}
+
{
cChunkData buffer(Pool);
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
{
- SrcNibbleBuffer[i+0] = 0xEF;
- SrcNibbleBuffer[i+1] = 0xDE;
- SrcNibbleBuffer[i+2] = 0xAD;
- SrcNibbleBuffer[i+3] = 0xBE;
+ SrcNibbleBuffer[i + 0] = 0xde;
+ SrcNibbleBuffer[i + 1] = 0xad;
+ SrcNibbleBuffer[i + 2] = 0xbe;
+ SrcNibbleBuffer[i + 3] = 0xef;
}
- buffer.SetMeta(SrcNibbleBuffer);
+ buffer.SetMetas(SrcNibbleBuffer);
NIBBLETYPE DstNibbleBuffer[16 * 16 * 256/ 2];
- buffer.CopyMeta(DstNibbleBuffer);
+ buffer.CopyMetas(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 /2);
- buffer.SetMeta(SrcNibbleBuffer);
- buffer.CopyMeta(DstNibbleBuffer);
+ buffer.SetMetas(SrcNibbleBuffer);
+ buffer.CopyMetas(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
-
-
}
+
{
cChunkData buffer(Pool);
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
{
- SrcNibbleBuffer[i+0] = 0xDE;
- SrcNibbleBuffer[i+1] = 0xAD;
- SrcNibbleBuffer[i+2] = 0xBE;
- SrcNibbleBuffer[i+3] = 0xEF;
+ SrcNibbleBuffer[i + 0] = 0xde;
+ SrcNibbleBuffer[i + 1] = 0xad;
+ SrcNibbleBuffer[i + 2] = 0xbe;
+ SrcNibbleBuffer[i + 3] = 0xef;
}
buffer.SetBlockLight(SrcNibbleBuffer);
@@ -89,19 +88,18 @@ int main(int argc, char** argv)
buffer.SetBlockLight(SrcNibbleBuffer);
buffer.CopyBlockLight(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 /2) - 1) == 0);
-
-
}
+
{
cChunkData buffer(Pool);
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
for (int i = 0; i < 16 * 16 * 256 / 2; i += 4)
{
- SrcNibbleBuffer[i+0] = 0xAD;
- SrcNibbleBuffer[i+1] = 0xBE;
- SrcNibbleBuffer[i+2] = 0xEF;
- SrcNibbleBuffer[i+3] = 0xDE;
+ SrcNibbleBuffer[i + 0] = 0xde;
+ SrcNibbleBuffer[i + 1] = 0xad;
+ SrcNibbleBuffer[i + 2] = 0xbe;
+ SrcNibbleBuffer[i + 3] = 0xef;
}
buffer.SetSkyLight(SrcNibbleBuffer);
@@ -109,26 +107,25 @@ int main(int argc, char** argv)
buffer.CopySkyLight(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
-
memset(SrcNibbleBuffer, 0xFF, 16 * 16 * 256 / 2);
buffer.SetSkyLight(SrcNibbleBuffer);
buffer.CopySkyLight(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
-
}
+
{
cChunkData buffer(Pool);
BLOCKTYPE SrcBlockBuffer[16 * 16 * 256];
memset(SrcBlockBuffer, 0x00, 16 * 16 * 256);
BLOCKTYPE DstBlockBuffer[16 * 16 * 256];
- buffer.CopyBlocks(DstBlockBuffer);
+ buffer.CopyBlockTypes(DstBlockBuffer);
testassert(memcmp(SrcBlockBuffer, DstBlockBuffer, (16 * 16 * 256) - 1) == 0);
NIBBLETYPE SrcNibbleBuffer[16 * 16 * 256 / 2];
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
NIBBLETYPE DstNibbleBuffer[16 * 16 * 256 / 2];
- buffer.CopyMeta(DstNibbleBuffer);
+ buffer.CopyMetas(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
memset(SrcNibbleBuffer, 0x00, 16 * 16 * 256 / 2);
@@ -139,4 +136,7 @@ int main(int argc, char** argv)
buffer.CopySkyLight(DstNibbleBuffer);
testassert(memcmp(SrcNibbleBuffer, DstNibbleBuffer, (16 * 16 * 256 / 2) - 1) == 0);
}
+
+ // All tests successful:
+ return 0;
}
diff --git a/tests/ChunkData/CopyBlocks.cpp b/tests/ChunkData/CopyBlocks.cpp
new file mode 100644
index 000000000..be8cab234
--- /dev/null
+++ b/tests/ChunkData/CopyBlocks.cpp
@@ -0,0 +1,76 @@
+
+// CopyBlocks.cpp
+
+// Implements the test for cChunkData::CopyBlockTypes() range copying
+
+
+
+
+
+#include "Globals.h"
+#include "ChunkData.h"
+
+
+
+
+
+int main(int argc, char ** argv)
+{
+ // Set up a cChunkData with known contents - all blocks 0x01, all metas 0x02:
+ cChunkData Data;
+ cChunkDef::BlockTypes BlockTypes;
+ cChunkDef::BlockNibbles BlockMetas;
+ memset(BlockTypes, 0x01, sizeof(BlockTypes));
+ memset(BlockMetas, 0x02, sizeof(BlockMetas));
+ Data.SetBlockTypes(BlockTypes);
+ Data.SetMetas(BlockMetas);
+
+ // Try to read varying amounts of blocktypes from the cChunkData.
+ // Verify that the exact amount of memory is copied, by copying to a larger buffer and checking its boundaries
+ BLOCKTYPE TestBuffer[5 * cChunkDef::NumBlocks];
+ size_t WritePosIdx = 2 * cChunkDef::NumBlocks;
+ BLOCKTYPE * WritePosition = &TestBuffer[WritePosIdx];
+ memset(TestBuffer, 0x03, sizeof(TestBuffer));
+ size_t LastReportedStep = 1;
+ for (size_t idx = 0; idx < 5000; idx += 7)
+ {
+ if (idx / 500 != LastReportedStep)
+ {
+ printf("Testing index %u...\n", (unsigned)idx);
+ LastReportedStep = idx / 500;
+ }
+
+ for (size_t len = 3; len < 1000; len += 13)
+ {
+ Data.CopyBlockTypes(WritePosition, idx, len);
+
+ // Verify the data copied:
+ for (size_t i = 0; i < len; i++)
+ {
+ assert_test(WritePosition[i] == 0x01);
+ }
+ // Verify the space before the copied data hasn't been changed:
+ for (size_t i = 0; i < WritePosIdx; i++)
+ {
+ assert_test(TestBuffer[i] == 0x03);
+ }
+ // Verify the space after the copied data hasn't been changed:
+ for (size_t i = WritePosIdx + idx + len; i < ARRAYCOUNT(TestBuffer); i++)
+ {
+ assert_test(TestBuffer[i] == 0x03);
+ }
+
+ // Re-initialize the buffer for the next test:
+ for (size_t i = 0; i < len; i++)
+ {
+ WritePosition[i] = 0x03;
+ }
+ } // for len
+ } // for idx
+ return 0;
+}
+
+
+
+
+
diff --git a/tests/ChunkData/creatable.cpp b/tests/ChunkData/creatable.cpp
index 78b1a82d1..0dde8cf3b 100644
--- a/tests/ChunkData/creatable.cpp
+++ b/tests/ChunkData/creatable.cpp
@@ -1,5 +1,5 @@
-#include "TestGlobals.h"
+#include "Globals.h"
#include "ChunkData.h"
int main(int argc, char** argv)
diff --git a/tests/TestGlobals.h b/tests/TestGlobals.h
deleted file mode 100644
index ea43de733..000000000
--- a/tests/TestGlobals.h
+++ /dev/null
@@ -1,139 +0,0 @@
-
-
-#include <cstdarg>
-#include <cstdio>
-#include <cstdlib>
-
-
-// Compiler-dependent stuff:
-#if defined(_MSC_VER)
- // MSVC produces warning C4481 on the override keyword usage, so disable the warning altogether
- #pragma warning(disable:4481)
-
- // Disable some warnings that we don't care about:
- #pragma warning(disable:4100) // Unreferenced formal parameter
-
- // Useful warnings from warning level 4:
- #pragma warning(3 : 4127) // Conditional expression is constant
- #pragma warning(3 : 4189) // Local variable is initialized but not referenced
- #pragma warning(3 : 4245) // Conversion from 'type1' to 'type2', signed/unsigned mismatch
- #pragma warning(3 : 4310) // Cast truncates constant value
- #pragma warning(3 : 4389) // Signed/unsigned mismatch
- #pragma warning(3 : 4505) // Unreferenced local function has been removed
- #pragma warning(3 : 4701) // Potentially unitialized local variable used
- #pragma warning(3 : 4702) // Unreachable code
- #pragma warning(3 : 4706) // Assignment within conditional expression
-
- // Disabling this warning, because we know what we're doing when we're doing this:
- #pragma warning(disable: 4355) // 'this' used in initializer list
-
- // Disabled because it's useless:
- #pragma warning(disable: 4512) // 'class': assignment operator could not be generated - reported for each class that has a reference-type member
-
- // 2014_01_06 xoft: Disabled this warning because MSVC is stupid and reports it in obviously wrong places
- // #pragma warning(3 : 4244) // Conversion from 'type1' to 'type2', possible loss of data
-
- #define OBSOLETE __declspec(deprecated)
-
- // No alignment needed in MSVC
- #define ALIGN_8
- #define ALIGN_16
-
- #define FORMATSTRING(formatIndex, va_argsIndex)
-
- // MSVC has its own custom version of zu format
- #define SIZE_T_FMT "%Iu"
- #define SIZE_T_FMT_PRECISION(x) "%" #x "Iu"
- #define SIZE_T_FMT_HEX "%Ix"
-
- #define NORETURN __declspec(noreturn)
-
-#elif defined(__GNUC__)
-
- // TODO: Can GCC explicitly mark classes as abstract (no instances can be created)?
- #define abstract
-
- // override is part of c++11
- #if __cplusplus < 201103L
- #define override
- #endif
-
- #define OBSOLETE __attribute__((deprecated))
-
- #define ALIGN_8 __attribute__((aligned(8)))
- #define ALIGN_16 __attribute__((aligned(16)))
-
- // Some portability macros :)
- #define stricmp strcasecmp
-
- #define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
-
- #define SIZE_T_FMT "%zu"
- #define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
- #define SIZE_T_FMT_HEX "%zx"
-
- #define NORETURN __attribute((__noreturn__))
-
-#else
-
- #error "You are using an unsupported compiler, you might need to #define some stuff here for your compiler"
-
- /*
- // Copy and uncomment this into another #elif section based on your compiler identification
-
- // Explicitly mark classes as abstract (no instances can be created)
- #define abstract
-
- // Mark virtual methods as overriding (forcing them to have a virtual function of the same signature in the base class)
- #define override
-
- // Mark functions as obsolete, so that their usage results in a compile-time warning
- #define OBSOLETE
-
- // Mark types / variables for alignment. Do the platforms need it?
- #define ALIGN_8
- #define ALIGN_16
- */
-
-#endif
-
-
-
-// Integral types with predefined sizes:
-typedef long long Int64;
-typedef int Int32;
-typedef short Int16;
-
-typedef unsigned long long UInt64;
-typedef unsigned int UInt32;
-typedef unsigned short UInt16;
-
-typedef unsigned char Byte;
-
-class cAssertFailure
-{
-};
-
-#define ASSERT(x) do { if (!(x)) { throw cAssertFailure();} } while (0)
-#define testassert(x) do { if(!(x)) { exit(1); } } while (0)
-#define CheckAsserts(x) do { try {x} catch (cAssertFailure) { break; } exit(1); } while (0)
-
-#ifndef TOLUA_TEMPLATE_BIND
-#define TOLUA_TEMPLATE_BIND(x)
-#endif
-
-// A macro that is used to mark unused function parameters, to avoid pedantic warnings in gcc
-#define UNUSED(X) (void)(X)
-
-// Logging functions
-void inline LOGERROR(const char* a_Format, ...) FORMATSTRING(1,2);
-
-void inline LOGERROR(const char* a_Format, ...)
-{
- va_list argList;
- va_start(argList, a_Format);
- vprintf(a_Format, argList);
- va_end(argList);
-}
-
-