Merge pull request #112 from ajsetter/header-parsing-brackets

Improve handling of brackets in function params. Thanks so much, @ajsetter!
This commit is contained in:
Mark VanderVoord
2017-03-03 14:30:59 -05:00
committed by GitHub
2 changed files with 5 additions and 3 deletions
+3 -3
View File
@@ -187,9 +187,9 @@ class CMockHeaderParser
return 'void'
else
c=0
arg_list.gsub!(/(\w+)(?:\s*\[[\s\d\w+-]*\])+/,'*\1') # magically turn brackets into asterisks
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
arg_list.gsub!(/(\w+)(?:\s*\[\s*\(*[\s\d\w+-]*\)*\s*\])+/,'*\1') # magically turn brackets into asterisks, also match for parentheses that come from macros
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
#scan argument list for function pointers and replace them with custom types
arg_list.gsub!(/([\w\s\*]+)\(+\s*\*[\*\s]*([\w\s]*)\s*\)+\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |m|
@@ -64,6 +64,8 @@
void oh_brackets1(int fudge[5]);
void oh_brackets2(int caramel[]);
void oh_brackets3(int toffee[(32)]);
void oh_brackets4(int taffy[ (64) ]);
#ifdef __cplusplus
}
#endif