Fixes annoying memory offset issue :)
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-03-23 19:16:27 +01:00
parent 9af68fa773
commit f6625a0bdf
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
4 changed files with 28 additions and 35 deletions

View File

@ -34,7 +34,7 @@ steps:
commands:
- cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=/usr/bin/clang -DCMAKE_CXX_COMPILER=/usr/bin/clang++ . -B build-release_valgrind -DSTATICC=ON -DPKMNLIB_TESTS=ON -DSHARED=ON -DSANITIZER_TESTS=OFF
- cmake --build build-release_valgrind --target all -- -j 4
- valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no --error-exitcode=1 --suppressions=angelscript.supp build-release_valgrind/pkmnLibTests
- valgrind --tool=memcheck --gen-suppressions=all --leak-check=full --leak-resolution=med --track-origins=yes --vgdb=no --error-exitcode=1 build-release_valgrind/pkmnLibTests
- name: style-check
image: deukhoofd/linux64builder
failure: ignore
@ -59,6 +59,6 @@ steps:
- wine64 build-release-windows/pkmnLibTests.exe -s --duration=true --force-colors=true
---
kind: signature
hmac: c069ef62b83d52f15ad57484fdf25eb359281cc9d4c6c3f8b8e38b2cfb805c44
hmac: 00bf200ae2970259d235942a21fccb4eabe2ec54aed9946e76476403eac45d9a
...

View File

@ -65,12 +65,12 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript")
execute_process(COMMAND ${CMAKE_COMMAND} --build ${Angelscript_BINARY_DIR}
RESULT_VARIABLE result
WORKING_DIRECTORY ${Angelscript_SOURCE_DIR}/angelscript/projects/cmake)
endif()
endif ()
include_directories(${CMAKE_CURRENT_BINARY_DIR}/include)
include_directories(${Angelscript_SOURCE_DIR}/angelscript/include)
include_directories(${Angelscript_SOURCE_DIR}/add_on)
endif()
endif ()
if (WINDOWS)
SET(CMAKE_SYSTEM_NAME Windows)
@ -145,14 +145,14 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript")
)
if (ANGELSCRIPT_DEBUGGER)
CPMAddPackage(
NAME AngelscriptDebugger
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/AngelscriptDebuggerServer.git
GIT_TAG master
NAME AngelscriptDebugger
GIT_REPOSITORY https://git.p-epsilon.com/Deukhoofd/AngelscriptDebuggerServer.git
GIT_TAG master
)
execute_process(COMMAND ln -sf ${AngelscriptDebugger_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/include/AngelscriptDebuggerServer)
set(_LINKS ${_LINKS} AngelscriptDebugger)
set(_TESTLINKS ${_TESTLINKS} AngelscriptDebugger)
endif()
endif ()
ADD_DEFINITIONS(-D AS_USE_ACCESSORS=1)
endif ()
@ -179,7 +179,7 @@ if (SCRIPT_PROVIDER STREQUAL "angelscript")
SET(_TESTLINKS ${_TESTLINKS} angelscript)
if (ANGELSCRIPT_DEBUGGER)
ADD_DEFINITIONS(-D ANGELSCRIPT_DEBUGGER=1)
endif()
endif ()
endif ()
# If we are building for Windows we need to set some specific variables.
@ -228,11 +228,11 @@ if (PKMNLIB_TESTS)
# Add a definition for the test library
target_compile_definitions(pkmnLibTests PRIVATE TESTS_BUILD)
if (SANITIZER_TESTS AND NOT WINDOWS)
target_compile_options(pkmnLibTests PRIVATE -fsanitize=address)
target_link_options(pkmnLibTests PRIVATE -fsanitize=address)
endif()
target_compile_options(pkmnLibTests PRIVATE -fsanitize=address,undefined,leak,integer,nullability -fno-sanitize-recover=all)
target_link_options(pkmnLibTests PRIVATE -fsanitize=address,undefined,leak,integer,nullability -fno-sanitize-recover=all)
endif ()
endif ()
if (ANGELSCRIPT_DEBUGGER)
include_directories(extern/AngelscriptDebuggerServer/extern/asio-1.18.2/include)
endif()
endif ()

View File

@ -1,6 +0,0 @@
{
SkipAngelScriptMemCheck
Memcheck:Cond
fun:_ZN10asCContext11ExecuteNextEv
fun:_ZN10asCContext7ExecuteEv
}

View File

@ -1,37 +1,36 @@
#include "ConstString.hpp"
#include <Arbutils/StringView.hpp>
#include <Arbutils/Ensure.hpp>
#include <Arbutils/StringView.hpp>
static void ConstructConstString(void* self) { new (self) ArbUt::StringView(); }
static void ConstructConstStringFromStd(void* self, const std::string& s) {
new (self) ArbUt::StringView(s.c_str(), s.length());
static ArbUt::StringView* ConstructConstString() { return new ArbUt::StringView(); }
static ArbUt::StringView* ConstructConstStringFromStd(const std::string& s) {
return new ArbUt::StringView(s.c_str(), s.length());
}
static void CopyConstructConstString(void* self, const ArbUt::StringView& other) {
new (self) ArbUt::StringView(other);
static ArbUt::StringView* CopyConstructConstString(ArbUt::StringView* other) {
return new ArbUt::StringView(*other);
}
static void DestructConstString(void* self) { ((ArbUt::StringView*)self)->~StringView(); }
static void DestructConstString(ArbUt::StringView* self) { delete self; }
static bool ConstStringEquality(const ArbUt::StringView& a, const ArbUt::StringView& b) { return a == b; }
static bool ConstStringStdStringEquality(const ArbUt::StringView& a, const std::string& b) { return a == b; }
static uint32_t ImplConstStringHashConv(const ArbUt::StringView& s) { return s.GetHash(); }
static std::string ImplConstStringStringConv(const ArbUt::StringView& s) { return std::string(s.std_str()); }
void ConstStringRegister::Register(asIScriptEngine* engine) {
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView),
asOBJ_VALUE | asGetTypeTraits<ArbUt::StringView>());
auto r = engine->RegisterObjectType("constString", sizeof(ArbUt::StringView), asOBJ_SCOPED | asOBJ_REF);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f()", asFUNCTION(ConstructConstString),
asCALL_CDECL_OBJFIRST);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_FACTORY, "constString@ f()",
asFUNCTION(ConstructConstString), asCALL_CDECL);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const string &in s)",
asFUNCTION(ConstructConstStringFromStd), asCALL_CDECL_OBJFIRST);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_FACTORY, "constString@ f(const string &in s)",
asFUNCTION(ConstructConstStringFromStd), asCALL_CDECL);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_CONSTRUCT, "void f(const constString &in)",
asFUNCTION(CopyConstructConstString), asCALL_CDECL_OBJFIRST);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_FACTORY, "constString@ f(const constString &in)",
asFUNCTION(CopyConstructConstString), asCALL_CDECL);
Ensure(r >= 0);
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_DESTRUCT, "void f()", asFUNCTION(DestructConstString),
r = engine->RegisterObjectBehaviour("constString", asBEHAVE_RELEASE, "void f()", asFUNCTION(DestructConstString),
asCALL_CDECL_OBJFIRST);
Ensure(r >= 0);