mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-07-31 16:27:49 +00:00
moved detection of varargs over to parser, where it belongs
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@21 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -13,10 +13,6 @@ class CMockGenerator
|
||||
end
|
||||
|
||||
def create_mock(parsed_stuff)
|
||||
parsed_stuff[:functions].each do |function|
|
||||
function[:args_string_without_varargs] = function[:args_string].gsub(/\,[a-zA-Z0-9_\*\s]*\.\.\./,'')
|
||||
end
|
||||
|
||||
create_mock_header_file(parsed_stuff)
|
||||
create_mock_source_file(parsed_stuff)
|
||||
end
|
||||
@@ -26,7 +22,7 @@ class CMockGenerator
|
||||
create_mock_header_header(file, filename)
|
||||
create_mock_header_externs(file, parsed_stuff)
|
||||
parsed_stuff[:functions].each do |function|
|
||||
@plugins.each { |plugin| file << plugin.mock_function_declarations(function[:name], function[:args_string_without_varargs], function[:rettype]) }
|
||||
@plugins.each { |plugin| file << plugin.mock_function_declarations(function[:name], function[:args_string], function[:rettype]) }
|
||||
end
|
||||
create_mock_header_footer(file)
|
||||
end
|
||||
@@ -42,7 +38,7 @@ class CMockGenerator
|
||||
create_mock_destroy_function(file, parsed_stuff[:functions])
|
||||
parsed_stuff[:functions].each do |function|
|
||||
create_mock_implementation(file, function)
|
||||
@plugins.each { |plugin| file << plugin.mock_interfaces( function[:name], function[:args_string_without_varargs], function[:args], function[:rettype]) }
|
||||
@plugins.each { |plugin| file << plugin.mock_interfaces( function[:name], function[:args_string], function[:args], function[:rettype]) }
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -145,9 +141,12 @@ class CMockGenerator
|
||||
function_mod_and_rettype = function[:modifier] + ' ' + function[:rettype]
|
||||
end
|
||||
|
||||
args_string = function[:args_string]
|
||||
args_string += (", " + function[:var_arg]) unless (function[:var_arg].nil?)
|
||||
|
||||
# Create mock function
|
||||
file << "#{function[:attributes]} " if (!function[:attributes].nil? && function[:attributes].length > 0)
|
||||
file << "#{function_mod_and_rettype} #{function[:name]}(#{function[:args_string]})\n"
|
||||
file << "#{function_mod_and_rettype} #{function[:name]}(#{args_string})\n"
|
||||
file << "{\n"
|
||||
|
||||
@plugins.each { |plugin| file << plugin.mock_implementation_prefix(function[:name], function[:rettype]) }
|
||||
|
||||
@@ -124,6 +124,19 @@ class CMockHeaderParser
|
||||
#remove default parameter statements from mock definitions
|
||||
args.gsub!(/=\s*[a-zA-Z0-9_\.]+\s*\,/, ',')
|
||||
args.gsub!(/=\s*[a-zA-Z0-9_\.]+\s*/, ' ')
|
||||
|
||||
#check for var args
|
||||
if (args =~ /\.\.\./)
|
||||
decl[:var_arg] = args.match( /[\w\s]*\.\.\./ ).to_s
|
||||
if (args =~ /\,[\w\s]*\.\.\./)
|
||||
args = args.gsub!(/\,[\w\s]*\.\.\./,'')
|
||||
else
|
||||
args = 'void'
|
||||
end
|
||||
else
|
||||
decl[:var_arg] = nil
|
||||
end
|
||||
|
||||
args.strip!
|
||||
decl[:args_string] = args
|
||||
decl[:args] = parse_args(args)
|
||||
|
||||
Reference in New Issue
Block a user