mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-06-06 05:25:29 +00:00
Better handling of inline functions with declaration in header
This commit is contained in:
@@ -112,6 +112,13 @@ class CMockHeaderParser
|
||||
end
|
||||
end
|
||||
|
||||
if (@treat_inline == :include)
|
||||
# Functions having "{ }" at this point are/were inline functions,
|
||||
# User wants them in so 'disguise' them as normal functions with the ";"
|
||||
source.gsub!("{ }", ";")
|
||||
end
|
||||
|
||||
|
||||
# remove function definitions by stripping off the arguments right now
|
||||
source.gsub!(/\([^\)]*\)\s*\{[^\}]*\}/m, ";")
|
||||
|
||||
|
||||
@@ -460,12 +460,18 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"uint32 extern_name_func(unsigned int);\n" +
|
||||
"uint32 funcinline(unsigned int);\n" +
|
||||
"inline void inlineBar(unsigned int);\n" +
|
||||
"static inline void bar(unsigned int);\n"
|
||||
"static inline void staticinlineBar(unsigned int);\n" +
|
||||
"static inline void bar(unsigned int);\n" +
|
||||
"static inline void bar(unsigned int)\n" +
|
||||
"{\n" +
|
||||
" // NOP\n" +
|
||||
"}\n"
|
||||
|
||||
expected =
|
||||
[ "uint32 extern_name_func(unsigned int)",
|
||||
"uint32 funcinline(unsigned int)",
|
||||
"void inlineBar(unsigned int)",
|
||||
"void staticinlineBar(unsigned int)",
|
||||
"void bar(unsigned int)"
|
||||
]
|
||||
|
||||
@@ -479,13 +485,19 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
||||
"uint32 extern_name_func(unsigned int);\n" +
|
||||
"uint32 funcinline(unsigned int);\n" +
|
||||
"inline void inlineBar(unsigned int);\n" +
|
||||
"static inline void bar(unsigned int);\n"
|
||||
"static inline void staticinlineBar(unsigned int);\n" +
|
||||
"static inline void bar(unsigned int);\n" +
|
||||
"static inline void bar(unsigned int)\n" +
|
||||
"{\n" +
|
||||
" // NOP\n" +
|
||||
"}\n"
|
||||
|
||||
expected =
|
||||
[ "extern uint32 foobar(unsigned int)",
|
||||
"uint32 extern_name_func(unsigned int)",
|
||||
"uint32 funcinline(unsigned int)",
|
||||
"void inlineBar(unsigned int)",
|
||||
"void staticinlineBar(unsigned int)",
|
||||
"void bar(unsigned int)"
|
||||
]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user