From 717912c88cfeaec571684536c44f6b9586980625 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 29 Nov 2018 20:09:41 +0100 Subject: [PATCH] - direct native methods for dynamic arrays. --- src/scripting/backend/dynarrays.cpp | 389 ++++++++++++++++------------ 1 file changed, 225 insertions(+), 164 deletions(-) diff --git a/src/scripting/backend/dynarrays.cpp b/src/scripting/backend/dynarrays.cpp index de09ec79b..503a59f04 100644 --- a/src/scripting/backend/dynarrays.cpp +++ b/src/scripting/backend/dynarrays.cpp @@ -42,7 +42,7 @@ #include "vm.h" #include "types.h" -// We need one specific type for each of the 7 integral VM types and instantiate the needed functions for each of them. +// We need one specific type for each of the 8 integral VM types and instantiate the needed functions for each of them. // Dynamic arrays cannot hold structs because for every type there'd need to be an internal implementation which is impossible. typedef TArray FDynArray_I8; @@ -54,27 +54,92 @@ typedef TArray FDynArray_Ptr; typedef TArray FDynArray_Obj; typedef TArray FDynArray_String; -// The following macros are used to zero initialize items implicitly added to a dynamic array -// Some function like Insert() and Resize() can append such items during their operation -// It's more natural for a scripting language to have them initialized -// This is a must for DObject pointers because of garbage collection - -#define PARAM_DYNARRAY_SIZE_PROLOGUE(type) \ - PARAM_SELF_STRUCT_PROLOGUE(type); \ - const unsigned oldSize = self->Size(); - -#define DYNARRAY_FILL_ITEMS_SKIP(skip) \ - const int fillCount = int(self->Size() - oldSize) - skip; \ - if (fillCount > 0) memset(&(*self)[oldSize], 0, sizeof(*self)[0] * fillCount); - - //----------------------------------------------------- // // Int8 array // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_I8, Copy) +template void ArrayCopy(T *self, T *other) +{ + *self = *other; +} + +template void ArrayMove(T *self, T* other) +{ + *self = std::move(*other); +} + +template int ArrayFind(T *self, U val) +{ + return self->Find(val); +} + +template int ArrayPush(T *self, U val) +{ + return self->Push(val); +} + +template bool ArrayPop(T *self) +{ + return self->Pop(); +} + +template void ArrayDelete(T *self, int index, int count) +{ + self->Delete(index, count); +} + +template void ArrayInsert(T *self, int index, U val) +{ + //int oldSize = self->Size(); + self->Insert(index, val); + // Is this even necessary? All Insert does is inserting one defined element into the array and moving the rest. + // It never creates empty tailing entries. fillcount in the macro will always be 0 + //if (fill) { DYNARRAY_FILL_ITEMS_SKIP(1); } +} + +template void ArrayShrinkToFit(T *self) +{ + self->ShrinkToFit(); +} + +template void ArrayGrow(T *self, int amount) +{ + self->Grow(amount); +} + +template void ArrayResize(T *self, int amount) +{ + int oldSize = self->Size(); + self->Resize(amount); + if (fill) + { + // This must ensure that all new entries get cleared. + const int fillCount = int(self->Size() - oldSize); + if (fillCount > 0) memset(&(*self)[oldSize], 0, sizeof(*self)[0] * fillCount); + } +} + +template void ArrayReserve(T *self, int amount) +{ + self->Reserve(amount); +} + +template int ArrayMax(T *self) +{ + return self->Max(); +} + +template void ArrayClear(T *self) +{ + self->Clear(); +} + +// without this the two-argument templates cannot be used in macros. +#define COMMA , + +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_POINTER(other, FDynArray_I8); @@ -82,7 +147,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_I8, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_POINTER(other, FDynArray_I8); @@ -90,27 +155,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_I8, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_INT(val); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_INT(val); ACTION_RETURN_INT(self->Push(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_INT(index); @@ -119,24 +184,23 @@ DEFINE_ACTION_FUNCTION(FDynArray_I8, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Insert, ArrayInsert) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_I8); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_INT(index); PARAM_INT(val); - self->Insert(index, val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_INT(count); @@ -144,29 +208,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_I8, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_I8); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_I8, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I8, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I8); self->Clear(); @@ -179,7 +242,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_I8, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_I16, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_POINTER(other, FDynArray_I16); @@ -187,7 +250,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_I16, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_POINTER(other, FDynArray_I16); @@ -195,27 +258,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_I16, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_INT(val); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_INT(val); ACTION_RETURN_INT(self->Push(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_INT(index); @@ -224,24 +287,23 @@ DEFINE_ACTION_FUNCTION(FDynArray_I16, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Insert, ArrayInsert) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_I16); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_INT(index); PARAM_INT(val); - self->Insert(index, val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_INT(count); @@ -249,29 +311,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_I16, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_I16); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_I16, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I16, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I16); self->Clear(); @@ -284,7 +345,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_I16, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_I32, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_POINTER(other, FDynArray_I32); @@ -292,7 +353,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_I32, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_POINTER(other, FDynArray_I32); @@ -300,27 +361,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_I32, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_INT(val); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_INT(val); ACTION_RETURN_INT(self->Push(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_INT(index); @@ -329,24 +390,23 @@ DEFINE_ACTION_FUNCTION(FDynArray_I32, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Insert, ArrayInsert) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_I32); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_INT(index); PARAM_INT(val); - self->Insert(index, val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_INT(count); @@ -354,29 +414,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_I32, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_I32); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_I32, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_I32, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_I32); self->Clear(); @@ -389,7 +448,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_I32, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_F32, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_POINTER(other, FDynArray_F32); @@ -397,7 +456,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_F32, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_POINTER(other, FDynArray_F32); @@ -405,27 +464,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_F32, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_FLOAT(val); ACTION_RETURN_INT(self->Find((float)val)); } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_FLOAT(val); ACTION_RETURN_INT(self->Push((float)val)); } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_INT(index); @@ -434,24 +493,23 @@ DEFINE_ACTION_FUNCTION(FDynArray_F32, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Insert, ArrayInsert) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_F32); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_INT(index); PARAM_FLOAT(val); - self->Insert(index, (float)val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_INT(count); @@ -459,29 +517,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_F32, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_F32); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_F32, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F32, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F32); self->Clear(); @@ -494,7 +551,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_F32, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_F64, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_POINTER(other, FDynArray_F64); @@ -502,7 +559,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_F64, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_POINTER(other, FDynArray_F64); @@ -510,27 +567,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_F64, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_FLOAT(val); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_FLOAT(val); ACTION_RETURN_INT(self->Push(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_INT(index); @@ -539,24 +596,23 @@ DEFINE_ACTION_FUNCTION(FDynArray_F64, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Insert, ArrayInsert) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_F64); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_INT(index); PARAM_FLOAT(val); - self->Insert(index, val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_INT(count); @@ -564,29 +620,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_F64, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_F64); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_F64, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_F64, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_F64); self->Clear(); @@ -599,7 +654,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_F64, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_POINTER(other, FDynArray_Ptr); @@ -607,7 +662,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_POINTER(other, FDynArray_Ptr); @@ -615,27 +670,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_POINTER(val, void); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_POINTER(val, void); ACTION_RETURN_INT(self->Push(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_INT(index); @@ -644,24 +699,23 @@ DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Insert, ArrayInsert) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_Ptr); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_INT(index); PARAM_POINTER(val, void); - self->Insert(index, val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_INT(count); @@ -669,29 +723,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_Ptr); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Ptr, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Ptr); self->Clear(); @@ -705,7 +758,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_Ptr, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_POINTER(other, FDynArray_Obj); @@ -713,7 +766,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_Obj, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_POINTER(other, FDynArray_Obj); @@ -721,28 +774,33 @@ DEFINE_ACTION_FUNCTION(FDynArray_Obj, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_OBJECT(val, DObject); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Push) +int ObjArrayPush(FDynArray_Obj *self, DObject *obj) +{ + GC::WriteBarrier(obj); + return self->Push(obj); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Push, ObjArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_OBJECT(val, DObject); - GC::WriteBarrier(val); - ACTION_RETURN_INT(self->Push(val)); + ACTION_RETURN_INT(ObjArrayPush(self, val)); } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(index); @@ -751,25 +809,29 @@ DEFINE_ACTION_FUNCTION(FDynArray_Obj, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Insert) +void ObjArrayInsert(FDynArray_Obj *self,int index, DObject *obj) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_Obj); + GC::WriteBarrier(obj); + self->Insert(index, obj); +} + +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Insert, ObjArrayInsert) +{ + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(index); PARAM_OBJECT(val, DObject); - GC::WriteBarrier(val); - self->Insert(index, val); - DYNARRAY_FILL_ITEMS_SKIP(1); + ObjArrayInsert(self, index, val); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); @@ -777,29 +839,28 @@ DEFINE_ACTION_FUNCTION(FDynArray_Obj, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Resize, ArrayResize) { - PARAM_DYNARRAY_SIZE_PROLOGUE(FDynArray_Obj); + PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); - self->Resize(count); - DYNARRAY_FILL_ITEMS_SKIP(0); + ArrayResize(self, count); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_Obj, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_Obj, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_Obj); self->Clear(); @@ -813,7 +874,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_Obj, Clear) // //----------------------------------------------------- -DEFINE_ACTION_FUNCTION(FDynArray_String, Copy) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Copy, ArrayCopy) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_POINTER(other, FDynArray_String); @@ -821,7 +882,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_String, Copy) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, Move) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Move, ArrayMove) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_POINTER(other, FDynArray_String); @@ -829,27 +890,27 @@ DEFINE_ACTION_FUNCTION(FDynArray_String, Move) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, Find) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Find, ArrayFind) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_STRING(val); ACTION_RETURN_INT(self->Find(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_String, Push) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Push, ArrayPush) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_STRING(val); ACTION_RETURN_INT(self->Push(val)); } -DEFINE_ACTION_FUNCTION(FDynArray_String, Pop) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Pop, ArrayPop) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); ACTION_RETURN_BOOL(self->Pop()); } -DEFINE_ACTION_FUNCTION(FDynArray_String, Delete) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Delete, ArrayDelete) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_INT(index); @@ -858,7 +919,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_String, Delete) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, Insert) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Insert, ArrayInsert) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_INT(index); @@ -867,14 +928,14 @@ DEFINE_ACTION_FUNCTION(FDynArray_String, Insert) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, ShrinkToFit) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, ShrinkToFit, ArrayShrinkToFit) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); self->ShrinkToFit(); return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, Grow) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Grow, ArrayGrow) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_INT(count); @@ -882,7 +943,7 @@ DEFINE_ACTION_FUNCTION(FDynArray_String, Grow) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, Resize) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Resize, ArrayResize) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_INT(count); @@ -890,20 +951,20 @@ DEFINE_ACTION_FUNCTION(FDynArray_String, Resize) return 0; } -DEFINE_ACTION_FUNCTION(FDynArray_String, Reserve) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Reserve, ArrayReserve) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); PARAM_INT(count); ACTION_RETURN_INT(self->Reserve(count)); } -DEFINE_ACTION_FUNCTION(FDynArray_String, Max) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Max, ArrayMax) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); ACTION_RETURN_INT(self->Max()); } -DEFINE_ACTION_FUNCTION(FDynArray_String, Clear) +DEFINE_ACTION_FUNCTION_NATIVE(FDynArray_String, Clear, ArrayClear) { PARAM_SELF_STRUCT_PROLOGUE(FDynArray_String); self->Clear();