Merge branch 'flatstaticmember'
* flatstaticmember: Test -flatstaticmethod and %extend Python -flatstaticmethod corrections Enable flat static constructor methods Move low level static methods Use flat static method if it's a "friend" Python: Option to generate flat class methods
This commit is contained in:
commit
9fd2356104
7 changed files with 67 additions and 34 deletions
|
|
@ -100,7 +100,7 @@ LIBS = -L.
|
|||
VALGRIND_OPT += --suppressions=pythonswig.supp
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
#python_flatstaticmethod.cpptest: SWIGOPT += -flatstaticmethod
|
||||
python_flatstaticmethod.cpptest: SWIGOPT += -flatstaticmethod
|
||||
|
||||
# Rules for the different types of tests
|
||||
%.cpptest:
|
||||
|
|
|
|||
|
|
@ -63,12 +63,8 @@ check(inspect.getdoc(A.func3default),
|
|||
|
||||
check(inspect.getdoc(A.func0static),
|
||||
"func0static(e, arg2, hello, f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func0static),
|
||||
"A_func0static(e, arg2, hello, f=2) -> int")
|
||||
check(inspect.getdoc(A.func1static),
|
||||
"func1static(A e, short arg2, Tuple hello, double f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func1static),
|
||||
"A_func1static(A e, short arg2, Tuple hello, double f=2) -> int")
|
||||
check(inspect.getdoc(A.func2static),
|
||||
"func2static(e, arg2, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
|
|
@ -78,15 +74,6 @@ check(inspect.getdoc(A.func2static),
|
|||
"arg2: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func2static),
|
||||
"A_func2static(e, arg2, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(A.func3static),
|
||||
"func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
|
|
@ -96,15 +83,6 @@ check(inspect.getdoc(A.func3static),
|
|||
"arg2: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func3static),
|
||||
"A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
|
||||
check(inspect.getdoc(A.variable_a),
|
||||
"variable_a"
|
||||
|
|
@ -119,7 +97,7 @@ check(inspect.getdoc(A.variable_d),
|
|||
"variable_d : int"
|
||||
)
|
||||
|
||||
# Check the low-level functions (not present when using -builtin except for the static ones)
|
||||
# Check the low-level functions (not present when using -builtin)
|
||||
if not is_python_builtin():
|
||||
check(inspect.getdoc(_autodoc.A_funk), "just a string.")
|
||||
check(inspect.getdoc(_autodoc.A_func0),
|
||||
|
|
@ -162,6 +140,28 @@ if not is_python_builtin():
|
|||
"arg3: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func0static),
|
||||
"A_func0static(e, arg2, hello, f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func1static),
|
||||
"A_func1static(A e, short arg2, Tuple hello, double f=2) -> int")
|
||||
check(inspect.getdoc(_autodoc.A_func2static),
|
||||
"A_func2static(e, arg2, hello, f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_func3static),
|
||||
"A_func3static(A e, short arg2, Tuple hello, double f=2) -> int\n"
|
||||
"\n"
|
||||
"Parameters\n"
|
||||
"----------\n"
|
||||
"e: A *\n"
|
||||
"arg2: short\n"
|
||||
"hello: int tuple[2]\n"
|
||||
"f: double")
|
||||
check(inspect.getdoc(_autodoc.A_variable_a_set), "A_variable_a_set(self, variable_a)")
|
||||
check(inspect.getdoc(_autodoc.A_variable_a_get), "A_variable_a_get(self) -> int" )
|
||||
check(inspect.getdoc(_autodoc.A_variable_b_set), "A_variable_b_set(A self, int variable_b)")
|
||||
|
|
|
|||
|
|
@ -83,3 +83,10 @@ if A.defargs(1) != 21:
|
|||
|
||||
if A.defargs(1, 2) != 3:
|
||||
raise RuntimeError
|
||||
|
||||
# %extend
|
||||
if A_staticextended(11) != 11:
|
||||
raise RuntimeError
|
||||
|
||||
if A.staticextended(11) != 11:
|
||||
raise RuntimeError
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
%typemap(in) (int c, int d) "$1 = 0; $2 = 0;";
|
||||
%typemap(doc,name="hello",type="Tuple") (int c, int d) "hello: int tuple[2]";
|
||||
|
||||
%extend A {
|
||||
static int staticextended(int i) { return i; }
|
||||
}
|
||||
|
||||
%inline %{
|
||||
struct A {
|
||||
static int bar(int a) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue