reenable autodoc for static methods + cosmetics

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6913 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Marcelo Matus 2004-12-22 20:34:15 +00:00
commit 3e64c5b3c2

View file

@ -75,7 +75,7 @@ Python Options (available with -python)\n\
-apply - Use apply() in proxy classes\n\ -apply - Use apply() in proxy classes\n\
-new_vwm - New value wrapper mode, use only when everything else fails \n\ -new_vwm - New value wrapper mode, use only when everything else fails \n\
-new_repr - Use more informative version of __repr__ in proxy classes\n\ -new_repr - Use more informative version of __repr__ in proxy classes\n\
-old_repr - Use shorter ald old version of __repr__ in proxy classes\n\ -old_repr - Use shorter and old version of __repr__ in proxy classes\n\
-noexcept - No automatic exception handling\n\ -noexcept - No automatic exception handling\n\
-noh - Don't generate the output header file\n\ -noh - Don't generate the output header file\n\
-noproxy - Don't generate proxy classes \n\n"; -noproxy - Don't generate proxy classes \n\n";
@ -854,11 +854,17 @@ public:
switch ( ad_type ) { switch ( ad_type ) {
case AUTODOC_CLASS: case AUTODOC_CLASS:
if (CPlusPlus) { {
Printf(doc, "Proxy of C++ %s class", class_name); // Only do the autodoc if there isn't a docstring for the class
} else { String* str = Getattr(n, "feature:docstring");
Printf(doc, "Proxy of C %s struct", class_name); if (str == NULL || Len(str) == 0) {
} if (CPlusPlus) {
Printf(doc, "Proxy of C++ %s class", class_name);
} else {
Printf(doc, "Proxy of C %s struct", class_name);
}
}
}
break; break;
case AUTODOC_CTOR: case AUTODOC_CTOR:
if ( Strcmp(class_name, symname) == 0) { if ( Strcmp(class_name, symname) == 0) {
@ -1028,8 +1034,10 @@ public:
if (n && Getattr(n,"feature:callback")) { if (n && Getattr(n,"feature:callback")) {
if (have_docstring(n)) { if (have_docstring(n)) {
String* ds = docstring(n, AUTODOC_FUNC, "", false);
Replaceall(ds, "\n", "\\n");
Printf(methods,"(char *)\"%s\\nswig_ptr: %s\"", Printf(methods,"(char *)\"%s\\nswig_ptr: %s\"",
docstring(n, AUTODOC_FUNC, "", false), ds,
Getattr(n,"feature:callback:name")); Getattr(n,"feature:callback:name"));
} else { } else {
Printf(methods,"(char *)\"swig_ptr: %s\"",Getattr(n,"feature:callback:name")); Printf(methods,"(char *)\"swig_ptr: %s\"",Getattr(n,"feature:callback:name"));
@ -1951,9 +1959,11 @@ public:
} }
} }
Printf(f_shadow,":\n"); Printf(f_shadow,":\n");
if ( have_docstring(n) ) if ( have_docstring(n) ) {
Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL); String* str = docstring(n, AUTODOC_CLASS, tab4);
if (str != NULL && Len(str))
Printv(f_shadow, tab4, str, "\n", NIL);
}
if (!modern) { if (!modern) {
Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL); Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
if (Len(base_class)) { if (Len(base_class)) {
@ -2140,9 +2150,9 @@ public:
Delete(pyaction); Delete(pyaction);
Printv(f_shadow,pycode,"\n",NIL); Printv(f_shadow,pycode,"\n",NIL);
} else { } else {
Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL); Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
if (!have_addtofunc(n)) { if (!have_addtofunc(n)) {
Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL); Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
} else { } else {
Printv(f_shadow, "\n", NIL); Printv(f_shadow, "\n", NIL);
if ( have_docstring(n) ) if ( have_docstring(n) )
@ -2176,10 +2186,7 @@ public:
} }
if (shadow) { if (shadow) {
// if ( !classic && !Getattr(n,"feature:python:callback") && have_addtofunc(n)) {
// static + autodoc/prepend/append + def args not working!!!, disable by now
//
if (0 && !classic && !Getattr(n,"feature:python:callback") && have_addtofunc(n)) {
int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0; int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0;
Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL); Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
if ( have_docstring(n) ) if ( have_docstring(n) )