-
Notifications
You must be signed in to change notification settings - Fork 39
Add CppInterOp API dispatch mechanism #730
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
ad03dcb
1a589ba
265d469
9abe899
a422a94
94b5d94
5f2350c
d87fc75
f8d869a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,20 @@ | ||||||
| #include <CppInterOp/Dispatch.h> | ||||||
|
|
||||||
| #include <string> | ||||||
| #include <unordered_map> | ||||||
|
Contributor
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. warning: included header string is not used directly [misc-include-cleaner]
Suggested change
|
||||||
|
|
||||||
| static const std::unordered_map<std::string_view, CppFnPtrTy> | ||||||
|
Contributor
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. warning: no header providing "std::string_view" is directly included [misc-include-cleaner] lib/CppInterOp/Dispatch.cpp:3: - #include <unordered_map>
+ #include <string_view>
+ #include <unordered_map> |
||||||
| DispatchMap = { | ||||||
| #define DISPATCH_API(name, type) {#name, (CppFnPtrTy) static_cast<type>(&CppImpl::name)}, | ||||||
| CPPINTEROP_API_TABLE | ||||||
|
Contributor
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. warning: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast] CPPINTEROP_API_TABLE
^Additional contextinclude/CppInterOp/Dispatch.h:44: expanded from macro 'CPPINTEROP_API_TABLE' DISPATCH_API(CreateInterpreter, decltype(&CppImpl::CreateInterpreter)) \
^lib/CppInterOp/Dispatch.cpp:7: expanded from macro 'DISPATCH_API' #define DISPATCH_API(name, type) {#name, (CppFnPtrTy) static_cast<type>(&CppImpl::name)},
^ |
||||||
| #undef DISPATCH_API | ||||||
| }; | ||||||
|
|
||||||
| static inline CppFnPtrTy _cppinterop_get_proc_address(const char* funcName) { | ||||||
|
Contributor
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. warning: declaration uses identifier '_cppinterop_get_proc_address', which is reserved in the global namespace [bugprone-reserved-identifier] static inline CppFnPtrTy _cppinterop_get_proc_address(const char* funcName) {
^this fix will not be applied because it overlaps with another fix
Contributor
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. warning: invalid case style for function '_cppinterop_get_proc_address' [readability-identifier-naming] static inline CppFnPtrTy _cppinterop_get_proc_address(const char* funcName) {
^this fix will not be applied because it overlaps with another fix |
||||||
| auto it = DispatchMap.find(funcName); | ||||||
| return (it != DispatchMap.end()) ? it->second : nullptr; | ||||||
| } | ||||||
|
|
||||||
| void (*CppGetProcAddress(const unsigned char* procName))(void) { | ||||||
| return _cppinterop_get_proc_address(reinterpret_cast<const char*>(procName)); | ||||||
| } | ||||||
Uh oh!
There was an error while loading. Please reload this page.