diff --git a/lib/cmock_config.rb b/lib/cmock_config.rb index 6a1feea..e19cbec 100644 --- a/lib/cmock_config.rb +++ b/lib/cmock_config.rb @@ -17,6 +17,7 @@ class CMockConfig :unity_helper => false, :treat_as => {}, :memcmp_if_unknown => true, + :when_no_prototypes => :warn, #the options being :ignore, :warn, or :error :when_ptr_star =>:compare_data, #the options being :compare_ptr, :compare_data, :compare_array :when_ptr_brackets => :compare_array, #not really supported yet } diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 414c1b2..4cd7e7f 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -3,13 +3,14 @@ class CMockHeaderParser attr_reader :src_lines, :prototypes, :attributes - def initialize(parser, source, cfg, name) + def initialize(parser, source, config, name) @src_lines = [] @prototypes = [] @function_names = [] @prototype_parse_matcher = /([\d\w\s\*\(\),\[\]]+??)\(([\d\w\s\*\(\),\.\[\]]*)\)$/m - @attributes = cfg.attributes + @attributes = config.attributes + @when_no_prototypes = config.when_no_prototypes @parser = parser @name = name @@ -86,7 +87,14 @@ class CMockHeaderParser @src_lines.each do |line| @prototypes << line if (line =~ @prototype_parse_matcher) end - raise "No function prototypes found in '#{@name}'" if @prototypes.empty? + if @prototypes.empty? + case @when_no_prototypes + when :error + raise "ERROR: No function prototypes found in '#{@name}'" + when :warn + puts "WARNING: No function prototypes found in '#{@name}'" + end + end end def parse_prototype(prototype) diff --git a/test/system/test_compilation/parsing.h b/test/system/test_compilation/parsing.h index 9d8543b..dc9f4a4 100644 --- a/test/system/test_compilation/parsing.h +++ b/test/system/test_compilation/parsing.h @@ -1,5 +1,6 @@ typedef unsigned short U16; +typedef signed int int32_t; typedef struct _POINT_T { @@ -48,3 +49,5 @@ void const_variants2( struct _DUMMY_T const * const param1, const unsigned long int const * const param2, const struct _DUMMY_T const * param3 ); + +int32_t example_c99_type(int32_t param1); diff --git a/test/unit/cmock_header_parser_test.rb b/test/unit/cmock_header_parser_test.rb index b71bd79..17643a2 100644 --- a/test/unit/cmock_header_parser_test.rb +++ b/test/unit/cmock_header_parser_test.rb @@ -7,6 +7,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase create_mocks :config, :prototype_parser, :parsed @test_name = 'test_file.h' @config.expect.attributes.returns(['__ramfunc', 'funky_attrib']) + @config.expect.when_no_prototypes.returns(:error) end def teardown @@ -256,7 +257,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase begin @parser.parse rescue RuntimeError => e - assert_equal("No function prototypes found in 'thinger.h'", e.message) + assert_equal("ERROR: No function prototypes found in 'thinger.h'", e.message) end end @@ -281,7 +282,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase begin @parser.parse rescue RuntimeError => e - assert_equal("No function prototypes found in 'hello_world.h'", e.message) + assert_equal("ERROR: No function prototypes found in 'hello_world.h'", e.message) end end