mirror of
https://github.com/ThrowTheSwitch/CMock.git
synced 2026-08-10 05:07:52 +00:00
convert Boolean values from int to char to reduce memory
This commit is contained in:
@@ -19,7 +19,7 @@ class CMockGeneratorPluginCallback
|
||||
|
||||
def instance_structure(function)
|
||||
func_name = function[:name]
|
||||
" int #{func_name}_CallbackBool;\n" \
|
||||
" char #{func_name}_CallbackBool;\n" \
|
||||
" CMOCK_#{func_name}_CALLBACK #{func_name}_CallbackFunctionPointer;\n" \
|
||||
" int #{func_name}_CallbackCalls;\n"
|
||||
end
|
||||
@@ -70,12 +70,12 @@ class CMockGeneratorPluginCallback
|
||||
has_ignore = @config.plugins.include? :ignore
|
||||
lines = ''
|
||||
lines << "void #{func_name}_AddCallback(CMOCK_#{func_name}_CALLBACK Callback)\n{\n"
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n" if has_ignore
|
||||
lines << " Mock.#{func_name}_CallbackBool = (int)1;\n"
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (char)0;\n" if has_ignore
|
||||
lines << " Mock.#{func_name}_CallbackBool = (char)1;\n"
|
||||
lines << " Mock.#{func_name}_CallbackFunctionPointer = Callback;\n}\n\n"
|
||||
lines << "void #{func_name}_Stub(CMOCK_#{func_name}_CALLBACK Callback)\n{\n"
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n" if has_ignore
|
||||
lines << " Mock.#{func_name}_CallbackBool = (int)0;\n"
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (char)0;\n" if has_ignore
|
||||
lines << " Mock.#{func_name}_CallbackBool = (char)0;\n"
|
||||
lines << " Mock.#{func_name}_CallbackFunctionPointer = Callback;\n}\n\n"
|
||||
end
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ class CMockGeneratorPluginExpectAnyArgs
|
||||
end
|
||||
|
||||
def instance_typedefs(_function)
|
||||
" int ExpectAnyArgsBool;\n"
|
||||
" char ExpectAnyArgsBool;\n"
|
||||
end
|
||||
|
||||
def mock_function_declarations(function)
|
||||
@@ -42,7 +42,7 @@ class CMockGeneratorPluginExpectAnyArgs
|
||||
unless function[:return][:void?]
|
||||
lines << " cmock_call_instance->ReturnVal = cmock_to_return;\n"
|
||||
end
|
||||
lines << " cmock_call_instance->ExpectAnyArgsBool = (int)1;\n"
|
||||
lines << " cmock_call_instance->ExpectAnyArgsBool = (char)1;\n"
|
||||
lines << "}\n\n"
|
||||
end
|
||||
lines
|
||||
|
||||
@@ -16,9 +16,9 @@ class CMockGeneratorPluginIgnore
|
||||
|
||||
def instance_structure(function)
|
||||
if function[:return][:void?]
|
||||
" int #{function[:name]}_IgnoreBool;\n"
|
||||
" char #{function[:name]}_IgnoreBool;\n"
|
||||
else
|
||||
" int #{function[:name]}_IgnoreBool;\n #{function[:return][:type]} #{function[:name]}_FinalReturn;\n"
|
||||
" char #{function[:name]}_IgnoreBool;\n #{function[:return][:type]} #{function[:name]}_FinalReturn;\n"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -59,12 +59,12 @@ class CMockGeneratorPluginIgnore
|
||||
unless function[:return][:void?]
|
||||
lines << " cmock_call_instance->ReturnVal = cmock_to_return;\n"
|
||||
end
|
||||
lines << " Mock.#{function[:name]}_IgnoreBool = (int)1;\n"
|
||||
lines << " Mock.#{function[:name]}_IgnoreBool = (char)1;\n"
|
||||
lines << "}\n\n"
|
||||
end
|
||||
|
||||
def mock_ignore(function)
|
||||
" Mock.#{function[:name]}_IgnoreBool = (int) 1;\n"
|
||||
" Mock.#{function[:name]}_IgnoreBool = (char) 1;\n"
|
||||
end
|
||||
|
||||
def mock_verify(function)
|
||||
|
||||
@@ -10,7 +10,7 @@ class CMockGeneratorPluginIgnoreArg
|
||||
def instance_typedefs(function)
|
||||
lines = ''
|
||||
function[:args].each do |arg|
|
||||
lines << " int IgnoreArg_#{arg[:name]};\n"
|
||||
lines << " char IgnoreArg_#{arg[:name]};\n"
|
||||
end
|
||||
lines
|
||||
end
|
||||
|
||||
@@ -12,7 +12,7 @@ class CMockGeneratorPluginReturnThruPtr
|
||||
function[:args].each do |arg|
|
||||
next unless @utils.ptr_or_str?(arg[:type]) && !(arg[:const?])
|
||||
|
||||
lines << " int ReturnThruPtr_#{arg[:name]}_Used;\n"
|
||||
lines << " char ReturnThruPtr_#{arg[:name]}_Used;\n"
|
||||
lines << " #{arg[:type]} ReturnThruPtr_#{arg[:name]}_Val;\n"
|
||||
lines << " int ReturnThruPtr_#{arg[:name]}_Size;\n"
|
||||
end
|
||||
|
||||
@@ -52,11 +52,11 @@ class CMockGeneratorUtils
|
||||
lines << " UNITY_TEST_ASSERT_NOT_NULL(cmock_call_instance, cmock_line, CMockStringOutOfMemory);\n"
|
||||
lines << " memset(cmock_call_instance, 0, sizeof(*cmock_call_instance));\n"
|
||||
lines << " Mock.#{func_name}_CallInstance = CMock_Guts_MemChain(Mock.#{func_name}_CallInstance, cmock_guts_index);\n"
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (int)0;\n" if @ignore
|
||||
lines << " Mock.#{func_name}_IgnoreBool = (char)0;\n" if @ignore
|
||||
lines << " cmock_call_instance->LineNumber = cmock_line;\n"
|
||||
lines << " cmock_call_instance->CallOrder = ++GlobalExpectCount;\n" if @ordered && global_ordering_supported
|
||||
lines << " cmock_call_instance->ExceptionToThrow = CEXCEPTION_NONE;\n" if @cexception
|
||||
lines << " cmock_call_instance->ExpectAnyArgsBool = (int)0;\n" if @expect_any
|
||||
lines << " cmock_call_instance->ExpectAnyArgsBool = (char)0;\n" if @expect_any
|
||||
lines
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user