2022-12-19 14:37:51 +00:00
|
|
|
|
includes = ["functional"]
|
|
|
|
|
|
|
|
|
|
definitions = '''
|
|
|
|
|
void myFunction(int x) {
|
|
|
|
|
(void)x;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Put this function pointer inside a struct since the test framework doesn't
|
|
|
|
|
// support the syntax required for passing raw function pointers as arguments
|
|
|
|
|
struct FuncPtrStruct {
|
|
|
|
|
void (*p)(int);
|
|
|
|
|
};
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
|
|
[cases]
|
|
|
|
|
[cases.raw]
|
2023-08-16 20:40:36 +01:00
|
|
|
|
skip = "function pointers are not handled correctly" # https://github.com/facebookexperimental/object-introspection/issues/22
|
2022-12-19 14:37:51 +00:00
|
|
|
|
param_types = ["const FuncPtrStruct&"]
|
|
|
|
|
setup = "return {{myFunction}};"
|
|
|
|
|
expect_json = '''[{
|
|
|
|
|
"staticSize": 8,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"members": [{
|
|
|
|
|
"typeName": "void (*)(int)",
|
|
|
|
|
"staticSize": 8,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"NOT": {"pointer": 0},
|
|
|
|
|
"NOT": "members"
|
|
|
|
|
}]
|
|
|
|
|
}]'''
|
|
|
|
|
[cases.raw_chase] # We should never chase function pointers
|
2022-12-30 22:41:09 +00:00
|
|
|
|
oid_skip = "function pointers are not handled correctly" # https://github.com/facebookexperimental/object-introspection/issues/22
|
2023-01-03 14:12:51 +00:00
|
|
|
|
oil_disable = "oil can't chase raw pointers safely"
|
2022-12-19 14:37:51 +00:00
|
|
|
|
param_types = ["const FuncPtrStruct&"]
|
|
|
|
|
setup = "return {{myFunction}};"
|
2023-06-22 13:24:39 +01:00
|
|
|
|
cli_options = ["-fchase-raw-pointers"]
|
2022-12-19 14:37:51 +00:00
|
|
|
|
expect_json = '''[{
|
|
|
|
|
"staticSize": 8,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"members": [{
|
|
|
|
|
"typeName": "void (*)(int)",
|
|
|
|
|
"staticSize": 8,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"NOT": {"pointer": 0},
|
|
|
|
|
"NOT": "members"
|
|
|
|
|
}]
|
|
|
|
|
}]'''
|
|
|
|
|
[cases.raw_null]
|
2023-08-16 20:40:36 +01:00
|
|
|
|
skip = "function pointers are not handled correctly" # https://github.com/facebookexperimental/object-introspection/issues/22
|
2022-12-19 14:37:51 +00:00
|
|
|
|
param_types = ["const FuncPtrStruct&"]
|
|
|
|
|
setup = "return {{nullptr}};"
|
|
|
|
|
expect_json = '''[{
|
|
|
|
|
"staticSize": 8,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"members": [{
|
|
|
|
|
"typeName": "void (*)(int)",
|
|
|
|
|
"staticSize": 8,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"pointer": 0,
|
|
|
|
|
"NOT": "members"
|
|
|
|
|
}]
|
|
|
|
|
}]'''
|
|
|
|
|
|
|
|
|
|
[cases.std_function]
|
2023-08-16 20:40:36 +01:00
|
|
|
|
skip = "function pointers are not handled correctly" # https://github.com/facebookexperimental/object-introspection/issues/22
|
2022-12-19 14:37:51 +00:00
|
|
|
|
param_types = ["std::function<void(int)> &"]
|
|
|
|
|
setup = "return myFunction;"
|
|
|
|
|
expect_json = '''[{
|
|
|
|
|
"typeName": "function<void (int)>",
|
|
|
|
|
"staticSize": 32,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"NOT": {"pointer": 0},
|
|
|
|
|
"NOT": "members"
|
|
|
|
|
}]'''
|
|
|
|
|
[cases.std_function_chase] # We should never chase function pointers
|
2022-12-30 22:41:09 +00:00
|
|
|
|
oid_skip = "function pointers are not handled correctly" # https://github.com/facebookexperimental/object-introspection/issues/22
|
2023-01-03 14:12:51 +00:00
|
|
|
|
oil_disable = "oil can't chase raw pointers safely"
|
2022-12-19 14:37:51 +00:00
|
|
|
|
param_types = ["std::function<void(int)> &"]
|
|
|
|
|
setup = "return myFunction;"
|
2023-06-22 13:24:39 +01:00
|
|
|
|
cli_options = ["-fchase-raw-pointers"]
|
2022-12-19 14:37:51 +00:00
|
|
|
|
expect_json = '''[{
|
|
|
|
|
"typeName": "function<void (int)>",
|
|
|
|
|
"staticSize": 32,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"NOT": {"pointer": 0},
|
|
|
|
|
"NOT": "members"
|
|
|
|
|
}]'''
|
|
|
|
|
[cases.std_function_null]
|
2023-08-16 20:40:36 +01:00
|
|
|
|
skip = "function pointers are not handled correctly" # https://github.com/facebookexperimental/object-introspection/issues/22
|
2022-12-19 14:37:51 +00:00
|
|
|
|
param_types = ["std::function<void(int)> &"]
|
|
|
|
|
setup = "return nullptr;"
|
|
|
|
|
expect_json = '''[{
|
|
|
|
|
"typeName": "function<void (int)>",
|
|
|
|
|
"staticSize": 32,
|
|
|
|
|
"dynamicSize": 0,
|
|
|
|
|
"pointer": 0,
|
|
|
|
|
"NOT": "members"
|
|
|
|
|
}]'''
|