ceedling 0.19.0 → 0.20.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +10 -10
- data/bin/ceedling +205 -92
- data/ceedling-0.19.0.gem +0 -0
- data/config/test_environment.rb +12 -12
- data/docs/CeedlingPacket.md +866 -853
- data/docs/CeedlingPacket.odt +0 -0
- data/docs/CeedlingPacket.pdf +0 -0
- data/examples/temp_sensor/rakefile.rb +4 -4
- data/examples/temp_sensor/src/AdcConductor.c +42 -42
- data/examples/temp_sensor/src/AdcConductor.h +13 -13
- data/examples/temp_sensor/src/AdcHardware.c +27 -27
- data/examples/temp_sensor/src/AdcHardware.h +11 -11
- data/examples/temp_sensor/src/AdcHardwareConfigurator.c +18 -18
- data/examples/temp_sensor/src/AdcHardwareConfigurator.h +10 -10
- data/examples/temp_sensor/src/AdcModel.c +33 -33
- data/examples/temp_sensor/src/AdcModel.h +13 -13
- data/examples/temp_sensor/src/AdcTemperatureSensor.c +51 -51
- data/examples/temp_sensor/src/AdcTemperatureSensor.h +10 -10
- data/examples/temp_sensor/src/Executor.c +25 -25
- data/examples/temp_sensor/src/Executor.h +9 -9
- data/examples/temp_sensor/src/IntrinsicsWrapper.c +18 -18
- data/examples/temp_sensor/src/IntrinsicsWrapper.h +7 -7
- data/examples/temp_sensor/src/Main.c +46 -46
- data/examples/temp_sensor/src/Main.h +7 -7
- data/examples/temp_sensor/src/Model.c +10 -10
- data/examples/temp_sensor/src/Model.h +8 -8
- data/examples/temp_sensor/src/ModelConfig.h +7 -7
- data/examples/temp_sensor/src/TaskScheduler.c +72 -72
- data/examples/temp_sensor/src/TaskScheduler.h +11 -11
- data/examples/temp_sensor/src/TemperatureCalculator.c +27 -27
- data/examples/temp_sensor/src/TemperatureCalculator.h +8 -8
- data/examples/temp_sensor/src/TemperatureFilter.c +38 -38
- data/examples/temp_sensor/src/TemperatureFilter.h +10 -10
- data/examples/temp_sensor/src/TimerConductor.c +15 -15
- data/examples/temp_sensor/src/TimerConductor.h +9 -9
- data/examples/temp_sensor/src/TimerConfigurator.c +51 -51
- data/examples/temp_sensor/src/TimerConfigurator.h +15 -15
- data/examples/temp_sensor/src/TimerHardware.c +15 -15
- data/examples/temp_sensor/src/TimerHardware.h +8 -8
- data/examples/temp_sensor/src/TimerInterruptConfigurator.c +55 -55
- data/examples/temp_sensor/src/TimerInterruptConfigurator.h +13 -13
- data/examples/temp_sensor/src/TimerInterruptHandler.c +25 -25
- data/examples/temp_sensor/src/TimerInterruptHandler.h +10 -10
- data/examples/temp_sensor/src/TimerModel.c +9 -9
- data/examples/temp_sensor/src/TimerModel.h +8 -8
- data/examples/temp_sensor/src/Types.h +90 -90
- data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.c +18 -18
- data/examples/temp_sensor/src/UsartBaudRateRegisterCalculator.h +8 -8
- data/examples/temp_sensor/src/UsartConductor.c +21 -21
- data/examples/temp_sensor/src/UsartConductor.h +7 -7
- data/examples/temp_sensor/src/UsartConfigurator.c +39 -39
- data/examples/temp_sensor/src/UsartConfigurator.h +13 -13
- data/examples/temp_sensor/src/UsartHardware.c +22 -22
- data/examples/temp_sensor/src/UsartHardware.h +9 -9
- data/examples/temp_sensor/src/UsartModel.c +34 -34
- data/examples/temp_sensor/src/UsartModel.h +10 -10
- data/examples/temp_sensor/src/UsartPutChar.c +16 -16
- data/examples/temp_sensor/src/UsartPutChar.h +8 -8
- data/examples/temp_sensor/src/UsartTransmitBufferStatus.c +7 -7
- data/examples/temp_sensor/src/UsartTransmitBufferStatus.h +8 -8
- data/examples/temp_sensor/test/TestAdcConductor.c +121 -121
- data/examples/temp_sensor/test/TestAdcHardware.c +44 -44
- data/examples/temp_sensor/test/TestAdcModel.c +33 -33
- data/examples/temp_sensor/test/TestExecutor.c +36 -36
- data/examples/temp_sensor/test/TestMain.c +24 -24
- data/examples/temp_sensor/test/TestModel.c +20 -20
- data/examples/temp_sensor/test/TestTaskScheduler.c +104 -104
- data/examples/temp_sensor/test/TestTemperatureCalculator.c +33 -33
- data/examples/temp_sensor/test/TestTemperatureFilter.c +79 -79
- data/examples/temp_sensor/test/TestTimerConductor.c +32 -32
- data/examples/temp_sensor/test/TestTimerHardware.c +26 -26
- data/examples/temp_sensor/test/TestTimerModel.c +18 -18
- data/examples/temp_sensor/test/TestUsartBaudRateRegisterCalculator.c +21 -21
- data/examples/temp_sensor/test/TestUsartConductor.c +40 -40
- data/examples/temp_sensor/test/TestUsartHardware.c +36 -36
- data/examples/temp_sensor/test/TestUsartModel.c +36 -36
- data/examples/temp_sensor/test/support/UnityHelper.c +12 -12
- data/examples/temp_sensor/test/support/UnityHelper.h +12 -12
- data/lib/ceedling/configurator_builder.rb +1 -1
- data/lib/ceedling/tasks_base.rake +10 -2
- data/lib/ceedling/tool_executor.rb +3 -0
- data/lib/ceedling/version.rb +3 -3
- data/license.txt +1 -1
- data/plugins/bullseye/bullseye.rake +162 -162
- data/plugins/gcov/gcov.rake +152 -152
- data/plugins/module_generator/lib/module_generator.rb +145 -145
- data/plugins/module_generator/module_generator.rake +14 -14
- data/plugins/stdout_gtestlike_tests_report/assets/template.erb +84 -0
- data/plugins/stdout_gtestlike_tests_report/assets/template.erb copy +59 -0
- data/plugins/stdout_gtestlike_tests_report/config/stdout_gtestlike_tests_report.yml +4 -0
- data/plugins/stdout_gtestlike_tests_report/lib/stdout_gtestlike_tests_report.rb +43 -0
- data/spec/system/deployment_spec.rb +0 -1
- data/test_graveyard/integration/paths_test.rb +80 -80
- data/test_graveyard/integration/rake_rules_aux_dependencies_test.rb +75 -75
- data/test_graveyard/integration/rake_rules_cmock_test.rb +74 -74
- data/test_graveyard/integration/rake_rules_preprocess_test.rb +178 -178
- data/test_graveyard/integration/rake_rules_test.rb +268 -268
- data/test_graveyard/integration/rake_tasks_test.rb +103 -103
- data/test_graveyard/integration_test_helper.rb +34 -34
- data/test_graveyard/rakefile_rules.rb +10 -10
- data/test_graveyard/rakefile_rules_aux_dependencies.rb +10 -10
- data/test_graveyard/rakefile_rules_cmock.rb +10 -10
- data/test_graveyard/rakefile_rules_preprocess.rb +10 -10
- data/test_graveyard/rakefile_tasks.rb +10 -10
- data/test_graveyard/system/file_system_test.rb +78 -78
- data/test_graveyard/system/project_mocks_test.rb +38 -38
- data/test_graveyard/system/project_simple_test.rb +39 -39
- data/test_graveyard/system/rule_mocks_test.rb +44 -44
- data/test_graveyard/system/rule_runners_test.rb +44 -44
- data/test_graveyard/system_test_helper.rb +73 -73
- data/test_graveyard/test_helper.rb +93 -93
- data/test_graveyard/unit/busted/configurator_builder_test.rb +569 -569
- data/test_graveyard/unit/busted/configurator_helper_test.rb +234 -234
- data/test_graveyard/unit/busted/configurator_test.rb +232 -232
- data/test_graveyard/unit/busted/configurator_validator_test.rb +169 -169
- data/test_graveyard/unit/busted/deep_merge_fix_test.rb +55 -55
- data/test_graveyard/unit/busted/dependinator_test.rb +129 -129
- data/test_graveyard/unit/busted/file_finder_helper_test.rb +45 -45
- data/test_graveyard/unit/busted/file_finder_test.rb +114 -114
- data/test_graveyard/unit/busted/file_path_utils_test.rb +97 -97
- data/test_graveyard/unit/busted/file_system_utils_test.rb +21 -21
- data/test_graveyard/unit/busted/generator_test.rb +187 -187
- data/test_graveyard/unit/busted/generator_test_results_test.rb +129 -129
- data/test_graveyard/unit/busted/generator_test_runner_test.rb +475 -475
- data/test_graveyard/unit/busted/preprocessinator_file_handler_test.rb +39 -39
- data/test_graveyard/unit/busted/preprocessinator_helper_test.rb +156 -156
- data/test_graveyard/unit/busted/preprocessinator_includes_handler_test.rb +93 -93
- data/test_graveyard/unit/busted/preprocessinator_test.rb +57 -57
- data/test_graveyard/unit/busted/project_file_loader_test.rb +142 -142
- data/test_graveyard/unit/busted/setupinator_test.rb +45 -45
- data/test_graveyard/unit/busted/streaminator_test.rb +49 -49
- data/test_graveyard/unit/busted/task_invoker_test.rb +69 -69
- data/test_graveyard/unit/busted/test_includes_extractor_test.rb +111 -111
- data/test_graveyard/unit/busted/test_invoker_helper_test.rb +62 -62
- data/test_graveyard/unit/busted/test_invoker_test.rb +47 -47
- data/test_graveyard/unit/busted/tool_executor_helper_test.rb +100 -100
- data/test_graveyard/unit/busted/tool_executor_test.rb +351 -351
- data/test_graveyard/unit/busted/verbosinator_test.rb +65 -65
- data/test_graveyard/unit/preprocessinator_extractor_test.rb +731 -731
- data/test_graveyard/unit_test_helper.rb +16 -16
- data/vendor/c_exception/LICENSE.txt +30 -30
- data/vendor/c_exception/README.md +11 -1
- data/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
- data/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
- data/vendor/c_exception/docs/readme.txt +261 -242
- data/vendor/c_exception/lib/CException.c +46 -46
- data/vendor/c_exception/lib/CException.h +110 -86
- data/vendor/c_exception/makefile +23 -23
- data/vendor/c_exception/test/CExceptionConfig.h +46 -46
- data/vendor/c_exception/test/TestException.c +391 -342
- data/vendor/c_exception/test/TestException_Runner.c +5 -12
- data/vendor/c_exception/vendor/unity/README.md +211 -0
- data/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +1 -1
- data/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +38 -38
- data/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -36
- data/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -202
- data/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +391 -320
- data/vendor/c_exception/vendor/unity/auto/parseOutput.rb +2 -0
- data/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +260 -0
- data/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +8 -0
- data/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +135 -0
- data/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +148 -139
- data/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +224 -216
- data/vendor/c_exception/vendor/unity/docs/license.txt +21 -31
- data/vendor/c_exception/vendor/unity/examples/example_1/makefile +40 -15
- data/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
- data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +32 -25
- data/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +29 -22
- data/vendor/c_exception/vendor/unity/examples/example_2/makefile +40 -14
- data/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
- data/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
- data/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +0 -1
- data/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +48 -37
- data/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +179 -179
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +135 -94
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +13 -17
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -18
- data/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +30 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +60 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +4 -3
- data/vendor/c_exception/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +182 -27
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +13 -0
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +8 -6
- data/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
- data/vendor/c_exception/vendor/unity/release/build.info +1 -1
- data/vendor/c_exception/vendor/unity/release/version.info +1 -1
- data/vendor/c_exception/vendor/unity/src/unity.c +1333 -1145
- data/vendor/c_exception/vendor/unity/src/unity.h +290 -307
- data/vendor/c_exception/vendor/unity/src/unity_internals.h +758 -620
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +7 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +7 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -0
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -0
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +4 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +4 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -0
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +4 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +4 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +4 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -6
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +9 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +7 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +7 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +9 -5
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +7 -3
- data/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +10 -6
- data/vendor/c_exception/vendor/unity/{rakefile.rb → test/rakefile} +60 -61
- data/vendor/c_exception/vendor/unity/{rakefile_helper.rb → test/rakefile_helper.rb} +255 -249
- data/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +83 -0
- data/vendor/c_exception/vendor/unity/{targets → test/targets}/clang_strict.yml +83 -83
- data/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -0
- data/vendor/c_exception/vendor/unity/{targets/gcc_64.yml → test/targets/gcc_auto_limits.yml} +46 -45
- data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +47 -0
- data/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +58 -0
- data/vendor/{cmock/vendor/c_exception/vendor/unity/targets/gcc_64.yml → c_exception/vendor/unity/test/targets/gcc_manual_math.yml} +46 -45
- data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/hitech_picc18.yml +101 -101
- data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_arm_v4.yml +89 -89
- data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_arm_v5.yml +79 -79
- data/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_arm_v5_3.yml +79 -79
- data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -93
- data/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_cortexm3_v5.yml +83 -83
- data/vendor/{cmock/vendor/c_exception/vendor/unity → c_exception/vendor/unity/test}/targets/iar_msp430.yml +94 -94
- data/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_sh2a_v6.yml +85 -85
- data/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +51 -51
- data/vendor/c_exception/vendor/unity/test/testdata/sample.yml +8 -8
- data/vendor/c_exception/vendor/unity/test/testdata/testsample.c +68 -51
- data/vendor/{cmock/vendor/c_exception/vendor/unity/test → c_exception/vendor/unity/test/tests}/test_generate_test_runner.rb +102 -88
- data/vendor/{cmock/vendor/c_exception/vendor/unity/test → c_exception/vendor/unity/test/tests}/testparameterized.c +104 -101
- data/vendor/c_exception/vendor/unity/test/{testunity.c → tests/testunity.c} +3682 -3447
- data/vendor/cmock/docs/CMock_Summary.md +3 -0
- data/vendor/cmock/lib/cmock_config.rb +1 -0
- data/vendor/cmock/lib/cmock_file_writer.rb +7 -3
- data/vendor/cmock/lib/cmock_generator.rb +3 -2
- data/vendor/cmock/lib/cmock_header_parser.rb +12 -5
- data/vendor/cmock/release/version.info +1 -1
- data/vendor/cmock/test/system/test_compilation/parsing.h +3 -0
- data/vendor/cmock/test/unit/cmock_generator_main_test.rb +7 -0
- data/vendor/cmock/test/unit/cmock_header_parser_test.rb +57 -1
- data/vendor/cmock/vendor/c_exception/LICENSE.txt +30 -30
- data/vendor/cmock/vendor/c_exception/README.md +11 -1
- data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.odt +0 -0
- data/vendor/cmock/vendor/c_exception/docs/CExceptionSummary.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/docs/readme.txt +261 -242
- data/vendor/cmock/vendor/c_exception/lib/CException.c +46 -46
- data/vendor/cmock/vendor/c_exception/lib/CException.h +110 -86
- data/vendor/cmock/vendor/c_exception/makefile +23 -23
- data/vendor/cmock/vendor/c_exception/test/CExceptionConfig.h +46 -46
- data/vendor/cmock/vendor/c_exception/test/TestException.c +391 -342
- data/vendor/cmock/vendor/c_exception/test/TestException_Runner.c +5 -12
- data/vendor/cmock/vendor/c_exception/vendor/unity/README.md +211 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_prompt.rb +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/colour_reporter.rb +38 -38
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_config.yml +36 -36
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_module.rb +202 -202
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/generate_test_runner.rb +391 -320
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/parseOutput.rb +2 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/stylize_as_junit.rb +260 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/type_sanitizer.rb +8 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.py +135 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/auto/unity_test_summary.rb +148 -139
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/Unity Summary.txt +224 -216
- data/vendor/cmock/vendor/c_exception/vendor/unity/docs/license.txt +21 -31
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/makefile +40 -15
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/src/ProductionCode2.c +2 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode2_Runner.c +32 -25
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_1/test/test_runners/TestProductionCode_Runner.c +29 -22
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/makefile +40 -14
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/src/ProductionCode2.c +2 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_2/test/test_runners/all_tests.c +2 -2
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/rakefile.rb +0 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/src/ProductionCode2.c +2 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile.rb +48 -37
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/rakefile_helper.rb +179 -179
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.c +135 -94
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture.h +13 -17
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -18
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +30 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/Makefile +60 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/main/AllTests.c +4 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_Test.c +182 -27
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +13 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.c +8 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/extras/fixture/test/unity_output_Spy.h +2 -2
- data/vendor/cmock/vendor/c_exception/vendor/unity/release/build.info +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/release/version.info +1 -1
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.c +1333 -1145
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity.h +290 -307
- data/vendor/cmock/vendor/c_exception/vendor/unity/src/unity_internals.h +758 -620
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_cmd.c +7 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_def.c +7 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.c +55 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_head1.h +15 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_cmd.c +4 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_def.c +4 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.c +75 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_head1.h +13 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new1.c +6 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_new2.c +4 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_param.c +4 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run1.c +6 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_run2.c +4 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_mock_yaml.c +7 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new1.c +9 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_new2.c +7 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_param.c +7 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run1.c +9 -5
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_run2.c +7 -3
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/expectdata/testsample_yaml.c +10 -6
- data/vendor/cmock/vendor/c_exception/vendor/unity/{rakefile.rb → test/rakefile} +60 -61
- data/vendor/cmock/vendor/c_exception/vendor/unity/{rakefile_helper.rb → test/rakefile_helper.rb} +255 -249
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/clang_file.yml +83 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/clang_strict.yml +83 -83
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_32.yml +49 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_64.yml +50 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/{targets/gcc_32.yml → test/targets/gcc_auto_limits.yml} +46 -44
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_sizeof.yml +47 -0
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/targets/gcc_auto_stdint.yml +58 -0
- data/vendor/{c_exception/vendor/unity/targets/gcc_32.yml → cmock/vendor/c_exception/vendor/unity/test/targets/gcc_manual_math.yml} +46 -44
- data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/hitech_picc18.yml +101 -101
- data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_arm_v4.yml +89 -89
- data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_arm_v5.yml +79 -79
- data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_arm_v5_3.yml +79 -79
- data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_armcortex_LM3S9B92_v5_4.yml +93 -93
- data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_cortexm3_v5.yml +83 -83
- data/vendor/{c_exception/vendor/unity → cmock/vendor/c_exception/vendor/unity/test}/targets/iar_msp430.yml +94 -94
- data/vendor/cmock/vendor/c_exception/vendor/unity/{targets → test/targets}/iar_sh2a_v6.yml +85 -85
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/mocksample.c +51 -51
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/sample.yml +8 -8
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/testdata/testsample.c +68 -51
- data/vendor/{c_exception/vendor/unity/test → cmock/vendor/c_exception/vendor/unity/test/tests}/test_generate_test_runner.rb +102 -88
- data/vendor/{c_exception/vendor/unity/test → cmock/vendor/c_exception/vendor/unity/test/tests}/testparameterized.c +104 -101
- data/vendor/cmock/vendor/c_exception/vendor/unity/test/{testunity.c → tests/testunity.c} +3682 -3447
- data/vendor/cmock/vendor/unity/auto/generate_test_runner.rb +30 -13
- data/vendor/cmock/vendor/unity/auto/stylize_as_junit.rb +260 -0
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.c +96 -93
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture.h +1 -1
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_internals.h +12 -19
- data/vendor/cmock/vendor/unity/extras/fixture/src/unity_fixture_malloc_overrides.h +18 -17
- data/vendor/cmock/vendor/unity/extras/fixture/test/Makefile +66 -5
- data/vendor/cmock/vendor/unity/extras/fixture/test/main/AllTests.c +2 -1
- data/vendor/cmock/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_Test.c +187 -27
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +14 -0
- data/vendor/cmock/vendor/unity/extras/fixture/test/unity_output_Spy.c +6 -5
- data/vendor/cmock/vendor/unity/release/version.info +1 -1
- data/vendor/cmock/vendor/unity/src/unity.c +38 -27
- data/vendor/cmock/vendor/unity/src/unity.h +5 -0
- data/vendor/cmock/vendor/unity/src/unity_internals.h +22 -18
- data/vendor/cmock/vendor/unity/test/Makefile +52 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_cmd.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_def.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_head1.h +7 -4
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_mock_head1.h +6 -4
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_new1.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_new2.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_param.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_run1.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_run2.c +4 -0
- data/vendor/cmock/vendor/unity/test/expectdata/testsample_yaml.c +4 -0
- data/vendor/cmock/vendor/unity/test/rakefile_helper.rb +1 -1
- data/vendor/cmock/vendor/unity/test/targets/clang_file.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/clang_strict.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_32.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_64.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_limits.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_sizeof.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_auto_stdint.yml +0 -1
- data/vendor/cmock/vendor/unity/test/targets/gcc_manual_math.yml +0 -1
- data/vendor/cmock/vendor/unity/test/testdata/testsample.c +19 -2
- data/vendor/cmock/vendor/unity/test/tests/testunity.c +55 -4
- data/vendor/unity/auto/generate_test_runner.rb +4 -2
- data/vendor/unity/auto/stylize_as_junit.rb +260 -0
- data/vendor/unity/extras/fixture/src/unity_fixture.c +24 -41
- data/vendor/unity/extras/fixture/src/unity_fixture.h +1 -1
- data/vendor/unity/extras/fixture/src/unity_fixture_internals.h +5 -7
- data/vendor/unity/extras/fixture/test/Makefile +53 -8
- data/vendor/unity/extras/fixture/test/{testunity_fixture.c → template_fixture_tests.c} +0 -0
- data/vendor/unity/extras/fixture/test/unity_fixture_Test.c +129 -32
- data/vendor/unity/extras/fixture/test/unity_fixture_TestRunner.c +6 -0
- data/vendor/unity/extras/fixture/test/unity_output_Spy.c +4 -4
- data/vendor/unity/release/version.info +1 -1
- data/vendor/unity/src/unity.c +32 -21
- data/vendor/unity/src/unity.h +5 -0
- data/vendor/unity/src/unity_internals.h +7 -3
- data/vendor/unity/test/Makefile +52 -0
- data/vendor/unity/test/expectdata/testsample_cmd.c +4 -0
- data/vendor/unity/test/expectdata/testsample_def.c +4 -0
- data/vendor/unity/test/expectdata/testsample_head1.c +4 -0
- data/vendor/unity/test/expectdata/testsample_head1.h +7 -4
- data/vendor/unity/test/expectdata/testsample_mock_head1.h +6 -4
- data/vendor/unity/test/expectdata/testsample_new1.c +4 -0
- data/vendor/unity/test/expectdata/testsample_new2.c +4 -0
- data/vendor/unity/test/expectdata/testsample_param.c +4 -0
- data/vendor/unity/test/expectdata/testsample_run1.c +4 -0
- data/vendor/unity/test/expectdata/testsample_run2.c +4 -0
- data/vendor/unity/test/expectdata/testsample_yaml.c +4 -0
- data/vendor/unity/test/testdata/testsample.c +19 -2
- data/vendor/unity/test/tests/testunity.c +35 -4
- metadata +75 -52
- data/ceedling-0.18.0.gem +0 -0
- data/docs/CeedlingLogo.png +0 -0
- data/vendor/c_exception/vendor/unity/Gemfile +0 -4
- data/vendor/c_exception/vendor/unity/Gemfile.lock +0 -12
- data/vendor/c_exception/vendor/unity/examples/example_3/makefile +0 -41
- data/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -46
- data/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -50
- data/vendor/c_exception/vendor/unity/makefile +0 -37
- data/vendor/cmock/vendor/c_exception/vendor/unity/Gemfile +0 -4
- data/vendor/cmock/vendor/c_exception/vendor/unity/Gemfile.lock +0 -12
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/makefile +0 -41
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode2_Runner.c +0 -46
- data/vendor/cmock/vendor/c_exception/vendor/unity/examples/example_3/test/no_ruby/TestProductionCode_Runner.c +0 -50
- data/vendor/cmock/vendor/c_exception/vendor/unity/makefile +0 -37
@@ -284,6 +284,9 @@ Defined in the yaml file, they look more like this:
|
|
284
284
|
The prefix to append to your mock files. Defaults to “Mock”, so a file
|
285
285
|
“USART.h” will get a mock called “MockUSART.c”
|
286
286
|
|
287
|
+
* `:mock_suffix`:
|
288
|
+
The suffix to append to your mock files. Defaults to “”.
|
289
|
+
|
287
290
|
* `:subdir`:
|
288
291
|
Relative subdir for your mocks. Set this to e.g. "sys" in order to
|
289
292
|
create mock for `sys/types.h` in `:mock_path`/sys/
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# CMock Project - Automatic Mock Generation for C
|
3
3
|
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
4
|
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
-
# ==========================================
|
5
|
+
# ==========================================
|
6
6
|
|
7
7
|
class CMockFileWriter
|
8
8
|
|
@@ -13,6 +13,10 @@ class CMockFileWriter
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def create_subdir(subdir)
|
16
|
+
if !Dir.exists?("#{@config.mock_path}/")
|
17
|
+
require 'fileutils'
|
18
|
+
FileUtils.mkdir_p "#{@config.mock_path}/"
|
19
|
+
end
|
16
20
|
if subdir && !Dir.exists?("#{@config.mock_path}/#{subdir+'/' if subdir}")
|
17
21
|
require 'fileutils'
|
18
22
|
FileUtils.mkdir_p "#{@config.mock_path}/#{subdir+'/' if subdir}"
|
@@ -28,9 +32,9 @@ class CMockFileWriter
|
|
28
32
|
end
|
29
33
|
update_file(full_file_name_done, full_file_name_temp)
|
30
34
|
end
|
31
|
-
|
35
|
+
|
32
36
|
private ###################################
|
33
|
-
|
37
|
+
|
34
38
|
def update_file(dest, src)
|
35
39
|
require 'fileutils'
|
36
40
|
FileUtils.rm(dest) if (File.exist?(dest))
|
@@ -14,6 +14,7 @@ class CMockGenerator
|
|
14
14
|
@plugins = plugins
|
15
15
|
@config = config
|
16
16
|
@prefix = @config.mock_prefix
|
17
|
+
@suffix = @config.mock_suffix
|
17
18
|
@ordered = @config.enforce_strict_ordering
|
18
19
|
@framework = @config.framework.to_s
|
19
20
|
|
@@ -39,7 +40,7 @@ class CMockGenerator
|
|
39
40
|
|
40
41
|
def create_mock(module_name, parsed_stuff)
|
41
42
|
@module_name = module_name
|
42
|
-
@mock_name = @prefix + @module_name
|
43
|
+
@mock_name = @prefix + @module_name + @suffix
|
43
44
|
@clean_mock_name = TypeSanitizer.sanitize_c_identifier(@mock_name)
|
44
45
|
create_mock_subdir()
|
45
46
|
create_mock_header_file(parsed_stuff)
|
@@ -83,7 +84,7 @@ class CMockGenerator
|
|
83
84
|
|
84
85
|
def create_mock_header_header(file, filename)
|
85
86
|
define_name = @clean_mock_name.upcase
|
86
|
-
orig_filename = (@subdir ? @subdir + "/" : "") +
|
87
|
+
orig_filename = (@subdir ? @subdir + "/" : "") + @module_name + ".h"
|
87
88
|
file << "/* AUTOGENERATED FILE. DO NOT EDIT. */\n"
|
88
89
|
file << "#ifndef _#{define_name}_H\n"
|
89
90
|
file << "#define _#{define_name}_H\n\n"
|
@@ -74,7 +74,7 @@ class CMockHeaderParser
|
|
74
74
|
|
75
75
|
# remove preprocessor statements and extern "C"
|
76
76
|
source.gsub!(/^\s*#.*/, '')
|
77
|
-
source.gsub!(/extern\s+\"C\"\s
|
77
|
+
source.gsub!(/extern\s+\"C\"\s*\{/, '')
|
78
78
|
|
79
79
|
# enums, unions, structs, and typedefs can all contain things (e.g. function pointers) that parse like function prototypes, so yank them
|
80
80
|
# forward declared structs are removed before struct definitions so they don't mess up real thing later. we leave structs keywords in function prototypes
|
@@ -93,12 +93,13 @@ class CMockHeaderParser
|
|
93
93
|
"#{functype} #{$2.strip}(#{$3});"
|
94
94
|
end
|
95
95
|
|
96
|
+
# remove nested pairs of braces because no function declarations will be inside of them (leave outer pair for function definition detection)
|
97
|
+
while source.gsub!(/\{[^\{\}]*\{[^\{\}]*\}[^\{\}]*\}/m, '{ }')
|
98
|
+
end
|
99
|
+
|
96
100
|
# remove function definitions by stripping off the arguments right now
|
97
101
|
source.gsub!(/\([^\)]*\)\s*\{[^\}]*\}/m, ";")
|
98
102
|
|
99
|
-
# remove pairs of braces because no function declarations will be inside of them
|
100
|
-
#source.gsub!(/\{[^\}]*\}/m, '')
|
101
|
-
|
102
103
|
#drop extra white space to make the rest go faster
|
103
104
|
source.gsub!(/^\s+/, '') # remove extra white space from beginning of line
|
104
105
|
source.gsub!(/\s+$/, '') # remove extra white space from end of line
|
@@ -142,7 +143,7 @@ class CMockHeaderParser
|
|
142
143
|
args << { :type => (arg_type = arg_elements[0..-2].join(' ')),
|
143
144
|
:name => arg_elements[-1],
|
144
145
|
:ptr? => divine_ptr(arg_type),
|
145
|
-
:const? =>
|
146
|
+
:const? => divine_const(arg)
|
146
147
|
}
|
147
148
|
end
|
148
149
|
return args
|
@@ -154,6 +155,12 @@ class CMockHeaderParser
|
|
154
155
|
return true
|
155
156
|
end
|
156
157
|
|
158
|
+
def divine_const(arg)
|
159
|
+
return false if /const[ *]/.match(arg).nil? # check for const
|
160
|
+
return false if /\*/.match(arg) and /const[^*]*\*/.match(arg).nil? # check const comes before * indicating const data
|
161
|
+
return true
|
162
|
+
end
|
163
|
+
|
157
164
|
def clean_args(arg_list)
|
158
165
|
if ((@local_as_void.include?(arg_list.strip)) or (arg_list.empty?))
|
159
166
|
return 'void'
|
@@ -1,2 +1,2 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.2
|
2
2
|
|
@@ -7,6 +7,9 @@
|
|
7
7
|
typedef unsigned short U16;
|
8
8
|
typedef signed int int32_t;
|
9
9
|
|
10
|
+
/* CMock should handle UTF-8 characters in comments. The world is an awesomely diverse place! */
|
11
|
+
/* my µC Rocks! Open Source, not ©! My language has no Ümlauts! ǺƜǝƧǾɱɛ! */ /**! Illegal: åäö */
|
12
|
+
|
10
13
|
typedef struct _POINT_T
|
11
14
|
{
|
12
15
|
int x;
|
@@ -43,6 +43,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
43
43
|
|
44
44
|
#no strict handling
|
45
45
|
@config.expect :mock_prefix, "Mock"
|
46
|
+
@config.expect :mock_suffix, ""
|
46
47
|
@config.expect :enforce_strict_ordering, nil
|
47
48
|
@config.expect :framework, :unity
|
48
49
|
@config.expect :includes, ["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"]
|
@@ -58,6 +59,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
58
59
|
|
59
60
|
#strict handling
|
60
61
|
@config.expect :mock_prefix, "Mock"
|
62
|
+
@config.expect :mock_suffix, ""
|
61
63
|
@config.expect :enforce_strict_ordering, true
|
62
64
|
@config.expect :framework, :unity
|
63
65
|
@config.expect :includes, nil
|
@@ -77,6 +79,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
77
79
|
|
78
80
|
it "create the top of a header file with optional include files from config and include file from plugin" do
|
79
81
|
@config.expect :mock_prefix, "Mock"
|
82
|
+
@config.expect :mock_suffix, ""
|
80
83
|
orig_filename = "PoutPoutFish.h"
|
81
84
|
define_name = "MOCKPOUTPOUTFISH_H"
|
82
85
|
mock_name = "MockPoutPoutFish"
|
@@ -112,6 +115,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
112
115
|
it "handle dashes and spaces in the module name" do
|
113
116
|
#no strict handling
|
114
117
|
@config.expect :mock_prefix, "Mock"
|
118
|
+
@config.expect :mock_suffix, ""
|
115
119
|
@config.expect :enforce_strict_ordering, nil
|
116
120
|
@config.expect :framework, :unity
|
117
121
|
@config.expect :includes, ["ConfigRequiredHeader1.h","ConfigRequiredHeader2.h"]
|
@@ -125,6 +129,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
125
129
|
@cmock_generator2.clean_mock_name = "MockPout_Pout_Fish"
|
126
130
|
|
127
131
|
@config.expect :mock_prefix, "Mock"
|
132
|
+
@config.expect :mock_suffix, ""
|
128
133
|
orig_filename = "Pout-Pout Fish.h"
|
129
134
|
define_name = "MOCKPOUT_POUT_FISH_H"
|
130
135
|
mock_name = "MockPout_Pout_Fish"
|
@@ -159,6 +164,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
159
164
|
|
160
165
|
it "create the top of a header file with optional include files from config" do
|
161
166
|
@config.expect :mock_prefix, "Mock"
|
167
|
+
@config.expect :mock_suffix, ""
|
162
168
|
orig_filename = "PoutPoutFish.h"
|
163
169
|
define_name = "MOCKPOUTPOUTFISH_H"
|
164
170
|
mock_name = "MockPoutPoutFish"
|
@@ -192,6 +198,7 @@ describe CMockGenerator, "Verify CMockGenerator Module" do
|
|
192
198
|
|
193
199
|
it "create the top of a header file with include file from plugin" do
|
194
200
|
@config.expect :mock_prefix, "Mock"
|
201
|
+
@config.expect :mock_suffix, ""
|
195
202
|
orig_filename = "PoutPoutFish.h"
|
196
203
|
define_name = "MOCKPOUTPOUTFISH_H"
|
197
204
|
mock_name = "MockPoutPoutFish"
|
@@ -311,6 +311,34 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
311
311
|
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
312
312
|
end
|
313
313
|
|
314
|
+
it "remove function definitions with nested braces but keep function declarations" do
|
315
|
+
source =
|
316
|
+
"uint32 func_with_decl_a(unsigned int);\n" +
|
317
|
+
"uint32 func_with_decl_a(unsigned int a) {\n" +
|
318
|
+
" while (stuff) {\n" +
|
319
|
+
" not_a_definition1(void);\n" +
|
320
|
+
" }\n" +
|
321
|
+
" not_a_definition2(blah, bleh);\n" +
|
322
|
+
" return a;\n" +
|
323
|
+
"}\n" +
|
324
|
+
"uint32 func_with_decl_b(unsigned int);\n" +
|
325
|
+
"uint32 func_with_decl_b(unsigned int a)\n" +
|
326
|
+
"{\n" +
|
327
|
+
" bar((unsigned int) a);\n" +
|
328
|
+
" stripme(a);\n" +
|
329
|
+
"}\n"
|
330
|
+
|
331
|
+
expected =
|
332
|
+
[
|
333
|
+
"uint32 func_with_decl_a(unsigned int)",
|
334
|
+
"uint32 func_with_decl_a", #okay. it's not going to be interpretted as another function
|
335
|
+
"uint32 func_with_decl_b(unsigned int)",
|
336
|
+
"uint32 func_with_decl_b", #okay. it's not going to be interpretted as another function
|
337
|
+
]
|
338
|
+
|
339
|
+
assert_equal(expected, @parser.import_source(source).map!{|s|s.strip})
|
340
|
+
end
|
341
|
+
|
314
342
|
it "remove a fully defined inline function" do
|
315
343
|
source =
|
316
344
|
"inline void foo(unsigned int a) { oranges = a; }\n" +
|
@@ -359,6 +387,34 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
359
387
|
end
|
360
388
|
end
|
361
389
|
|
390
|
+
it "remove a fully defined inline function that contains nested braces" do
|
391
|
+
source =
|
392
|
+
"inline void bar(unsigned int a)\n" +
|
393
|
+
"{" +
|
394
|
+
" apples(bananas, grapes);\n" +
|
395
|
+
" if (bananas == a)\n" +
|
396
|
+
" {\n" +
|
397
|
+
" oranges(a);\n" +
|
398
|
+
" grapes = a;\n" +
|
399
|
+
" }\n" +
|
400
|
+
" grapefruit(bananas, grapes);\n" +
|
401
|
+
"}"
|
402
|
+
|
403
|
+
# ensure it's expected type of exception
|
404
|
+
assert_raises RuntimeError do
|
405
|
+
@parser.parse("module", source)
|
406
|
+
end
|
407
|
+
|
408
|
+
assert_equal([], @parser.funcs)
|
409
|
+
|
410
|
+
# verify exception message
|
411
|
+
begin
|
412
|
+
@parser.parse("module", source)
|
413
|
+
rescue RuntimeError => e
|
414
|
+
assert_equal("ERROR: No function prototypes found!", e.message)
|
415
|
+
end
|
416
|
+
end
|
417
|
+
|
362
418
|
it "remove just inline functions if externs to be included" do
|
363
419
|
source =
|
364
420
|
" extern uint32 foobar(unsigned int);\n" +
|
@@ -858,7 +914,7 @@ describe CMockHeaderParser, "Verify CMockHeaderParser Module" do
|
|
858
914
|
{:type=>"int", :name=>"int_param", :ptr? => false, :const? => false},
|
859
915
|
{:type=>"int", :name=>"integer", :ptr? => false, :const? => false},
|
860
916
|
{:type=>"char", :name=>"character", :ptr? => false, :const? => false},
|
861
|
-
{:type=>"int*", :name=>"constant", :ptr? => true, :const? =>
|
917
|
+
{:type=>"int*", :name=>"constant", :ptr? => true, :const? => false}
|
862
918
|
],
|
863
919
|
:args_string=>"const unsigned int const_param, int int_param, int integer, char character, int* const constant",
|
864
920
|
:args_call=>"const_param, int_param, integer, character, constant" }]
|
@@ -1,30 +1,30 @@
|
|
1
|
-
Copyright (c) 2007-2014 Mark VanderVoord
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person
|
4
|
-
obtaining a copy of this software and associated documentation
|
5
|
-
files (the "Software"), to deal in the Software without
|
6
|
-
restriction, including without limitation the rights to use,
|
7
|
-
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
-
copies of the Software, and to permit persons to whom the
|
9
|
-
Software is furnished to do so, subject to the following
|
10
|
-
conditions:
|
11
|
-
|
12
|
-
The above copyright notice and this permission notice shall be
|
13
|
-
included in all copies or substantial portions of the Software.
|
14
|
-
|
15
|
-
The end-user documentation included with the redistribution, if
|
16
|
-
any, must include the following acknowledgment: "This product
|
17
|
-
includes software developed for the CEXCeption Project, by Mark
|
18
|
-
VanderVoord and other contributors", in the same place and form
|
19
|
-
as other third-party acknowledgments. Alternately, this
|
20
|
-
acknowledgment may appear in the software itself, in the same
|
21
|
-
form and location as other such third-party acknowledgments.
|
22
|
-
|
23
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
25
|
-
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
27
|
-
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
28
|
-
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
29
|
-
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
30
|
-
OTHER DEALINGS IN THE SOFTWARE.
|
1
|
+
Copyright (c) 2007-2014 Mark VanderVoord
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person
|
4
|
+
obtaining a copy of this software and associated documentation
|
5
|
+
files (the "Software"), to deal in the Software without
|
6
|
+
restriction, including without limitation the rights to use,
|
7
|
+
copy, modify, merge, publish, distribute, sublicense, and/or sell
|
8
|
+
copies of the Software, and to permit persons to whom the
|
9
|
+
Software is furnished to do so, subject to the following
|
10
|
+
conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be
|
13
|
+
included in all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
The end-user documentation included with the redistribution, if
|
16
|
+
any, must include the following acknowledgment: "This product
|
17
|
+
includes software developed for the CEXCeption Project, by Mark
|
18
|
+
VanderVoord and other contributors", in the same place and form
|
19
|
+
as other third-party acknowledgments. Alternately, this
|
20
|
+
acknowledgment may appear in the software itself, in the same
|
21
|
+
form and location as other such third-party acknowledgments.
|
22
|
+
|
23
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
24
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
25
|
+
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
26
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
27
|
+
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
28
|
+
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
29
|
+
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
30
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
@@ -96,6 +96,9 @@ CException API
|
|
96
96
|
* `Throw(e)`
|
97
97
|
* `Throw` is the method used to throw an error. `Throw`s should only occur from within a protected (`Try`...`Catch`) block, though it may easily be nested many function calls deep without an impact on performance or functionality. `Throw` takes a single argument, which is an exception id which will be passed to `Catch` as the reason for the error. If you wish to _re-throw_ an error, this can be done by calling `Throw(e)` with the error code you just caught. It _IS_ valid to throw from a `Catch` block.
|
98
98
|
|
99
|
+
* `ExitTry()`
|
100
|
+
* `ExitTry` is a method used to immediately exit your current Try block but NOT treat this as an error. Don't run the Catch. Just start executing from after the Catch as if nothing had happened.
|
101
|
+
|
99
102
|
Configuration
|
100
103
|
=============
|
101
104
|
|
@@ -124,6 +127,13 @@ You have options for configuring the library, if the defaults aren't good enough
|
|
124
127
|
|
125
128
|
You may also want to include any header files which will commonly be needed by the rest of your application where it uses exception handling here. For example, OS header files or exception codes would be useful.
|
126
129
|
|
130
|
+
Finally, there are some hook macros which you can implement to inject your own target-specific code in particular places. It is a rare instance where you will need these, but they are here if you need them:
|
131
|
+
|
132
|
+
* `CEXCEPTION_HOOK_START_TRY` - called immediately before the Try block
|
133
|
+
* `CEXCEPTION_HOOK_HAPPY_TRY` - called immediately after the Try block if no exception was thrown
|
134
|
+
* `CEXCEPTION_HOOK_AFTER_TRY` - called immediately after the Try block OR before an exception is caught
|
135
|
+
* `CEXCEPTION_HOOK_START_CATCH` - called immediately before the catch
|
136
|
+
|
127
137
|
Testing
|
128
138
|
=======
|
129
139
|
|
@@ -138,7 +148,7 @@ License
|
|
138
148
|
=======
|
139
149
|
|
140
150
|
*This software is licensed under the MIT License:
|
141
|
-
Copyright (c) 2007-
|
151
|
+
Copyright (c) 2007-2016 Mark VanderVoord*
|
142
152
|
|
143
153
|
*Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
144
154
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.*
|
Binary file
|
Binary file
|
@@ -1,242 +1,261 @@
|
|
1
|
-
====================================================================
|
2
|
-
CException
|
3
|
-
====================================================================
|
4
|
-
|
5
|
-
CException is a basic exception framework for C, suitable for use in
|
6
|
-
embedded applications. It provides an exception framework similar in
|
7
|
-
use to C++, but with much less overhead.
|
8
|
-
|
9
|
-
CException uses C standard library functions setjmp and longjmp to
|
10
|
-
operate. As long as the target system has these two functions defined,
|
11
|
-
this library should be useable with very little configuration. It
|
12
|
-
even supports environments where multiple program flows are in use,
|
13
|
-
such as real-time operating systems.
|
14
|
-
|
15
|
-
There are about a gabillion exception frameworks using a similar
|
16
|
-
setjmp/longjmp method out there... and there will probably be more
|
17
|
-
in the future. Unfortunately, when we started our last embedded
|
18
|
-
project, all those that existed either (a) did not support multiple
|
19
|
-
tasks (therefore multiple stacks) or (b) were way more complex than
|
20
|
-
we really wanted. CException was born.
|
21
|
-
|
22
|
-
Why use CException?
|
23
|
-
|
24
|
-
0. It's ANSI C, and it beats passing error codes around.
|
25
|
-
|
26
|
-
1. You want something simple... CException throws a single id. You can
|
27
|
-
define those ID's to be whatever you like. You might even choose which
|
28
|
-
type that number is for your project. But that's as far as it goes.
|
29
|
-
We weren't interested in passing objects or structs or strings...
|
30
|
-
just simple error codes.
|
31
|
-
|
32
|
-
2. Performance... CException can be configured for single tasking or
|
33
|
-
multitasking. In single tasking, there is very little overhead past
|
34
|
-
the setjmp/longjmp calls (which are already fast). In multitasking,
|
35
|
-
your only additional overhead is the time it takes you to determine
|
36
|
-
a unique task id 0 - num_tasks.
|
37
|
-
|
38
|
-
For the latest version, go to http://cexception.sourceforge.net
|
39
|
-
|
40
|
-
--------------------------------------------------------------------
|
41
|
-
CONTENTS OF THIS DOCUMENT
|
42
|
-
--------------------------------------------------------------------
|
43
|
-
|
44
|
-
Usage
|
45
|
-
Limitations
|
46
|
-
API
|
47
|
-
Configuration
|
48
|
-
Testing
|
49
|
-
License
|
50
|
-
|
51
|
-
--------------------------------------------------------------------
|
52
|
-
Usage
|
53
|
-
--------------------------------------------------------------------
|
54
|
-
|
55
|
-
Code that is to be protected are wrapped in Try { } Catch { } blocks.
|
56
|
-
The code directly following the Try call is "protected", meaning that
|
57
|
-
if any Throws occur, program control is directly transferred to the
|
58
|
-
start of the Catch block.
|
59
|
-
|
60
|
-
A numerical exception ID is included with Throw, and is made accessible
|
61
|
-
from the Catch block.
|
62
|
-
|
63
|
-
Throws can occur from within function calls (nested as deeply as you
|
64
|
-
like) or directly from within the function itself.
|
65
|
-
|
66
|
-
--------------------------------------------------------------------
|
67
|
-
Limitations
|
68
|
-
--------------------------------------------------------------------
|
69
|
-
|
70
|
-
This library was made to be as fast as possible, and provide basic
|
71
|
-
exception handling. It is not a full-blown exception library. Because
|
72
|
-
of this, there are a few limitations that should be observed in order
|
73
|
-
to successfully utilize this library:
|
74
|
-
|
75
|
-
1. Do not directly "return" from within a Try block, nor "goto"
|
76
|
-
into or out of a Try block.
|
77
|
-
|
78
|
-
Why?
|
79
|
-
|
80
|
-
The "Try" macro allocates some local memory and alters a global
|
81
|
-
pointer. These are cleaned up at the top of the "Catch" macro.
|
82
|
-
Gotos and returns would bypass some of these steps, resulting in
|
83
|
-
memory leaks or unpredictable behavior.
|
84
|
-
|
85
|
-
2. If (a) you change local (stack) variables within your Try block,
|
86
|
-
AND (b) wish to make use of the updated values after an exception
|
87
|
-
is thrown, those variables should be made volatile. Note that this
|
88
|
-
is ONLY for locals and ONLY when you need access to them after a
|
89
|
-
throw.
|
90
|
-
|
91
|
-
Why?
|
92
|
-
|
93
|
-
Compilers optimize. There is no way to guarantee that the actual
|
94
|
-
memory location was updated and not just a register unless the
|
95
|
-
variable is marked volatile.
|
96
|
-
|
97
|
-
3. Memory which is malloc'd or new'd is not automatically released
|
98
|
-
when an error is thrown. This will sometimes be desirable, and
|
99
|
-
othertimes may not. It will be the responsibility of the Catch
|
100
|
-
block to perform this kind of cleanup.
|
101
|
-
|
102
|
-
Why?
|
103
|
-
|
104
|
-
There's just no easy way to track malloc'd memory, etc., without
|
105
|
-
replacing or wrapping malloc calls or something like that. This
|
106
|
-
is a light framework, so these options were not desirable.
|
107
|
-
|
108
|
-
--------------------------------------------------------------------
|
109
|
-
API
|
110
|
-
--------------------------------------------------------------------
|
111
|
-
|
112
|
-
Try
|
113
|
-
---
|
114
|
-
|
115
|
-
Try is a macro which starts a protected block. It MUST be followed by
|
116
|
-
a pair of braces or a single protected line (similar to an 'if'),
|
117
|
-
enclosing the data that is to be protected. It MUST be followed by a
|
118
|
-
Catch block (don't worry, you'll get compiler errors to let you know if
|
119
|
-
you mess any of that up).
|
120
|
-
|
121
|
-
Catch(e)
|
122
|
-
--------
|
123
|
-
|
124
|
-
Catch is a macro which ends the Try block and starts the error handling
|
125
|
-
block. The catch block is called if and only if an exception was thrown
|
126
|
-
while within the Try block. This error was thrown by a Throw call
|
127
|
-
somewhere within Try (or within a function called within Try, or a function
|
128
|
-
called by a function called within Try, etc).
|
129
|
-
|
130
|
-
The single parameter 'e' is filled with the error code which was thrown.
|
131
|
-
This can be used for reporting, conditional cleanup, etc. (or you can just
|
132
|
-
ignore it if you really want... people ignore return codes all the time,
|
133
|
-
right?). 'e' should be of type EXCEPTION_T;
|
134
|
-
|
135
|
-
Throw(e)
|
136
|
-
--------
|
137
|
-
|
138
|
-
The method of throwing an error. Throws should only occur from within a
|
139
|
-
protected (Try...Catch) block, though it may easily be nested many function
|
140
|
-
calls deep without an impact on performance or functionality. Throw takes
|
141
|
-
a single argument, which is an exception id which will be passed to Catch
|
142
|
-
as the reason for the error.
|
143
|
-
|
144
|
-
If you wish to Rethrow an error, this can be done by calling Throw(e) with
|
145
|
-
the error code you just caught. It IS valid to throw from a catch block.
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
to
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
1
|
+
====================================================================
|
2
|
+
CException
|
3
|
+
====================================================================
|
4
|
+
|
5
|
+
CException is a basic exception framework for C, suitable for use in
|
6
|
+
embedded applications. It provides an exception framework similar in
|
7
|
+
use to C++, but with much less overhead.
|
8
|
+
|
9
|
+
CException uses C standard library functions setjmp and longjmp to
|
10
|
+
operate. As long as the target system has these two functions defined,
|
11
|
+
this library should be useable with very little configuration. It
|
12
|
+
even supports environments where multiple program flows are in use,
|
13
|
+
such as real-time operating systems.
|
14
|
+
|
15
|
+
There are about a gabillion exception frameworks using a similar
|
16
|
+
setjmp/longjmp method out there... and there will probably be more
|
17
|
+
in the future. Unfortunately, when we started our last embedded
|
18
|
+
project, all those that existed either (a) did not support multiple
|
19
|
+
tasks (therefore multiple stacks) or (b) were way more complex than
|
20
|
+
we really wanted. CException was born.
|
21
|
+
|
22
|
+
Why use CException?
|
23
|
+
|
24
|
+
0. It's ANSI C, and it beats passing error codes around.
|
25
|
+
|
26
|
+
1. You want something simple... CException throws a single id. You can
|
27
|
+
define those ID's to be whatever you like. You might even choose which
|
28
|
+
type that number is for your project. But that's as far as it goes.
|
29
|
+
We weren't interested in passing objects or structs or strings...
|
30
|
+
just simple error codes.
|
31
|
+
|
32
|
+
2. Performance... CException can be configured for single tasking or
|
33
|
+
multitasking. In single tasking, there is very little overhead past
|
34
|
+
the setjmp/longjmp calls (which are already fast). In multitasking,
|
35
|
+
your only additional overhead is the time it takes you to determine
|
36
|
+
a unique task id 0 - num_tasks.
|
37
|
+
|
38
|
+
For the latest version, go to http://cexception.sourceforge.net
|
39
|
+
|
40
|
+
--------------------------------------------------------------------
|
41
|
+
CONTENTS OF THIS DOCUMENT
|
42
|
+
--------------------------------------------------------------------
|
43
|
+
|
44
|
+
Usage
|
45
|
+
Limitations
|
46
|
+
API
|
47
|
+
Configuration
|
48
|
+
Testing
|
49
|
+
License
|
50
|
+
|
51
|
+
--------------------------------------------------------------------
|
52
|
+
Usage
|
53
|
+
--------------------------------------------------------------------
|
54
|
+
|
55
|
+
Code that is to be protected are wrapped in Try { } Catch { } blocks.
|
56
|
+
The code directly following the Try call is "protected", meaning that
|
57
|
+
if any Throws occur, program control is directly transferred to the
|
58
|
+
start of the Catch block.
|
59
|
+
|
60
|
+
A numerical exception ID is included with Throw, and is made accessible
|
61
|
+
from the Catch block.
|
62
|
+
|
63
|
+
Throws can occur from within function calls (nested as deeply as you
|
64
|
+
like) or directly from within the function itself.
|
65
|
+
|
66
|
+
--------------------------------------------------------------------
|
67
|
+
Limitations
|
68
|
+
--------------------------------------------------------------------
|
69
|
+
|
70
|
+
This library was made to be as fast as possible, and provide basic
|
71
|
+
exception handling. It is not a full-blown exception library. Because
|
72
|
+
of this, there are a few limitations that should be observed in order
|
73
|
+
to successfully utilize this library:
|
74
|
+
|
75
|
+
1. Do not directly "return" from within a Try block, nor "goto"
|
76
|
+
into or out of a Try block.
|
77
|
+
|
78
|
+
Why?
|
79
|
+
|
80
|
+
The "Try" macro allocates some local memory and alters a global
|
81
|
+
pointer. These are cleaned up at the top of the "Catch" macro.
|
82
|
+
Gotos and returns would bypass some of these steps, resulting in
|
83
|
+
memory leaks or unpredictable behavior.
|
84
|
+
|
85
|
+
2. If (a) you change local (stack) variables within your Try block,
|
86
|
+
AND (b) wish to make use of the updated values after an exception
|
87
|
+
is thrown, those variables should be made volatile. Note that this
|
88
|
+
is ONLY for locals and ONLY when you need access to them after a
|
89
|
+
throw.
|
90
|
+
|
91
|
+
Why?
|
92
|
+
|
93
|
+
Compilers optimize. There is no way to guarantee that the actual
|
94
|
+
memory location was updated and not just a register unless the
|
95
|
+
variable is marked volatile.
|
96
|
+
|
97
|
+
3. Memory which is malloc'd or new'd is not automatically released
|
98
|
+
when an error is thrown. This will sometimes be desirable, and
|
99
|
+
othertimes may not. It will be the responsibility of the Catch
|
100
|
+
block to perform this kind of cleanup.
|
101
|
+
|
102
|
+
Why?
|
103
|
+
|
104
|
+
There's just no easy way to track malloc'd memory, etc., without
|
105
|
+
replacing or wrapping malloc calls or something like that. This
|
106
|
+
is a light framework, so these options were not desirable.
|
107
|
+
|
108
|
+
--------------------------------------------------------------------
|
109
|
+
API
|
110
|
+
--------------------------------------------------------------------
|
111
|
+
|
112
|
+
Try
|
113
|
+
---
|
114
|
+
|
115
|
+
Try is a macro which starts a protected block. It MUST be followed by
|
116
|
+
a pair of braces or a single protected line (similar to an 'if'),
|
117
|
+
enclosing the data that is to be protected. It MUST be followed by a
|
118
|
+
Catch block (don't worry, you'll get compiler errors to let you know if
|
119
|
+
you mess any of that up).
|
120
|
+
|
121
|
+
Catch(e)
|
122
|
+
--------
|
123
|
+
|
124
|
+
Catch is a macro which ends the Try block and starts the error handling
|
125
|
+
block. The catch block is called if and only if an exception was thrown
|
126
|
+
while within the Try block. This error was thrown by a Throw call
|
127
|
+
somewhere within Try (or within a function called within Try, or a function
|
128
|
+
called by a function called within Try, etc).
|
129
|
+
|
130
|
+
The single parameter 'e' is filled with the error code which was thrown.
|
131
|
+
This can be used for reporting, conditional cleanup, etc. (or you can just
|
132
|
+
ignore it if you really want... people ignore return codes all the time,
|
133
|
+
right?). 'e' should be of type EXCEPTION_T;
|
134
|
+
|
135
|
+
Throw(e)
|
136
|
+
--------
|
137
|
+
|
138
|
+
The method of throwing an error. Throws should only occur from within a
|
139
|
+
protected (Try...Catch) block, though it may easily be nested many function
|
140
|
+
calls deep without an impact on performance or functionality. Throw takes
|
141
|
+
a single argument, which is an exception id which will be passed to Catch
|
142
|
+
as the reason for the error.
|
143
|
+
|
144
|
+
If you wish to Rethrow an error, this can be done by calling Throw(e) with
|
145
|
+
the error code you just caught. It IS valid to throw from a catch block.
|
146
|
+
|
147
|
+
ExitTry()
|
148
|
+
---------
|
149
|
+
|
150
|
+
On rare occasion, you might want to immediately exit your current Try block
|
151
|
+
but NOT treat this as an error. Don't run the Catch. Just start executing
|
152
|
+
from after the Catch as if nothing had happened... That's what ExitTry is
|
153
|
+
for.
|
154
|
+
|
155
|
+
--------------------------------------------------------------------
|
156
|
+
CONFIGURATION
|
157
|
+
--------------------------------------------------------------------
|
158
|
+
|
159
|
+
CException is a mostly portable library. It has one universal
|
160
|
+
dependency, and some macros which are required if working in a
|
161
|
+
multi-tasking environment.
|
162
|
+
|
163
|
+
1. The standard C library setjmp must be available. Since this is part
|
164
|
+
of the standard library, chances are good that you'll be fine.
|
165
|
+
|
166
|
+
2. If working in a multitasking environment, methods for obtaining an
|
167
|
+
index into an array of frames and to get the overall number of
|
168
|
+
id's are required. If the OS supports a method to retrieve Task
|
169
|
+
ID's, and those Tasks are number 0, 1, 2... you are in an ideal
|
170
|
+
situation. Otherwise, a more creative mapping function may be
|
171
|
+
required. Note that this function is likely to be called twice
|
172
|
+
for each protected block and once during a throw. This is the
|
173
|
+
only overhead in the system.
|
174
|
+
|
175
|
+
Exception.h
|
176
|
+
-----------------
|
177
|
+
By convention, most projects include Exception.h which defines any
|
178
|
+
further requirements, then calls CException.h to do the gruntwork. All
|
179
|
+
of these are optional. You could directly include CException.h if
|
180
|
+
you wanted and just use the defaults provided.
|
181
|
+
|
182
|
+
EXCEPTION_T - Set this to the type you want your exception id's
|
183
|
+
to be. Defaults to 'unsigned int'.
|
184
|
+
|
185
|
+
EXCEPTION_NONE - Set this to a number which will never be an
|
186
|
+
exception id in your system. Defaults to 0x5a5a5a5a.
|
187
|
+
|
188
|
+
EXCEPTION_GET_ID - If in a multi-tasking environment, this should be
|
189
|
+
set to be a call to the function described in #2 above.
|
190
|
+
Defaults to just return 0 all the time (good for
|
191
|
+
single tasking environments)
|
192
|
+
|
193
|
+
EXCEPTION_NUM_ID - If in a multi-tasking environment, this should be set
|
194
|
+
to the number of ID's required (usually the number of
|
195
|
+
tasks in the system). Defaults to 1 (for single
|
196
|
+
tasking environments).
|
197
|
+
|
198
|
+
CEXCEPTION_NO_CATCH_HANDLER(id) - This macro can be optionally specified.
|
199
|
+
It allows you to specify code to be called when a Throw
|
200
|
+
is made outside of Try...Catch protection. Consider
|
201
|
+
this the emergency fallback plan for when something has
|
202
|
+
gone terribly wrong.
|
203
|
+
|
204
|
+
You may also want to include any header files which will commonly be
|
205
|
+
needed by the rest of your application where it uses exception handling
|
206
|
+
here. For example, OS header files or exception codes would be useful.
|
207
|
+
|
208
|
+
Finally, there are some hook macros which you can implement to inject
|
209
|
+
your own target-specific code in particular places. It is a rare instance
|
210
|
+
where you will need these, but they are here if you need them:
|
211
|
+
|
212
|
+
CEXCEPTION_HOOK_START_TRY - called immediately before the Try block
|
213
|
+
CEXCEPTION_HOOK_HAPPY_TRY - called immediately after the Try block
|
214
|
+
if no exception was thrown
|
215
|
+
CEXCEPTION_HOOK_AFTER_TRY - called immediately after the Try block
|
216
|
+
OR before an exception is caught
|
217
|
+
CEXCEPTION_HOOK_START_CATCH - called immediately before the catch
|
218
|
+
|
219
|
+
--------------------------------------------------------------------
|
220
|
+
TESTING
|
221
|
+
--------------------------------------------------------------------
|
222
|
+
|
223
|
+
If you want to validate that CException works with your tools or that
|
224
|
+
it works with your custom configuration, you may want to run the test
|
225
|
+
suite.
|
226
|
+
|
227
|
+
The test suite included makes use of the Unity Test Framework. It will
|
228
|
+
require a native C compiler. The example makefile uses MinGW's gcc.
|
229
|
+
Modify the makefile to include the proper paths to tools, then run 'make'
|
230
|
+
to compile and run the test application.
|
231
|
+
|
232
|
+
C_COMPILER - The C compiler to use to perform the tests
|
233
|
+
C_LIBS - The path to the C libraries (including setjmp)
|
234
|
+
UNITY_DIR - The path to the Unity framework (required to run tests)
|
235
|
+
(get it at http://unity.sourceforge.net)
|
236
|
+
|
237
|
+
--------------------------------------------------------------------
|
238
|
+
LICENSE
|
239
|
+
--------------------------------------------------------------------
|
240
|
+
|
241
|
+
This software is licensed under the MIT License
|
242
|
+
|
243
|
+
Copyright (c) 2007-2016 Mark VanderVoord
|
244
|
+
|
245
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
246
|
+
of this software and associated documentation files (the "Software"), to deal
|
247
|
+
in the Software without restriction, including without limitation the rights
|
248
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
249
|
+
copies of the Software, and to permit persons to whom the Software is
|
250
|
+
furnished to do so, subject to the following conditions:
|
251
|
+
|
252
|
+
The above copyright notice and this permission notice shall be included in
|
253
|
+
all copies or substantial portions of the Software.
|
254
|
+
|
255
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
256
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
257
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
258
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
259
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
260
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
261
|
+
THE SOFTWARE.
|