-
Notifications
You must be signed in to change notification settings - Fork 0
Add iterator-based API to list loaded and available modules #106
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: develop
Are you sure you want to change the base?
Conversation
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
JohnAmadis
left a comment
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.
@copilot zmieniamy trochę koncepcje - zrob to podobnie do opendir, readdir i closedir
inc/dmod.h
Outdated
| DMOD_BUILTIN_API( Dmod, 1.0, bool , _GetPackageInfo, ( uint32_t PackageIndex, char* outName, size_t NameMaxLength, size_t* outSize ) ); | ||
| DMOD_BUILTIN_API( Dmod, 1.0, uint32_t , _GetMainIndexFromPackage, ( const char* PackageName ) ); | ||
|
|
||
| DMOD_BUILTIN_API( Dmod, 1.0, size_t , _ReadModules, ( Dmod_ModuleInfo_t* outModules, size_t Max ) ); |
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.
tak myślę o tym API i trochę mnie boli, że aż tyle pamięci się marnuje na raz przy tym rozwiązaniu...
Zróbmy może trochę inaczej...
Zrób to podobnie do OpenDir, ReadDir i CloseDir - to będzie lepsze, pewniejsze i bezpieczniejsze
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.
Changed to iterator pattern (OpenModules/ReadModule/CloseModules) similar to OpenDir/ReadDir/CloseDir. This is much more memory efficient as it doesn't require allocating a large array upfront. Commit: 0601708
| Dmod_ModuleType_Count, | ||
| } Dmod_ModuleType_t; | ||
|
|
||
| typedef enum |
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.
Jakiś doxygen do tego enuma też by się przydał
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.
Added Doxygen documentation for the enum. Commit: 0601708
| char ModuleName[DMOD_MAX_MODULE_NAME_LENGTH]; | ||
| char Version[DMOD_MAX_VERSION_LENGTH]; | ||
| Dmod_ModuleState_t State; | ||
| } Dmod_ModuleInfo_t; |
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.
ta struktura też powinna mieć dokumentację
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.
Added Doxygen documentation for the struct with field descriptions. Commit: 0601708
- Changed from Dmod_ReadModules to OpenModules/ReadModule/CloseModules pattern - Added Doxygen documentation for Dmod_ModuleState_t enum - Added Doxygen documentation for Dmod_ModuleInfo_t struct - Added Dmod_ModulesIterator_t opaque handle type - Updated example application to use new API - Updated unit tests (8 tests passing) - Memory efficient: no large array allocation required Co-authored-by: JohnAmadis <17320783+JohnAmadis@users.noreply.github.com>
Refactored to iterator-based API pattern similar to opendir/readdir/closedir:
This approach is memory efficient and follows familiar POSIX patterns. Commit: 0601708 |
Adds iterator-based API to enumerate loaded modules and scan available modules in search paths and packages, using a memory-efficient pattern similar to
opendir/readdir/closedir.Changes
New Types (
inc/dmod_types.h):Dmod_ModuleState_tenum: Available, Loaded, Enabled, Running (with Doxygen documentation)Dmod_ModuleInfo_tstruct: module name, version, state (with Doxygen documentation)Dmod_ModulesIterator_t: Opaque iterator handleAPI (
inc/dmod.h,src/system/dmod_system.c):Iterator-based pattern that:
Example (
examples/system/list_modules/):Demonstrates listing all modules with formatted output using the iterator API.
Tests (
tests/system/public/tests_dmod_read_modules.cpp):8 tests covering iterator lifecycle, null validation, empty lists, structure integrity, and consistency.
Bug Fixes
Null pointer crash in
Dmod_Hlp_AddSearchNode: Added null check for Path parameter before strlen()Package validation: Check
Dmod_Pck_IsSlotUsed()beforeDmod_Pck_IsValidSlot()to avoid spurious errorsMissing include: Added
<string.h>todmod_hlp.cBenefits
Usage
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.