From f7945c5439cddc8dc2453f1bbba8f2fa1920047c Mon Sep 17 00:00:00 2001 From: mvandervoord Date: Tue, 3 Jun 2008 01:20:48 +0000 Subject: [PATCH] The asterisk can now be on either side (type or variable) for parameters. Defines are now removed from the list of potential functions. git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@12 bf332499-1b4d-0410-844d-d2d48d5cc64c --- lib/cmock_header_parser.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/cmock_header_parser.rb b/lib/cmock_header_parser.rb index 8ff6259..dba5aaa 100644 --- a/lib/cmock_header_parser.rb +++ b/lib/cmock_header_parser.rb @@ -4,6 +4,7 @@ class CMockHeaderParser def initialize(source, match_type=/\w+\**/, attributes=['static', '__monitor', '__ramfunc', '__irq', '__fiq']) source = source.gsub(/\/\/.*$/, '') #remove line comments + source = source.gsub(/\#define.*$/, '') #remove defines source = source.gsub(/\/\*.*?\*\//m, '') #remove block comments @lines = source.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line | (;|\{|\}) /x) # Match ;, {, and } as end of lines @@ -94,8 +95,15 @@ class CMockHeaderParser arg_list.split(',').each do |arg| arg = arg.strip return args if ((arg == @var_args_ellipsis) || (arg == 'void')) - arg_match = arg.match /^(.+)\s+(\w+)$/ + arg_match = arg.match /^(.+)\s+(\*?\w+)$/ raise "Failed parsing argument list at argument: '#{arg}'" if arg_match.nil? + + #put the asterix with the type (where it belongs) + if (arg_match[-1][0] == '*') + arg_match[1] << '*' + arg_match[-1].slice!(0) + end + args << {:type => arg_match[1], :name => arg_match[-1]} end return args