diff --git a/CMakeLists.txt b/CMakeLists.txt index 463ea95a..b41b37e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,7 +42,7 @@ enable_testing() # Project setup project(inkcpp VERSION 0.1.8) -SET(CMAKE_CXX_STANDARD 20) +SET(CMAKE_CXX_STANDARD 17) # Make sure this project and all dependencies use the C++17 standard SET(CMAKE_CXX_STANDARD_REQUIRED ON) SET(CMAKE_INSTALL_LIBRARY_DIR lib) SET(CMAKE_INSTALL_INCLUDE_DIR include) @@ -59,7 +59,7 @@ set_property(CACHE INKCPP_INKLECATE PROPERTY STRINGS "NONE" "OS" "ALL") string(TOUPPER "${INKCPP_INKLECATE}" inkcpp_inklecate_upper) if (inkcpp_inklecate_upper STREQUAL "ALL") FetchContent_MakeAvailable(inklecate_windows inklecate_mac inklecate_linux) -elseif(inkcpp_inklecate_upper STREQUAL "OS") +elseif(inkcpp_inklecate_upper STREQUAL "OS") if(UNIX AND NOT APPLE) FetchContent_MakeAvailable(inklecate_linux) elseif(APPLE) @@ -153,7 +153,7 @@ if (DOXYGEN_FOUND) if (INKCPP_DOC_BlueprintUE AND NOT "${NODEJS_PATH}" STREQUAL "NODEJS-NOTFOUND") # TODO: make as dependecy file(COPY "${PROJECT_SOURCE_DIR}/unreal/blueprint_filter.js" DESTINATION ${PROJECT_BINARY_DIR}) - # file(DOWNLOAD + # file(DOWNLOAD # "https://raw.githubusercontent.com/blueprintue/blueprintue-self-hosted-edition/main/www/bue-render/render.css" # "${PROJECT_BINARY_DIR}/render.css" # EXPECTED_HASH SHA256=875364e36f8aa5d6c1d41d58043f13b48a499b5c969e8daef35bd29bbf7c6e8d) @@ -195,7 +195,7 @@ if (DOXYGEN_FOUND) COMMAND ${CMAKE_COMMAND} -E copy "./inkcpp_py.html" ${PY_HTML} DEPENDS inkcpp_py WORKING_DIRECTORY $ - COMMENT "Generates simple python documentation") + COMMENT "Generates simple python documentation") add_dependencies(doc inkcpp_py_doc) else() message(WARNING "The python target is disabled, therfore no python documentation will be build. Set INKCPP_PY to change this") diff --git a/inkcpp/CMakeLists.txt b/inkcpp/CMakeLists.txt index 0616b4cd..f044d4df 100644 --- a/inkcpp/CMakeLists.txt +++ b/inkcpp/CMakeLists.txt @@ -1,10 +1,10 @@ set_property(GLOBAL PROPERTY USE_FOLDERS ON) -list(APPEND SOURCES +list(APPEND SOURCES array.h choice.cpp functional.cpp - functions.h functions.cpp + functions.h functions.cpp globals_impl.h globals_impl.cpp output.h output.cpp platform.h @@ -33,7 +33,7 @@ list(APPEND SOURCES random.h ) list(APPEND COLLECTION_SOURCES - collections/restorable.h + collections/restorable.h collections/restorable.cpp ) FILE(GLOB PUBLIC_HEADERS "include/*") @@ -51,11 +51,9 @@ target_include_directories(inkcpp PUBLIC ) set_target_properties(inkcpp PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS}") -# Make sure the include directory is included +# Make sure the include directory is included target_link_libraries(inkcpp_o PRIVATE inkcpp_shared) target_link_libraries(inkcpp PRIVATE inkcpp_shared) -# Make sure this project and all dependencies use the C++17 standard -target_compile_features(inkcpp PUBLIC cxx_std_17) # Unreal installation diff --git a/inkcpp/globals_impl.cpp b/inkcpp/globals_impl.cpp index 1714d685..16064bbe 100644 --- a/inkcpp/globals_impl.cpp +++ b/inkcpp/globals_impl.cpp @@ -188,7 +188,7 @@ bool globals_impl::set_var(hash_t name, const ink::runtime::value& val) void globals_impl::internal_observe(hash_t name, callback_base* callback) { - _callbacks.push() = Callback{.name = name, .operation = callback}; + _callbacks.push() = Callback{name, callback}; if (_globals_initialized) { value* p_var = _variables.get(name); inkAssert( diff --git a/inkcpp/list_impl.cpp b/inkcpp/list_impl.cpp index 26e71b2f..a9d2bccd 100644 --- a/inkcpp/list_impl.cpp +++ b/inkcpp/list_impl.cpp @@ -40,7 +40,7 @@ void list_impl::next(const char*& flag_name, const char*& list_name, int& i, boo return; } - list_flag flag{.list_id = static_cast(i >> 16), .flag = static_cast(i & 0xFF)}; + list_flag flag{static_cast(i >> 16), static_cast(i & 0xFF)}; if (flag_name != nullptr) { ++flag.flag; } diff --git a/inkcpp/list_table.cpp b/inkcpp/list_table.cpp index fd267602..24e292a4 100644 --- a/inkcpp/list_table.cpp +++ b/inkcpp/list_table.cpp @@ -699,9 +699,7 @@ optional list_table::toFlag(const char* flag_name) const int list_begin = list.list_id == 0 ? 0 : _list_end[list.list_id - 1]; for (int i = list_begin; i != _list_end[list.list_id]; ++i) { if (str_equal(flag_name, _flag_names[i])) { - return { - list_flag{.list_id = list.list_id, .flag = static_cast(i - list_begin)} - }; + return list_flag{list.list_id, static_cast(i - list_begin)}; } } } else { @@ -717,10 +715,7 @@ optional list_table::toFlag(const char* flag_name) const } begin = *list_itr; } - return { - list_flag{ - .list_id = static_cast(lid), .flag = static_cast(fid - begin)} - }; + return list_flag{static_cast(lid), static_cast(fid - begin)}; } } } diff --git a/inkcpp/runner_impl.cpp b/inkcpp/runner_impl.cpp index e51572a1..b5bf8db8 100644 --- a/inkcpp/runner_impl.cpp +++ b/inkcpp/runner_impl.cpp @@ -354,7 +354,7 @@ void runner_impl::jump(ip_t dest, bool record_visits, bool track_knot_visit) break; } if (_container.empty() || _container.top().id != id) { - _container.push({.id = id, .offset = offset}); + _container.push({id, offset}); } else { _container.pop(); if (_container.size() < comm_end) { @@ -373,7 +373,7 @@ void runner_impl::jump(ip_t dest, bool record_visits, bool track_knot_visit) _entered_knot = true; } _ptr += 6; - _container.push({.id = id, .offset = offset}); + _container.push({id, offset}); if (reversed && comm_end == _container.size() - 1) { ++comm_end; } @@ -1394,7 +1394,7 @@ void runner_impl::step() // Keep track of current container auto index = read(); // offset points to command, command has size 6 - _container.push({.id = index, .offset = _ptr - 6}); + _container.push({index, _ptr - 6}); // Increment visit count if (flag & CommandFlag::CONTAINER_MARKER_TRACK_VISITS diff --git a/inkcpp_compiler/CMakeLists.txt b/inkcpp_compiler/CMakeLists.txt index 962a9d82..b0c60c0a 100644 --- a/inkcpp_compiler/CMakeLists.txt +++ b/inkcpp_compiler/CMakeLists.txt @@ -1,6 +1,6 @@ list(APPEND SOURCES compiler.cpp binary_stream.h binary_stream.cpp json.hpp - json_compiler.h json_compiler.cpp + json_compiler.h json_compiler.cpp emitter.h emitter.cpp reporter.h reporter.cpp binary_emitter.h binary_emitter.cpp @@ -25,10 +25,6 @@ set_target_properties(inkcpp_compiler PROPERTIES PUBLIC_HEADER "${PUBLIC_HEADERS target_link_libraries(inkcpp_compiler PRIVATE inkcpp_shared) target_link_libraries(inkcpp_compiler_o PRIVATE inkcpp_shared) -# Make sure this project and all dependencies use the C++17 standard -target_compile_features(inkcpp_compiler PUBLIC cxx_std_17) -target_compile_features(inkcpp_compiler PUBLIC cxx_std_17) - # Unreal installation list(REMOVE_ITEM SOURCES "json.hpp") configure_file("json.hpp" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/ThirdParty/Private/json.hpp" COPYONLY) diff --git a/inkcpp_compiler/json_compiler.cpp b/inkcpp_compiler/json_compiler.cpp index 6083affe..ee3581e9 100644 --- a/inkcpp_compiler/json_compiler.cpp +++ b/inkcpp_compiler/json_compiler.cpp @@ -138,7 +138,8 @@ void json_compiler::compile_container( bool is_knot = name_override != "" && index_in_parent == -1; if (is_knot) { // it is not a wave or choice - if (name_override.starts_with("c-") || name_override.starts_with("g-")) { + if (::ink::internal::starts_with(name_override.c_str(), "c-") + || ::ink::internal::starts_with(name_override.c_str(), "g-")) { is_knot = false; for (auto itr = name_override.begin() + 2; itr != name_override.end(); ++itr) { if (*itr > '9' || *itr < '0') { diff --git a/inkcpp_compiler/list_data.cpp b/inkcpp_compiler/list_data.cpp index 4062f4af..e9f881bd 100644 --- a/inkcpp_compiler/list_data.cpp +++ b/inkcpp_compiler/list_data.cpp @@ -30,8 +30,9 @@ void list_data::new_flag(const std::string& flag_name, int value) _flags.emplace_back( &flag_name, list_flag{ - .list_id = static_cast(_list_name.size() - 1), - .flag = static_cast(value)} + static_cast(_list_name.size() - 1), + static_cast(value) + } ); } diff --git a/shared/public/system.h b/shared/public/system.h index 137b060c..5047a971 100644 --- a/shared/public/system.h +++ b/shared/public/system.h @@ -97,6 +97,19 @@ constexpr list_flag empty_flag{-1, 0}; namespace internal { + /** Checks if a string starts with a given prefix*/ + static bool starts_with(const char* string, const char* prefix) + { + while (*prefix) { + if (*string != *prefix) { + return false; + } + string++; + prefix++; + } + return true; + } + /** Checks if a string is only whitespace*/ static bool is_whitespace(const char* string, bool includeNewline = true) {