Hah you are too smart. I could have never figured this stuff out.
Hah you are too smart. I could have never figured this stuff out.
Hey Brandon, today I tried your code out. It keeps complaining that "SomeRecord" is unknown declaration. Then I decided to do some analysis of Simbas calls.
Setup.
I have added couts to get order, output:Code:////////////////////////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 don't know, shouldn't variables to be called before functions trying to use them :PCode: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"
Edit:Removed function that uses "SomeRecord". Still gives that same error.
It is all copy paste, how it could not work.
Edit:Code:static const char* PascalTypes[] = { "SomeRecord", "SomeRecord", R"( packed record x, y: Int32; txt: String; end; )" };
Changed code into:Now it works. When clicking in Simbas plugin record thing it shows:Code:static const char* PascalTypes[] = { "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.Code:Declaration: SomeRecord = record x, y: Int32; txt: String; end
yeah what you have is correct.
The function should be called. It gets called for me
The difference between a packed record and regular record is the alignment.
For example:
c++ Code:struct Foo
{
int a;
int b;
char c;
int d;
};
The size of this structure in my compiler is `sizeof(int) * 4 => 16`. WHY though? There are only 3 integers and a single char! Well.. turns out for various reasons, the compiler will `PAD` the structure to align on the nearest DWORD boundary.. IE: That char will be padded to an int..
IF you pack the structure or specify that it should be packed or aligned on a boundary of your choice (IE: 1).. then the compiler will NOT do this padding..
So in order to guarantee that Simba has the same padding as your plugin, we ask Simba to pack the record/struct tightly AND we ask our compiler to do the same for our struct.. Therefore they both have the same alignment and same size and we access the fields at the same offset
See: https://stackoverflow.com/questions/...ng-and-packing
I am Ggzz..
Hackintosher
Hey Brandon I noticed that strcpy wants char* type to copy but in my structs there are strings not chars.
Edit: Made struct specially for exporting out. Now i can:
Edit:Nvm.Code:arr[i].Action = AllocateString<char>(AllNPC[i].Name.length()); strcpy(arr[i].Action, AllNPC[i].Name.c_str());
@alar82 and @here, change the `refCount` to 0 by default (as shown below):
C++ Code: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..
}
I am Ggzz..
Hackintosher
There are currently 1 users browsing this thread. (0 members and 1 guests)