acpc_dealer 2.0.6 → 2.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +4 -2
- data/lib/acpc_dealer.rb +6 -2
- data/lib/acpc_dealer/version.rb +1 -1
- data/vendor/project_acpc_server/Makefile +12 -2
- data/vendor/project_acpc_server/README +1 -0
- data/vendor/project_acpc_server/example_player.limit.2p.sh +2 -1
- data/vendor/project_acpc_server/example_player.limit.3p.sh +2 -1
- data/vendor/project_acpc_server/example_player.nolimit.2p.sh +2 -1
- data/vendor/project_acpc_server/example_player.nolimit.3p.sh +2 -1
- data/vendor/project_acpc_server/kuhn.limit.3p.game +14 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf1.sh +3 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf2.sh +3 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player.sf3.sh +3 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/LICENCE +23 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/Makefile +128 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/README.md +35 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/CExceptionConfig.h +12 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.c +49 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/dealer_connection.h +22 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.c +483 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/kuhn_3p_equilibrium_player.h +107 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/main.c +84 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.c +252 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/src/player_config.h +21 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.c +45 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/support/test_helper.h +27 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player.c +698 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_1.c +324 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_2.c +262 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/test/test_kuhn_3p_equilibrium_player_sub_family_3.c +177 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/CExceptionSummary.odt +0 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/CExceptionSummary.pdf +0 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/license.txt +30 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/docs/readme.txt +242 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.c +43 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/lib/CException.h +86 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/build.info +2 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cexception/release/version.info +2 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/config/production_environment.rb +14 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/config/test_environment.rb +16 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock Summary.odt +0 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock Summary.pdf +0 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/CMock_Summary.md +356 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/docs/license.txt +31 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_FLASH.mac +71 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_RAM.mac +94 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/SAM7_SIM.mac +67 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_FLASH.xcl +185 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/at91SAM7X256_RAM.xcl +185 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/Resource/ioat91sam7x256.ddf +2259 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.dep +3691 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.ewd +1696 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.ewp +2581 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/cmock_demo.eww +10 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X-EK.h +61 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.inc +2314 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.rdf +4704 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256.tcl +3407 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/AT91SAM7X256_inc.h +2268 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/ioat91sam7x256.h +4380 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/incIAR/lib_AT91SAM7X256.h +4211 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.cspy.bat +32 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.dbgdt +86 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.dni +42 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/settings/cmock_demo.wsdt +76 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/srcIAR/Cstartup.s79 +266 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v4/srcIAR/Cstartup_SAM7.c +98 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_FLASH.mac +71 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_RAM.mac +94 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/SAM7_SIM.mac +67 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_FLASH.icf +43 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/Resource/at91SAM7X256_RAM.icf +42 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.dep +4204 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.ewd +1906 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.ewp +2426 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/cmock_demo.eww +26 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X-EK.h +61 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/AT91SAM7X256_inc.h +2268 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/lib_AT91SAM7X256.h +4211 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/incIAR/project.h +30 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.cspy.bat +33 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.dbgdt +5 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.dni +18 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X.wsdt +74 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/BasicInterrupt_SAM7X_FLASH_Debug.jlink +12 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.cspy.bat +33 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.dbgdt +85 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.dni +44 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo.wsdt +73 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_Binary.jlink +12 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_FLASH_Debug.jlink +12 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/settings/cmock_demo_RAM_Debug.jlink +12 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/srcIAR/Cstartup.s +299 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/iar/iar_v5/srcIAR/Cstartup_SAM7.c +98 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock.rb +65 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_config.rb +129 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_file_writer.rb +33 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator.rb +195 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_array.rb +57 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_callback.rb +78 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_cexception.rb +51 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_expect.rb +86 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_ignore.rb +95 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_ignore_arg.rb +44 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_plugin_return_thru_ptr.rb +74 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_generator_utils.rb +202 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_header_parser.rb +277 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_plugin_manager.rb +40 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_unityhelper_parser.rb +75 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/release/build.info +2 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/release/version.info +2 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock.c +176 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock.h +31 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/src/cmock_internals.h +43 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/gcc.yml +53 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/iar_arm_v4.yml +108 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/targets/iar_arm_v5.yml +93 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/History.md +27 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Makefile +8 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/Readme.md +103 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/package.json +9 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.c +250 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/src/commander.h +88 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/commander.c/test.c +34 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_prompt.rb +94 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/colour_reporter.rb +39 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_config.yml +36 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_module.rb +202 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/generate_test_runner.rb +316 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/test_file_filter.rb +23 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/auto/unity_test_summary.rb +139 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.odt +0 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.pdf +0 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/Unity Summary.txt +216 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/docs/license.txt +31 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/build.info +2 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/release/version.info +2 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.c +1146 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity.h +245 -0
- data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/unity/src/unity_internals.h +546 -0
- data/vendor/project_acpc_server/net.c +0 -0
- data/vendor/project_acpc_server/net.h +1 -0
- data/vendor/project_acpc_server/tags +298 -0
- metadata +158 -26
data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_header_parser.rb
ADDED
@@ -0,0 +1,277 @@
|
|
1
|
+
# ==========================================
|
2
|
+
# CMock Project - Automatic Mock Generation for C
|
3
|
+
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
|
+
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
+
# ==========================================
|
6
|
+
|
7
|
+
class CMockHeaderParser
|
8
|
+
|
9
|
+
attr_accessor :funcs, :c_attributes, :treat_as_void, :treat_externs
|
10
|
+
|
11
|
+
def initialize(cfg)
|
12
|
+
@funcs = []
|
13
|
+
@c_strippables = cfg.strippables
|
14
|
+
@c_attributes = (['const'] + cfg.attributes).uniq
|
15
|
+
@c_calling_conventions = cfg.c_calling_conventions.uniq
|
16
|
+
@treat_as_void = (['void'] + cfg.treat_as_void).uniq
|
17
|
+
@declaration_parse_matcher = /([\d\w\s\*\(\),\[\]]+??)\(([\d\w\s\*\(\),\.\[\]+-]*)\)$/m
|
18
|
+
@standards = (['int','short','char','long','unsigned','signed'] + cfg.treat_as.keys).uniq
|
19
|
+
@when_no_prototypes = cfg.when_no_prototypes
|
20
|
+
@local_as_void = @treat_as_void
|
21
|
+
@verbosity = cfg.verbosity
|
22
|
+
@treat_externs = cfg.treat_externs
|
23
|
+
@c_strippables += ['extern'] if (@treat_externs == :include) #we'll need to remove the attribute if we're allowing externs
|
24
|
+
end
|
25
|
+
|
26
|
+
def parse(name, source)
|
27
|
+
@module_name = name.gsub(/\W/,'')
|
28
|
+
@typedefs = []
|
29
|
+
@funcs = []
|
30
|
+
function_names = []
|
31
|
+
|
32
|
+
parse_functions( import_source(source) ).map do |decl|
|
33
|
+
func = parse_declaration(decl)
|
34
|
+
unless (function_names.include? func[:name])
|
35
|
+
@funcs << func
|
36
|
+
function_names << func[:name]
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
{ :includes => nil,
|
41
|
+
:functions => @funcs,
|
42
|
+
:typedefs => @typedefs
|
43
|
+
}
|
44
|
+
end
|
45
|
+
|
46
|
+
private if $ThisIsOnlyATest.nil? ################
|
47
|
+
|
48
|
+
def import_source(source)
|
49
|
+
|
50
|
+
# void must be void for cmock _ExpectAndReturn calls to process properly, not some weird typedef which equates to void
|
51
|
+
# to a certain extent, this action assumes we're chewing on pre-processed header files, otherwise we'll most likely just get stuff from @treat_as_void
|
52
|
+
@local_as_void = @treat_as_void
|
53
|
+
void_types = source.scan(/typedef\s+(?:\(\s*)?void(?:\s*\))?\s+([\w\d]+)\s*;/)
|
54
|
+
if void_types
|
55
|
+
@local_as_void += void_types.flatten.uniq.compact
|
56
|
+
end
|
57
|
+
|
58
|
+
# smush multiline macros into single line (checking for continuation character at end of line '\')
|
59
|
+
source.gsub!(/\s*\\\s*/m, ' ')
|
60
|
+
|
61
|
+
#remove comments (block and line, in three steps to ensure correct precedence)
|
62
|
+
source.gsub!(/\/\/(?:.+\/\*|\*(?:$|[^\/])).*$/, '') # remove line comments that comment out the start of blocks
|
63
|
+
source.gsub!(/\/\*.*?\*\//m, '') # remove block comments
|
64
|
+
source.gsub!(/\/\/.*$/, '') # remove line comments (all that remain)
|
65
|
+
|
66
|
+
# remove assembler pragma sections
|
67
|
+
source.gsub!(/^\s*#\s*pragma\s+asm\s+.*?#\s*pragma\s+endasm/m, '')
|
68
|
+
|
69
|
+
# remove gcc's __attribute__ tags
|
70
|
+
source.gsub(/__attrbute__\s*\(\(\.*\)\)/, '')
|
71
|
+
|
72
|
+
# remove preprocessor statements and extern "C"
|
73
|
+
source.gsub!(/^\s*#.*/, '')
|
74
|
+
source.gsub!(/extern\s+\"C\"\s+\{/, '')
|
75
|
+
|
76
|
+
# enums, unions, structs, and typedefs can all contain things (e.g. function pointers) that parse like function prototypes, so yank them
|
77
|
+
# forward declared structs are removed before struct definitions so they don't mess up real thing later. we leave structs keywords in function prototypes
|
78
|
+
source.gsub!(/^[\w\s]*struct[^;\{\}\(\)]+;/m, '') # remove forward declared structs
|
79
|
+
source.gsub!(/^[\w\s]*(enum|union|struct|typepdef)[\w\s]*\{[^\}]+\}[\w\s\*\,]*;/m, '') # remove struct, union, and enum definitions and typedefs with braces
|
80
|
+
source.gsub!(/(\W)(?:register|auto|static|restrict)(\W)/, '\1\2') # remove problem keywords
|
81
|
+
source.gsub!(/\s*=\s*['"a-zA-Z0-9_\.]+\s*/, '') # remove default value statements from argument lists
|
82
|
+
source.gsub!(/^(?:[\w\s]*\W)?typedef\W.*/, '') # remove typedef statements
|
83
|
+
source.gsub!(/(^|\W+)(?:#{@c_strippables.join('|')})(?=$|\W+)/,'\1') unless @c_strippables.empty? # remove known attributes slated to be stripped
|
84
|
+
|
85
|
+
#scan for functions which return function pointers, because they are a pain
|
86
|
+
source.gsub!(/([\w\s\*]+)\(*\(\s*\*([\w\s\*]+)\s*\(([\w\s\*,]*)\)\)\s*\(([\w\s\*,]*)\)\)*/) do |m|
|
87
|
+
functype = "cmock_#{@module_name}_func_ptr#{@typedefs.size + 1}"
|
88
|
+
@typedefs << "typedef #{$1.strip}(*#{functype})(#{$4});"
|
89
|
+
"#{functype} #{$2.strip}(#{$3});"
|
90
|
+
end
|
91
|
+
|
92
|
+
#drop extra white space to make the rest go faster
|
93
|
+
source.gsub!(/^\s+/, '') # remove extra white space from beginning of line
|
94
|
+
source.gsub!(/\s+$/, '') # remove extra white space from end of line
|
95
|
+
source.gsub!(/\s*\(\s*/, '(') # remove extra white space from before left parens
|
96
|
+
source.gsub!(/\s*\)\s*/, ')') # remove extra white space from before right parens
|
97
|
+
source.gsub!(/\s+/, ' ') # remove remaining extra white space
|
98
|
+
|
99
|
+
#split lines on semicolons and remove things that are obviously not what we are looking for
|
100
|
+
src_lines = source.split(/\s*;\s*/)
|
101
|
+
src_lines.delete_if {|line| line.strip.length == 0} # remove blank lines
|
102
|
+
src_lines.delete_if {|line| !(line =~ /[\w\s\*]+\(+\s*\*[\*\s]*[\w\s]+(?:\[[\w\s]*\]\s*)+\)+\s*\((?:[\w\s\*]*,?)*\s*\)/).nil?} #remove function pointer arrays
|
103
|
+
if (@treat_externs == :include)
|
104
|
+
src_lines.delete_if {|line| !(line =~ /(?:^|\s+)(?:inline)\s+/).nil?} # remove inline functions
|
105
|
+
else
|
106
|
+
src_lines.delete_if {|line| !(line =~ /(?:^|\s+)(?:extern|inline)\s+/).nil?} # remove inline and extern functions
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def parse_functions(source)
|
111
|
+
funcs = []
|
112
|
+
source.each {|line| funcs << line.strip.gsub(/\s+/, ' ') if (line =~ @declaration_parse_matcher)}
|
113
|
+
if funcs.empty?
|
114
|
+
case @when_no_prototypes
|
115
|
+
when :error
|
116
|
+
raise "ERROR: No function prototypes found!"
|
117
|
+
when :warn
|
118
|
+
puts "WARNING: No function prototypes found!" unless (@verbosity < 1)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
return funcs
|
122
|
+
end
|
123
|
+
|
124
|
+
def parse_args(arg_list)
|
125
|
+
args = []
|
126
|
+
arg_list.split(',').each do |arg|
|
127
|
+
arg.strip!
|
128
|
+
return args if (arg =~ /^\s*((\.\.\.)|(void))\s*$/) # we're done if we reach void by itself or ...
|
129
|
+
arg_array = arg.split
|
130
|
+
arg_elements = arg_array - @c_attributes # split up words and remove known attributes
|
131
|
+
args << { :type => (arg_type =arg_elements[0..-2].join(' ')),
|
132
|
+
:name => arg_elements[-1],
|
133
|
+
:ptr? => divine_ptr(arg_type),
|
134
|
+
:const? => arg_array.include?('const')
|
135
|
+
}
|
136
|
+
end
|
137
|
+
return args
|
138
|
+
end
|
139
|
+
|
140
|
+
def divine_ptr(arg_type)
|
141
|
+
return false unless arg_type.include? '*'
|
142
|
+
return false if arg_type.gsub(/(const|char|\*|\s)+/,'').empty?
|
143
|
+
return true
|
144
|
+
end
|
145
|
+
|
146
|
+
def clean_args(arg_list)
|
147
|
+
if ((@local_as_void.include?(arg_list.strip)) or (arg_list.empty?))
|
148
|
+
return 'void'
|
149
|
+
else
|
150
|
+
c=0
|
151
|
+
arg_list.gsub!(/(\w+)(?:\s*\[[\s\d\w+-]*\])+/,'*\1') # magically turn brackets into asterisks
|
152
|
+
arg_list.gsub!(/\s+\*/,'*') # remove space to place asterisks with type (where they belong)
|
153
|
+
arg_list.gsub!(/\*(\w)/,'* \1') # pull asterisks away from arg to place asterisks with type (where they belong)
|
154
|
+
|
155
|
+
#scan argument list for function pointers and replace them with custom types
|
156
|
+
arg_list.gsub!(/([\w\s\*]+)\(+\s*\*[\*\s]*([\w\s]*)\s*\)+\s*\(((?:[\w\s\*]*,?)*)\s*\)*/) do |m|
|
157
|
+
|
158
|
+
functype = "cmock_#{@module_name}_func_ptr#{@typedefs.size + 1}"
|
159
|
+
funcret = $1.strip
|
160
|
+
funcname = $2.strip
|
161
|
+
funcargs = $3.strip
|
162
|
+
funconst = ''
|
163
|
+
if (funcname.include? 'const')
|
164
|
+
funcname.gsub!('const','').strip!
|
165
|
+
funconst = 'const '
|
166
|
+
end
|
167
|
+
@typedefs << "typedef #{funcret}(*#{functype})(#{funcargs});"
|
168
|
+
funcname = "cmock_arg#{c+=1}" if (funcname.empty?)
|
169
|
+
"#{functype} #{funconst}#{funcname}"
|
170
|
+
end
|
171
|
+
|
172
|
+
#automatically name unnamed arguments (those that only had a type)
|
173
|
+
arg_list.split(/\s*,\s*/).map { |arg|
|
174
|
+
parts = (arg.split - ['struct', 'union', 'enum', 'const', 'const*'])
|
175
|
+
if ((parts.size < 2) or (parts[-1][-1].chr == '*') or (@standards.include?(parts[-1])))
|
176
|
+
"#{arg} cmock_arg#{c+=1}"
|
177
|
+
else
|
178
|
+
arg
|
179
|
+
end
|
180
|
+
}.join(', ')
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
def parse_declaration(declaration)
|
185
|
+
decl = {}
|
186
|
+
|
187
|
+
regex_match = @declaration_parse_matcher.match(declaration)
|
188
|
+
raise "Failed parsing function declaration: '#{declaration}'" if regex_match.nil?
|
189
|
+
|
190
|
+
#grab argument list
|
191
|
+
args = regex_match[2].strip
|
192
|
+
|
193
|
+
#process function attributes, return type, and name
|
194
|
+
descriptors = regex_match[1]
|
195
|
+
descriptors.gsub!(/\s+\*/,'*') #remove space to place asterisks with return type (where they belong)
|
196
|
+
descriptors.gsub!(/\*(\w)/,'* \1') #pull asterisks away from function name to place asterisks with return type (where they belong)
|
197
|
+
descriptors = descriptors.split #array of all descriptor strings
|
198
|
+
|
199
|
+
#grab name
|
200
|
+
decl[:name] = descriptors[-1] #snag name as last array item
|
201
|
+
|
202
|
+
#build attribute and return type strings
|
203
|
+
decl[:modifier] = []
|
204
|
+
rettype = []
|
205
|
+
descriptors[0..-2].each do |word|
|
206
|
+
if @c_attributes.include?(word)
|
207
|
+
decl[:modifier] << word
|
208
|
+
elsif @c_calling_conventions.include?(word)
|
209
|
+
decl[:c_calling_convention] = word
|
210
|
+
else
|
211
|
+
rettype << word
|
212
|
+
end
|
213
|
+
end
|
214
|
+
decl[:modifier] = decl[:modifier].join(' ')
|
215
|
+
rettype = rettype.join(' ')
|
216
|
+
rettype = 'void' if (@local_as_void.include?(rettype.strip))
|
217
|
+
decl[:return] = { :type => rettype,
|
218
|
+
:name => 'cmock_to_return',
|
219
|
+
:ptr? => divine_ptr(rettype),
|
220
|
+
:const? => rettype.split(/\s/).include?('const'),
|
221
|
+
:str => "#{rettype} cmock_to_return",
|
222
|
+
:void? => (rettype == 'void')
|
223
|
+
}
|
224
|
+
|
225
|
+
#remove default argument statements from mock definitions
|
226
|
+
args.gsub!(/=\s*[a-zA-Z0-9_\.]+\s*/, ' ')
|
227
|
+
|
228
|
+
#check for var args
|
229
|
+
if (args =~ /\.\.\./)
|
230
|
+
decl[:var_arg] = args.match( /[\w\s]*\.\.\./ ).to_s.strip
|
231
|
+
if (args =~ /\,[\w\s]*\.\.\./)
|
232
|
+
args = args.gsub!(/\,[\w\s]*\.\.\./,'')
|
233
|
+
else
|
234
|
+
args = 'void'
|
235
|
+
end
|
236
|
+
else
|
237
|
+
decl[:var_arg] = nil
|
238
|
+
end
|
239
|
+
args = clean_args(args)
|
240
|
+
decl[:args_string] = args
|
241
|
+
decl[:args] = parse_args(args)
|
242
|
+
decl[:args_call] = decl[:args].map{|a| a[:name]}.join(', ')
|
243
|
+
decl[:contains_ptr?] = decl[:args].inject(false) {|ptr, arg| arg[:ptr?] ? true : ptr }
|
244
|
+
|
245
|
+
if (decl[:return][:type].nil? or decl[:name].nil? or decl[:args].nil? or
|
246
|
+
decl[:return][:type].empty? or decl[:name].empty?)
|
247
|
+
raise "Failed Parsing Declaration Prototype!\n" +
|
248
|
+
" declaration: '#{declaration}'\n" +
|
249
|
+
" modifier: '#{decl[:modifier]}'\n" +
|
250
|
+
" return: #{prototype_inspect_hash(decl[:return])}\n" +
|
251
|
+
" function: '#{decl[:name]}'\n" +
|
252
|
+
" args: #{prototype_inspect_array_of_hashes(decl[:args])}\n"
|
253
|
+
end
|
254
|
+
|
255
|
+
return decl
|
256
|
+
end
|
257
|
+
|
258
|
+
def prototype_inspect_hash(hash)
|
259
|
+
pairs = []
|
260
|
+
hash.each_pair { |name, value| pairs << ":#{name} => #{"'" if (value.class == String)}#{value}#{"'" if (value.class == String)}" }
|
261
|
+
return "{#{pairs.join(', ')}}"
|
262
|
+
end
|
263
|
+
|
264
|
+
def prototype_inspect_array_of_hashes(array)
|
265
|
+
hashes = []
|
266
|
+
array.each { |hash| hashes << prototype_inspect_hash(hash) }
|
267
|
+
case (array.size)
|
268
|
+
when 0
|
269
|
+
return "[]"
|
270
|
+
when 1
|
271
|
+
return "[#{hashes[0]}]"
|
272
|
+
else
|
273
|
+
return "[\n #{hashes.join("\n ")}\n ]\n"
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
end
|
data/vendor/project_acpc_server/kuhn_3p_equilibrium_player/vendor/cmock/lib/cmock_plugin_manager.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
# ==========================================
|
2
|
+
# CMock Project - Automatic Mock Generation for C
|
3
|
+
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
|
+
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
+
# ==========================================
|
6
|
+
|
7
|
+
class CMockPluginManager
|
8
|
+
|
9
|
+
attr_accessor :plugins
|
10
|
+
|
11
|
+
def initialize(config, utils)
|
12
|
+
@plugins = []
|
13
|
+
plugins_to_load = [:expect, config.plugins].flatten.uniq.compact
|
14
|
+
plugins_to_load.each do |plugin|
|
15
|
+
plugin_name = plugin.to_s
|
16
|
+
object_name = "CMockGeneratorPlugin" + camelize(plugin_name)
|
17
|
+
begin
|
18
|
+
unless (Object.const_defined? object_name)
|
19
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/cmock_generator_plugin_#{plugin_name.downcase}.rb"
|
20
|
+
end
|
21
|
+
@plugins << eval("#{object_name}.new(config, utils)")
|
22
|
+
rescue
|
23
|
+
raise "ERROR: CMock unable to load plugin '#{plugin_name}'"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
@plugins.sort! {|a,b| a.priority <=> b.priority }
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(method, args=nil)
|
30
|
+
if args.nil?
|
31
|
+
return @plugins.collect{ |plugin| plugin.send(method) if plugin.respond_to?(method) }.flatten.join
|
32
|
+
else
|
33
|
+
return @plugins.collect{ |plugin| plugin.send(method, args) if plugin.respond_to?(method) }.flatten.join
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def camelize(lower_case_and_underscored_word)
|
38
|
+
lower_case_and_underscored_word.gsub(/\/(.?)/) { "::" + $1.upcase }.gsub(/(^|_)(.)/) { $2.upcase }
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# ==========================================
|
2
|
+
# CMock Project - Automatic Mock Generation for C
|
3
|
+
# Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
|
+
# [Released under MIT License. Please refer to license.txt for details]
|
5
|
+
# ==========================================
|
6
|
+
|
7
|
+
class CMockUnityHelperParser
|
8
|
+
|
9
|
+
attr_accessor :c_types
|
10
|
+
|
11
|
+
def initialize(config)
|
12
|
+
@config = config
|
13
|
+
@fallback = @config.plugins.include?(:array) ? 'UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY' : 'UNITY_TEST_ASSERT_EQUAL_MEMORY'
|
14
|
+
@c_types = map_C_types.merge(import_source)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_helper(ctype)
|
18
|
+
lookup = ctype.gsub(/(?:^|(\S?)(\s*)|(\W))const(?:$|(\s*)(\S)|(\W))/,'\1\3\5\6').strip.gsub(/\s+/,'_')
|
19
|
+
return [@c_types[lookup], ''] if (@c_types[lookup])
|
20
|
+
if (lookup =~ /\*$/)
|
21
|
+
lookup = lookup.gsub(/\*$/,'')
|
22
|
+
return [@c_types[lookup], '*'] if (@c_types[lookup])
|
23
|
+
else
|
24
|
+
lookup = lookup + '*'
|
25
|
+
return [@c_types[lookup], '&'] if (@c_types[lookup])
|
26
|
+
end
|
27
|
+
return ['UNITY_TEST_ASSERT_EQUAL_PTR', ''] if (ctype =~ /cmock_\w+_ptr\d+/)
|
28
|
+
raise("Don't know how to test #{ctype} and memory tests are disabled!") unless @config.memcmp_if_unknown
|
29
|
+
return (lookup =~ /\*$/) ? [@fallback, '&'] : [@fallback, '']
|
30
|
+
end
|
31
|
+
|
32
|
+
private ###########################
|
33
|
+
|
34
|
+
def map_C_types
|
35
|
+
c_types = {}
|
36
|
+
@config.treat_as.each_pair do |ctype, expecttype|
|
37
|
+
c_type = ctype.gsub(/\s+/,'_')
|
38
|
+
if (expecttype =~ /\*/)
|
39
|
+
c_types[c_type] = "UNITY_TEST_ASSERT_EQUAL_#{expecttype.gsub(/\*/,'')}_ARRAY"
|
40
|
+
else
|
41
|
+
c_types[c_type] = "UNITY_TEST_ASSERT_EQUAL_#{expecttype}"
|
42
|
+
c_types[c_type+'*'] ||= "UNITY_TEST_ASSERT_EQUAL_#{expecttype}_ARRAY"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
c_types
|
46
|
+
end
|
47
|
+
|
48
|
+
def import_source
|
49
|
+
source = @config.load_unity_helper
|
50
|
+
return {} if source.nil?
|
51
|
+
c_types = {}
|
52
|
+
source = source.gsub(/\/\/.*$/, '') #remove line comments
|
53
|
+
source = source.gsub(/\/\*.*?\*\//m, '') #remove block comments
|
54
|
+
|
55
|
+
#scan for comparison helpers
|
56
|
+
match_regex = Regexp.new('^\s*#define\s+(UNITY_TEST_ASSERT_EQUAL_(\w+))\s*\(' + Array.new(4,'\s*\w+\s*').join(',') + '\)')
|
57
|
+
pairs = source.scan(match_regex).flatten.compact
|
58
|
+
(pairs.size/2).times do |i|
|
59
|
+
expect = pairs[i*2]
|
60
|
+
ctype = pairs[(i*2)+1]
|
61
|
+
c_types[ctype] = expect unless expect.include?("_ARRAY")
|
62
|
+
end
|
63
|
+
|
64
|
+
#scan for array variants of those helpers
|
65
|
+
match_regex = Regexp.new('^\s*#define\s+(UNITY_TEST_ASSERT_EQUAL_(\w+_ARRAY))\s*\(' + Array.new(5,'\s*\w+\s*').join(',') + '\)')
|
66
|
+
pairs = source.scan(match_regex).flatten.compact
|
67
|
+
(pairs.size/2).times do |i|
|
68
|
+
expect = pairs[i*2]
|
69
|
+
ctype = pairs[(i*2)+1]
|
70
|
+
c_types[ctype.gsub('_ARRAY','*')] = expect
|
71
|
+
end
|
72
|
+
|
73
|
+
c_types
|
74
|
+
end
|
75
|
+
end
|
@@ -0,0 +1,176 @@
|
|
1
|
+
/* ==========================================
|
2
|
+
CMock Project - Automatic Mock Generation for C
|
3
|
+
Copyright (c) 2007 Mike Karlesky, Mark VanderVoord, Greg Williams
|
4
|
+
[Released under MIT License. Please refer to license.txt for details]
|
5
|
+
========================================== */
|
6
|
+
|
7
|
+
#include "unity.h"
|
8
|
+
|
9
|
+
#include "cmock_internals.h"
|
10
|
+
|
11
|
+
//private variables
|
12
|
+
#ifdef CMOCK_MEM_DYNAMIC
|
13
|
+
static unsigned char* CMock_Guts_Buffer = NULL;
|
14
|
+
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_ALIGN_SIZE;
|
15
|
+
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr;
|
16
|
+
#else
|
17
|
+
static unsigned char CMock_Guts_Buffer[CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE];
|
18
|
+
static CMOCK_MEM_INDEX_TYPE CMock_Guts_BufferSize = CMOCK_MEM_SIZE + CMOCK_MEM_ALIGN_SIZE;
|
19
|
+
static CMOCK_MEM_INDEX_TYPE CMock_Guts_FreePtr;
|
20
|
+
#endif
|
21
|
+
|
22
|
+
//-------------------------------------------------------
|
23
|
+
// CMock_Guts_MemNew
|
24
|
+
//-------------------------------------------------------
|
25
|
+
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemNew(CMOCK_MEM_INDEX_TYPE size)
|
26
|
+
{
|
27
|
+
CMOCK_MEM_INDEX_TYPE index;
|
28
|
+
|
29
|
+
//verify arguments valid (we must be allocating space for at least 1 byte, and the existing chain must be in memory somewhere)
|
30
|
+
if (size < 1)
|
31
|
+
return CMOCK_GUTS_NONE;
|
32
|
+
|
33
|
+
//verify we have enough room
|
34
|
+
size = size + CMOCK_MEM_INDEX_SIZE;
|
35
|
+
if (size & CMOCK_MEM_ALIGN_MASK)
|
36
|
+
size = (size + CMOCK_MEM_ALIGN_MASK) & ~CMOCK_MEM_ALIGN_MASK;
|
37
|
+
if ((CMock_Guts_BufferSize - CMock_Guts_FreePtr) < size)
|
38
|
+
{
|
39
|
+
#ifdef CMOCK_MEM_DYNAMIC
|
40
|
+
CMock_Guts_BufferSize += CMOCK_MEM_SIZE + size;
|
41
|
+
CMock_Guts_Buffer = realloc(CMock_Guts_Buffer, CMock_Guts_BufferSize);
|
42
|
+
if (CMock_Guts_Buffer == NULL)
|
43
|
+
#endif //yes that if will continue to the return below if TRUE
|
44
|
+
return CMOCK_GUTS_NONE;
|
45
|
+
}
|
46
|
+
|
47
|
+
//determine where we're putting this new block, and init its pointer to be the end of the line
|
48
|
+
index = CMock_Guts_FreePtr + CMOCK_MEM_INDEX_SIZE;
|
49
|
+
*(CMOCK_MEM_INDEX_TYPE*)(&CMock_Guts_Buffer[CMock_Guts_FreePtr]) = CMOCK_GUTS_NONE;
|
50
|
+
CMock_Guts_FreePtr += size;
|
51
|
+
|
52
|
+
return index;
|
53
|
+
}
|
54
|
+
|
55
|
+
//-------------------------------------------------------
|
56
|
+
// CMock_Guts_MemChain
|
57
|
+
//-------------------------------------------------------
|
58
|
+
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemChain(CMOCK_MEM_INDEX_TYPE root_index, CMOCK_MEM_INDEX_TYPE obj_index)
|
59
|
+
{
|
60
|
+
CMOCK_MEM_INDEX_TYPE index;
|
61
|
+
void* root;
|
62
|
+
void* obj;
|
63
|
+
void* next;
|
64
|
+
|
65
|
+
if (root_index == CMOCK_GUTS_NONE)
|
66
|
+
{
|
67
|
+
//if there is no root currently, we return this object as the root of the chain
|
68
|
+
return obj_index;
|
69
|
+
}
|
70
|
+
else
|
71
|
+
{
|
72
|
+
//reject illegal nodes
|
73
|
+
if ((root_index < CMOCK_MEM_ALIGN_SIZE) || (root_index >= CMock_Guts_FreePtr))
|
74
|
+
{
|
75
|
+
return CMOCK_GUTS_NONE;
|
76
|
+
}
|
77
|
+
if ((obj_index < CMOCK_MEM_ALIGN_SIZE) || (obj_index >= CMock_Guts_FreePtr))
|
78
|
+
{
|
79
|
+
return CMOCK_GUTS_NONE;
|
80
|
+
}
|
81
|
+
|
82
|
+
root = (void*)(&CMock_Guts_Buffer[root_index]);
|
83
|
+
obj = (void*)(&CMock_Guts_Buffer[obj_index]);
|
84
|
+
|
85
|
+
//find the end of the existing chain and add us
|
86
|
+
next = root;
|
87
|
+
do {
|
88
|
+
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE);
|
89
|
+
if (index >= CMock_Guts_FreePtr)
|
90
|
+
return CMOCK_GUTS_NONE;
|
91
|
+
if (index > 0)
|
92
|
+
next = (void*)(&CMock_Guts_Buffer[index]);
|
93
|
+
} while (index > 0);
|
94
|
+
*(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)next - CMOCK_MEM_INDEX_SIZE) = ((CMOCK_MEM_PTR_AS_INT)obj - (CMOCK_MEM_PTR_AS_INT)CMock_Guts_Buffer);
|
95
|
+
return root_index;
|
96
|
+
}
|
97
|
+
}
|
98
|
+
|
99
|
+
//-------------------------------------------------------
|
100
|
+
// CMock_Guts_MemNext
|
101
|
+
//-------------------------------------------------------
|
102
|
+
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemNext(CMOCK_MEM_INDEX_TYPE previous_item_index)
|
103
|
+
{
|
104
|
+
CMOCK_MEM_INDEX_TYPE index;
|
105
|
+
void* previous_item;
|
106
|
+
|
107
|
+
//There is nothing "next" if the pointer isn't from our buffer
|
108
|
+
if ((previous_item_index < CMOCK_MEM_ALIGN_SIZE) || (previous_item_index >= CMock_Guts_FreePtr))
|
109
|
+
return CMOCK_GUTS_NONE;
|
110
|
+
previous_item = (void*)(&CMock_Guts_Buffer[previous_item_index]);
|
111
|
+
|
112
|
+
//if the pointer is good, then use it to look up the next index
|
113
|
+
//(we know the first element always goes in zero, so NEXT must always be > 1)
|
114
|
+
index = *(CMOCK_MEM_INDEX_TYPE*)((CMOCK_MEM_PTR_AS_INT)previous_item - CMOCK_MEM_INDEX_SIZE);
|
115
|
+
if ((index > 1) && (index < CMock_Guts_FreePtr))
|
116
|
+
return index;
|
117
|
+
else
|
118
|
+
return CMOCK_GUTS_NONE;
|
119
|
+
}
|
120
|
+
|
121
|
+
//-------------------------------------------------------
|
122
|
+
// CMock_Guts_MemEndOfChain
|
123
|
+
//-------------------------------------------------------
|
124
|
+
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemEndOfChain(CMOCK_MEM_INDEX_TYPE root_index)
|
125
|
+
{
|
126
|
+
CMOCK_MEM_INDEX_TYPE index = root_index;
|
127
|
+
CMOCK_MEM_INDEX_TYPE next_index;
|
128
|
+
|
129
|
+
for (next_index = root_index;
|
130
|
+
next_index != CMOCK_GUTS_NONE;
|
131
|
+
next_index = CMock_Guts_MemNext(index))
|
132
|
+
{
|
133
|
+
index = next_index;
|
134
|
+
}
|
135
|
+
|
136
|
+
return index;
|
137
|
+
}
|
138
|
+
|
139
|
+
//-------------------------------------------------------
|
140
|
+
// CMock_GetAddressFor
|
141
|
+
//-------------------------------------------------------
|
142
|
+
void* CMock_Guts_GetAddressFor(CMOCK_MEM_INDEX_TYPE index)
|
143
|
+
{
|
144
|
+
if ((index >= CMOCK_MEM_ALIGN_SIZE) && (index < CMock_Guts_FreePtr))
|
145
|
+
{
|
146
|
+
return (void*)(&CMock_Guts_Buffer[index]);
|
147
|
+
}
|
148
|
+
else
|
149
|
+
{
|
150
|
+
return NULL;
|
151
|
+
}
|
152
|
+
}
|
153
|
+
|
154
|
+
//-------------------------------------------------------
|
155
|
+
// CMock_Guts_MemBytesFree
|
156
|
+
//-------------------------------------------------------
|
157
|
+
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesFree(void)
|
158
|
+
{
|
159
|
+
return CMock_Guts_BufferSize - CMock_Guts_FreePtr;
|
160
|
+
}
|
161
|
+
|
162
|
+
//-------------------------------------------------------
|
163
|
+
// CMock_Guts_MemBytesUsed
|
164
|
+
//-------------------------------------------------------
|
165
|
+
CMOCK_MEM_INDEX_TYPE CMock_Guts_MemBytesUsed(void)
|
166
|
+
{
|
167
|
+
return CMock_Guts_FreePtr - CMOCK_MEM_ALIGN_SIZE;
|
168
|
+
}
|
169
|
+
|
170
|
+
//-------------------------------------------------------
|
171
|
+
// CMock_Guts_MemFreeAll
|
172
|
+
//-------------------------------------------------------
|
173
|
+
void CMock_Guts_MemFreeAll(void)
|
174
|
+
{
|
175
|
+
CMock_Guts_FreePtr = CMOCK_MEM_ALIGN_SIZE; //skip the very beginning
|
176
|
+
}
|