Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion fakegen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ def include_dependencies
putd "#include <stdarg.h>"
putd "#include <string.h> /* For memset and memcpy */"
puts
putd "#ifdef __cplusplus"
putd "#include <type_traits>"
putd "#endif"
puts
end

def output_constants
Expand Down Expand Up @@ -45,6 +49,7 @@ def output_internal_helper_macros
define_return_sequence_helper
define_custom_fake_sequence_helper
define_reset_fake_macro
define_normalize_arg_types
define_declare_arg_helper
define_declare_all_func_common_helper
define_declare_return_value_history
Expand Down Expand Up @@ -91,6 +96,27 @@ def define_reset_fake_macro
puts
end

def define_normalize_arg_types
puts
putd "#ifdef __cplusplus"
indent {
putd_backslash "#define FFF_NORMALIZE_TYPE(TYPE, n, FUNCNAME)"
indent {
putd_backslash "typedef std::remove_const<TYPE>::type FUNCNAME##_arg##n;"
}
puts
}
putd "#else /* ansi c */"
indent {
putd_backslash "#define FFF_NORMALIZE_TYPE(TYPE, n, FUNCNAME)"
indent {
putd_backslash "typedef TYPE FUNCNAME##_arg##n;"
}
puts
}
putd "#endif /* cpp/ansi c */"
end

def define_declare_arg_helper
puts
putd_backslash "#define DECLARE_ARG(type, n, FUNCNAME)"
Expand Down Expand Up @@ -331,9 +357,12 @@ def macro_signature_for(macro_name, arg_count, has_varargs, has_calling_conventi
end

def output_variables(arg_count, has_varargs, has_calling_conventions, is_value_function)
arg_count.times { |argN|
putd_backslash "FFF_NORMALIZE_TYPE(ARG#{argN}_TYPE, #{argN}, FUNCNAME)"
}
in_struct{
arg_count.times { |argN|
putd_backslash "DECLARE_ARG(ARG#{argN}_TYPE, #{argN}, FUNCNAME)"
putd_backslash "DECLARE_ARG(FUNCNAME##_arg#{argN}, #{argN}, FUNCNAME)"
}
putd_backslash "DECLARE_ALL_FUNC_COMMON"
putd_backslash "DECLARE_VALUE_FUNCTION_VARIABLES(RETURN_TYPE)" unless not is_value_function
Expand Down
Loading