Merge pull request #66 from lioncash/seek

General: Be explicit about SeekOrigin and Endian types
This commit is contained in:
Phillip Stephens 2019-09-10 04:05:41 -07:00 committed by GitHub
commit 2392dde366
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 7 additions and 7 deletions

View File

@ -1,7 +1,7 @@
#include <athena/DNAYaml.hpp> #include <athena/DNAYaml.hpp>
using namespace athena; using namespace athena;
typedef io::DNA<Big> BigDNA; typedef io::DNA<Endian::Big> BigDNA;
enum ETest : atUint8 { ZERO, ONE, TWO, THREE }; enum ETest : atUint8 { ZERO, ONE, TWO, THREE };
@ -54,13 +54,13 @@ struct AT_SPECIALIZE_PARMS(atUint16, 42, atUint32, 87, atUint32, 2) TESTFile : p
Value<TESTTemplateSubFile<atInt32, 36>> nestedTemplate1; Value<TESTTemplateSubFile<atInt32, 36>> nestedTemplate1;
Value<TESTTemplateSubFile<atInt64, 96>> nestedTemplate2; Value<TESTTemplateSubFile<atInt64, 96>> nestedTemplate2;
Value<atUint32, Little> arrCount[2]; Value<atUint32, Endian::Little> arrCount[2];
Vector<atUint32, AT_DNA_COUNT(arrCount[0])> array; Vector<atUint32, AT_DNA_COUNT(arrCount[0])> array;
Value<atUint32> arrAltCount; Value<atUint32> arrAltCount;
Vector<atUint32, AT_DNA_COUNT(arrAltCount)> arrayAlt; Vector<atUint32, AT_DNA_COUNT(arrAltCount)> arrayAlt;
Seek<21, Current> seek; Seek<21, SeekOrigin::Current> seek;
Value<atUint32> arrCount2; Value<atUint32> arrCount2;
Vector<TESTSubFile<ETest::ZERO>, AT_DNA_COUNT(arrCount[1] + arrCount2)> array2; Vector<TESTSubFile<ETest::ZERO>, AT_DNA_COUNT(arrCount[1] + arrCount2)> array2;

View File

@ -372,7 +372,7 @@ struct Read {
} }
static void DoSeek(atInt64 amount, SeekOrigin whence, StreamT& r) { r.seek(amount, whence); } static void DoSeek(atInt64 amount, SeekOrigin whence, StreamT& r) { r.seek(amount, whence); }
static void DoAlign(atInt64 amount, StreamT& r) { static void DoAlign(atInt64 amount, StreamT& r) {
r.seek((r.position() + amount - 1) / amount * amount, athena::Begin); r.seek((r.position() + amount - 1) / amount * amount, athena::SeekOrigin::Begin);
} }
}; };
#define __READ_S(type, endian) \ #define __READ_S(type, endian) \

View File

@ -116,7 +116,7 @@ bool ValidateFromYAMLStream(athena::io::IStreamReader& fin) {
atUint64 pos = fin.position(); atUint64 pos = fin.position();
yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)YAMLAthenaReader, &fin); yaml_parser_set_input(reader.getParser(), (yaml_read_handler_t*)YAMLAthenaReader, &fin);
bool retval = reader.ValidateClassType(DNASubtype::DNAType()); bool retval = reader.ValidateClassType(DNASubtype::DNAType());
fin.seek(pos, athena::Begin); fin.seek(pos, athena::SeekOrigin::Begin);
return retval; return retval;
} }

View File

@ -16,8 +16,8 @@ constexpr bool isSystemBigEndian() { return false; }
#else #else
constexpr bool isSystemBigEndian() { return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__; } constexpr bool isSystemBigEndian() { return __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__; }
#endif #endif
constexpr ::athena::Endian SystemEndian = isSystemBigEndian() ? Big : Little; constexpr ::athena::Endian SystemEndian = isSystemBigEndian() ? ::athena::Endian::Big : ::athena::Endian::Little;
constexpr ::athena::Endian NotSystemEndian = isSystemBigEndian() ? Little : Big; constexpr ::athena::Endian NotSystemEndian = isSystemBigEndian() ? ::athena::Endian::Little : ::athena::Endian::Big;
#if _MSC_VER #if _MSC_VER
#define BSWAP_CONSTEXPR inline #define BSWAP_CONSTEXPR inline