[Python] Fix lack of generation of docstrings when -O is used.

Also, fix generation of docstrings containing a double quote
character.  Patch from Richard Boulton in bug#1700146.


git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9684 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Olly Betts 2007-04-20 01:16:31 +00:00
commit 898e5f7f3d
8 changed files with 66 additions and 2 deletions

View file

@ -1419,19 +1419,26 @@ public:
Printf(methods, "\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function);
}
if (n && Getattr(n, "feature:callback")) {
if (!n) {
Append(methods, "NULL");
} else if (Getattr(n, "feature:callback")) {
if (have_docstring(n)) {
String *ds = docstring(n, AUTODOC_FUNC, "", false);
Replaceall(ds, "\n", "\\n");
Replaceall(ds, "\"", "\\\"");
Printf(methods, "(char *)\"%s\\nswig_ptr: %s\"", ds, Getattr(n, "feature:callback:name"));
} else {
Printf(methods, "(char *)\"swig_ptr: %s\"", Getattr(n, "feature:callback:name"));
}
} else if (have_docstring(n)) {
String *ds = docstring(n, AUTODOC_FUNC, "", false);
Replaceall(ds, "\n", "\\n");
Replaceall(ds, "\"", "\\\"");
Printf(methods, "(char *)\"%s\"", ds);
} else {
Append(methods, "NULL");
}
Append(methods, "},\n");
}