Fix alignment issues with optional implementation

Update single.py to look at toplevel file rather than listing out all base sources
string_shim didn't have the proper header
Improve gitignore
This commit is contained in:
ThePhD 2016-12-16 00:31:45 -05:00
parent bbcbd41efe
commit e1329d244a
6 changed files with 162 additions and 106 deletions

1
.gitignore vendored
View File

@ -70,3 +70,4 @@ main.lua
LuaJIT-2.1.0/ LuaJIT-2.1.0/
lua-5.3.3-cxx/ lua-5.3.3-cxx/
lua-5.3.3.vcxproj-cxx.filters lua-5.3.3.vcxproj-cxx.filters
sol.pyproj

View File

@ -148,7 +148,7 @@ if not args.quiet:
print('Current version: {version} (revision {revision})\n'.format(version = version, revision = revision)) print('Current version: {version} (revision {revision})\n'.format(version = version, revision = revision))
processed_files = [os.path.join(script_path, 'sol', x) for x in ('state.hpp', 'object.hpp', 'function.hpp', 'coroutine.hpp')] processed_files = [os.path.join(script_path, x) for x in ['sol.hpp']]
result = '' result = ''
ss = StringIO() ss = StringIO()

View File

@ -20,13 +20,35 @@
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
// This file was generated with a script. // This file was generated with a script.
// Generated 2016-12-10 10:55:55.463053 UTC // Generated 2016-12-16 05:28:22.940422 UTC
// This header was generated with sol v2.15.5 (revision f4f3bff) // This header was generated with sol v2.15.5 (revision bbcbd41)
// https://github.com/ThePhD/sol2 // https://github.com/ThePhD/sol2
#ifndef SOL_SINGLE_INCLUDE_HPP #ifndef SOL_SINGLE_INCLUDE_HPP
#define SOL_SINGLE_INCLUDE_HPP #define SOL_SINGLE_INCLUDE_HPP
// beginning of sol.hpp
#ifndef SOL_HPP
#define SOL_HPP
#if defined(UE_BUILD_DEBUG) || defined(UE_BUILD_DEVELOPMENT) || defined(UE_BUILD_TEST) || defined(UE_BUILD_SHIPPING) || defined(UE_SERVER)
#define SOL_INSIDE_UNREAL
#endif // Unreal Engine 4 bullshit
#ifdef SOL_INSIDE_UNREAL
#ifdef check
#define SOL_INSIDE_UNREAL_REMOVED_CHECK
#undef check
#endif
#endif // Unreal Engine 4 Bullshit
#ifdef __GNUC__
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wshadow"
#pragma GCC diagnostic ignored "-Wconversion"
#endif // g++
// beginning of sol/state.hpp // beginning of sol/state.hpp
// beginning of sol/state_view.hpp // beginning of sol/state_view.hpp
@ -1388,7 +1410,7 @@ inline int luaL_fileresult(lua_State *L, int stat, const char *fname) {
} }
else { else {
char buf[1024]; char buf[1024];
#ifdef __GLIBC__ #if defined(__GLIBC__) || defined(_POSIX_VERSION)
strerror_r(en, buf, 1024); strerror_r(en, buf, 1024);
#else #else
strerror_s(buf, 1024, en); strerror_s(buf, 1024, en);
@ -2067,18 +2089,17 @@ namespace sol {
}; };
template <class T> template <class T>
struct optional_base struct optional_base {
{ char storage_[sizeof(T) + (sizeof(T) % alignof(T))];
bool init_; bool init_;
char storage_[sizeof(T)];
constexpr optional_base() noexcept : init_(false), storage_() {}; constexpr optional_base() noexcept : storage_(), init_(false) {};
explicit optional_base(const T& v) : init_(true), storage_() { explicit optional_base(const T& v) : storage_(), init_(true) {
new (&storage())T(v); new (&storage())T(v);
} }
explicit optional_base(T&& v) : init_(true), storage_() { explicit optional_base(T&& v) : storage_(), init_(true) {
new (&storage())T(constexpr_move(v)); new (&storage())T(constexpr_move(v));
} }
@ -2116,17 +2137,16 @@ namespace sol {
using constexpr_optional_base = optional_base<T>; using constexpr_optional_base = optional_base<T>;
#else #else
template <class T> template <class T>
struct constexpr_optional_base struct constexpr_optional_base {
{ char storage_[sizeof(T) + (sizeof(T) % alignof(T))];
bool init_; bool init_;
char storage_[sizeof(T)]; constexpr constexpr_optional_base() noexcept : storage_(), init_(false) {}
constexpr constexpr_optional_base() noexcept : init_(false), storage_() {}
explicit constexpr constexpr_optional_base(const T& v) : init_(true), storage_() { explicit constexpr constexpr_optional_base(const T& v) : storage_(), init_(true) {
new (&storage())T(v); new (&storage())T(v);
} }
explicit constexpr constexpr_optional_base(T&& v) : init_(true), storage_() { explicit constexpr constexpr_optional_base(T&& v) : storage_(), init_(true) {
new (&storage())T(constexpr_move(v)); new (&storage())T(constexpr_move(v));
} }
@ -2917,8 +2937,6 @@ namespace sol {
// beginning of sol/string_shim.hpp // beginning of sol/string_shim.hpp
#pragma once
namespace sol { namespace sol {
namespace string_detail { namespace string_detail {
struct string_shim { struct string_shim {
@ -2977,7 +2995,9 @@ namespace sol {
} }
}; };
} }
}// end of sol/string_shim.hpp }
// end of sol/string_shim.hpp
#include <array> #include <array>
@ -13057,4 +13077,17 @@ namespace sol {
// end of sol/coroutine.hpp // end of sol/coroutine.hpp
#ifdef __GNUC__
#pragma GCC diagnostic pop
#endif // g++
#ifdef SOL_INSIDE_UNREAL
#ifdef SOL_INSIDE_UNREAL_REMOVED_CHECK
#define check(expr) { if(UNLIKELY(!(expr))) { FDebug::LogAssertFailedMessage( #expr, __FILE__, __LINE__ ); _DebugBreakAndPromptForRemote(); FDebug::AssertFailed( #expr, __FILE__, __LINE__ ); CA_ASSUME(false); } }}
#endif
#endif // Unreal Engine 4 Bullshit
#endif // SOL_HPP
// end of sol.hpp
#endif // SOL_SINGLE_INCLUDE_HPP #endif // SOL_SINGLE_INCLUDE_HPP

View File

@ -309,7 +309,7 @@ inline int luaL_fileresult(lua_State *L, int stat, const char *fname) {
} }
else { else {
char buf[1024]; char buf[1024];
#ifdef __GLIBC__ #if defined(__GLIBC__) || defined(_POSIX_VERSION)
strerror_r(en, buf, 1024); strerror_r(en, buf, 1024);
#else #else
strerror_s(buf, 1024, en); strerror_s(buf, 1024, en);

View File

@ -287,18 +287,17 @@ namespace sol {
template <class T> template <class T>
struct optional_base struct optional_base {
{ char storage_[sizeof(T) + (sizeof(T) % alignof(T))];
bool init_; bool init_;
char storage_[sizeof(T)];
constexpr optional_base() noexcept : init_(false), storage_() {}; constexpr optional_base() noexcept : storage_(), init_(false) {};
explicit optional_base(const T& v) : init_(true), storage_() { explicit optional_base(const T& v) : storage_(), init_(true) {
new (&storage())T(v); new (&storage())T(v);
} }
explicit optional_base(T&& v) : init_(true), storage_() { explicit optional_base(T&& v) : storage_(), init_(true) {
new (&storage())T(constexpr_move(v)); new (&storage())T(constexpr_move(v));
} }
@ -336,17 +335,16 @@ namespace sol {
using constexpr_optional_base = optional_base<T>; using constexpr_optional_base = optional_base<T>;
#else #else
template <class T> template <class T>
struct constexpr_optional_base struct constexpr_optional_base {
{ char storage_[sizeof(T) + (sizeof(T) % alignof(T))];
bool init_; bool init_;
char storage_[sizeof(T)]; constexpr constexpr_optional_base() noexcept : storage_(), init_(false) {}
constexpr constexpr_optional_base() noexcept : init_(false), storage_() {}
explicit constexpr constexpr_optional_base(const T& v) : init_(true), storage_() { explicit constexpr constexpr_optional_base(const T& v) : storage_(), init_(true) {
new (&storage())T(v); new (&storage())T(v);
} }
explicit constexpr constexpr_optional_base(T&& v) : init_(true), storage_() { explicit constexpr constexpr_optional_base(T&& v) : storage_(), init_(true) {
new (&storage())T(constexpr_move(v)); new (&storage())T(constexpr_move(v));
} }

View File

@ -1,4 +1,26 @@
#pragma once // The MIT License (MIT)
// Copyright (c) 2013-2016 Rapptz, ThePhD and contributors
// Permission is hereby granted, free of charge, to any person obtaining a copy of
// this software and associated documentation files (the "Software"), to deal in
// the Software without restriction, including without limitation the rights to
// use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
// the Software, and to permit persons to whom the Software is furnished to do so,
// subject to the following conditions:
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
// FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
// COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
// IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
// CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#ifndef SOL_STRING_SHIM_HPP
#define SOL_STRING_SHIM_HPP
#include <cstddef> #include <cstddef>
#include <string> #include <string>
@ -62,3 +84,5 @@ namespace sol {
}; };
} }
} }
#endif // SOL_STRING_SHIM_HPP