Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d406c87
bump(UE) add version UE5.7, no changes necessary
Nov 20, 2025
018b169
WIP
Nov 20, 2025
507c865
refactor: Removed memory leaks in test scenarios
JBenda Nov 21, 2025
5e4462a
refactor improve code quality
Nov 21, 2025
315662a
fix(snapshots): Store tags for choices with index
JBenda Nov 26, 2025
ee43336
fix(snapshot): cleare temporary data used for reconstruction
JBenda Nov 26, 2025
01e5727
WIP
JBenda Nov 28, 2025
bb99e12
Add option for inkcpp to compile without exceptions
harryr0se Dec 13, 2025
2add7d3
Run clang-format
harryr0se Dec 13, 2025
c7ed6a3
Combine INK_ENABLE_EH and INK_ENABLE_EXCEPTIONS defines/options
harryr0se Dec 14, 2025
d804139
fix(STL): guard references to STL and CSTD behind compile options
JBenda Dec 10, 2025
9718608
fix(NO_STD): touchups needed for rebase of current master
JBenda Jan 6, 2026
3cce88b
Merge branch 'fix/135-cpp-bindings-in-clib' into feature/migration
JBenda Jan 6, 2026
c68c033
feat(Migration): add hungarian_solver to match list elements
JBenda Mar 23, 2026
73b02df
WIP
JBenda Mar 25, 2026
3b98bb3
Merge remote-tracking branch 'origin/master' into feature/migration
JBenda Mar 25, 2026
3812d28
feat(Migration): add distance functions for labels and values
JBenda Mar 25, 2026
629a288
fix(assert): fixes defines (INKCPP_ENABLE... -> INK_ENABLE_...) to ha…
JBenda Mar 27, 2026
74caada
Merge branch 'fix/assert' into feature/migration
JBenda Mar 27, 2026
c89dce1
fix(assert): fixes defines (INKCPP_ENABLE... -> INK_ENABLE_...) to ha…
JBenda Mar 30, 2026
0038b30
fix(Snapshot): only access optional data if accasible
JBenda Mar 30, 2026
f7c94ec
fix(Snapshot): visit count migration now can handle different capacit…
JBenda Apr 1, 2026
e573b85
fix(Migration): also migrate permanent lists
JBenda Apr 7, 2026
254395b
fix(Migration): also migrate permanent lists
JBenda Apr 7, 2026
c7a3203
fix(Migration): also migrate permanent lists
JBenda Apr 15, 2026
8d6d2f9
build(Py): bump pybind11 to version v3.0.3
JBenda Apr 15, 2026
a922651
style: adapt to clang-format version used by github runner
JBenda Apr 15, 2026
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
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,7 @@ jobs:
git fetch origin master
- name: Check clang-format
run: |
clang-format-18 --version
git clang-format-18 --extensions c,cpp,h,hpp --style file -q --diff origin/master
diff=$(git clang-format-18 --extensions c,cpp,h,hpp --style file -q --diff origin/master)
echo "::error Format diff >$diff<"
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
url: https://pypi.org/p/inkcpp-py
permissions:
id-token: write
contents: write
contents: write
steps:
- uses: actions/checkout@v4
- name: Download artifacts
Expand Down Expand Up @@ -46,4 +46,3 @@ jobs:
--title="${GITHUB_REPOSITORY#*/} ${tag#v}" \
--generate-notes \
"$tag" "linux-cl.zip" "linux-lib.zip" "linux-clib.zip" "unreal_5_7.zip" "unreal_5_6.zip" "unreal_5_5.zip" "unreal_5_4.zip" "macos-cl.zip" "macos-lib.zip" "macos-clib.zip" "win64-cl.zip" "macos-arm-cl.zip" "macos-arm-lib.zip" "macos-arm-clib.zip" "win64-lib.zip" "win64-clib.zip"

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Adapt `TargetPlatforms` as nessesarry. You might also want to install the Plugin
Nice features for testing:
+ predefined choice selection `echo 1 2 1 | inkpp-cl -p story.(ink|json|bin)`
+ create snapshots to shorten testing:
+ create snapshot by entering `-1` as choice `echo 1 2 -1 | inkcpp-cl -p story.ink`
+ create snapshot by entering `-1` as choice `echo 1 2 -1 1 | inkcpp-cl -p story.ink`
+ load snapshot as an additional argument `echo 1 | inkcpp-cl -p story.snap story.ink`

## Including in C++ Code
Expand Down
2 changes: 2 additions & 0 deletions inkcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ list(
string_operations.cpp
string_operations.cpp
numeric_operations.cpp
hungarian_solver.h
hungarian_solver.cpp
casting.h
executioner.h
string_utils.h
Expand Down
54 changes: 44 additions & 10 deletions inkcpp/array.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ namespace ink::runtime::internal
* @tparam simple if the object has a trivial destructor, so delete[](char*) can be used instead of
* calling the constructor.
* @tparam dynamic if the memory should be allocated on the heap and grow if needed
* @tparam initialCapacitiy number of elements to allocate at construction, if !dynamic, this is
* @tparam initial capacity number of elements to allocate at construction, if !dynamic, this is
* allocated in place and can not be changed.
*/
template<typename T, bool dynamic, size_t initialCapacity, bool simple>
Expand Down Expand Up @@ -157,6 +157,8 @@ class managed_array : public snapshot_interface

void extend(size_t capacity = 0);

bool can_be_migrated() const { return true; }

size_t snap(unsigned char* data, const snapper& snapper) const
{
inkAssert(! is_pointer<T>{}(), "here is a special case oversight");
Expand Down Expand Up @@ -229,6 +231,8 @@ class managed_restorable_array : public managed_array<T, dynamic, initialCapacit
_last_size = 0;
}

bool is_saved() const { return _last_size != 0; }

void save() { _last_size = this->size(); }

void forgett() { _last_size = 0; }
Expand All @@ -237,6 +241,8 @@ class managed_restorable_array : public managed_array<T, dynamic, initialCapacit

size_t last_size() const { return _last_size; }

bool can_be_migrated() const { return ! is_saved(); }

size_t snap(unsigned char* data, const snapshot_interface::snapper& snapper) const
{
unsigned char* ptr = data;
Expand Down Expand Up @@ -306,7 +312,7 @@ class basic_restorable_array : public snapshot_interface
clear_temp();
}

// == Non-Copyable ==
// not copyable
basic_restorable_array(const basic_restorable_array<T>&) = delete;
basic_restorable_array<T>& operator=(const basic_restorable_array<T>&) = delete;

Expand All @@ -315,10 +321,19 @@ class basic_restorable_array : public snapshot_interface

// get value by index
const T& get(size_t index) const;
const T& get_old(size_t index) const;

// size of the array
inline size_t capacity() const { return _capacity; }

inline size_t loaded_capacity() const
{
inkAssert(
_loaded_capacity != static_cast<size_t>(~0), "This object was not loaded from a snapshot."
);
return _loaded_capacity;
}

// only const indexing is supported due to save/restore system
inline const T& operator[](size_t index) const { return get(index); }

Expand All @@ -331,6 +346,7 @@ class basic_restorable_array : public snapshot_interface
void clear(const T& value);

// snapshot interface
virtual bool can_be_migrated() const;
virtual size_t snap(unsigned char* data, const snapper&) const;
virtual const unsigned char* snap_load(const unsigned char* data, const loader&);

Expand Down Expand Up @@ -358,12 +374,15 @@ class basic_restorable_array : public snapshot_interface
// real values live here
T* _array;

// we store values here when we're in save mode
// we store values here when we're in safe mode
// they're copied on a call to forget()
T* _temp;

// size of both _array and _temp
size_t _capacity;
// if loaded with snap_load, this value was the original size, the current capacity might be
// higher
size_t _loaded_capacity = static_cast<size_t>(~0);

// null
const T _null;
Expand All @@ -389,7 +408,7 @@ inline const T& basic_restorable_array<T>::get(size_t index) const
{
check_index(index);

// If we're in save mode and we have a value at that index, return that instead
// If we're in safe mode, and we have a value at that index, return that instead
if (_saved && _temp[index] != _null) {
return _temp[index];
}
Expand All @@ -398,6 +417,15 @@ inline const T& basic_restorable_array<T>::get(size_t index) const
return _array[index];
}

template<typename T>
inline const T& basic_restorable_array<T>::get_old(size_t index) const
{
check_index(index);
inkAssert(_saved, "Use old only on saved arrays.");

return _array[index];
}

template<typename T>
inline void basic_restorable_array<T>::save()
{
Expand All @@ -419,7 +447,7 @@ inline void basic_restorable_array<T>::forget()
{
// Run through the _temp array
for (size_t i = 0; i < _capacity; i++) {
// Copy if there's values
// Copy if there are values
if (_temp[i] != _null) {
_array[i] = _temp[i];
}
Expand Down Expand Up @@ -521,6 +549,12 @@ class allocated_restorable_array : public basic_restorable_array<T>
T* _buffer;
};

template<typename T>
inline bool basic_restorable_array<T>::can_be_migrated() const
{
return ! _saved;
}

template<typename T>
inline size_t basic_restorable_array<T>::snap(unsigned char* data, const snapper&) const
{
Expand All @@ -542,18 +576,18 @@ inline const unsigned char*
{
auto ptr = data;
ptr = snap_read(ptr, _saved);
decltype(_capacity) capacity;
ptr = snap_read(ptr, capacity);
ptr = snap_read(ptr, _loaded_capacity);
if (buffer() == nullptr) {
static_cast<allocated_restorable_array<T>&>(*this).resize(capacity);
static_cast<allocated_restorable_array<T>&>(*this).resize(_loaded_capacity);
}
inkAssert(
_capacity >= capacity, "New config does not allow for necessary size used by this snapshot!"
_capacity >= _loaded_capacity,
"New config does not allow for necessary size used by this snapshot!"
);
T null;
ptr = snap_read(ptr, null);
inkAssert(null == _null, "null value is different to snapshot!");
for (size_t i = 0; i < _capacity; ++i) {
for (size_t i = 0; i < _loaded_capacity; ++i) {
ptr = snap_read(ptr, _array[i]);
ptr = snap_read(ptr, _temp[i]);
}
Expand Down
2 changes: 2 additions & 0 deletions inkcpp/collections/restorable.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ class restorable : public snapshot_interface
virtual size_t snap(unsigned char* data, const snapper&) const;
const unsigned char* snap_load(const unsigned char* data, const loader&);

bool can_be_migrated() const { return ! is_saved(); }

protected:
// Called when we run out of space in buffer.
virtual void overflow(ElementType*&, size_t&) { inkFail("Restorable run out of memory!"); }
Expand Down
13 changes: 13 additions & 0 deletions inkcpp/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ float function_base::pop<float>(basic_eval_stack* stack, list_table&)
return casting::numeric_cast<value_type::float32>(val);
}

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

template<>
const char* function_base::pop<const char*>(basic_eval_stack* stack, list_table&)
{
Expand All @@ -79,6 +86,12 @@ void function_base::push<float>(basic_eval_stack* stack, const float& v)
stack->push(value{}.set<value_type::float32>(v));
}

template<>
void function_base::push<double>(basic_eval_stack* stack, const double& v)
{
stack->push(value{}.set<value_type::float32>(static_cast<float>(v)));
}

template<>
void function_base::push<bool>(basic_eval_stack* stack, const bool& v)
{
Expand Down
Loading
Loading