mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-16 23:29:57 +00:00
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
This commit is contained in:
@@ -4,6 +4,7 @@ class CMockHeaderParser
|
|||||||
|
|
||||||
def initialize(source, match_type=/\w+\**/, attributes=['static', '__monitor', '__ramfunc', '__irq', '__fiq'])
|
def initialize(source, match_type=/\w+\**/, attributes=['static', '__monitor', '__ramfunc', '__irq', '__fiq'])
|
||||||
source = source.gsub(/\/\/.*$/, '') #remove line comments
|
source = source.gsub(/\/\/.*$/, '') #remove line comments
|
||||||
|
source = source.gsub(/\#define.*$/, '') #remove defines
|
||||||
source = source.gsub(/\/\*.*?\*\//m, '') #remove block comments
|
source = source.gsub(/\/\*.*?\*\//m, '') #remove block comments
|
||||||
@lines = source.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
@lines = source.split(/(^\s*\#.*$) # Treat preprocessor directives as a logical line
|
||||||
| (;|\{|\}) /x) # Match ;, {, and } as end of lines
|
| (;|\{|\}) /x) # Match ;, {, and } as end of lines
|
||||||
@@ -94,8 +95,15 @@ class CMockHeaderParser
|
|||||||
arg_list.split(',').each do |arg|
|
arg_list.split(',').each do |arg|
|
||||||
arg = arg.strip
|
arg = arg.strip
|
||||||
return args if ((arg == @var_args_ellipsis) || (arg == 'void'))
|
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?
|
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]}
|
args << {:type => arg_match[1], :name => arg_match[-1]}
|
||||||
end
|
end
|
||||||
return args
|
return args
|
||||||
|
|||||||
Reference in New Issue
Block a user