mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-09 21:24:14 +00:00
40af807d8b
Support the capture-thrift-isset feature with TreeBuilder-v2. Fairly minor changes here except the type of the Enum in a template parameter now matters. We follow the previous behaviour of capturing a value for each field in a struct that has an `isset_bitset`. This value is a VarInt captured before the C++ contents of the member. It has 3 values: 0 (not set), 1 (set), and 2 (unavailable). These are handled by the processor and represented in the output as `false`, `true`, and `std::nullopt_t` respectively. Changes: - Add a simple Thrift isset processor before any fields that have Thrift isset. - Store the fully qualified names of enum types in DrgnParser - it already worked out this information anyway for naming the values and this is consistent with classes. - Forward all enum template parameters under their input name under the assumption that they will all be policy type things like `IssetBitsetOption`. This could turn out to be wrong. Test plan: - CI (doesn't test thrift changes but covers other regressions) - Updated Thrift enum tests for new format. - `FILTER='OilIntegration.*' make test` - Thrift tests failed before, succeed after.
67 lines
1.9 KiB
TOML
67 lines
1.9 KiB
TOML
definitions = '''
|
|
enum class ScopedEnum {
|
|
CaseA,
|
|
CaseB,
|
|
CaseC,
|
|
};
|
|
|
|
enum class ScopedEnumUint8 : uint8_t {
|
|
CaseA = 2,
|
|
CaseB = 3,
|
|
CaseC = 4,
|
|
};
|
|
|
|
|
|
enum UNSCOPED_ENUM {
|
|
CASE_A = 5,
|
|
CASE_B = -2,
|
|
CASE_C = 20,
|
|
};
|
|
|
|
struct Holder {
|
|
enum {
|
|
One,
|
|
Two,
|
|
} e;
|
|
};
|
|
|
|
template <typename T1, typename T2>
|
|
struct Pair {
|
|
T1 first;
|
|
T2 second;
|
|
};
|
|
'''
|
|
[cases]
|
|
[cases.scoped]
|
|
param_types = ["ScopedEnum"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":4, "dynamicSize":0}]'
|
|
expect_json_v2 = '[{"typeNames": ["ns_enums::ScopedEnum"], "staticSize":4, "exclusiveSize":4, "size":4}]'
|
|
[cases.scoped_uint8]
|
|
param_types = ["ScopedEnumUint8"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":1, "dynamicSize":0}]'
|
|
expect_json_v2 = '[{"typeNames": ["ns_enums::ScopedEnumUint8"], "staticSize":1, "exclusiveSize":1, "size":1}]'
|
|
[cases.unscoped]
|
|
param_types = ["UNSCOPED_ENUM"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}]'
|
|
[cases.anonymous]
|
|
skip = "TreeBuilder crashes" # https://github.com/facebookexperimental/object-introspection/issues/232
|
|
param_types = ["Holder&"]
|
|
setup = "return {};"
|
|
expect_json = '''[
|
|
{"staticSize":4, "dynamicSize":0, "exclusiveSize":0, "size":4, "members":[
|
|
{"name":"e", "staticSize":4, "dynamicSize":0, "exclusiveSize":4, "size":4}
|
|
]}]'''
|
|
[cases.paired_with_element]
|
|
param_types = ["Pair<ScopedEnumUint8, uint8_t>"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":2, "dynamicSize":0}]'
|
|
expect_json_v2 = '''[
|
|
{"staticSize": 2, "exclusiveSize": 0, "size":2, "members": [
|
|
{"typeNames": ["ns_enums::ScopedEnumUint8"], "staticSize":1, "exclusiveSize":1, "size":1},
|
|
{"typeNames": ["uint8_t"], "staticSize":1, "exclusiveSize":1, "size":1}
|
|
]}
|
|
]'''
|