mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-07-29 15:27:49 +00:00
made new typedef void handling more better to ignore function pointer typedefs with void return type
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@90 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -27,7 +27,7 @@ class CMockHeaderParser
|
||||
# look for any edge cases of typedef'd void;
|
||||
# void must be void for cmock AndReturn calls to process properly.
|
||||
# to a certain extent, these replacements assume we're chewing on pre-processed header files
|
||||
void_types = source.scan(/typedef\s+void\s+([^\s]+)\s*;/)
|
||||
void_types = source.scan(/typedef\s+void\s+([\w\d]+)\s*;/)
|
||||
void_types.each {|type| source.gsub!(/#{type}/, 'void')} if void_types.size > 0
|
||||
|
||||
source.gsub!(/\s*\\\s*/m, ' ') # smush multiline into single line
|
||||
|
||||
@@ -115,10 +115,11 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
|
||||
source =
|
||||
"typedef void SILLY_VOID_TYPE1;\n" +
|
||||
"typedef void SILLY_VOID_TYPE2 ;\n\n" +
|
||||
"typedef void SILLY_VOID_TYPE2 ;\n" +
|
||||
"typedef void (*FUNCPTR)(void);\n\n" + # do no substitution on type
|
||||
"SILLY_VOID_TYPE2 Foo(int a, unsigned int b);\n" +
|
||||
"void\n shiz(SILLY_VOID_TYPE1 *);\n" +
|
||||
"void tat(void);\n"
|
||||
"void tat(FUNCPTR);\n"
|
||||
|
||||
@parser = CMockHeaderParser.new(source, @config)
|
||||
parsed_stuff = @parser.parse
|
||||
@@ -145,10 +146,10 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
|
||||
{
|
||||
:modifier => "",
|
||||
:args_string => "void",
|
||||
:args_string => "FUNCPTR cmock_arg1",
|
||||
:rettype => "void",
|
||||
:var_arg => nil,
|
||||
:args => [],
|
||||
:args => [{:type => "FUNCPTR", :name => "cmock_arg1"}],
|
||||
:name => "tat"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in New Issue
Block a user