-
-
Notifications
You must be signed in to change notification settings - Fork 182
Refactor/plugin header split #1506
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
Open
pgrandin
wants to merge
12
commits into
trunk
Choose a base branch
from
refactor/plugin-header-split
base: trunk
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
f766610
Merge 5dbfa770d884c277ce673e4a862b2d8dede51486 into master
github-actions[bot] b11b7d6
Merge f676de08aff242f753b075b9f8be9fd7763699fa into master
github-actions[bot] 5637c79
Merge 8afa64e1baf19c1209c3624c5fdc6aa2025143cd into master
github-actions[bot] e75cb24
Merge 067f50ef9f6af28e7b0857ad33a51bbdee8d68aa into master
github-actions[bot] 815e677
Merge 6d6704c47db9e4423f58b4c7a431d174dda108ba into master
github-actions[bot] 2d8c6a4
Merge 7b471edc317500bdff873c5943f8a324fd745e20 into master
github-actions[bot] b781a33
Merge 1dfa645751fba6efb00410617955b3d2dec226d0 into master
github-actions[bot] aa24d01
Merge 17550cc5c11cbe3d63dc51776be98618e240aa2c into master
github-actions[bot] e44b274
Refactoring:core:Split plugin.h implementation macros into plugin_impl.h
pgrandin e50324e
Refactoring:core:Update copyright years to 2005-2026 in plugin headers
pgrandin 7f63241
Refactoring:core:Apply clang-format to plugin header files
pgrandin 59bffc0
Merge branch 'trunk' into refactor/plugin-header-split
pgrandin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,90 @@ | ||
| /** | ||
| * Navit, a modular navigation system. | ||
| * Copyright (C) 2005-2026 Navit Team | ||
| * | ||
| * This program is free software; you can redistribute it and/or | ||
| * modify it under the terms of the GNU Library General Public License | ||
| * version 2 as published by the Free Software Foundation. | ||
| * | ||
| * This program is distributed in the hope that it will be useful, | ||
| * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| * GNU Library General Public License for more details. | ||
| * | ||
| * You should have received a copy of the GNU Library General Public | ||
| * License along with this program; if not, write to the | ||
| * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
| * Boston, MA 02110-1301, USA. | ||
| */ | ||
|
|
||
| /** | ||
| * @file plugin_impl.h | ||
| * @brief Plugin implementation macros — included only by plugin.c. | ||
| * | ||
| * This header provides the macro definitions that expand PLUGIN_FUNC* and | ||
| * PLUGIN_CATEGORY into function bodies and global variable definitions. | ||
| * It must be included exactly once, after plugin.h, in plugin.c. | ||
| */ | ||
|
|
||
| #ifndef NAVIT_PLUGIN_IMPL_H | ||
| #define NAVIT_PLUGIN_IMPL_H | ||
|
|
||
| #include "plugin.h" | ||
| #include <glib.h> | ||
|
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. I think including "glib.h" is better here, if we want to continue supporting platforms without native glib. |
||
|
|
||
| #undef PLUGIN_FUNC1 | ||
| #undef PLUGIN_FUNC3 | ||
| #undef PLUGIN_FUNC4 | ||
| #undef PLUGIN_CATEGORY | ||
|
|
||
| #define PLUGIN_REGISTER(name, ...) \ | ||
| void plugin_register_##name(PLUGIN_PROTO((*func), __VA_ARGS__)) { \ | ||
| plugin_##name##_func = func; \ | ||
| } | ||
|
|
||
| #define PLUGIN_CALL(name, ...) \ | ||
| { \ | ||
| if (plugin_##name##_func) \ | ||
| (*plugin_##name##_func)(__VA_ARGS__); \ | ||
| } | ||
|
|
||
| #define PLUGIN_FUNC1(name, t1, p1) \ | ||
| PLUGIN_PROTO((*plugin_##name##_func), t1 p1); \ | ||
| void plugin_call_##name(t1 p1) PLUGIN_CALL(name, p1) PLUGIN_REGISTER(name, t1 p1) | ||
|
|
||
| #define PLUGIN_FUNC3(name, t1, p1, t2, p2, t3, p3) \ | ||
| PLUGIN_PROTO((*plugin_##name##_func), t1 p1, t2 p2, t3 p3); \ | ||
| void plugin_call_##name(t1 p1, t2 p2, t3 p3) PLUGIN_CALL(name, p1, p2, p3) \ | ||
| PLUGIN_REGISTER(name, t1 p1, t2 p2, t3 p3) | ||
|
|
||
| #define PLUGIN_FUNC4(name, t1, p1, t2, p2, t3, p3, t4, p4) \ | ||
| PLUGIN_PROTO((*plugin_##name##_func), t1 p1, t2 p2, t3 p3, t4 p4); \ | ||
| void plugin_call_##name(t1 p1, t2 p2, t3 p3, t4 p4) PLUGIN_CALL(name, p1, p2, p3, p4) \ | ||
| PLUGIN_REGISTER(name, t1 p1, t2 p2, t3 p3, t4 p4) | ||
|
|
||
| struct name_val { | ||
| char *name; | ||
| void *val; | ||
| }; | ||
|
|
||
| GList *plugin_categories[plugin_category_last]; | ||
|
|
||
| #define PLUGIN_CATEGORY(category, newargs) \ | ||
| struct category##_priv; \ | ||
| struct category##_methods; \ | ||
| void plugin_register_category_##category(const char *name, struct category##_priv *(*new_)newargs) { \ | ||
| struct name_val *nv; \ | ||
| nv = g_new(struct name_val, 1); \ | ||
| nv->name = g_strdup(name); \ | ||
| nv->val = new_; \ | ||
| plugin_categories[plugin_category_##category] = \ | ||
| g_list_append(plugin_categories[plugin_category_##category], nv); \ | ||
| } \ | ||
| \ | ||
| void *plugin_get_category_##category(const char *name) { \ | ||
| return plugin_get_category(plugin_category_##category, #category, name); \ | ||
| } | ||
|
|
||
| #include "plugin_def.h" | ||
|
|
||
| #endif /* NAVIT_PLUGIN_IMPL_H */ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
It its only included inside plugin.c why do we need a header for it?
Uh oh!
There was an error while loading. Please reload this page.
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.
It felt cleaner that way, keeping the .c file focused on the actual logic instead of dealing with macros. The impl header also needs to
#undefand redefine several macros before re-expandingplugin_def.ha second time so that's ~60 lines of macro machinery that could clutterplugin.cif inlined.What do you think?
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.
I think, having it is fine and for my taste plugin.c still contains too many macros/defines (which is no way speaking to this PR but rather to the structure that is in place).
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.
I did notice there is still some kind of problem around plugin_def.h. If that one receives an include guard, linking fails. I have not been able to look into this further