Skip to content

Commit

Permalink
Replace empty putd with puts
Browse files Browse the repository at this point in the history
  • Loading branch information
usr42 committed Jan 26, 2017
1 parent 49c814f commit 985fbe3
Show file tree
Hide file tree
Showing 2 changed files with 106 additions and 106 deletions.
52 changes: 26 additions & 26 deletions fakegen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
def include_dependencies
putd "#include <stdarg.h>"
putd "#include <string.h> /* For memset and memcpy */"
putd ""
puts
end

def output_constants
Expand Down Expand Up @@ -53,7 +53,7 @@ def output_internal_helper_macros
define_reset_fake_helper

putd "/* -- END INTERNAL HELPER MACROS -- */"
putd ""
puts
end

def define_return_sequence_helper
Expand All @@ -73,18 +73,18 @@ def define_custom_fake_sequence_helper
end

def define_reset_fake_macro
putd ""
puts
putd "/* Defining a function to reset a fake function */"
putdml("#define RESET_FAKE(FUNCNAME) {")
indent {
putdml("FUNCNAME##_reset();")
}
putdml("}")
putd ""
puts
end

def define_declare_arg_helper
putd ""
puts
putdml("#define DECLARE_ARG(type, n, FUNCNAME)")
indent {
putdml("type arg##n##_val;")
Expand All @@ -93,7 +93,7 @@ def define_declare_arg_helper
end

def define_declare_all_func_common_helper
putd ""
puts
putdml("#define DECLARE_ALL_FUNC_COMMON")
indent {
putdml("unsigned int call_count;")
Expand All @@ -103,39 +103,39 @@ def define_declare_all_func_common_helper
end

def define_save_arg_helper
putd ""
puts
putdml("#define SAVE_ARG(FUNCNAME, n)")
indent {
putd "memcpy((void*)&FUNCNAME##_fake.arg##n##_val, (void*)&arg##n, sizeof(arg##n));"
}
end

def define_room_for_more_history
putd ""
puts
putdml("#define ROOM_FOR_MORE_HISTORY(FUNCNAME)")
indent {
putd "FUNCNAME##_fake.call_count < FFF_ARG_HISTORY_LEN"
}
end

def define_save_arg_history_helper
putd ""
puts
putdml("#define SAVE_ARG_HISTORY(FUNCNAME, ARGN)")
indent {
putd "memcpy((void*)&FUNCNAME##_fake.arg##ARGN##_history[FUNCNAME##_fake.call_count], (void*)&arg##ARGN, sizeof(arg##ARGN));"
}
end

def define_history_dropped_helper
putd ""
puts
putdml("#define HISTORY_DROPPED(FUNCNAME)")
indent {
putd "FUNCNAME##_fake.arg_histories_dropped++"
}
end

def define_value_function_variables_helper
putd ""
puts
putdml("#define DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE)")
indent {
putdml("RETURN_TYPE return_val;")
Expand All @@ -146,7 +146,7 @@ def define_value_function_variables_helper
end

def define_custom_fake_seq_variables_helper
putd ""
puts
putdml("#define DECLARE_CUSTOM_FAKE_SEQ_VARIABLES")
indent {
putdml("int custom_fake_seq_len;")
Expand All @@ -155,15 +155,15 @@ def define_custom_fake_seq_variables_helper
end

def define_increment_call_count_helper
putd ""
puts
putdml("#define INCREMENT_CALL_COUNT(FUNCNAME)")
indent {
putd "FUNCNAME##_fake.call_count++"
}
end

def define_return_fake_result_helper
putd ""
puts
putdml("#define RETURN_FAKE_RESULT(FUNCNAME)")
indent {
putdml("if (FUNCNAME##_fake.return_val_seq_len){ /* then its a sequence */")
Expand All @@ -181,7 +181,7 @@ def define_return_fake_result_helper
end

def define_extern_c_helper
putd ""
puts
putd "#ifdef __cplusplus"
indent {
putd "#define FFF_EXTERN_C extern \"C\"{"
Expand All @@ -196,7 +196,7 @@ def define_extern_c_helper
end

def define_reset_fake_helper
putd ""
puts
putdml("#define DEFINE_RESET_FUNCTION(FUNCNAME)")
indent {
putdml("void FUNCNAME##_reset(){")
Expand Down Expand Up @@ -244,15 +244,15 @@ def output_macro(arg_count, has_varargs, is_value_function)
saved_arg_count = arg_count - (has_varargs ? 1 : 0)
return_type = is_value_function ? "RETURN_TYPE" : ""

putd ""
puts
output_macro_header(declare_macro_name, saved_arg_count, has_varargs, return_type)
indent {
extern_c { # define argument capture variables
output_variables(saved_arg_count, has_varargs, is_value_function)
}
}

putd ""
puts
output_macro_header(define_macro_name, saved_arg_count, has_varargs, return_type)
indent {
extern_c {
Expand All @@ -266,13 +266,13 @@ def output_macro(arg_count, has_varargs, is_value_function)
}
}

putd ""
puts

output_macro_header(fake_macro_name, saved_arg_count, has_varargs, return_type)
indent {
putd macro_signature_for(declare_macro_name, saved_arg_count, has_varargs, return_type)
putd macro_signature_for(define_macro_name, saved_arg_count, has_varargs, return_type)
putd ""
puts
}
end

Expand Down Expand Up @@ -426,11 +426,11 @@ def define_fff_globals
putd "unsigned int call_history_idx;"
}
putd "} fff_globals_t;"
putd ""
puts
putdml("FFF_EXTERN_C")
putd "extern fff_globals_t fff;"
putdml("FFF_END_EXTERN_C")
putd ""
puts
putdml("#define DEFINE_FFF_GLOBALS")
indent {
putdml("FFF_EXTERN_C")
Expand All @@ -439,9 +439,9 @@ def define_fff_globals
}
putd "FFF_END_EXTERN_C"
}
putd ""
puts
putd "#define FFF_RESET_HISTORY() fff.call_history_idx = 0;"
putd ""
puts
putdml("#define REGISTER_CALL(function)")
indent {
putdml("if(fff.call_history_idx < FFF_CALL_HISTORY_LEN)")
Expand Down Expand Up @@ -470,11 +470,11 @@ def in_struct
def include_guard
putd "#ifndef FAKE_FUNCTIONS"
putd "#define FAKE_FUNCTIONS"
putd ""
puts

yield

putd ""
puts
putd "#endif /* FAKE_FUNCTIONS */"
end

Expand Down
Loading

0 comments on commit 985fbe3

Please sign in to comment.