mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-09-09 19:59:58 +00:00
updated header parser comments and tests to capture new beahvior of extracting removing structs, unions, & enums including any modifiers at beginning of line.
git-svn-id: http://cmock.svn.sourceforge.net/svnroot/cmock/trunk@129 bf332499-1b4d-0410-844d-d2d48d5cc64c
This commit is contained in:
@@ -48,12 +48,13 @@ class CMockHeaderParser
|
||||
|
||||
# unions, structs, and typedefs can all contain things (e.g. function pointers) that parse like function prototypes, so yank them;
|
||||
# enums might cause trouble or might not - pull 'em just to be safe
|
||||
source.gsub!(/^[\w\s]*enum[\w\s]*\{[^\}]+\}[\w\s]*;/m, '') # remove enum definitions (do before typedef removal because an enum can be typedef'd)
|
||||
source.gsub!(/^[\w\s]*union[\w\s]*\{[^\}]+\}[\w\s]*;/m, '') # remove union definitions (do before typedef removal because a union can be typedef'd)
|
||||
source.gsub!(/^[\w\s]*struct[^;\{\}\(\)]+;/m, '') # remove forward declared structs but leave prototypes having struct in types
|
||||
source.gsub!(/^[\w\s]*enum[\w\s]*\{[^\}]+\}[\w\s]*;/m, '') # remove enum definitions
|
||||
source.gsub!(/^[\w\s]*union[\w\s]*\{[^\}]+\}[\w\s]*;/m, '') # remove union definitions
|
||||
source.gsub!(/^[\w\s]*struct[^;\{\}\(\)]+;/m, '') # remove forward declared structs but leave function prototypes having struct in types
|
||||
# (do before struct definitions so as to not mess up recognizing full struct definitions)
|
||||
source.gsub!(/^[\w\s]*struct[\w\s]*\{[^\}]+\}[\w\s]*;/m, '') # remove struct definitions (do before typedef removal because a struct can be typedef'd)
|
||||
source.gsub!(/typedef.*/, '') # remove typedef statements
|
||||
source.gsub!(/^[\w\s]*struct[\w\s]*\{[^\}]+\}[\w\s]*;/m, '') # remove struct definitions
|
||||
|
||||
source.gsub!(/typedef.*/, '') # remove typedef statements
|
||||
|
||||
source.gsub!(/\s*=\s*['"a-zA-Z0-9_\.]+\s*/, '') # remove default value statements from argument lists
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
" THING2 = (0x0001 << 5),\n" +
|
||||
"}ListOValues;\n\n" +
|
||||
"don't delete me!!\n" +
|
||||
" modifier_str enum _NamedEnum {THING1 = (0x0001), THING2 = (0x0001 << 5)} ListOValues;\n\n" +
|
||||
"typedef enum {\n" +
|
||||
" THING1,\n" +
|
||||
" THING2,\n" +
|
||||
@@ -127,6 +128,7 @@ class CMockHeaderParserTest < Test::Unit::TestCase
|
||||
" char b;\n" +
|
||||
"} Doohicky;\n\n" +
|
||||
"I want to live!!\n" +
|
||||
"some_modifier union { unsigned int a; char b;} Whatever;\n" +
|
||||
"typedef union {\n" +
|
||||
" unsigned int a;\n" +
|
||||
" char b;\n" +
|
||||
|
||||
Reference in New Issue
Block a user