2012-03-19 06:59:11 -06:00
|
|
|
#include "Internal.h"
|
|
|
|
#include "DataDefs.h"
|
|
|
|
#include "MiscUtils.h"
|
|
|
|
#include "VersionInfo.h"
|
|
|
|
|
2016-03-18 21:11:11 -06:00
|
|
|
#ifndef STATIC_FIELDS_GROUP
|
2012-03-19 06:59:11 -06:00
|
|
|
#include "df/world.h"
|
|
|
|
#include "df/world_data.h"
|
|
|
|
#include "df/ui.h"
|
2016-03-18 21:11:11 -06:00
|
|
|
#endif
|
2012-03-19 06:59:11 -06:00
|
|
|
|
|
|
|
#include "DataIdentity.h"
|
2012-03-25 04:06:05 -06:00
|
|
|
#include "DataFuncs.h"
|
2012-03-19 06:59:11 -06:00
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
|
|
|
#pragma GCC diagnostic ignored "-Winvalid-offsetof"
|
|
|
|
|
2012-03-19 10:12:27 -06:00
|
|
|
namespace df {
|
2016-07-28 14:36:02 -06:00
|
|
|
#define NUMBER_IDENTITY_TRAITS(category, type) \
|
|
|
|
category##_identity<type> identity_traits<type>::identity(#type);
|
|
|
|
#define INTEGER_IDENTITY_TRAITS(type) NUMBER_IDENTITY_TRAITS(integer, type)
|
|
|
|
#define FLOAT_IDENTITY_TRAITS(type) NUMBER_IDENTITY_TRAITS(float, type)
|
2012-03-20 03:56:29 -06:00
|
|
|
|
2016-03-18 21:11:11 -06:00
|
|
|
#ifndef STATIC_FIELDS_GROUP
|
2016-07-28 14:36:02 -06:00
|
|
|
INTEGER_IDENTITY_TRAITS(char);
|
|
|
|
INTEGER_IDENTITY_TRAITS(int8_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(uint8_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(int16_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(uint16_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(int32_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(uint32_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(int64_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(uint64_t);
|
2016-07-27 17:46:49 -06:00
|
|
|
#ifdef _WIN32
|
2016-07-28 14:36:02 -06:00
|
|
|
INTEGER_IDENTITY_TRAITS(long);
|
|
|
|
INTEGER_IDENTITY_TRAITS(unsigned long);
|
2016-07-27 17:46:49 -06:00
|
|
|
#else
|
2016-07-28 14:36:02 -06:00
|
|
|
INTEGER_IDENTITY_TRAITS(intptr_t);
|
|
|
|
INTEGER_IDENTITY_TRAITS(uintptr_t);
|
2016-07-27 17:46:49 -06:00
|
|
|
#endif
|
2016-07-28 14:36:02 -06:00
|
|
|
FLOAT_IDENTITY_TRAITS(float);
|
|
|
|
FLOAT_IDENTITY_TRAITS(double);
|
2012-03-20 03:56:29 -06:00
|
|
|
|
|
|
|
bool_identity identity_traits<bool>::identity;
|
|
|
|
stl_string_identity identity_traits<std::string>::identity;
|
2012-03-25 09:12:59 -06:00
|
|
|
ptr_string_identity identity_traits<char*>::identity;
|
|
|
|
ptr_string_identity identity_traits<const char*>::identity;
|
2012-03-20 03:56:29 -06:00
|
|
|
pointer_identity identity_traits<void*>::identity;
|
|
|
|
stl_ptr_vector_identity identity_traits<std::vector<void*> >::identity;
|
2012-03-21 03:26:53 -06:00
|
|
|
stl_bit_vector_identity identity_traits<std::vector<bool> >::identity;
|
2012-03-29 12:56:06 -06:00
|
|
|
bit_array_identity identity_traits<BitArray<int> >::identity;
|
2012-03-21 03:26:53 -06:00
|
|
|
|
2014-09-24 12:47:04 -06:00
|
|
|
static void *fstream_allocator_fn(void *out, const void *in) {
|
|
|
|
if (out) { /* *(T*)out = *(const T*)in;*/ return NULL; }
|
|
|
|
else if (in) { delete (std::fstream*)in; return (std::fstream*)in; }
|
|
|
|
else return new std::fstream();
|
|
|
|
}
|
|
|
|
opaque_identity identity_traits<std::fstream>::identity(
|
|
|
|
sizeof(std::fstream), fstream_allocator_fn, "fstream");
|
|
|
|
|
2012-03-21 03:26:53 -06:00
|
|
|
buffer_container_identity buffer_container_identity::base_instance;
|
2016-03-18 21:11:11 -06:00
|
|
|
#endif
|
2012-03-20 03:56:29 -06:00
|
|
|
#undef NUMBER_IDENTITY_TRAITS
|
2016-07-28 14:36:02 -06:00
|
|
|
#undef INTEGER_IDENTITY_TRAITS
|
|
|
|
#undef FLOAT_IDENTITY_TRAITS
|
2012-03-19 10:12:27 -06:00
|
|
|
}
|
|
|
|
|
2012-03-19 06:59:11 -06:00
|
|
|
#define TID(type) (&identity_traits< type >::identity)
|
|
|
|
|
|
|
|
#define FLD(mode, name) struct_field_info::mode, #name, offsetof(CUR_STRUCT, name)
|
2012-03-20 03:56:29 -06:00
|
|
|
#define GFLD(mode, name) struct_field_info::mode, #name, (size_t)&df::global::name
|
2012-03-25 04:06:05 -06:00
|
|
|
#define METHOD(mode, name) struct_field_info::mode, #name, 0, wrap_function(&CUR_STRUCT::name)
|
2012-03-19 06:59:11 -06:00
|
|
|
#define FLD_END struct_field_info::END
|