-
Notifications
You must be signed in to change notification settings - Fork 288
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
Add TupleHelper and SelectHelper to improve SWIG Go wrapper. #862
Add TupleHelper and SelectHelper to improve SWIG Go wrapper. #862
Conversation
common/tuplehelper.h
Outdated
@@ -0,0 +1,28 @@ | |||
#ifndef __TUPLE_HELPER__ |
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.
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.
Fixed
common/tuplehelper.cpp
Outdated
return kfvOp(tuple); | ||
} | ||
|
||
std::vector<FieldValueTuple> TupleHelper::getFieldsValues(const KeyOpFieldsValuesTuple& tuple) |
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.
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.
Fixed, return reference
common/tuplehelper.cpp
Outdated
return fvValue(tuple); | ||
} | ||
|
||
std::string TupleHelper::getKey(const KeyOpFieldsValuesTuple& tuple) |
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.
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.
SWIG does not generate wrapper for C++ macro.
We can't change macros to method, because there are code like this:
https://github.com/sonic-net/sonic-swss-common/blob/master/common/json.cpp
kfvKey(cur_db_item) = cur_obj_key;
kfvOp(cur_db_item) = op;
Similer code are in some other projects:
@@ -73,6 +73,27 @@ class Select | |||
std::set<Selectable *, Select::cmp> m_ready; | |||
}; | |||
|
|||
class SelectHelper |
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.
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.
We need this new class because SWIG can't handle pointer to pointer parameter:
int Select::select(**Selectable **c,** int timeout = -1, bool interrupt_on_signal = false);
We need this helper class handle the pointer to pointer parameter in C++ code.
Close because Go wrapper still need improve. the change for GNMI support will create new PR. |
Why I did it
SWIG not support std::tuple, also not support C++ inheritance well, this make go wrapper method of select and pops method does not work.
How I did it
Add TupleHelper and SelectHelper to improve SWIG Go wrapper.
Work item tracking
How to verify it
Pass all test cases.
Add new test case.
Which release branch to backport (provide reason below if selected)
Description for the changelog
Add TupleHelper and SelectHelper to improve SWIG Go wrapper.
Link to config_db schema for YANG module changes
A picture of a cute animal (not mandatory but encouraged)