1
0
mirror of https://github.com/meekrosoft/fff synced 2026-01-23 00:15:59 +01:00

Add global definition macro and remove cpp static initializer

This commit is contained in:
Mike Long
2012-05-24 17:36:49 +08:00
parent 5d89d72d16
commit f145ecd3ad

View File

@@ -126,7 +126,7 @@ end
# ------ End Helper macros ------ # # ------ End Helper macros ------ #
#fakegen helpers #fakegen helpers to print at levels of indentation
$current_depth = 0 $current_depth = 0
def putd(str) def putd(str)
$current_depth.times {|not_used| print " "} $current_depth.times {|not_used| print " "}
@@ -171,7 +171,7 @@ def output_macro(arg_count, is_value_function)
} }
popd popd
putd "STATIC_INIT(FUNCNAME) \\" if $cpp_output # putd "STATIC_INIT(FUNCNAME) \\" if $cpp_output
putd "" putd ""
output_macro_header(fake_macro_name, arg_count, return_type) output_macro_header(fake_macro_name, arg_count, return_type)
@@ -318,12 +318,17 @@ end
def define_call_history def define_call_history
putd "static void * call_history[FFF_CALL_HISTORY_LEN];" putd "extern void * call_history[FFF_CALL_HISTORY_LEN];"
putd "static unsigned int call_history_idx;" putd "extern unsigned int call_history_idx;"
putd "static void RESET_HISTORY() { " putd "void RESET_HISTORY();"
putd " call_history_idx = 0; " putd ""
putd "}" putd "#define DEFINE_FFF_GLOBALS \\"
putd " void * call_history[FFF_CALL_HISTORY_LEN]; \\"
putd " unsigned int call_history_idx; \\"
putd " void RESET_HISTORY() { \\"
putd " call_history_idx = 0; \\"
putd " } \\"
putd ""
putd "#define REGISTER_CALL(function) \\" putd "#define REGISTER_CALL(function) \\"
putd " if(call_history_idx < FFF_CALL_HISTORY_LEN) call_history[call_history_idx++] = (void *)function;" putd " if(call_history_idx < FFF_CALL_HISTORY_LEN) call_history[call_history_idx++] = (void *)function;"
end end
@@ -422,8 +427,8 @@ end
output_c_and_cpp{ output_c_and_cpp{
define_call_history define_call_history
output_cpp_reset_code if $cpp_output # output_cpp_reset_code if $cpp_output
output_cpp_static_initializer if $cpp_output # output_cpp_static_initializer if $cpp_output
$MAX_ARGS.times {|arg_count| output_macro(arg_count, false)} $MAX_ARGS.times {|arg_count| output_macro(arg_count, false)}
$MAX_ARGS.times {|arg_count| output_macro(arg_count, true)} $MAX_ARGS.times {|arg_count| output_macro(arg_count, true)}
} }