Fix C default arguments with -builtin and -fastunpack and -modernargs.
Problem occurred when there is just one (defaulted) parameter in the parameter list. Closes #1126
This commit is contained in:
parent
142d4062df
commit
18383340e9
4 changed files with 58 additions and 6 deletions
|
|
@ -20,3 +20,30 @@ int foo43(int x) {
|
|||
return x;
|
||||
}
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
struct FooStruct {};
|
||||
%}
|
||||
%extend FooStruct {
|
||||
void no_arg() {}
|
||||
void one_req(int *required) {}
|
||||
void one_opt(int *optional = NULL) {}
|
||||
void two_arg(int *required, int *optional = NULL) {}
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct StaticStruct {};
|
||||
%}
|
||||
%extend StaticStruct {
|
||||
static void no_arg() {}
|
||||
static void one_req(int *required) {}
|
||||
static void one_opt(int *optional = NULL) {}
|
||||
static void two_arg(int *required, int *optional = NULL) {}
|
||||
}
|
||||
|
||||
%{
|
||||
void global_opts1(int *optional) {}
|
||||
void global_opts2(int *required, int *optional) {}
|
||||
%}
|
||||
void global_opts1(int *optional = NULL) {}
|
||||
void global_opts2(int *required, int *optional = NULL) {}
|
||||
|
|
|
|||
|
|
@ -4,3 +4,23 @@ if default_args_c.foo1() != 1:
|
|||
raise RuntimeError("failed")
|
||||
if default_args_c.foo43() != 43:
|
||||
raise RuntimeError("failed")
|
||||
|
||||
f = default_args_c.FooStruct()
|
||||
f.no_arg()
|
||||
f.one_req(None)
|
||||
f.one_opt()
|
||||
f.one_opt(None)
|
||||
f.two_arg(None)
|
||||
f.two_arg(None, None)
|
||||
|
||||
default_args_c.StaticStruct.no_arg()
|
||||
default_args_c.StaticStruct.one_req(None)
|
||||
default_args_c.StaticStruct.one_opt()
|
||||
default_args_c.StaticStruct.one_opt(None)
|
||||
default_args_c.StaticStruct.two_arg(None)
|
||||
default_args_c.StaticStruct.two_arg(None, None)
|
||||
|
||||
default_args_c.global_opts1()
|
||||
default_args_c.global_opts1(None)
|
||||
default_args_c.global_opts2(None)
|
||||
default_args_c.global_opts2(None, None)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue