Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ set(INKCPP_INKLECATE
set_property(CACHE INKCPP_INKLECATE PROPERTY STRINGS "NONE" "OS" "ALL")
option(INKCPP_NO_RTTI
"Disable real time type information depended code. Used to build without RTTI." OFF)
option(INKCPP_NO_EXCEPTIONS
"Used to build without support for exceptions, disables try/catch blocks and throws" OFF)
option(INKCPP_NO_STD "Disables the use of C(++) std libs." OFF)

if(INKCPP_NO_RTTI)
Expand Down
114 changes: 65 additions & 49 deletions inkcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,73 +1,89 @@
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

list(APPEND SOURCES
array.h
choice.cpp
functional.cpp
functions.h functions.cpp
globals_impl.h globals_impl.cpp
output.h output.cpp
platform.h
runner_impl.h runner_impl.cpp
simple_restorable_stack.h stack.h stack.cpp
story_impl.h story_impl.cpp
snapshot_impl.h snapshot_impl.cpp snapshot_interface.h
story_ptr.cpp
system.cpp
value.h value.cpp
list(
APPEND
SOURCES
array.h
choice.cpp
functional.cpp
functions.h
functions.cpp
globals_impl.h
globals_impl.cpp
output.h
output.cpp
platform.h
runner_impl.h
runner_impl.cpp
simple_restorable_stack.h
stack.h
stack.cpp
story_impl.h
story_impl.cpp
snapshot_impl.h
snapshot_impl.cpp
snapshot_interface.h
story_ptr.cpp
system.cpp
value.h
value.cpp
tuple.hpp
string_table.h string_table.cpp
list_table.h list_table.cpp
list_impl.h list_impl.cpp
operations.h operation_bases.h
list_operations.h list_operations.cpp
container_operations.h container_operations.cpp
numeric_operations.h numeric_operations.cpp
string_operations.h string_operations.cpp
string_table.h
string_table.cpp
list_table.h
list_table.cpp
list_impl.h
list_impl.cpp
operations.h
operation_bases.h
list_operations.h
list_operations.cpp
container_operations.h
container_operations.cpp
numeric_operations.h
numeric_operations.cpp
string_operations.h
string_operations.cpp
string_operations.cpp
numeric_operations.cpp
casting.h
executioner.h
string_utils.h
header.cpp
random.h
)
list(APPEND COLLECTION_SOURCES
collections/restorable.h
collections/restorable.cpp
)
FILE(GLOB PUBLIC_HEADERS "include/*")
random.h)
list(APPEND COLLECTION_SOURCES collections/restorable.h collections/restorable.cpp)
file(GLOB PUBLIC_HEADERS "include/*")

source_group(Collections REGULAR_EXPRESSION collections/.*)
add_library(inkcpp_o OBJECT ${SOURCES} ${COLLECTION_SOURCES})
target_include_directories(inkcpp_o PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
add_library(inkcpp $<TARGET_OBJECTS:inkcpp_o>)
target_include_directories(inkcpp PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
target_include_directories(inkcpp_o PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
target_compile_definitions(inkcpp_o PRIVATE INKCPP_BUILD_CLIB INKCPP_NO_EXCEPTIONS INKCPP_NO_RTTI)
add_library(inkcpp ${SOURCES} ${COLLECTION_SOURCES})
target_include_directories(inkcpp PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>)
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 PUBLIC inkcpp_shared)
target_link_libraries(inkcpp PUBLIC inkcpp_shared)
# Make sure this project and all dependencies use the C++17 standard
target_compile_features(inkcpp PUBLIC cxx_std_17)


# Unreal installation
list(REMOVE_ITEM SOURCES "avl_array.h")
configure_file("avl_array.h" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/ThirdParty/Private/avl_array.h" COPYONLY)
foreach(FILE IN LISTS SOURCES)
configure_file("${FILE}" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/inkcpp/Private/ink/${FILE}" COPYONLY)
configure_file("avl_array.h"
"${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/ThirdParty/Private/avl_array.h" COPYONLY)
foreach(file IN LISTS SOURCES)
configure_file("${file}" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/inkcpp/Private/ink/${file}"
COPYONLY)
endforeach()
foreach(FILE IN LISTS PUBLIC_HEADERS)
get_filename_component(FILE "${FILE}" NAME)
configure_file("include/${FILE}" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/inkcpp/Public/ink/${FILE}" COPYONLY)
foreach(file IN LISTS PUBLIC_HEADERS)
get_filename_component(file "${file}" NAME)
configure_file("include/${file}"
"${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/inkcpp/Public/ink/${FILE}" COPYONLY)
endforeach()
foreach(FILE IN LISTS COLLECTION_SOURCES)
configure_file("${FILE}" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/inkcpp/Private/ink/${FILE}" COPYONLY)
foreach(file IN LISTS COLLECTION_SOURCES)
configure_file("${file}" "${CMAKE_BINARY_DIR}/unreal/inkcpp/Source/inkcpp/Private/ink/${file}"
COPYONLY)
endforeach()
22 changes: 11 additions & 11 deletions inkcpp/avl_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ class avl_array

// node storage, due to possible structure packing effects, single arrays are used instead of a
// 'node' structure
ink::runtime::internal::if_t<dynamic, Key*, Key[Size]> key_;
ink::runtime::internal::if_t<dynamic, T*, T[Size]> val_;
ink::runtime::internal::if_t<dynamic, std::int8_t*, std::int8_t[Size]> balance_;
ink::runtime::internal::if_t<dynamic, child_type*, child_type[Size]> child_;
size_type size_; // actual size
size_type _capacity;
size_type root_; // root node
ink::runtime::internal::if_t<dynamic, Key*, Key[Size]> key_;
ink::runtime::internal::if_t<dynamic, T*, T[Size]> val_;
ink::runtime::internal::if_t<dynamic, char*, char[Size]> balance_;
ink::runtime::internal::if_t<dynamic, child_type*, child_type[Size]> child_;
size_type size_; // actual size
size_type _capacity;
size_type root_; // root node
ink::runtime::internal::if_t<dynamic, size_type*, size_type[Fast ? Size : 1]> parent_;

// invalid index (like 'nullptr' in a pointer implementation)
Expand Down Expand Up @@ -197,7 +197,7 @@ class avl_array
if constexpr (dynamic) {
key_ = new Key[Size];
val_ = new T[Size];
balance_ = new std::int8_t[Size];
balance_ = new char[Size];
child_ = new child_type[Size];
if constexpr (Fast) {
parent_ = new size_type[Size];
Expand Down Expand Up @@ -285,7 +285,7 @@ class avl_array
val_ = new_data;
}
{
std::int8_t* new_data = new std::int8_t[new_size];
char* new_data = new char[new_size];
for (size_type i = 0; i < _capacity; ++i) {
new_data[i] = balance_[i];
}
Expand Down Expand Up @@ -660,7 +660,7 @@ class avl_array
set_parent(target, get_parent(source));
}

void insert_balance(size_type node, std::int8_t balance)
void insert_balance(size_type node, char balance)
{
while (node != INVALID_IDX) {
balance = (balance_[node] += balance);
Expand Down Expand Up @@ -691,7 +691,7 @@ class avl_array
}
}

void delete_balance(size_type node, std::int8_t balance)
void delete_balance(size_type node, char balance)
{
while (node != INVALID_IDX) {
balance = (balance_[node] += balance);
Expand Down
6 changes: 3 additions & 3 deletions inkcpp/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,21 @@ int32_t function_base::pop<int32_t>(basic_eval_stack* stack, list_table&)
}

template<>
uint32_t function_base::pop<uint32_t>(basic_eval_stack* stack, list_table& lists)
uint32_t function_base::pop<uint32_t>(basic_eval_stack* stack, list_table&)
{
value val = stack->pop();
return casting::numeric_cast<value_type::uint32>(val);
}

template<>
bool function_base::pop<bool>(basic_eval_stack* stack, list_table& lists)
bool function_base::pop<bool>(basic_eval_stack* stack, list_table&)
{
value val = stack->pop();
return casting::numeric_cast<value_type::int32>(val) != 0;
}

template<>
float function_base::pop<float>(basic_eval_stack* stack, list_table& lists)
float function_base::pop<float>(basic_eval_stack* stack, list_table&)
{
value val = stack->pop();
return casting::numeric_cast<value_type::float32>(val);
Expand Down
4 changes: 2 additions & 2 deletions inkcpp/include/list.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# include <ostream>
#endif

#ifdef INK_BUILD_CLIB
#ifdef INKCPP_BUILD_CLIB
struct InkListIter;
struct HInkList;
int ink_list_flags(const HInkList*, InkListIter*);
Expand Down Expand Up @@ -61,7 +61,7 @@ class list_interface
int _i;
bool _one_list_iterator; ///< iterates only though values of one list
friend list_interface;
#ifdef INK_BUILD_CLIB
#ifdef INKCPP_BUILD_CLIB
friend int ::ink_list_flags(const HInkList*, InkListIter*);
friend int ::ink_list_flags_from(const HInkList*, const char*, InkListIter*);
friend int ::ink_list_iter_next(InkListIter* self);
Expand Down
2 changes: 0 additions & 2 deletions inkcpp/include/runner.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,6 @@ class runner_interface
*/
virtual snapshot* create_snapshot() const = 0;

#ifdef INK_ENABLE_CSTD
/**
* Continue execution until the next newline, then allocate a c-style
* string with the output. This allocated string is managed by the runtime
Expand All @@ -93,7 +92,6 @@ class runner_interface
* @return allocated c-style string with the output of a single line of execution
*/
virtual const char* getline_alloc() = 0;
#endif

#if defined(INK_ENABLE_STL) || defined(INK_ENABLE_UNREAL)
/**
Expand Down
Loading