-
yonghong-song authored
Fix issue #2017. For python programs, the map data passed from C++ library is parsed through the key/value desc types which are generated by C++ json map declaration visitor. The map declaration visitor visits the map key/value declaration types and generate a string to represent the type, which is later used by python to reconstruct the cttype. The map declaration already tries to add all the padding to the type string in order to make sure C++ and python see the same layout. This patch further added packed support such that if C++ json map visitor has applied padding, the python type reconstructor is free to add _pack_=1 for structure type since the structure is already packed. For example, for a type, struct t { char a; int b; } the structure after json visitor will look like struct t { char a; char __pad[3]; int b; } If the type is struct t { char a; int b; } __packed; the structure after json visitor will look like struct t { char a; int b; } In either case, it will be okay to add __packed attribute for the type generated by json map visitor in order to match the original declaration. Thanks Chaitanya for filing the issue and providing the test case! Signed-off-by: Yonghong Song <yhs@fb.com>
9410c86d