-
Notifications
You must be signed in to change notification settings - Fork 50
feat: Enhance memory allocation and SDK generation #85
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
base: main
Are you sure you want to change the base?
Conversation
Updated `GetMemAlloc` in `IMemAlloc.h` to use `__declspec(dllimport)` for proper external linkage. Improved SDK generation in `startup.cpp` by adding support for dumping enums and classes from global type scopes.
| auto type_scopes = sdk::g_schema->GetTypeScopes(); | ||
| assert(type_scopes.Count() > 0 && "sdk is outdated"); | ||
|
|
||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| } | ||
|
|
||
| // @note: @es3n1n: Obtaining type scopes and generating sdk | ||
| const auto type_scopes = sdk::g_schema->GetTypeScopes(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why did you remove const?
| const auto global_scope = sdk::g_schema->GlobalTypeScope(); | ||
| auto current_enums = global_scope->GetEnumBindings(); | ||
| for (auto el : current_enums.GetElements()) { | ||
| auto& dump{dumped_modules.emplace(el->m_pszModule, unique_module_dump{}).first->second}; | ||
| dump.enums.emplace(el->m_pszName, el); | ||
| } | ||
|
|
||
| auto current_classes = global_scope->GetClassBindings(); | ||
| for (auto el : current_classes.GetElements()) { | ||
| auto& dump{dumped_modules.emplace(el->m_pszModule, unique_module_dump{}).first->second}; | ||
| dump.classes.emplace(el->m_pszName, el); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not a huge fan of code repetition here. How about making a lambda that takes a pointer to CSchemaSystemTypeScope and does this processing so that we can just call lambda in the loop and for the global scope?
| }; | ||
|
|
||
| extern IMemAlloc* GetMemAlloc(); | ||
| extern "C" __declspec(dllimport) IMemAlloc* GetMemAlloc(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
__declspec is a microsoft-specific attribute. This code would not work on linux.
Would really love to put this under a macro, but for now we have only one use case so we can just inline it.
| extern "C" __declspec(dllimport) IMemAlloc* GetMemAlloc(); | |
| #if defined(_WIN64) || defined(_WIN32) | |
| extern "C" __declspec(dllimport) IMemAlloc* GetMemAlloc(); | |
| #else | |
| extern "C" IMemAlloc* GetMemAlloc(); | |
| #endif |
Updated
GetMemAllocinIMemAlloc.hto use__declspec(dllimport)for proper external linkage. Improved SDK generation instartup.cppby adding support for dumping enums and classes from global type scopes.