-
Notifications
You must be signed in to change notification settings - Fork 51
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||
|---|---|---|---|---|
|
|
@@ -89,6 +89,19 @@ namespace source2_gen { | |||
| } | ||||
| } | ||||
|
|
||||
| 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); | ||||
| } | ||||
|
|
||||
|
Comment on lines
+92
to
+104
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||
| std::unordered_map<std::string, module_dump> result{}; | ||||
|
|
||||
| for (const auto& [module_name, unique_dump] : dumped_modules) { | ||||
|
|
@@ -150,8 +163,8 @@ namespace source2_gen { | |||
| } | ||||
|
|
||||
| [[nodiscard]] | ||||
| constexpr std::string_view GetStaticSdkName(source2_gen::Language language) { | ||||
| using enum source2_gen::Language; | ||||
| constexpr std::string_view GetStaticSdkName(Language language) { | ||||
| using enum Language; | ||||
| switch (language) { | ||||
| case cpp: | ||||
| return "cpp"; | ||||
|
|
@@ -237,16 +250,17 @@ namespace source2_gen { | |||
| } | ||||
|
|
||||
| // @note: @es3n1n: Obtaining type scopes and generating sdk | ||||
| const auto type_scopes = sdk::g_schema->GetTypeScopes(); | ||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why did you remove const? |
||||
| auto type_scopes = sdk::g_schema->GetTypeScopes(); | ||||
| assert(type_scopes.Count() > 0 && "sdk is outdated"); | ||||
|
|
||||
|
|
||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||
| const std::unordered_map all_modules = CollectModules(std::span{type_scopes.m_pElements, static_cast<std::size_t>(type_scopes.m_Size)}); | ||||
|
|
||||
| sdk::GeneratorCache cache{}; | ||||
| std::unordered_set<std::filesystem::path> generated_files{}; | ||||
|
|
||||
| for (const auto& [module_name, dump] : all_modules) { | ||||
| const auto result = sdk::GenerateTypeScopeSdk(options, cache, module_name, dump.enums, dump.classes); | ||||
| const auto result = GenerateTypeScopeSdk(options, cache, module_name, dump.enums, dump.classes); | ||||
| std::ranges::move(result.generated_files, std::inserter(generated_files, generated_files.end())); | ||||
| } | ||||
|
|
||||
|
|
@@ -256,7 +270,7 @@ namespace source2_gen { | |||
| std::filesystem::copy(FindSdkStatic(options), kOutDirName, | ||||
| std::filesystem::copy_options::recursive | std::filesystem::copy_options::overwrite_existing); | ||||
|
|
||||
| if (options.emit_language == source2_gen::Language::c_ida) { | ||||
| if (options.emit_language == Language::c_ida) { | ||||
| PostProcessCIDA(generated_files); | ||||
| } | ||||
|
|
||||
|
|
||||
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.
__declspecis 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.