[ox] MSVC fixes

This commit is contained in:
Gary Talent 2023-11-11 17:45:09 -06:00
parent 868adae053
commit 7ee52db6a1
8 changed files with 70 additions and 24 deletions

View File

@ -7,12 +7,15 @@
*/ */
#ifdef OX_USE_STDLIB #ifdef OX_USE_STDLIB
#include <sys/socket.h> #include <cstdio>
#ifndef _WIN32
#include <sys/socket.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <netinet/in.h> #include <netinet/in.h>
#include <sys/types.h>
#include <unistd.h> #include <unistd.h>
#include <cstdio> #endif
#include <sys/types.h>
#include <ox/std/bit.hpp> #include <ox/std/bit.hpp>

View File

@ -67,7 +67,7 @@ consteval auto modelFieldCount() noexcept {
auto t = a.allocate(1); auto t = a.allocate(1);
detail::FieldCounter<T> c; detail::FieldCounter<T> c;
const auto err = model(&c, t); const auto err = model(&c, t);
oxAssert(err, "Count failed"); //oxAssert(err, "Count failed");
a.deallocate(t, 1); a.deallocate(t, 1);
return c.fields; return c.fields;
} }

View File

@ -25,10 +25,18 @@ class ModelHandlerInterface {
template<typename T = std::nullptr_t> template<typename T = std::nullptr_t>
constexpr ox::Error setTypeInfo( constexpr ox::Error setTypeInfo(
const char *name = T::TypeName, const char* name = T::TypeName,
int version = T::TypeVersion, int version = T::TypeVersion,
const Vector<String> &typeParams = {}, const Vector<String>& typeParams = {}) noexcept {
std::size_t fields = ModelFieldCount_v<T>) noexcept { return m_handler->template setTypeInfo<T>(name, version, typeParams, ModelFieldCount_v<T>);
}
template<typename T = std::nullptr_t>
constexpr ox::Error setTypeInfo(
const char* name,
int version,
const Vector<String>& typeParams,
std::size_t fields) noexcept {
return m_handler->template setTypeInfo<T>(name, version, typeParams, fields); return m_handler->template setTypeInfo<T>(name, version, typeParams, fields);
} }

View File

@ -187,9 +187,16 @@ class OrganicClawWriter {
template<typename T> template<typename T>
constexpr ox::Error setTypeInfo( constexpr ox::Error setTypeInfo(
const char* = T::TypeName, const char* = T::TypeName,
int = T::TypeVersion, int = T::TypeVersion) noexcept {
const Vector<String>& = {}, return {};
std::size_t = ModelFieldCount_v<T>) noexcept { }
template<typename T>
constexpr ox::Error setTypeInfo(
const char*,
int,
const Vector<String>&,
std::size_t) noexcept {
return {}; return {};
} }

View File

@ -28,9 +28,16 @@ struct AlignmentCatcher: public ModelHandlerBase<AlignmentCatcher<PlatSpec>> {
template<typename T> template<typename T>
constexpr ox::Error setTypeInfo( constexpr ox::Error setTypeInfo(
const char* = T::TypeName, const char* = T::TypeName,
int = T::TypeVersion, int = T::TypeVersion) noexcept {
const Vector<String>& = {}, return {};
std::size_t = ModelFieldCount_v<T>) noexcept { }
template<typename T>
constexpr ox::Error setTypeInfo(
const char*,
int,
const Vector<String>&,
std::size_t) noexcept {
return {}; return {};
} }

View File

@ -74,9 +74,16 @@ class Preloader: public ModelHandlerBase<Preloader<PlatSpec>> {
template<typename T> template<typename T>
constexpr ox::Error setTypeInfo( constexpr ox::Error setTypeInfo(
const char* = T::TypeName, const char* = T::TypeName,
int = T::TypeVersion, int = T::TypeVersion) noexcept {
const Vector<String>& = {}, return {};
std::size_t = ModelFieldCount_v<T>) noexcept { }
template<typename T>
constexpr ox::Error setTypeInfo(
const char*,
int,
const Vector<String>&,
std::size_t) noexcept {
return {}; return {};
} }
@ -246,7 +253,7 @@ constexpr ox::Error Preloader<PlatSpec>::field(CRStringView, const T **val, std:
template<typename PlatSpec> template<typename PlatSpec>
constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(std::size_t sz) noexcept { constexpr ox::Result<std::size_t> Preloader<PlatSpec>::startAlloc(std::size_t sz) noexcept {
oxRequire(a, ox::allocate(&m_writer, sz)); oxRequire(a, ox::allocate(&m_writer, sz));
m_allocStack.emplace_back(m_writer.tellp()); m_allocStack.emplace_back(static_cast<PlatSpec::PtrType>(m_writer.tellp()));
oxReturnError(m_writer.seekp(a)); oxReturnError(m_writer.seekp(a));
return a; return a;
} }

View File

@ -34,9 +34,16 @@ class SizeCatcher: public ModelHandlerBase<SizeCatcher<PlatSpec>> {
template<typename T> template<typename T>
constexpr ox::Error setTypeInfo( constexpr ox::Error setTypeInfo(
const char* = T::TypeName, const char* = T::TypeName,
int = T::TypeVersion, int = T::TypeVersion) noexcept {
const Vector<String>& = {}, return {};
std::size_t = ModelFieldCount_v<T>) noexcept { }
template<typename T>
constexpr ox::Error setTypeInfo(
const char*,
int,
const Vector<String>&,
std::size_t) noexcept {
return {}; return {};
} }

View File

@ -23,9 +23,16 @@ class UnionSizeCatcher: public ModelHandlerBase<UnionSizeCatcher<PlatSpec>> {
template<typename T> template<typename T>
constexpr ox::Error setTypeInfo( constexpr ox::Error setTypeInfo(
const char* = T::TypeName, const char* = T::TypeName,
int = T::TypeVersion, int = T::TypeVersion) noexcept {
const Vector<String>& = {}, return {};
std::size_t = ModelFieldCount_v<T>) noexcept { }
template<typename T>
constexpr ox::Error setTypeInfo(
const char*,
int,
const Vector<String>&,
std::size_t) noexcept {
return {}; return {};
} }