-
Notifications
You must be signed in to change notification settings - Fork 484
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
[master][SAI-PTF] Convert generated enum code from ctypesgen into pythoon enum class #1758
Merged
richardyu-ms
merged 1 commit into
opencomputeproject:master
from
richardyu-ms:add_header_converter
Feb 24, 2023
Merged
[master][SAI-PTF] Convert generated enum code from ctypesgen into pythoon enum class #1758
richardyu-ms
merged 1 commit into
opencomputeproject:master
from
richardyu-ms:add_header_converter
Feb 24, 2023
Conversation
This file contains 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
richardyu-ms
force-pushed
the
add_header_converter
branch
4 times, most recently
from
February 24, 2023 00:25
fcc33ad
to
8fda361
Compare
lolyu
reviewed
Feb 24, 2023
richardyu-ms
force-pushed
the
add_header_converter
branch
from
February 24, 2023 01:44
8fda361
to
65fc919
Compare
lolyu
reviewed
Feb 24, 2023
…m class why When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class. the code like ```C++ /** * @brief SAI common API type */ typedef enum _sai_common_api_t { SAI_COMMON_API_CREATE = 0, SAI_COMMON_API_REMOVE = 1, SAI_COMMON_API_SET = 2, SAI_COMMON_API_GET = 3, SAI_COMMON_API_BULK_CREATE = 4, SAI_COMMON_API_BULK_REMOVE = 5, SAI_COMMON_API_BULK_SET = 6, SAI_COMMON_API_BULK_GET = 7, SAI_COMMON_API_MAX = 8, } sai_common_api_t; ``` original converted by ctypesgen ``` enum__sai_common_api_t = c_int# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 sai_common_api_t = enum__sai_common_api_t# /usr/include/sai/saitypes.h: 183 enum__sai_object_type_t = c_int# /usr/include/sai/saitypes.h: 294 ``` new code ``` class sai_common_api(SAIEnum): SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = sai_common_api.SAI_COMMON_API_CREATE SAI_COMMON_API_REMOVE = sai_common_api.SAI_COMMON_API_REMOVE SAI_COMMON_API_SET = sai_common_api.SAI_COMMON_API_SET SAI_COMMON_API_GET = sai_common_api.SAI_COMMON_API_GET SAI_COMMON_API_BULK_CREATE = sai_common_api.SAI_COMMON_API_BULK_CREATE SAI_COMMON_API_BULK_REMOVE = sai_common_api.SAI_COMMON_API_BULK_REMOVE SAI_COMMON_API_BULK_SET = sai_common_api.SAI_COMMON_API_BULK_SET SAI_COMMON_API_BULK_GET = sai_common_api.SAI_COMMON_API_BULK_GET SAI_COMMON_API_MAX = sai_common_api.SAI_COMMON_API_MAX ``` how Convert the python code after generated from ctypesgen verify pipeline local testing Signed-off-by: richardyu-ms <richard.yu@microsoft.com> reformat code Signed-off-by: richardyu-ms <richard.yu@microsoft.com> refactor code Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
richardyu-ms
force-pushed
the
add_header_converter
branch
from
February 24, 2023 02:54
65fc919
to
36e29b3
Compare
richardyu-ms
changed the title
[SAI-PTF] Convert generated enum code from ctypesgen into pythoon enum class
[master][SAI-PTF] Convert generated enum code from ctypesgen into pythoon enum class
Feb 24, 2023
lolyu
approved these changes
Feb 24, 2023
richardyu-ms
added a commit
that referenced
this pull request
Feb 24, 2023
…en into pythoon enum class (#1760) why cherry-pick from #1758 When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class. the code like ```C++ /** * @brief SAI common API type */ typedef enum _sai_common_api_t { SAI_COMMON_API_CREATE = 0, SAI_COMMON_API_REMOVE = 1, SAI_COMMON_API_SET = 2, SAI_COMMON_API_GET = 3, SAI_COMMON_API_BULK_CREATE = 4, SAI_COMMON_API_BULK_REMOVE = 5, SAI_COMMON_API_BULK_SET = 6, SAI_COMMON_API_BULK_GET = 7, SAI_COMMON_API_MAX = 8, } sai_common_api_t; ``` original converted by ctypesgen ``` enum__sai_common_api_t = c_int# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 sai_common_api_t = enum__sai_common_api_t# /usr/include/sai/saitypes.h: 183 enum__sai_object_type_t = c_int# /usr/include/sai/saitypes.h: 294 ``` new code ``` class sai_common_api(SAIEnum): SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = sai_common_api.SAI_COMMON_API_CREATE SAI_COMMON_API_REMOVE = sai_common_api.SAI_COMMON_API_REMOVE SAI_COMMON_API_SET = sai_common_api.SAI_COMMON_API_SET SAI_COMMON_API_GET = sai_common_api.SAI_COMMON_API_GET SAI_COMMON_API_BULK_CREATE = sai_common_api.SAI_COMMON_API_BULK_CREATE SAI_COMMON_API_BULK_REMOVE = sai_common_api.SAI_COMMON_API_BULK_REMOVE SAI_COMMON_API_BULK_SET = sai_common_api.SAI_COMMON_API_BULK_SET SAI_COMMON_API_BULK_GET = sai_common_api.SAI_COMMON_API_BULK_GET SAI_COMMON_API_MAX = sai_common_api.SAI_COMMON_API_MAX ``` how Convert the python code after generated from ctypesgen verify pipeline local testing reformat refactor code Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
richardyu-ms
added a commit
that referenced
this pull request
Feb 24, 2023
…n into pythoon enum class (#1761) why cherry-pick from #1758 When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class. the code like ```C++ /** * @brief SAI common API type */ typedef enum _sai_common_api_t { SAI_COMMON_API_CREATE = 0, SAI_COMMON_API_REMOVE = 1, SAI_COMMON_API_SET = 2, SAI_COMMON_API_GET = 3, SAI_COMMON_API_BULK_CREATE = 4, SAI_COMMON_API_BULK_REMOVE = 5, SAI_COMMON_API_BULK_SET = 6, SAI_COMMON_API_BULK_GET = 7, SAI_COMMON_API_MAX = 8, } sai_common_api_t; ``` original converted by ctypesgen ``` enum__sai_common_api_t = c_int# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 sai_common_api_t = enum__sai_common_api_t# /usr/include/sai/saitypes.h: 183 enum__sai_object_type_t = c_int# /usr/include/sai/saitypes.h: 294 ``` new code ``` class sai_common_api(SAIEnum): SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = sai_common_api.SAI_COMMON_API_CREATE SAI_COMMON_API_REMOVE = sai_common_api.SAI_COMMON_API_REMOVE SAI_COMMON_API_SET = sai_common_api.SAI_COMMON_API_SET SAI_COMMON_API_GET = sai_common_api.SAI_COMMON_API_GET SAI_COMMON_API_BULK_CREATE = sai_common_api.SAI_COMMON_API_BULK_CREATE SAI_COMMON_API_BULK_REMOVE = sai_common_api.SAI_COMMON_API_BULK_REMOVE SAI_COMMON_API_BULK_SET = sai_common_api.SAI_COMMON_API_BULK_SET SAI_COMMON_API_BULK_GET = sai_common_api.SAI_COMMON_API_BULK_GET SAI_COMMON_API_MAX = sai_common_api.SAI_COMMON_API_MAX ``` how Convert the python code after generated from ctypesgen verify pipeline local testing reformat refactor code Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
richardyu-ms
added a commit
that referenced
this pull request
Feb 24, 2023
…en into pythoon enum class (#1762) why cherry-pick from #1758 When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class. the code like ```C++ /** * @brief SAI common API type */ typedef enum _sai_common_api_t { SAI_COMMON_API_CREATE = 0, SAI_COMMON_API_REMOVE = 1, SAI_COMMON_API_SET = 2, SAI_COMMON_API_GET = 3, SAI_COMMON_API_BULK_CREATE = 4, SAI_COMMON_API_BULK_REMOVE = 5, SAI_COMMON_API_BULK_SET = 6, SAI_COMMON_API_BULK_GET = 7, SAI_COMMON_API_MAX = 8, } sai_common_api_t; ``` original converted by ctypesgen ``` enum__sai_common_api_t = c_int# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 sai_common_api_t = enum__sai_common_api_t# /usr/include/sai/saitypes.h: 183 enum__sai_object_type_t = c_int# /usr/include/sai/saitypes.h: 294 ``` new code ``` class sai_common_api(SAIEnum): SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = sai_common_api.SAI_COMMON_API_CREATE SAI_COMMON_API_REMOVE = sai_common_api.SAI_COMMON_API_REMOVE SAI_COMMON_API_SET = sai_common_api.SAI_COMMON_API_SET SAI_COMMON_API_GET = sai_common_api.SAI_COMMON_API_GET SAI_COMMON_API_BULK_CREATE = sai_common_api.SAI_COMMON_API_BULK_CREATE SAI_COMMON_API_BULK_REMOVE = sai_common_api.SAI_COMMON_API_BULK_REMOVE SAI_COMMON_API_BULK_SET = sai_common_api.SAI_COMMON_API_BULK_SET SAI_COMMON_API_BULK_GET = sai_common_api.SAI_COMMON_API_BULK_GET SAI_COMMON_API_MAX = sai_common_api.SAI_COMMON_API_MAX ``` how Convert the python code after generated from ctypesgen verify pipeline local testing reformat code refactor code Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
JaiOCP
pushed a commit
to JaiOCP/SAI
that referenced
this pull request
Mar 10, 2023
…m class (opencomputeproject#1758) why When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class. the code like ```C++ /** * @brief SAI common API type */ typedef enum _sai_common_api_t { SAI_COMMON_API_CREATE = 0, SAI_COMMON_API_REMOVE = 1, SAI_COMMON_API_SET = 2, SAI_COMMON_API_GET = 3, SAI_COMMON_API_BULK_CREATE = 4, SAI_COMMON_API_BULK_REMOVE = 5, SAI_COMMON_API_BULK_SET = 6, SAI_COMMON_API_BULK_GET = 7, SAI_COMMON_API_MAX = 8, } sai_common_api_t; ``` original converted by ctypesgen ``` enum__sai_common_api_t = c_int# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 sai_common_api_t = enum__sai_common_api_t# /usr/include/sai/saitypes.h: 183 enum__sai_object_type_t = c_int# /usr/include/sai/saitypes.h: 294 ``` new code ``` class sai_common_api(SAIEnum): SAI_COMMON_API_CREATE = 0# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_REMOVE = 1# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_SET = 2# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_GET = 3# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_CREATE = 4# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_REMOVE = 5# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_SET = 6# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_BULK_GET = 7# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_MAX = 8# /usr/include/sai/saitypes.h: 183 SAI_COMMON_API_CREATE = sai_common_api.SAI_COMMON_API_CREATE SAI_COMMON_API_REMOVE = sai_common_api.SAI_COMMON_API_REMOVE SAI_COMMON_API_SET = sai_common_api.SAI_COMMON_API_SET SAI_COMMON_API_GET = sai_common_api.SAI_COMMON_API_GET SAI_COMMON_API_BULK_CREATE = sai_common_api.SAI_COMMON_API_BULK_CREATE SAI_COMMON_API_BULK_REMOVE = sai_common_api.SAI_COMMON_API_BULK_REMOVE SAI_COMMON_API_BULK_SET = sai_common_api.SAI_COMMON_API_BULK_SET SAI_COMMON_API_BULK_GET = sai_common_api.SAI_COMMON_API_BULK_GET SAI_COMMON_API_MAX = sai_common_api.SAI_COMMON_API_MAX ``` how Convert the python code after generated from ctypesgen verify pipeline local testing reformat code refactor code Signed-off-by: richardyu-ms <richard.yu@microsoft.com>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
[SAI-PTF] Convert generated enum code from ctypesgen into pythoon enum class
why
When ctypesgen generated the python code for c++ enum, the python cannot be logged by it enum name, we need to change it to enum class.
the code like
originally converted by ctypesgen
new code
how
Convert the python code after generated from ctypesgen
verify
pipeline
local testing