Fix SF#2552488: indentation adjust of %pythonappend and %pythonprepend

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11100 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Haoyu Bai 2009-01-31 14:37:54 +00:00
commit afd67f8c67
5 changed files with 57 additions and 16 deletions

View file

@ -1,5 +1,9 @@
Version 1.3.38 (in progress) Version 1.3.38 (in progress)
================================ ================================
2008-01-31: bhy
[Python] Fix SF#2552488 reported by Gaetan Lehmann. Now %pythonprepend
and %pythonappend have correct indentation.
2008-01-31: bhy 2008-01-31: bhy
[Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list [Python] Fix SF#2552048 reported by Gaetan Lehmann. The parameter list
of static member function in generated proxy code should not have the of static member function in generated proxy code should not have the

View file

@ -32,6 +32,7 @@ PY2TO3 = 2to3 -x import
CPP_TEST_CASES += \ CPP_TEST_CASES += \
argcargvtest \ argcargvtest \
python_autodoc \ python_autodoc \
python_append \
callback \ callback \
complextest \ complextest \
director_stl \ director_stl \

View file

@ -0,0 +1,4 @@
from python_append import *
t=Test()
t.func()
t.static_func()

View file

@ -0,0 +1,32 @@
/*
Testcase to test %pythonprepend and %pythonappend
*/
%module python_append
%pythonappend Test::func %{
pass
%}
%pythonprepend Test::func %{
pass
%}
%pythonappend Test::static_func %{
pass
%}
%pythonprepend Test::static_func {
pass
}
%inline %{
class Test {
public:
static void static_func() {};
void func() {};
};
%}

View file

@ -958,7 +958,7 @@ public:
* pythoncode() - Output python code into the shadow file * pythoncode() - Output python code into the shadow file
* ------------------------------------------------------------ */ * ------------------------------------------------------------ */
String *pythoncode(String *code, const String *indent) { String *pythoncode(String *code, const_String_or_char_ptr indent) {
String *out = NewString(""); String *out = NewString("");
String *temp; String *temp;
char *t; char *t;
@ -1645,10 +1645,10 @@ public:
if (have_docstring(n)) if (have_docstring(n))
Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL); Printv(f_dest, " ", docstring(n, AUTODOC_FUNC, tab4), "\n", NIL);
if (have_pythonprepend(n)) if (have_pythonprepend(n))
Printv(f_dest, " ", pythonprepend(n), "\n", NIL); Printv(f_dest, pythoncode(pythonprepend(n), " "), "\n", NIL);
if (have_pythonappend(n)) { if (have_pythonappend(n)) {
Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL); Printv(f_dest, " val = ", funcCall(name, callParms), "\n", NIL);
Printv(f_dest, " ", pythonappend(n), "\n", NIL); Printv(f_dest, pythoncode(pythonappend(n), " "), "\n", NIL);
Printv(f_dest, " return val\n", NIL); Printv(f_dest, " return val\n", NIL);
} else { } else {
Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL); Printv(f_dest, " return ", funcCall(name, callParms), "\n", NIL);
@ -3118,12 +3118,12 @@ public:
Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL); Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
if (have_pythonprepend(n)) { if (have_pythonprepend(n)) {
fproxy = 0; fproxy = 0;
Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
} }
if (have_pythonappend(n)) { if (have_pythonappend(n)) {
fproxy = 0; fproxy = 0;
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL);
} else { } else {
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL);
@ -3165,10 +3165,10 @@ public:
if (have_docstring(n)) if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL); Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
if (have_pythonprepend(n)) if (have_pythonprepend(n))
Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
if (have_pythonappend(n)) { if (have_pythonappend(n)) {
Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL); Printv(f_shadow, tab8, "val = ", funcCall(Swig_name_member(class_name, symname), callParms), "\n", NIL);
Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "return val\n\n", NIL); Printv(f_shadow, tab8, "return val\n\n", NIL);
} else { } else {
Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL); Printv(f_shadow, tab8, "return ", funcCall(Swig_name_member(class_name, symname), callParms), "\n\n", NIL);
@ -3275,7 +3275,7 @@ public:
if (have_docstring(n)) if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL); Printv(f_shadow, tab8, docstring(n, AUTODOC_CTOR, tab8), "\n", NIL);
if (have_pythonprepend(n)) if (have_pythonprepend(n))
Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
Printv(f_shadow, pass_self, NIL); Printv(f_shadow, pass_self, NIL);
if (fastinit) { if (fastinit) {
Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL); Printv(f_shadow, tab8, module, ".", class_name, "_swiginit(self,", funcCall(Swig_name_construct(symname), callParms), ")\n", NIL);
@ -3285,7 +3285,7 @@ public:
tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL); tab8, "try: self.this.append(this)\n", tab8, "except: self.this = this\n", NIL);
} }
if (have_pythonappend(n)) if (have_pythonappend(n))
Printv(f_shadow, tab8, pythonappend(n), "\n\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n\n", NIL);
Delete(pass_self); Delete(pass_self);
} }
have_constructor = 1; have_constructor = 1;
@ -3308,13 +3308,13 @@ public:
if (have_docstring(n)) if (have_docstring(n))
Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL); Printv(f_shadow_stubs, tab4, docstring(n, AUTODOC_CTOR, tab4), "\n", NIL);
if (have_pythonprepend(n)) if (have_pythonprepend(n))
Printv(f_shadow_stubs, tab4, pythonprepend(n), "\n", NIL); Printv(f_shadow_stubs, pythoncode(pythonprepend(n), tab4), "\n", NIL);
Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL); Printv(f_shadow_stubs, tab4, "val = ", funcCall(Swig_name_construct(symname), callParms), "\n", NIL);
#ifdef USE_THISOWN #ifdef USE_THISOWN
Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL); Printv(f_shadow_stubs, tab4, "val.thisown = 1\n", NIL);
#endif #endif
if (have_pythonappend(n)) if (have_pythonappend(n))
Printv(f_shadow_stubs, tab4, pythonappend(n), "\n", NIL); Printv(f_shadow_stubs, pythoncode(pythonappend(n), tab4), "\n", NIL);
Printv(f_shadow_stubs, tab4, "return val\n", NIL); Printv(f_shadow_stubs, tab4, "return val\n", NIL);
} }
} }
@ -3356,7 +3356,7 @@ public:
if (have_docstring(n)) if (have_docstring(n))
Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL); Printv(f_shadow, tab8, docstring(n, AUTODOC_DTOR, tab8), "\n", NIL);
if (have_pythonprepend(n)) if (have_pythonprepend(n))
Printv(f_shadow, tab8, pythonprepend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonprepend(n), tab8), "\n", NIL);
#ifdef USE_THISOWN #ifdef USE_THISOWN
Printv(f_shadow, tab8, "try:\n", NIL); Printv(f_shadow, tab8, "try:\n", NIL);
Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL); Printv(f_shadow, tab8, tab4, "if self.thisown: ", module, ".", Swig_name_destroy(symname), "(self)\n", NIL);
@ -3364,7 +3364,7 @@ public:
#else #else
#endif #endif
if (have_pythonappend(n)) if (have_pythonappend(n))
Printv(f_shadow, tab8, pythonappend(n), "\n", NIL); Printv(f_shadow, pythoncode(pythonappend(n), tab8), "\n", NIL);
Printv(f_shadow, tab8, "pass\n", NIL); Printv(f_shadow, tab8, "pass\n", NIL);
Printv(f_shadow, "\n", NIL); Printv(f_shadow, "\n", NIL);
} }