mirror of
https://github.com/meekrosoft/fff
synced 2026-01-23 00:15:59 +01:00
Fix fakegen.rb C header generator for M macro compatibility.
This commit is contained in:
20
fakegen.rb
20
fakegen.rb
@@ -405,6 +405,11 @@ def include_guard
|
||||
putd "#endif /* FAKE_FUNCTIONS */"
|
||||
end
|
||||
|
||||
def msvc_expand_macro_fix
|
||||
putd "/* MSVC expand macro fix */"
|
||||
putd "#define EXPAND(x) x"
|
||||
end
|
||||
|
||||
def generate_arg_sequence(args, prefix, do_reverse, joinstr)
|
||||
fmap = (0..args).flat_map {|i| [prefix + i.to_s]}
|
||||
if do_reverse then fmap.reverse.join(joinstr) else fmap.join(", ") end
|
||||
@@ -416,25 +421,26 @@ def counting_macro_instance(type, vararg = :non_vararg, prefix = "")
|
||||
|
||||
<<-MACRO_COUNTING_INSTANCE
|
||||
#define #{prefix}FAKE_#{type.to_s}_FUNC#{appendix}(...) \
|
||||
#{prefix}FUNC_#{type.to_s}#{appendix}_(PP_NARG_MINUS#{minus_count}(__VA_ARGS__), __VA_ARGS__)
|
||||
EXPAND(#{prefix}FUNC_#{type.to_s}#{appendix}_(PP_NARG_MINUS#{minus_count}(__VA_ARGS__), __VA_ARGS__))
|
||||
|
||||
#define #{prefix}FUNC_#{type.to_s}#{appendix}_(N,...) \
|
||||
#{prefix}FUNC_#{type.to_s}#{appendix}_N(N,__VA_ARGS__)
|
||||
EXPAND(#{prefix}FUNC_#{type.to_s}#{appendix}_N(N,__VA_ARGS__))
|
||||
|
||||
#define #{prefix}FUNC_#{type.to_s}#{appendix}_N(N,...) \
|
||||
#{prefix}FAKE_#{type.to_s}_FUNC ## N#{" ## _VARARG" if vararg == :vararg}(__VA_ARGS__)
|
||||
EXPAND(#{prefix}FAKE_#{type.to_s}_FUNC ## N#{" ## _VARARG" if vararg == :vararg}(__VA_ARGS__))
|
||||
|
||||
MACRO_COUNTING_INSTANCE
|
||||
end
|
||||
|
||||
def output_macro_counting_shortcuts
|
||||
msvc_expand_macro_fix
|
||||
putd <<-MACRO_COUNTING
|
||||
|
||||
#define PP_NARG_MINUS2(...) \
|
||||
PP_NARG_MINUS2_(__VA_ARGS__, PP_RSEQ_N_MINUS2())
|
||||
EXPAND(PP_NARG_MINUS2_(__VA_ARGS__, PP_RSEQ_N_MINUS2()))
|
||||
|
||||
#define PP_NARG_MINUS2_(...) \
|
||||
PP_ARG_MINUS2_N(__VA_ARGS__)
|
||||
EXPAND(PP_ARG_MINUS2_N(__VA_ARGS__))
|
||||
|
||||
#define PP_ARG_MINUS2_N(returnVal, #{generate_arg_sequence($MAX_ARGS, '_', false, ", ")}, N, ...) N
|
||||
|
||||
@@ -443,10 +449,10 @@ def output_macro_counting_shortcuts
|
||||
|
||||
|
||||
#define PP_NARG_MINUS1(...) \
|
||||
PP_NARG_MINUS1_(__VA_ARGS__, PP_RSEQ_N_MINUS1())
|
||||
EXPAND(PP_NARG_MINUS1_(__VA_ARGS__, PP_RSEQ_N_MINUS1()))
|
||||
|
||||
#define PP_NARG_MINUS1_(...) \
|
||||
PP_ARG_MINUS1_N(__VA_ARGS__)
|
||||
EXPAND(PP_ARG_MINUS1_N(__VA_ARGS__))
|
||||
|
||||
#define PP_ARG_MINUS1_N(#{generate_arg_sequence($MAX_ARGS, '_', false, ", ")}, N, ...) N
|
||||
|
||||
|
||||
Reference in New Issue
Block a user