- strips out gcc's __attribute__ tags

git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@223 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
mvandervoord
2012-05-28 17:24:22 +00:00
parent a9b9a61ed0
commit e2cc434883
2 changed files with 23 additions and 0 deletions
+3
View File
@@ -66,6 +66,9 @@ class CMockHeaderParser
# remove assembler pragma sections
source.gsub!(/^\s*#\s*pragma\s+asm\s+.*?#\s*pragma\s+endasm/m, '')
# remove gcc's __attribute__ tags
source.gsub(/__attrbute__\s*\(\(\.*\)\)/, '')
# remove preprocessor statements and extern "C"
source.gsub!(/^\s*#.*/, '')
source.gsub!(/extern\s+\"C\"\s+\{/, '')
+20
View File
@@ -85,6 +85,26 @@ class CMockHeaderParserTest < Test::Unit::TestCase
end
should "remove gcc's function __attribute__'s" do
source =
"void* my_calloc(size_t, size_t) __attribute__((alloc_size(1,2)));\n" +
"void\n" +
" my_realloc(void*, size_t) __attribute__((alloc_size(2)));\n" +
"extern int\n" +
" my_printf (void *my_object, const char *my_format, ...)\n" +
" __attribute__ ((format (printf, 2, 3)));\n" +
" void __attribute__ ((interrupt)) universal_handler ();\n"
expected =
[
"void* my_calloc(size_t, size_t)",
"void my_realloc(void*, size_t)",
"void universal_handler()"
]
assert_equal(expected, @parser.import_source(source))
end
should "remove preprocessor directives" do
source =
"#when stuff_happens\n" +