alar82
2020-01-28 18:07:06

What is going on here, some kind of error huh.
2020-01-28 18:07:06

2020-01-31 12:31:07
From: alar82
What is going on here, some kind of error huh.
#ifndef TMEMORYMANAGER_HXX_INCLUDED
#define TMEMORYMANAGER_HXX_INCLUDED
#if !defined(_MSC_VER)
#define DELPHI_CALLING_CONVENTION __attribute__((regparm(3)))
typedef struct
{
std::uint32_t TotalAddressSpace;
std::uint32_t TotalUncommited;
std::uint32_t TotalCommited;
std::uint32_t TotalAllocated;
std::uint32_t TotalFree;
std::uint32_t FreeSmall;
std::uint32_t FreeBig;
std::uint32_t Unused;
std::uint32_t Overhead;
std::uint32_t HeapErrorCode;
} THeapStatus;
typedef struct
{
std::uintptr_t MaxHeapSize;
std::uintptr_t MaxHeapUsed;
std::uintptr_t CurrHeapSize;
std::uintptr_t CurrHeapUsed;
std::uintptr_t CurrHeapFree;
} TFPCHeapStatus;
typedef struct
{
bool NeedLock;
void* (*GetMem)(std::intptr_t size) DELPHI_CALLING_CONVENTION;
std::intptr_t (*FreeMem)(void* &ptr) DELPHI_CALLING_CONVENTION;
std::intptr_t (*FreeMemSize)(void* &ptr, std::intptr_t size) DELPHI_CALLING_CONVENTION;
void* (*AllocMem)(std::intptr_t size) DELPHI_CALLING_CONVENTION;
void* (*ReAllocMem)(void* &ptr, std::intptr_t size) DELPHI_CALLING_CONVENTION;
std::intptr_t (*MemSize)(void* ptr) DELPHI_CALLING_CONVENTION;
void (*InitThread)() DELPHI_CALLING_CONVENTION;
void (*DoneThread)() DELPHI_CALLING_CONVENTION;
void (*RelocateHeap)() DELPHI_CALLING_CONVENTION;
THeapStatus (*GetHeapStatus)() DELPHI_CALLING_CONVENTION;
TFPCHeapStatus (*GetFPCHeapStatus)() DELPHI_CALLING_CONVENTION;
} TMemoryManager;
typedef struct
{
bool NeedLock;
void* (*GetMem)(std::intptr_t size) DELPHI_CALLING_CONVENTION;
std::intptr_t (*FreeMem)(void* &ptr) DELPHI_CALLING_CONVENTION;
std::intptr_t (*FreeMemSize)(void* &ptr, std::intptr_t size) DELPHI_CALLING_CONVENTION;
void* (*AllocMem)(std::intptr_t size) DELPHI_CALLING_CONVENTION;
void* (*ReAllocMem)(void* &ptr, std::intptr_t size) DELPHI_CALLING_CONVENTION;
std::intptr_t (*MemSize)(void* ptr) DELPHI_CALLING_CONVENTION;
void (*InitThread)() DELPHI_CALLING_CONVENTION;
void (*DoneThread)() DELPHI_CALLING_CONVENTION;
void (*RelocateHeap)() DELPHI_CALLING_CONVENTION;
THeapStatus (*GetHeapStatus)() DELPHI_CALLING_CONVENTION;
TFPCHeapStatus (*GetFPCHeapStatus)() DELPHI_CALLING_CONVENTION;
} __attribute__((__packed__)) TCMemoryManager;
#endif
typedef struct
{
void (__cdecl *Sync)(void(__cdecl *synchronize_method)(void*), void* data);
} __attribute__((__packed__)) TSimbaMethods;
typedef struct
{
void* (__cdecl *GetMem)(std::size_t size);
void (__cdecl *FreeMem)(void* ptr);
} __attribute__((__packed__)) TSimbaMemoryAllocators;
#endif // TMEMORYMANAGER_HXX_INCLUDED
#if !defined(_MSC_VER)
TMemoryManager PLUGIN_MEMORY_MANAGER = {0};
#endif
TSimbaMethods PLUGIN_SYNC_METHODS = {0};
TSimbaMemoryAllocators PLUGIN_MEMORY_ALLOCATORS = {0};
#if !defined(_MSC_VER)
void SetPluginMemManager(TMemoryManager MemMgr)
{
PLUGIN_MEMORY_MANAGER = MemMgr;
}
#endif
void SetPluginSimbaMethods(TSimbaMethods Methods)
{
PLUGIN_SYNC_METHODS = Methods;
}
void SetPluginSimbaMemoryAllocators(TSimbaMemoryAllocators Allocators)
{
PLUGIN_MEMORY_ALLOCATORS = Allocators;
}
typedef struct
{
std::make_signed_t<std::size_t> refCount;
std::make_signed_t<std::size_t> length;
char data[];
} __attribute__((__packed__)) PascalArray;
#if defined(FPC2)
typedef struct
{
std::make_signed_t<std::size_t> refCount;
std::make_signed_t<std::size_t> length;
char data[];
} __attribute__((__packed__)) PascalString;
#else
typedef struct
{
std::uint16_t codePage;
std::uint16_t elementSize;
#if defined(__x86_64__)
std::uint32_t dummy;
#endif
std::make_signed_t<std::size_t> refCount;
std::make_signed_t<std::size_t> length;
char data[];
} __attribute__((__packed__)) PascalString;
#endif // defined
template<typename T, std::size_t size>
struct __attribute__((__packed__)) StaticPascalArray
{
const std::make_signed_t<std::size_t> refCount = -1;
const std::make_signed_t<std::size_t> length = size;
T data[size] = {0};
};
template<typename T>
int PascalHigh(T* Arr)
{
return reinterpret_cast<int*>(Arr)[-1];
}
template<typename T>
int PascalLength(T* Arr)
{
return PascalHigh<T>(Arr) + 1;
}
template<typename T>
T* AllocateArray(std::size_t size, std::size_t element_size = sizeof(T))
{
std::size_t new_size = (size * element_size) + sizeof(PascalArray);
#if !defined(_MSC_VER)
PascalArray* ptr = static_cast<PascalArray*>(PLUGIN_MEMORY_MANAGER.AllocMem(new_size));
#else
PascalArray* ptr = static_cast<PascalArray*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
#endif
ptr->refCount = 1;
ptr->length = size - 1;
return reinterpret_cast<T*>(++ptr);
}
template<typename T>
T* AllocateString(std::size_t size, std::size_t element_size = sizeof(T))
{
std::size_t new_size = (size * element_size) + sizeof(PascalString);
#if !defined(_MSC_VER)
PascalString* ptr = static_cast<PascalString*>(PLUGIN_MEMORY_MANAGER.AllocMem(new_size + 1));
#else
PascalString* ptr = static_cast<PascalString*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size + 1));
#endif
ptr->refCount = 1;
ptr->length = size;
return reinterpret_cast<T*>(++ptr);
}
template<typename T>
T* GetArray(void* ptr, std::size_t* size)
{
PascalArray* mem = static_cast<PascalArray*>(ptr);
return reinterpret_cast<T*>((--mem)->data);
}
template<typename T>
T* GetString(void* ptr)
{
PascalString* mem = static_cast<PascalString*>(ptr);
return reinterpret_cast<T*>((--mem)->data);
}
int* IntArray = AllocateArray(100); //equivalent to SetLength(TIntegerArray, 100);
char* CharArray = AllocateArray(100); //equivalent to SetLength(TCharArray, 100);
char* StrArray = AllocateString(5); //Allocates a string of length 5 in pascal.
strcpy(StrArray, "Hello");
//Array of array:
int** Array2D = AllocateArray(4, sizeof(int)); //explicitly specify we want an array of array of integers (in this example, 4 x 5).
for (int i = 0; i < 4; ++i)
{
Array2D[i] = AllocateArray(5);
Array2D[i][0] = 1;
Array2D[i][1] = 2;
Array2D[i][2] = 3;
Array2D[i][3] = 4;
Array2D[i][4] = 5; //Can also use memcpy or memset to set values..
}
//Alternatively:
Array2D[0][0] = 0;
Array2D[0][1] = 1;
Array2D[0][2] = 2;
//etc..
Array2D[1][0] = 0;
Array2D[1][1] = 1;
Array2D[1][2] = 2;
//etc..
Array2D[2][0] = 0;
Array2D[2][1] = 1;
Array2D[2][2] = 2;
//etc..
static const char* PascalExports[] =
{
"SomeFunc", "Function SomeFunc(A: Int32; B: String; C: Char): Boolean; native;"
}
void SomeFunc(void** Params, void** Result)
{
int32_t A = ReadPointer(Params[0]); //*static_cast<int32_t*>(Params[0])
char* B = ReadPointer(Params[1]); //*static_cast<char**>(Params[1])
char C = ReadPointer(Params[2]); //*static_cast<char*>(Params[2])
WritePointer(Result, true); //*static_cast<bool*>(Result) = true;
}
2020-02-01 02:14:36
if !defined(_MSC_VER)
#define DELPHI_CALLING_CONVENTION __attribute__((regparm(3)))
#endifBetween those lines code is grayed out and then goes into red again. Do I have to do something extra?
2020-02-01 09:36:09
From: alar82
Between those lines code is grayed out and then goes into red again. Do I have to do something extra?if !defined(_MSC_VER)
#define DELPHI_CALLING_CONVENTION __attribute__((regparm(3)))
#endif
2020-05-04 07:53:52
TSimbaMethods PLUGIN_SYNC_METHODS = { 0 };
TSimbaMemoryAllocators PLUGIN_MEMORY_ALLOCATORS = { 0 };
void SetPluginSimbaMethods(TSimbaMethods Methods)
{
PLUGIN_SYNC_METHODS = Methods;
}
void SetPluginSimbaMemoryAllocators(TSimbaMemoryAllocators Allocators)
{
PLUGIN_MEMORY_ALLOCATORS = Allocators;
}
Other header file.
typedef struct
{
void(__cdecl* Sync)(void(__cdecl* synchronize_method)(void*), void* data);
}TSimbaMethods;
typedef struct
{
void* (__cdecl* GetMem)(std::size_t size);
void(__cdecl* FreeMem)(void* ptr);
}TSimbaMemoryAllocators;
typedef struct
{
std::make_signed_t<std::size_t> refCount;
std::make_signed_t<std::size_t> length;
char data[];
}PascalArray;
#if defined(FPC2)
typedef struct
{
std::make_signed_t<std::size_t> refCount;
std::make_signed_t<std::size_t> length;
char data[];
}PascalString;
#else
typedef struct
{
std::uint16_t codePage;
std::uint16_t elementSize;
#if defined(__x86_64__)
std::uint32_t dummy;
#endif
std::make_signed_t<std::size_t> refCount;
std::make_signed_t<std::size_t> length;
char data[];
}PascalString;
#endif // defined
template<typename T, std::size_t size>
struct StaticPascalArray
{
const std::make_signed_t<std::size_t> refCount = -1;
const std::make_signed_t<std::size_t> length = size;
T data[size] = { 0 };
};
template<typename T>
int PascalHigh(T* Arr)
{
return reinterpret_cast<int*>(Arr)[-1];
}
template<typename T>
int PascalLength(T* Arr)
{
return PascalHigh<T>(Arr) + 1;
}
template<typename T>
T* AllocateArray(std::size_t size, std::size_t element_size = sizeof(T))
{
std::size_t new_size = (size * element_size) + sizeof(PascalArray);
PascalArray* ptr = static_cast<PascalArray*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
ptr->refCount = 1;
ptr->length = size - 1;
return reinterpret_cast<T*>(++ptr);
}
template<typename T>
T* AllocateString(std::size_t size, std::size_t element_size = sizeof(T))
{
std::size_t new_size = (size * element_size) + sizeof(PascalString);
PascalString* ptr = static_cast<PascalString*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size + 1));
ptr->refCount = 1;
ptr->length = size;
return reinterpret_cast<T*>(++ptr);
}
template<typename T>
T* GetArray(void* ptr, std::size_t* size)
{
PascalArray* mem = static_cast<PascalArray*>(ptr);
return reinterpret_cast<T*>((--mem)->data);
}
template<typename T>
T* GetString(void* ptr)
{
PascalString* mem = static_cast<PascalString*>(ptr);
return reinterpret_cast<T*>((--mem)->data);
}
It does compile.
2020-05-04 09:14:58
From: alar82
It does compile.
But when I try to call AllocateArray(100);
It complains that int type doesn't fit there.![]()
//Allocating
int* foo = AllocateArray<int>(100); //Explicitly specify to `AllocateArray` that you want `int` type.
float* something = AllocateArray<float>(100); //returns space for simba array with 100 floats.
char* string = AllocateString<char>(100); //returns space for simba string with 100 characters.
//testing..
for (int i = 0; i < 100; ++i)
{
foo[i] = i;
}
2020-05-04 10:54:14
void Testt()
{
int* IntArray = AllocateArray <int>(100);
for (int i = 0; i < 100; ++i)
{
IntArray[i] = i + 1;
}
for (int i = 0; i < 100; ++i)
{
cout << IntArray[i] << endl;
}
}
Is this now stored in simbas memory not just plugins?
TSimbaMethods PLUGIN_SYNC_METHODS = { 0 };
TSimbaMemoryAllocators PLUGIN_MEMORY_ALLOCATORS = { 0 };
extern "C" __declspec(dllexport) void SetPluginSimbaMethods(TSimbaMethods Methods)
{
PLUGIN_SYNC_METHODS = Methods;
}
extern "C" __declspec(dllexport) void SetPluginSimbaMemoryAllocators(TSimbaMemoryAllocators Allocators)
{
cout << "SetPluginSimbaMemoryAllocators called" <<endl;
PLUGIN_MEMORY_ALLOCATORS = Allocators;
}
CHAR* PascalExports[] =
{
(CHAR*)"SomeFunc", (CHAR*)"Procedure SomeFunc(A: Int32) native;"
}
2020-05-06 11:52:37
From: alar82
Thanks for helping. Nows it does somethin.
Edit44:
It doesn't even matter. It crashes if i try to access that memory. I have attached visual studio debugger thing to see what is happening. Any ideas?
Do I have to declare array before?
template<typename T>
T PascalRead(void* ptr)
{
return *static_cast<T*>(ptr);
}
template<typename T>
void PascalWrite(void* result, T value)
{
*static_cast<T*>(result) = value;
}
CHAR* PascalExports[] =
{
(CHAR*)"SomeFunc", (CHAR*)"Procedure SomeFunc(A: Int32); native;",
(CHAR*)"SomeFunc2", (CHAR*)"Function SomeFunc2(size: Int32): Array of Int32; native;",
}
void SomeFunc(void** Params, void** Result) //YOU MUST have a Result parameter even if you aren't going to use it (for procedures and functions).
{
int32_t a = PascalRead<int32_t>(Params[0]);
//int32_t b = PascalRead<int32_t>(Params[1]);
//size_t length = 0;
//int32_t* indices = GetArray<int32_t>(PascalRead<void*>(Params[2]), &length);
printf("%d\n", a); //or std::cout<<a<<"\n";
}
void SomeFunc2(void** Params, void** Result)
{
//retrieve parameter..
int32_t size = PascalRead<int32_t>(Params[0]);
//allocate int32 array..
int32_t* arr = AllocateArray<int32_t>(size);
for (int i = 0; i < arr; ++i)
{
arr[i] = i + 1;
}
//Return arr..
PascalWrite(Result, arr);
}
2020-05-06 17:49:20
From: Brandon
Are you also using: https://github.com/ollydev/SimbaDevelopment/releases
@alar82;
2020-05-07 00:07:17
From: alar82
Omg with 1400 build it works!!
I had 1302.
2020-05-07 08:32:01
2020-05-08 00:15:25
2020-05-08 10:32:44
2020-05-08 10:37:43

PascalRead<vector<int>>(Params[0]);First params[0] is declared at pascal exports as array of INT32.
PascalArray* mem = static_cast<PascalArray*>(Params[0]);
cout << mem->length << endl;
Give some kind of big number. If it would be standard array length. I could Insert one array into those vector arrays, if I would know size that is.2020-05-09 17:36:51
From: alar82
….
template<typename T>
T* GetArray(void* ptr, std::size_t* size) noexcept
{
PascalArray* mem = static_cast<PascalArray*>(ptr) - 1;
*size = mem->length;
return reinterpret_cast<T*>(mem)->data);
}
template<typename T>
std::vector<T> GetArray(void* ptr) noexcept
{
std::size_t size = 0;
T* raw_data = GetArray<T>(ptr, &size);
return std::vector<T>{raw_data, raw_data + size};
}
std::string GetString(void* ptr) noexcept
{
return GetString<char>(ptr);
}
template<typename T>
void PascalWrite(void* result, const std::vector<T> &value)
{
T* array = AllocateArray<T>(value.size());
std::memcpy(array, value.data(), value.size() * sizeof(T));
PascalWrite(result, array);
}
template<typename T>
void PascalWrite(void* result, const std::string &value)
{
T* str = AllocateString<char>(value.size());
std::memcpy(str, value.data(), value.size() * sizeof(T));
PascalWrite(result, str);
}
void Usage_Example(void** Params, void** Result)
{
std::vector<int> vec = GetArray<int>(Params[0]);
std::string str = GetString<char>(Params[1]);
}
2020-05-10 04:24:31
From: Brandon
Also, the plugin unloading thing is intentional. Don't worry, it's not unloading forever. It's just that scripts are now ran in their own process so if a plugin or script crashes, it will only crash that process and won't crash your Simba itself. The next time you run the script, it will just load the plugin again.
This shouldn't cause you any problems.
2020-05-10 12:48:19
From: alar82
My global variables are lost:I
2020-05-10 14:35:15
From: Brandon
What exactly do you mean by global variables are lost?

2020-05-11 20:59:54
From: alar82
Old version:
I has plainly declared variables. Vars like AOB scan results, so I wouldn't need to re-search them. I stop the script they stay there, re-start script instant go. Open different script tab, amazingly it uses those previous vars instantly.
New version:
It also kills my detached debug thread, which is just annoying, I have to keep script running to display it. Loses all vars.
Plain vars:
Although new Simba feels faster than previous.
2020-05-14 11:33:58
template<typename T>
T* AllocateString(std::size_t size, std::size_t element_size) noexcept
{
std::size_t new_size = (size * element_size) + sizeof(PascalString) + sizeof(T);
PascalString* ptr = static_cast<PascalString*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
ptr->refCount = 1;
ptr->length = size;
ptr->codePage = 65001; //CP_UTF8
ptr->elementSize = sizeof(T);
*reinterpret_cast<char*>(ptr + 1) = '\0';
return reinterpret_cast<T*>(++ptr);
}
2020-05-15 05:19:14
2020-06-22 01:18:51
//for
struct intPOINTtest {
int x;
int y;
//string txt;
};
Call.
(CHAR*)"SomeFunc", (CHAR*)"Function SomeFunc(A: Int32; B: String; C: Char): Array of dataP; native;"
program Test;
//custom data type
type
dataP= record
x: Int32;
y: Int32;
// txt: string;
end;
{$loadlib MemoryError}
begin
wait(199);
SetupRSReading(True,0);
wait(100+random(1099));
repeat
wait(5000+random(1099));
Writeln(SomeFunc(99,"test","t"));
until(false)
end.
2020-06-29 08:13:29
template<typename T>
T* AllocateArrayTest(std::vector<intPOINTtest> value)
{
std::size_t new_size = (1 * sizeof(UINT32)) + sizeof(PascalArray);
//x
PascalArray* ptr1 = static_cast<PascalArray*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
ptr1->refCount = 1;
ptr1->length = 1;
std::memcpy(ptr1, value.data(), value.size());
//y
PascalArray* ptr2 = static_cast<PascalArray*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
ptr2->refCount = 1;
ptr2->length = 1;
std::memcpy(ptr2, value.data(), value.size());
//txt
PascalString* ptr3 = static_cast<PascalString*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
ptr3->refCount = 1;
ptr3->length = 1;
ptr3->codePage = 65001; //CP_UTF8
ptr3->elementSize = sizeof(T);
*reinterpret_cast<char*>(ptr3 + 1) = '\0';
std::memcpy(ptr3, value.data(), value.size());
cout <<"x:"<< *(int*)ptr1 << endl;
cout <<"y:"<< *(int*)ptr2 << endl;
cout << "txt:" << *(char*)ptr3 << endl;
return 0;
}
2020-07-02 10:17:21
PascalString* ptr3 = static_cast<PascalString*>(PLUGIN_MEMORY_ALLOCATORS.GetMem(new_size));
#define EXPORT __declspec(dllexport)
static const char* PascalExports[] =
{
"Pascal_Alloc_Struct", "Function Pascal_Alloc_Struct(): Array of SomeRecord; native;"
};
static const char* PascalTypes[] =
{
//You don't have to use multi-line string..
//You can just make it all one string: "packed record x, y: Int32; txt: String; end;".. etc.. if you wanted.
"SomeRecord", "SomeRecord", R"(
packed record
x, y: Int32;
txt: String;
end;
)"
};
static const long int PascalExportCount = sizeof(PascalExports) / (sizeof(PascalExports[0]) * 2);
static const long int PascalTypeCount = sizeof(PascalTypes) / (sizeof(PascalTypes[0]) * 2);
int GetPluginABIVersion() noexcept
{
return 2;
}
int GetFunctionCount() noexcept
{
return PascalExportCount;
}
int GetTypeCount() noexcept
{
return PascalTypeCount;
}
int GetFunctionInfo(int Index, void** Address, char** Definition) noexcept
{
if (Index < PascalExportCount)
{
*Address = (void*)GetProcAddress(module, PascalExports[Index * 2]);
strcpy(*Definition, PascalExports[Index * 2 + 1]);
return Index;
}
return -1;
}
int GetTypeInfo(int Index, char** Type, char** Definition) noexcept
{
if (Index < PascalTypeCount)
{
strcpy(*Type, PascalTypes[Index * 2 + 0]);
strcpy(*Definition, PascalTypes[Index * 2 + 1]);
return Index;
}
return -1;
}
extern "C" {
void Pascal_Alloc_Struct(void** Params, void** Result);
}
typedef struct
{
std::int32_t x;
std::int32_t y;
char* txt;
} __attribute__((__packed__)) SomeRecord; //#pragma push(1) //#pragma pack(1)
void Pascal_Alloc_Struct(void** Params, void** Result)
{
SomeRecord* arr = AllocateArray<SomeRecord>(4); //allocate however many you want..
for (std::uint32_t i = 0; i < 4; ++i) //fill them..
{
arr[i].x = i + 1;
arr[i].y = i + 1;
arr[i].txt = AllocateString<char>(11); //string length..
strcpy(arr[i].txt, "Hello World"); //copy string..
}
PascalWrite(Result, arr);
}
Succesfully compiled in 121 milliseconds.
[{X = 1, Y = 1, TXT = Hello World}, {X = 2, Y = 2, TXT = Hello World}, {X = 3, Y = 3, TXT = Hello World}, {X = 4, Y = 4, TXT = Hello World}]
2020-07-03 01:44:17
2020-07-04 09:58:09
////////////////////////plugincalls////////////////////////////////////
extern "C" int __declspec(dllexport) GetPluginABIVersion()
{
cout << "1" << endl;
return 2;
}
extern "C" int __declspec(dllexport) GetTypeInfo(int Index, char** Type, char** Definition)
{
cout << "2" << endl;
if (Index < PascalTypeCount)
{
strcpy(*Type, PascalTypes[Index * 2 + 0]);
strcpy(*Definition, PascalTypes[Index * 2 + 1]);
return Index;
}
return 0;
}
extern "C" int __declspec(dllexport) GetTypeCount()
{
cout << "3" << endl;
return PascalTypeCount;
}
extern "C" int __declspec(dllexport) GetFunctionInfo(int Index, VOID** Address, CHAR** Definition)
{
cout << "4" << endl;
if (Index < PascalExportCount)
{
*Address = (void*)GetProcAddress(module, PascalExports[Index * 2]);
strcpy(*Definition, PascalExports[Index * 2 + 1]);
return Index;
}
return -1;
}
extern "C" int __declspec(dllexport) GetFunctionCount()
{
cout << "5" << endl;
return PascalExportCount;
}
extern "C" __declspec(dllexport) void SetPluginSimbaMethods(TSimbaMethods Methods)
{
PLUGIN_SYNC_METHODS = Methods;
}
extern "C" __declspec(dllexport) void SetPluginSimbaMemoryAllocators(TSimbaMemoryAllocators Allocators)
{
cout << "SetPluginSimbaMemoryAllocators called" << endl;
PLUGIN_MEMORY_ALLOCATORS = Allocators;
}
///////////////////////////////////////////////////////////////////////
I have added couts to get order, output:
STARTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT
5
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
3
2
SetPluginSimbaMemoryAllocators called
Unknown declaration "SomeRecord" at line 1, column 14 in file "!addGlobalType::SomeRecord" at line 3, column 11 in file "C:\Users\Al\Documents\Simba64\Scripts\serenspiritwatch.simba"
static const char* PascalTypes[] =
{
"SomeRecord", "SomeRecord", R"(
packed record
x, y: Int32;
txt: String;
end;
)"
};Edit:static const char* PascalTypes[] =
{
"SomeRecord", "record x, y: Int32; txt: String; end;"
};Now it works. When clicking in Simbas plugin record thing it shows: Declaration:
SomeRecord = record x, y: Int32; txt: String; end But thanks. What is difference between packed record and just record? Btw GetPluginABIVersion is never called/used.
2020-07-12 22:49:01
From: alar82
Now it works. When clicking in Simbas plugin record thing it shows:But thanks. What is difference between packed record and just record? Btw GetPluginABIVersion is never called/used.Declaration:
SomeRecord = record x, y: Int32; txt: String; end
struct Foo
{
int a;
int b;
char c;
int d;
};
2020-07-13 18:31:33
arr[i].Action = AllocateString<char>(AllNPC[i].Name.length());
strcpy(arr[i].Action, AllNPC[i].Name.c_str());Edit:Nvm.
2020-07-25 17:35:29
template<typename T>
T* AllocateArray(std::size_t size, std::size_t element_size) noexcept
{
//other code here..
ptr->refCount = 0; //CHANGE THIS LINE TO 0 IN YOUR CODE
//other code here..
}
template<typename T>
T* AllocateString(std::size_t size, std::size_t element_size) noexcept
{
//other code here..
ptr->refCount = 0; //CHANGE THIS LINE TO 0 IN YOUR CODE
//other code here..
}