[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")
add_subdirectory(clargs)
endif(OX_USE_STDLIB STREQUAL "ON")
add_subdirectory(fs)
add_subdirectory(trace)
add_subdirectory(mc)
add_subdirectory(ptrarith)
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
)
if(OX_USE_STDLIB)
target_link_libraries(
OxFS PUBLIC
c++fs
)
endif()
target_link_libraries(
OxFS PUBLIC
c++fs
OxMetalClaw
OxStd
OxTrace
)
set_property(
@ -34,7 +38,6 @@ if(OX_BUILD_EXEC STREQUAL "ON")
#target_link_libraries(
# oxfstool
# OxFS
# OxTrace
# OxMetalClaw
# OxStd
#)

View File

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

View File

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

View File

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

View File

@ -119,4 +119,16 @@ void MetalClawReader::setTypeInfo(const char*, int fields) {
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/string.hpp>
#include <ox/std/vector.hpp>
#include "err.hpp"
#include "optype.hpp"
#include "presencemask.hpp"
@ -21,9 +22,6 @@ namespace ox {
class MetalClawReader {
private:
using ArrayLength = uint32_t;
using StringLength = uint32_t;
FieldPresenseMask m_fieldPresence;
int m_fields = 0;
int m_field = 0;
@ -69,7 +67,27 @@ class MetalClawReader {
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;
}
@ -127,7 +145,7 @@ int MetalClawReader::op(const char*, T *val, std::size_t valLen) {
// read the list
if (valLen >= len) {
MetalClawReader reader(m_buff + m_buffIt, m_buffLen - m_buffIt);
auto reader = child();
reader.setTypeInfo("List", len);
for (std::size_t i = 0; i < len; i++) {
err |= reader.op("", &val[i]);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -5,7 +5,7 @@ add_executable(
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\\ 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
)