| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
class CMockGeneratorPluginCexception |
| 8 |
attr_reader :priority |
| 9 |
attr_reader :config, :utils |
| 10 |
|
| 11 |
def initialize(config, utils) |
| 12 |
@config = config |
| 13 |
@utils = utils |
| 14 |
@priority = 7 |
| 15 |
raise 'Error: cexception is not supported without setjmp support' if @config.exclude_setjmp_h |
| 16 |
end |
| 17 |
|
| 18 |
def include_files |
| 19 |
"#include \"CException.h\"\n" |
| 20 |
end |
| 21 |
|
| 22 |
def instance_typedefs(_function) |
| 23 |
" CEXCEPTION_T ExceptionToThrow;\n" |
| 24 |
end |
| 25 |
|
| 26 |
def mock_function_declarations(function) |
| 27 |
if function[:args_string] == 'void' |
| 28 |
"#define #{function[:name]}_ExpectAndThrow(cmock_to_throw) #{function[:name]}_CMockExpectAndThrow(__LINE__, cmock_to_throw)\n" \ |
| 29 |
"void #{function[:name]}_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, CEXCEPTION_T cmock_to_throw);\n" |
| 30 |
else |
| 31 |
"#define #{function[:name]}_ExpectAndThrow(#{function[:args_call]}, cmock_to_throw) #{function[:name]}_CMockExpectAndThrow(__LINE__, #{function[:args_call]}, cmock_to_throw)\n" \ |
| 32 |
"void #{function[:name]}_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, #{function[:args_string]}, CEXCEPTION_T cmock_to_throw);\n" |
| 33 |
end |
| 34 |
end |
| 35 |
|
| 36 |
def mock_implementation(_function) |
| 37 |
" if (cmock_call_instance->ExceptionToThrow != CEXCEPTION_NONE)\n {\n" \ |
| 38 |
" UNITY_CLR_DETAILS();\n" \ |
| 39 |
" Throw(cmock_call_instance->ExceptionToThrow);\n }\n" |
| 40 |
end |
| 41 |
|
| 42 |
def mock_interfaces(function) |
| 43 |
arg_insert = function[:args_string] == 'void' ? '' : "#{function[:args_string]}, " |
| 44 |
["void #{function[:name]}_CMockExpectAndThrow(UNITY_LINE_TYPE cmock_line, #{arg_insert}CEXCEPTION_T cmock_to_throw)\n{\n", |
| 45 |
@utils.code_add_base_expectation(function[:name]), |
| 46 |
@utils.code_call_argument_loader(function), |
| 47 |
" cmock_call_instance->ExceptionToThrow = cmock_to_throw;\n", |
| 48 |
"}\n\n"].join |
| 49 |
end |
| 50 |
end |