[ox] Move buildinfo and trace packages into std

This commit is contained in:
Gary Talent 2019-02-23 23:02:25 -06:00
parent 57aa0d556c
commit 5a1d1c0a2f
25 changed files with 78 additions and 78 deletions

View File

@ -1,11 +1,7 @@
cmake_minimum_required(VERSION 2.8)
add_subdirectory(__buildinfo)
if(OX_USE_STDLIB STREQUAL "ON") if(OX_USE_STDLIB STREQUAL "ON")
add_subdirectory(clargs) add_subdirectory(clargs)
endif(OX_USE_STDLIB STREQUAL "ON") endif(OX_USE_STDLIB STREQUAL "ON")
add_subdirectory(fs) add_subdirectory(fs)
add_subdirectory(trace)
add_subdirectory(mc) add_subdirectory(mc)
add_subdirectory(ptrarith) add_subdirectory(ptrarith)
add_subdirectory(std) add_subdirectory(std)

View File

@ -1,6 +0,0 @@
install(
FILES
defines.hpp
DESTINATION
include/ox/__buildinfo
)

View File

@ -9,12 +9,16 @@ add_library(
filesystem/passthroughfs.cpp filesystem/passthroughfs.cpp
) )
if(OX_USE_STDLIB)
target_link_libraries(
OxFS PUBLIC
c++fs
)
endif()
target_link_libraries( target_link_libraries(
OxFS PUBLIC OxFS PUBLIC
c++fs
OxMetalClaw OxMetalClaw
OxStd
OxTrace
) )
set_property( set_property(
@ -34,7 +38,6 @@ if(OX_BUILD_EXEC STREQUAL "ON")
#target_link_libraries( #target_link_libraries(
# oxfstool # oxfstool
# OxFS # OxFS
# OxTrace
# OxMetalClaw # OxMetalClaw
# OxStd # OxStd
#) #)

View File

@ -9,7 +9,6 @@ target_link_libraries(
FSTests FSTests
OxFS OxFS
OxStd OxStd
OxTrace
OxMetalClaw OxMetalClaw
) )

View File

@ -1,5 +1,3 @@
cmake_minimum_required(VERSION 2.8)
add_library( add_library(
OxMetalClaw OxMetalClaw
defwriter.cpp defwriter.cpp
@ -11,7 +9,6 @@ add_library(
target_link_libraries( target_link_libraries(
OxMetalClaw PUBLIC OxMetalClaw PUBLIC
OxStd OxStd
OxTrace
) )
set_property( set_property(
@ -23,10 +20,13 @@ set_property(
install( install(
FILES FILES
deftypes.hpp
defwriter.hpp defwriter.hpp
err.hpp err.hpp
optype.hpp
presencemask.hpp presencemask.hpp
read.hpp read.hpp
types.hpp
write.hpp write.hpp
DESTINATION DESTINATION
include/ox/mc include/ox/mc

View File

@ -11,9 +11,9 @@
#include <ox/std/byteswap.hpp> #include <ox/std/byteswap.hpp>
#include <ox/std/hashmap.hpp> #include <ox/std/hashmap.hpp>
#include <ox/std/string.hpp> #include <ox/std/string.hpp>
#include <ox/std/trace.hpp>
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
#include <ox/trace/trace.hpp>
#include "deftypes.hpp" #include "deftypes.hpp"
#include "err.hpp" #include "err.hpp"

View File

@ -119,4 +119,16 @@ void MetalClawReader::setTypeInfo(const char*, int fields) {
m_fieldPresence.setMaxLen(m_buffIt); m_fieldPresence.setMaxLen(m_buffIt);
} }
MetalClawReader MetalClawReader::child() {
return MetalClawReader(m_buff + m_buffIt, m_buffLen - m_buffIt);
}
bool MetalClawReader::fieldPresent() {
return m_fieldPresence.get(m_field);
}
bool MetalClawReader::fieldPresent(int fieldNo) {
return m_fieldPresence.get(fieldNo);
}
} }

View File

@ -11,6 +11,7 @@
#include <ox/std/byteswap.hpp> #include <ox/std/byteswap.hpp>
#include <ox/std/string.hpp> #include <ox/std/string.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
#include "err.hpp" #include "err.hpp"
#include "optype.hpp" #include "optype.hpp"
#include "presencemask.hpp" #include "presencemask.hpp"
@ -21,9 +22,6 @@ namespace ox {
class MetalClawReader { class MetalClawReader {
private: private:
using ArrayLength = uint32_t;
using StringLength = uint32_t;
FieldPresenseMask m_fieldPresence; FieldPresenseMask m_fieldPresence;
int m_fields = 0; int m_fields = 0;
int m_field = 0; int m_field = 0;
@ -69,7 +67,27 @@ class MetalClawReader {
void setTypeInfo(const char *name, int fields); void setTypeInfo(const char *name, int fields);
constexpr OpType opType() { /**
* Returns a MetalClawReader to parse a child object.
*/
MetalClawReader child();
/**
* Indicates whether or not the next field to be read is present.
*/
bool fieldPresent();
/**
* Indicates whether or not the given field is present.
*/
bool fieldPresent(int fieldNo);
/**
* @return the number of fields in this struct or list
*/
bool fields();
static constexpr OpType opType() {
return OpType::Read; return OpType::Read;
} }
@ -127,7 +145,7 @@ int MetalClawReader::op(const char*, T *val, std::size_t valLen) {
// read the list // read the list
if (valLen >= len) { if (valLen >= len) {
MetalClawReader reader(m_buff + m_buffIt, m_buffLen - m_buffIt); auto reader = child();
reader.setTypeInfo("List", len); reader.setTypeInfo("List", len);
for (std::size_t i = 0; i < len; i++) { for (std::size_t i = 0; i < len; i++) {
err |= reader.op("", &val[i]); err |= reader.op("", &val[i]);

View File

@ -8,8 +8,6 @@ add_executable(
target_link_libraries( target_link_libraries(
McTest McTest
OxMetalClaw OxMetalClaw
OxStd
OxTrace
) )
add_test("Test\\ McTest\\ Writer" McTest MetalClawWriter) add_test("Test\\ McTest\\ Writer" McTest MetalClawWriter)

View File

@ -13,6 +13,9 @@
namespace ox { namespace ox {
using StringLength = uint32_t;
using ArrayLength = uint32_t;
class McStr { class McStr {
protected: protected:

View File

@ -65,7 +65,6 @@ Error MetalClawWriter::op(const char*, McStr val) {
bool fieldSet = false; bool fieldSet = false;
if (val.cap()) { if (val.cap()) {
// write the length // write the length
typedef uint32_t StringLength;
if (m_buffIt + sizeof(StringLength) + val.bytes() < m_buffLen) { if (m_buffIt + sizeof(StringLength) + val.bytes() < m_buffLen) {
*reinterpret_cast<LittleEndian<StringLength>*>(&m_buff[m_buffIt]) = static_cast<StringLength>(val.bytes()); *reinterpret_cast<LittleEndian<StringLength>*>(&m_buff[m_buffIt]) = static_cast<StringLength>(val.bytes());
m_buffIt += sizeof(StringLength); m_buffIt += sizeof(StringLength);

View File

@ -12,6 +12,7 @@
#include <ox/std/string.hpp> #include <ox/std/string.hpp>
#include <ox/std/vector.hpp> #include <ox/std/vector.hpp>
#include <ox/std/types.hpp> #include <ox/std/types.hpp>
#include "err.hpp" #include "err.hpp"
#include "optype.hpp" #include "optype.hpp"
#include "presencemask.hpp" #include "presencemask.hpp"
@ -64,7 +65,7 @@ class MetalClawWriter {
std::size_t size(); std::size_t size();
constexpr OpType opType() { static constexpr OpType opType() {
return OpType::Write; return OpType::Write;
} }
@ -125,7 +126,6 @@ Error MetalClawWriter::op(const char*, T *val, std::size_t len) {
if (len) { if (len) {
// write the length // write the length
typedef uint32_t ArrayLength;
if (m_buffIt + sizeof(ArrayLength) < m_buffLen) { if (m_buffIt + sizeof(ArrayLength) < m_buffLen) {
*reinterpret_cast<LittleEndian<ArrayLength>*>(&m_buff[m_buffIt]) = static_cast<ArrayLength>(len); *reinterpret_cast<LittleEndian<ArrayLength>*>(&m_buff[m_buffIt]) = static_cast<ArrayLength>(len);
m_buffIt += sizeof(ArrayLength); m_buffIt += sizeof(ArrayLength);

View File

@ -8,7 +8,7 @@
#pragma once #pragma once
#include <ox/trace/trace.hpp> #include <ox/std/trace.hpp>
#include "ptr.hpp" #include "ptr.hpp"

View File

@ -1,13 +1,13 @@
cmake_minimum_required(VERSION 2.8)
add_library( add_library(
OxStd OxStd
assert.cpp assert.cpp
buildinfo.cpp
byteswap.cpp byteswap.cpp
memops.cpp memops.cpp
random.cpp random.cpp
stacktrace.cpp stacktrace.cpp
strops.cpp strops.cpp
trace.cpp
) )
set_property( set_property(
@ -17,14 +17,15 @@ set_property(
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
) )
target_link_libraries(OxStd PUBLIC OxTrace)
install( install(
FILES FILES
assert.hpp assert.hpp
bitops.hpp bitops.hpp
buildinfo.hpp
byteswap.hpp byteswap.hpp
defines.hpp
error.hpp error.hpp
hashmap.hpp
math.hpp math.hpp
memops.hpp memops.hpp
new.hpp new.hpp
@ -34,6 +35,7 @@ install(
strops.hpp strops.hpp
std.hpp std.hpp
stddef.hpp stddef.hpp
trace.hpp
types.hpp types.hpp
typetraits.hpp typetraits.hpp
vector.hpp vector.hpp

View File

@ -11,8 +11,7 @@
#include <iostream> #include <iostream>
#endif #endif
#include <ox/__buildinfo/defines.hpp> #include "defines.hpp"
#include "stacktrace.hpp" #include "stacktrace.hpp"
#include "assert.hpp" #include "assert.hpp"

View File

@ -8,8 +8,7 @@
#pragma once #pragma once
#include <ox/__buildinfo/defines.hpp> #include "defines.hpp"
#include "error.hpp" #include "error.hpp"
namespace ox { namespace ox {

View File

@ -8,30 +8,35 @@
namespace ox::buildinfo { namespace ox::buildinfo {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wunused-const-variable"
#if defined(OX_USE_STDLIB) #if defined(OX_USE_STDLIB)
const auto UseStdLib = true; const bool UseStdLib = true;
#else #else
const auto UseStdLib = false; const bool UseStdLib = false;
#endif #endif
#if defined(DEBUG) #if defined(DEBUG)
const auto Debug = true; const bool Debug = true;
#else #else
const auto Debug = false; const bool Debug = false;
#endif #endif
#if defined(NDEBUG) #if defined(NDEBUG)
const auto NDebug = true; const bool NDebug = true;
#else #else
const auto NDebug = false; const bool NDebug = false;
#endif #endif
#if defined(__BIG_ENDIAN__) #if defined(__BIG_ENDIAN__)
const auto BigEndian = true; const bool BigEndian = true;
const auto LittleEndian = false; const bool LittleEndian = false;
#else #else
const auto BigEndian = false; const bool BigEndian = false;
const auto LittleEndian = true; const bool LittleEndian = true;
#endif #endif
#pragma clang diagnostic pop
} }

View File

@ -8,8 +8,7 @@
#pragma once #pragma once
#include <ox/__buildinfo/defines.hpp> #include "defines.hpp"
#include "types.hpp" #include "types.hpp"
#include "typetraits.hpp" #include "typetraits.hpp"

View File

@ -8,8 +8,7 @@
#pragma once #pragma once
#include <ox/__buildinfo/defines.hpp> #include "defines.hpp"
#include "types.hpp" #include "types.hpp"
#if defined(_MSC_VER) #if defined(_MSC_VER)

View File

@ -5,7 +5,7 @@ add_executable(
tests.cpp tests.cpp
) )
target_link_libraries(StdTest OxTrace OxStd) target_link_libraries(StdTest OxStd)
add_test("Test\\ ox_memcmp\\ ABCDEFG\\ !=\\ HIJKLMN" StdTest "ABCDEFG != HIJKLMN") add_test("Test\\ ox_memcmp\\ ABCDEFG\\ !=\\ HIJKLMN" StdTest "ABCDEFG != HIJKLMN")
add_test("Test\\ ox_memcmp\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG") add_test("Test\\ ox_memcmp\\ HIJKLMN\\ !=\\ ABCDEFG" StdTest "HIJKLMN != ABCDEFG")

View File

@ -1,25 +0,0 @@
cmake_minimum_required(VERSION 2.8)
add_library(
OxTrace
trace.cpp
)
set_property(
TARGET
OxTrace
PROPERTY
POSITION_INDEPENDENT_CODE ON
)
install(
FILES
trace.hpp
DESTINATION
include/ox/mc
)
install(TARGETS OxTrace
LIBRARY DESTINATION lib/ox
ARCHIVE DESTINATION lib/ox
)