removed automatic extern instance handling wonkiness (possibly leftover from previous cmock mechanisms)

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@83 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
mkarlesky
2009-04-19 01:04:17 +00:00
parent e149f7b235
commit 98658b5fb6
4 changed files with 5 additions and 95 deletions
+2 -13
View File
@@ -24,7 +24,6 @@ class CMockGenerator
def create_mock_header_file(parsed_stuff)
@file_writer.create_file(@mock_name + ".h") do |file, filename|
create_mock_header_header(file, filename)
create_mock_header_externs(file, parsed_stuff)
parsed_stuff[:functions].each do |function|
file << @plugins.run(:mock_function_declarations, function)
end
@@ -36,7 +35,7 @@ class CMockGenerator
@file_writer.create_file(@mock_name + ".c") do |file, filename|
create_source_header_section(file, filename, parsed_stuff[:includes])
create_instance_structure(file, parsed_stuff[:functions])
create_extern_declarations(file, parsed_stuff[:externs])
create_extern_declarations(file)
create_mock_verify_function(file, parsed_stuff[:functions])
create_mock_init_function(file)
create_mock_destroy_function(file, parsed_stuff[:functions])
@@ -59,15 +58,6 @@ class CMockGenerator
file << "void #{@mock_name}_Verify(void);\n\n"
end
def create_mock_header_externs(header, parsed_stuff)
unless (parsed_stuff[:externs].empty?)
parsed_stuff[:externs].each do |extern|
header << extern << ";\n"
end
header << "\n"
end
end
def create_mock_header_footer(header)
header << "\n#endif\n"
end
@@ -97,8 +87,7 @@ class CMockGenerator
file << "} Mock;\n\n"
end
def create_extern_declarations(file, externs)
file << externs.collect {|extern| extern.gsub(/extern\s*/,'') << ";\n"}.flatten
def create_extern_declarations(file)
file << "extern jmp_buf AbortFrame;\n"
file << "extern int GlobalExpectOrder;\n"
file << "extern int GlobalVerifyOrder;\n"
+1 -23
View File
@@ -11,9 +11,8 @@ class CMockHeaderParser
end
def parse
mod = {:includes => nil, :externs => nil, :functions => []}
mod = {:includes => nil, :functions => []}
mod[:includes] = included_files
mod[:externs] = externs
parse_functions
if !@funcs.nil? and @funcs.length > 0
@funcs.each do |decl|
@@ -55,27 +54,6 @@ class CMockHeaderParser
return @included
end
def externs
if !@externs
@externs = []
depth = 0
if !@src_lines.nil? and @src_lines.length > 0
@src_lines.each do |line|
if depth.zero? && line =~ /^\s*extern.*/m
@externs << $&.strip.gsub(/\s+/, ' ')
end
if line =~ /\{/
depth += 1
end
if line =~ /\}/
depth -= 1
end
end
end
end
return @externs
end
def parse_functions
if @funcs.nil?
@funcs = []
+2 -38
View File
@@ -77,26 +77,6 @@ class CMockGeneratorTest < Test::Unit::TestCase
assert_equal(expected, output)
end
should "extern nothing if not requested to do so" do
parsed_stuff = { :externs => []}
output = []
expected = []
@cmock_generator.create_mock_header_externs(output, parsed_stuff)
assert_equal(expected, output)
end
should "extern whatever it is requested to" do
parsed_stuff = { :externs => ["extern int kisskissfish", "extern int blubblubblub"]}
output = []
expected = [ "extern int kisskissfish",";\n","extern int blubblubblub",";\n","\n" ]
@cmock_generator.create_mock_header_externs(output, parsed_stuff)
assert_equal(expected, output)
end
should "append the proper footer to the header file" do
output = []
expected = ["\n#endif\n"]
@@ -163,30 +143,14 @@ class CMockGeneratorTest < Test::Unit::TestCase
assert_equal(expected, output.flatten)
end
should "create extern declarations for source file if no extra externs requested" do
externs = []
should "create extern declarations for source file" do
output = []
expected = [ "extern jmp_buf AbortFrame;\n",
"extern int GlobalExpectOrder;\n",
"extern int GlobalVerifyOrder;\n",
"\n" ]
@cmock_generator.create_extern_declarations(output, externs)
assert_equal(expected, output.flatten)
end
should "create extern declarations for source file if extra externs requested" do
externs = ["extern int whatever", "extern short somethingelse"]
output = []
expected = [ "int whatever;\n",
"short somethingelse;\n",
"extern jmp_buf AbortFrame;\n",
"extern int GlobalExpectOrder;\n",
"extern int GlobalVerifyOrder;\n",
"\n"]
@cmock_generator.create_extern_declarations(output, externs)
@cmock_generator.create_extern_declarations(output)
assert_equal(expected, output.flatten)
end
-21
View File
@@ -166,27 +166,6 @@ class CMockHeaderParserTest < Test::Unit::TestCase
assert_equal(expected, parsed_stuff[:includes])
end
should "extract and return externs" do
source =
"extern int Foo(int a, unsigned int b);\n" +
"extern unsigned int NumSamples;\n" +
"extern FOO_TYPE fooFun;"
@parser = CMockHeaderParser.new(source, @config)
expected =
[
"extern int Foo(int a, unsigned int b)",
";",
"\nextern unsigned int NumSamples",
";",
"\nextern FOO_TYPE fooFun",
";"
]
assert_equal(expected, @parser.src_lines)
end
should "extract and return function declarations" do
source =