mirror of
https://github.com/JakeHillion/object-introspection.git
synced 2024-11-10 05:26:56 +00:00
2d28b20d46
Multi dimensional arrays are not flattened into 1-D arrays when using TypeGraph. Update TreeBuilder to account for this. By not flattening arrays, we are able to produce more descriptive results. The disadvantage is that we must now recurse inside arrays containing only primitives. A better solution to requiring flattening would be the planned work to not recurse into any static types (not just primitives). This would also apply to multi-dimensional arrays of primtivies.
96 lines
3.2 KiB
TOML
96 lines
3.2 KiB
TOML
definitions = '''
|
|
struct Foo10 {
|
|
int arr[10];
|
|
};
|
|
|
|
#pragma clang diagnostic push
|
|
#pragma clang diagnostic ignored "-Wzero-length-array"
|
|
struct Foo0 {
|
|
int arr[0];
|
|
};
|
|
|
|
using ZeroLengthIntArray = int[0];
|
|
#pragma clang diagnostic pop
|
|
|
|
struct MultiDim {
|
|
int arr[2][3];
|
|
};
|
|
'''
|
|
[cases]
|
|
[cases.member_int10]
|
|
param_types = ["const Foo10&"]
|
|
setup = "return {};"
|
|
expect_json = '''[{
|
|
"staticSize":40,
|
|
"dynamicSize":0,
|
|
"members":[{
|
|
"staticSize":40,
|
|
"dynamicSize":0,
|
|
"length":10,
|
|
"capacity":10,
|
|
"elementStaticSize":4
|
|
}]}]'''
|
|
[cases.member_int0]
|
|
# WARNING: zero-length arrays are handled differently to non-empty arrays.
|
|
# They end up not being treated as containers. This should probably change
|
|
# in the future.
|
|
param_types = ["const Foo0&"]
|
|
setup = "return {};"
|
|
expect_json = '''[{
|
|
"staticSize":0,
|
|
"dynamicSize":0,
|
|
"members":[{
|
|
"staticSize":0,
|
|
"dynamicSize":0
|
|
}]}]'''
|
|
[cases.multidim_legacy] # Test for legacy behaviour. Remove with OICodeGen
|
|
cli_options = ["-Ftype-graph"]
|
|
param_types = ["const MultiDim&"]
|
|
setup = "return {};"
|
|
expect_json = '''[{
|
|
"staticSize":24,
|
|
"dynamicSize":0,
|
|
"members":[{
|
|
"staticSize":24,
|
|
"dynamicSize":0,
|
|
"length":6,
|
|
"capacity":6,
|
|
"elementStaticSize":4
|
|
}]}]'''
|
|
[cases.multidim]
|
|
cli_options = ["-ftype-graph"]
|
|
param_types = ["const MultiDim&"]
|
|
setup = "return {};"
|
|
expect_json = '''[
|
|
{"staticSize":24, "dynamicSize":0, "exclusiveSize":0, "members":[
|
|
{"staticSize":24, "dynamicSize":0, "exclusiveSize":0, "length":2, "capacity":2, "elementStaticSize":12, "members":[
|
|
{"staticSize":12, "dynamicSize":0, "exclusiveSize":12, "length":3, "capacity":3, "elementStaticSize":4},
|
|
{"staticSize":12, "dynamicSize":0, "exclusiveSize":12, "length":3, "capacity":3, "elementStaticSize":4}]
|
|
}]}]'''
|
|
[cases.direct_int10]
|
|
skip = "Direct array arguments don't work"
|
|
param_types = ["int[10]"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":40, "dynamicSize":0, "length":10, "capacity":10, "elementStaticSize":4}]'
|
|
[cases.direct_int0]
|
|
skip = "Direct array arguments don't work"
|
|
# WARNING: zero-length arrays are handled differently to non-empty arrays.
|
|
# They end up not being treated as containers. This should probably change
|
|
# in the future.
|
|
param_types = ["ZeroLengthIntArray"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":0, "dynamicSize":0}]'
|
|
[cases.ref_int10]
|
|
skip = "CodeGen bug with array reference arguments"
|
|
param_types = ["const int(&)[10]"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":40, "dynamicSize":0, "length":10, "capacity":10, "elementStaticSize":4}]'
|
|
[cases.ref_int0]
|
|
skip = "CodeGen bug with array reference arguments"
|
|
# WARNING: zero-length arrays are handled differently to non-empty arrays.
|
|
# They end up not being treated as containers. This should probably change
|
|
# in the future.
|
|
param_types = ["const ZeroLengthIntArray&"]
|
|
setup = "return {};"
|
|
expect_json = '[{"staticSize":0, "dynamicSize":0}]'
|