1
-
1
+ #=============================================================================#
2
+ # Attempts to match a given function definition signature to its' declaration, searching in all given headers.
3
+ # These headers are usually a list of all headers included by the function's file, recursively.
4
+ # Given a match, the declaration is returned, otherwise - "NOTFOUND" string.
5
+ # _definition_signature - String representing a full function signature, e.g. 'int main(int argc, char **argv)'
6
+ # _included_headers - List of headers to search the declaration in.
7
+ # Should include the function's containing file itself.
8
+ # _return_var - Name of variable in parent-scope holding the return value.
9
+ # Returns - Function's declaration signature if exists, otherwise "NOTFOUND".
10
+ #=============================================================================#
2
11
function (match_function_declaration _definition_signature _included_headers _return_var)
3
12
4
13
# Get function name and list of argument-types
5
14
strip_function_signature("${_definition_signature} " original_stripped_function)
6
-
7
- # ToDo: Consider writing a utility function
8
- list (LENGTH original_stripped_function orig_func_list_len)
9
- set (original_function_args_length ${orig_func_list_len} )
10
- decrement_integer(original_function_args_length 1)
11
-
12
15
list (GET original_stripped_function 0 original_function_name)
16
+ list_max_index("${original_stripped_function} " original_function_args_length)
13
17
14
18
foreach (included_header ${_included_headers} )
15
19
@@ -22,13 +26,8 @@ function(match_function_declaration _definition_signature _included_headers _ret
22
26
23
27
# Get function name and list of argument-types
24
28
strip_function_signature("${line} " iterated_stripped_function)
25
-
26
- # ToDo: Consider writing a utility function
27
- list (LENGTH iterated_stripped_function iter_func_list_len)
28
- set (iterated_function_args_length ${iter_func_list_len} )
29
- decrement_integer(iterated_function_args_length 1)
30
-
31
29
list (GET iterated_stripped_function 0 iterated_function_name)
30
+ list_max_index("${iterated_stripped_function} " iterated_function_args_length)
32
31
33
32
if ("${original_function_name} " STREQUAL "${iterated_function_name} " )
34
33
if (${orig_func_list_len} EQUAL ${iter_func_list_len} )
0 commit comments