Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Unreal Build and 4.26 Compatibility #35

Closed
wants to merge 2 commits into from
Closed
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
10 changes: 7 additions & 3 deletions inkcpp/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
set_property(GLOBAL PROPERTY USE_FOLDERS ON)

list(APPEND SOURCES
collections/restorable.h
collections/restorable.cpp
restorable.h
array.h
choice.cpp
functional.cpp
Expand All @@ -18,11 +17,16 @@ list(APPEND SOURCES
value.h value.cpp
string_table.h string_table.cpp avl_array.h
list_table.h list_table.cpp
casting.h
operations.h operation_bases.h
numeric_operations.h string_operations.h
list_operations.h list_operations.cpp
container_operations.h container_operations.cpp
string_operations.cpp
numeric_operations.cpp
header.cpp
header.cpp tuple.hpp
string_utils.h random.h
executioner.h
)
source_group(Collections REGULAR_EXPRESSION collections/.*)
add_library(inkcpp ${SOURCES})
Expand Down
4 changes: 2 additions & 2 deletions inkcpp/avl_array.h
Original file line number Diff line number Diff line change
Expand Up @@ -482,9 +482,9 @@ class avl_array

/**
* Integrity (self) check
* \return True if the tree intergity is correct, false if error (should not happen normally)
* \return True if the tree integrity is correct, false if error (should not happen normally)
*/
bool check() const
bool check_integrity() const
{
// check root
if (empty() && (root_ != INVALID_IDX)) {
Expand Down
Empty file removed inkcpp/collections/restorable.cpp
Empty file.
33 changes: 17 additions & 16 deletions inkcpp/functional.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,50 +43,51 @@ namespace ink::runtime::internal
}
#endif
#ifdef INK_ENABLE_UNREAL
SUPPORT_TYPE_PARAMETER_ONLY(FString);
template<>
FString function_base::pop<FString>(basic_eval_stack* stack) {
return FString(pop<const char*>(stack));
}

template<>
FInkVar function_base::pop<FInkVar>(basic_eval_stack* stack)
{
value v = stack->pop();
switch (v.type())
{
case value_type::null:
case value_type::divert:
inkFail("Trying to pass null or divert as ink parameter to external function");
break;
case value_type::integer:
return FInkVar(v.get<int>());
case value_type::decimal:
return FInkVar(v.get<float>());
case value_type::int32:
return FInkVar(v.get<value_type::int32>());
case value_type::float32:
return FInkVar(v.get<value_type::float32>());
case value_type::string:
return FInkVar(v.get<FString>());
return FInkVar(FString(v.get<value_type::string>().str));
}

inkFail("You can only pass integers, floats, or strings into ink functions.");
return FInkVar();
}

template<>
void function_base::push<FInkVar>(basic_eval_stack* stack, const FInkVar& value)
{
internal::value v;

switch (value.type)
{
case EInkVarType::None:
{
internal::value v;
stack->push(v);
}
// Set to none
break;
case EInkVarType::Int:
stack->push(value.intVar);
v.set<value_type::int32>(value.intVar);
break;
case EInkVarType::Float:
stack->push(value.floatVar);
v.set<value_type::float32>(value.floatVar);
break;
case EInkVarType::String:
inkFail("NOT IMPLEMENTED"); // TODO: String support
return;
}

stack->push(v);
}
#endif
}
26 changes: 13 additions & 13 deletions inkcpp/list_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
) \
)); \
} else {\
inkAssert(vals[1].type()==value_type::list_flag);\
inkAssert(vals[1].type()==value_type::list_flag, "Value must be a list!");\
stack.push(value{}.set<value_type::RET1>( \
_list_table.FUN( \
vals[0].get<value_type::list_flag>(), \
Expand All @@ -32,7 +32,7 @@
)); \
} \
} else { \
inkAssert(vals[0].type() == value_type::list); \
inkAssert(vals[0].type() == value_type::list, "Value must be a list!"); \
if(vals[1].type() == value_type::list) { \
stack.push(value{}.set<value_type::RET2>( \
_list_table.FUN( \
Expand All @@ -41,7 +41,7 @@
) \
)); \
} else {\
inkAssert(vals[1].type()==value_type::list_flag);\
inkAssert(vals[1].type()==value_type::list_flag, "Value must be a list!");\
stack.push(value{}.set<value_type::RET3>( \
_list_table.FUN( \
vals[0].get<value_type::list>(), \
Expand Down Expand Up @@ -77,7 +77,7 @@ namespace ink::runtime::internal {
int i = vals[1].type() == value_type::int32
? vals[1].get<value_type::int32>()
: vals[1].get<value_type::uint32>();
inkAssert(vals[0].type() == value_type::list);
inkAssert(vals[0].type() == value_type::list, "Value must be a list!");
stack.push(value{}.set<value_type::list>(
_list_table.add(vals[0].get<value_type::list>(), i)
));
Expand All @@ -88,9 +88,9 @@ namespace ink::runtime::internal {
void operation<Command::ADD, value_type::list_flag, void>::operator()(
basic_eval_stack& stack, value* vals)
{
inkAssert(vals[0].type() == value_type::list_flag);
inkAssert(vals[0].type() == value_type::list_flag, "Value must be a list!");
inkAssert(vals[1].type() == value_type::int32
|| vals[1].type() == value_type::uint32);
|| vals[1].type() == value_type::uint32, "Second value must be a number!");
int i = vals[1].type() == value_type::int32
? vals[1].get<value_type::int32>()
: vals[1].get<value_type::uint32>();
Expand All @@ -108,7 +108,7 @@ namespace ink::runtime::internal {
int i = vals[1].type() == value_type::int32
? vals[1].get<value_type::int32>()
: vals[1].get<value_type::uint32>();
inkAssert(vals[0].type() == value_type::list);
inkAssert(vals[0].type() == value_type::list, "Value must be a list!");
stack.push(value{}.set<value_type::list>(
_list_table.sub(vals[0].get<value_type::list>(), i)
));
Expand All @@ -119,9 +119,9 @@ namespace ink::runtime::internal {
void operation<Command::SUBTRACT, value_type::list_flag, void>::operator()(
basic_eval_stack& stack, value* vals)
{
inkAssert(vals[0].type() == value_type::list_flag);
inkAssert(vals[0].type() == value_type::list_flag, "Value must be a list!");
inkAssert(vals[1].type() == value_type::int32
|| vals[1].type() == value_type::uint32);
|| vals[1].type() == value_type::uint32, "Second value must be a number!");
int i = vals[1].type() == value_type::int32
? vals[1].get<value_type::int32>()
: vals[1].get<value_type::uint32>();
Expand Down Expand Up @@ -170,8 +170,8 @@ namespace ink::runtime::internal {
void operation<Command::LIST_INT, value_type::string, void>::operator()(
basic_eval_stack& stack, value* vals)
{
inkAssert(vals[0].type() == value_type::string);
inkAssert(vals[1].type() == value_type::int32);
inkAssert(vals[0].type() == value_type::string, "Value must be a string!");
inkAssert(vals[1].type() == value_type::int32, "Second value must be a number!");
list_flag entry = _list_table.get_list_id(vals[0].get<value_type::string>());
entry.flag = vals[1].get<value_type::int32>() - 1;
stack.push(value{}.set<value_type::list_flag>(entry));
Expand All @@ -181,14 +181,14 @@ namespace ink::runtime::internal {
if(val.type() == value_type::int32) {
return val.get<value_type::int32>() - 1;
} else {
inkAssert(val.type() == value_type::list_flag);
inkAssert(val.type() == value_type::list_flag, "Value must be a list!");
return val.get<value_type::list_flag>().flag;
}
}
void operation<Command::LIST_RANGE, value_type::list, void>::operator()(
basic_eval_stack& stack, value* vals)
{
inkAssert(vals[0].type() == value_type::list);
inkAssert(vals[0].type() == value_type::list, "Value must be a list!");
stack.push(value{}.set<value_type::list>(_list_table.range(
vals[0].get<value_type::list>(),
get_limit(vals[1]),
Expand Down
28 changes: 14 additions & 14 deletions inkcpp/list_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace ink::runtime::internal

list_table::list list_table::create()
{
for(int i = 0; i < _entry_state.size(); ++i) {
for(int i = 0; i < (int)_entry_state.size(); ++i) {
if (_entry_state[i] == state::empty) {
_entry_state[i] = state::used;
return list(i);
Expand Down Expand Up @@ -82,7 +82,7 @@ namespace ink::runtime::internal
}

void list_table::gc() {
for(int i = 0; i < _entry_state.size(); ++i) {
for(int i = 0; i < (int)_entry_state.size(); ++i) {
if (_entry_state[i] == state::unused) {
_entry_state[i] = state::empty;
data_t* entry = getPtr(i);
Expand Down Expand Up @@ -308,19 +308,19 @@ namespace ink::runtime::internal
data_t* l = getPtr(arg.lid);
data_t* o = getPtr(res.lid);
bool active_flag = false;;
for(int i = 0; i < numLists(); ++i) {
if(hasList(l, i)) {
for(int m = 0; m < numLists(); ++m) {
if(hasList(l, m)) {
bool has_flag = false;
for(int j = listBegin(i); j < _list_end[i] - i;++j)
for(int j = listBegin(m); j < _list_end[m] - m;++j)
{
if(hasFlag(l, j)) {
setFlag(o,j+i);
setFlag(o,j+m);
has_flag = true;
}
}
if(has_flag) {
active_flag = true;
setList(o,i);
setList(o,m);
}
}
}
Expand Down Expand Up @@ -348,19 +348,19 @@ namespace ink::runtime::internal
data_t* l = getPtr(arg.lid);
data_t* o = getPtr(res.lid);
bool active_flag = false;
for(int i = 0; i < numLists(); ++i) {
if(hasList(l, i)) {
for(int m = 0; m < numLists(); ++m) {
if(hasList(l, m)) {
bool has_flag = false;
for(int j = listBegin(i) + i; j < _list_end[i]; ++j)
for(int j = listBegin(m) + m; j < _list_end[m]; ++j)
{
if(hasFlag(l,j)) {
setFlag(o,j-i);
setFlag(o,j-m);
has_flag = true;
}
}
if(has_flag) {
active_flag = true;
setList(o, i);
setList(o, m);
}
}
}
Expand Down Expand Up @@ -554,8 +554,8 @@ namespace ink::runtime::internal

list_flag list_table::lrnd(list lh, prng& rng) const {
const data_t* l = getPtr(lh.lid);
int i = count(lh);
rng.rand(i);
int c = count(lh);
rng.rand(c);
int count = 0;
for(int i = 0; i < numLists(); ++i) {
if(hasList(l, i)) {
Expand Down
4 changes: 2 additions & 2 deletions inkcpp/list_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#endif

namespace ink::internal {
class header;
struct header;
}
namespace ink::runtime::internal
{
Expand Down Expand Up @@ -215,7 +215,7 @@ namespace ink::runtime::internal
abs(config::maxListTypes)
+ abs(config::maxFlags),
sizeof(data_t)
) * abs(config::maxLists);
) * (int)abs(config::maxLists);

int _entrySize; ///< entry size in data_t
// entries (created lists)
Expand Down
4 changes: 2 additions & 2 deletions inkcpp/numeric_operations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@ namespace ink::runtime::internal {
void operation<Command::FLOOR, value_type::float32, void>::operator()(
basic_eval_stack& stack, value* vals)
{
inkAssert(vals[0].type() == value_type::float32);
inkAssert(vals[0].type() == value_type::float32, "Value must be a float!");
stack.push(value{}.set<value_type::float32>(
floor(vals->get<value_type::float32>())));
}

void operation<Command::CEILING, value_type::float32, void>::operator()(
basic_eval_stack& stack, value* vals)
{
inkAssert(vals[0].type() == value_type::float32);
inkAssert(vals[0].type() == value_type::float32, "Value must be a float!");
stack.push(value{}.set<value_type::float32>(
ceil(vals->get<value_type::float32>())));
}
Expand Down
2 changes: 1 addition & 1 deletion inkcpp/operations.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

/// Define base constructs to specify by operation headers.

#include "../shared/private/command.h"
#include "command.h"

namespace ink::runtime::internal {

Expand Down
6 changes: 3 additions & 3 deletions inkcpp/output.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ namespace ink
return false;
}

template<typename OUT>
void basic_stream::copy_string(const char* str, size_t& dataIter, OUT& output)
template<typename OutputType>
void basic_stream::copy_string(const char* str, size_t& dataIter, OutputType& output)
{
while(*str != 0) {
write_char(output, *str++);
write_char(output, *str++);
}
}

Expand Down
4 changes: 2 additions & 2 deletions inkcpp/output.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ namespace ink
size_t find_start() const;
bool should_skip(size_t iter, bool& hasGlue, bool& lastNewline) const;

template<typename OUT>
void copy_string(const char* str, size_t& dataIter, OUT& output);
template<typename OutputType>
void copy_string(const char* str, size_t& dataIter, OutputType& output);

private:
char _last_char;
Expand Down
2 changes: 1 addition & 1 deletion inkcpp/random.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

#include "../shared/public/system.h"
#include "system.h"

namespace ink::runtime::internal {
/**
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions inkcpp/runner_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,8 @@ namespace ink::runtime::internal
// TODO
return nullptr;

#endif
}
#endif

bool runner_impl::move_to(hash_t path)
{
Expand Down Expand Up @@ -832,7 +832,7 @@ namespace ink::runtime::internal
if(flag & CommandFlag::TUNNEL_TO_VARIABLE) {
hash_t var_name = read<hash_t>();
const value* val = get_var(var_name);
inkAssert(val != nullptr);
inkAssert(val != nullptr, "Tunnel variable undefined");
target = val->get<value_type::divert>();
} else {
target = read<uint32_t>();
Expand All @@ -847,7 +847,7 @@ namespace ink::runtime::internal
if(flag & CommandFlag::FUNCTION_TO_VARIABLE) {
hash_t var_name = read<hash_t>();
const value* val = get_var(var_name);
inkAssert(val != nullptr);
inkAssert(val != nullptr, "Function variable undefined");
target = val->get<value_type::divert>();
} else {
target = read<uint32_t>();
Expand Down
2 changes: 2 additions & 0 deletions inkcpp/runner_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ namespace ink::runtime::internal
_threadDone.clear(nullptr);
}

virtual ~threads() { }

void clear() {
base::clear();
_threadDone.clear(nullptr);
Expand Down
Loading