6 ? Source/Modules/mystuff
7 Index: Doc/Manual/Python.html
8 ===================================================================
9 RCS file: /cvsroot/swig/SWIG/Doc/Manual/Python.html,v
10 retrieving revision 1.20
11 diff -u -4 -r1.20 Python.html
12 --- Doc/Manual/Python.html 25 Oct 2004 20:42:08 -0000 1.20
13 +++ Doc/Manual/Python.html 23 Dec 2004 20:14:06 -0000
14 @@ -3869,10 +3869,10 @@
16 <H2><a name="Python_nn65"></a>26.10 Docstring Features</H2>
19 -Usign docstrings in Python code is becoming more and more important
20 -ans more tools are coming on the scene that take advantage of them,
21 +Using docstrings in Python code is becoming more and more important
22 +and more tools are coming on the scene that take advantage of them,
23 everything from full-blown documentaiton generators to class browsers
24 and popup call-tips in Python-aware IDEs. Given the way that SWIG
25 generates the proxy code by default, your users will normally get
26 something like <tt>"function_name(*args)"</tt> in the popup calltip of
27 Index: Source/Modules/python.cxx
28 ===================================================================
29 RCS file: /cvsroot/swig/SWIG/Source/Modules/python.cxx,v
30 retrieving revision 1.81
31 diff -u -4 -r1.81 python.cxx
32 --- Source/Modules/python.cxx 13 Dec 2004 22:12:47 -0000 1.81
33 +++ Source/Modules/python.cxx 23 Dec 2004 20:14:07 -0000
35 -modern - Use modern python features only, without compatibility code\n\
36 -apply - Use apply() in proxy classes\n\
37 -new_vwm - New value wrapper mode, use only when everything else fails \n\
38 -new_repr - Use more informative version of __repr__ in proxy classes\n\
39 - -old_repr - Use shorter ald old version of __repr__ in proxy classes\n\
40 + -old_repr - Use shorter and old version of __repr__ in proxy classes\n\
41 -noexcept - No automatic exception handling\n\
42 -noh - Don't generate the output header file\n\
43 -noproxy - Don't generate proxy classes \n\n";
47 // Do the param type too?
49 type = SwigType_base(type);
50 - lookup = Swig_symbol_clookup(type, 0);
51 - if (lookup) type = Getattr(lookup, "sym:name");
52 + SwigType* qt = SwigType_typedef_resolve_all(type);
53 + if (SwigType_isenum(qt))
54 + type = NewString("int");
56 + lookup = Swig_symbol_clookup(type, 0);
57 + if (lookup) type = Getattr(lookup, "sym:name");
59 Printf(doc, "%s ", type);
69 - Printf(doc, "Proxy of C++ %s class", class_name);
71 - Printf(doc, "Proxy of C %s struct", class_name);
74 + // Only do the autodoc if there isn't a docstring for the class
75 + String* str = Getattr(n, "feature:docstring");
76 + if (str == NULL || Len(str) == 0) {
78 + Printf(doc, "Proxy of C++ %s class", class_name);
80 + Printf(doc, "Proxy of C %s struct", class_name);
86 if ( Strcmp(class_name, symname) == 0) {
87 String* paramList = make_autodocParmList(n, showTypes);
88 @@ -1027,10 +1038,12 @@
89 Printf(methods,"\t { (char *)\"%s\", (PyCFunction) %s, METH_VARARGS | METH_KEYWORDS, ", name, function);
91 if (n && Getattr(n,"feature:callback")) {
92 if (have_docstring(n)) {
93 + String* ds = docstring(n, AUTODOC_FUNC, "", false);
94 + Replaceall(ds, "\n", "\\n");
95 Printf(methods,"(char *)\"%s\\nswig_ptr: %s\"",
96 - docstring(n, AUTODOC_FUNC, "", false),
98 Getattr(n,"feature:callback:name"));
100 Printf(methods,"(char *)\"swig_ptr: %s\"",Getattr(n,"feature:callback:name"));
102 @@ -1950,11 +1963,13 @@
103 Printf(f_shadow, modern ? "(object)" : "(_object)");
106 Printf(f_shadow,":\n");
107 - if ( have_docstring(n) )
108 - Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL);
110 + if ( have_docstring(n) ) {
111 + String* str = docstring(n, AUTODOC_CLASS, tab4);
112 + if (str != NULL && Len(str))
113 + Printv(f_shadow, tab4, str, "\n", NIL);
116 Printv(f_shadow,tab4,"__swig_setmethods__ = {}\n",NIL);
117 if (Len(base_class)) {
118 Printf(f_shadow,"%sfor _s in [%s]: __swig_setmethods__.update(_s.__swig_setmethods__)\n",tab4,base_class);
119 @@ -2139,11 +2154,11 @@
120 Replaceall(pycode,"$action", pyaction);
122 Printv(f_shadow,pycode,"\n",NIL);
124 - Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "): ", NIL);
125 + Printv(f_shadow, tab4, "def ", symname, "(*args", (allow_kwargs ? ", **kwargs" : ""), "):", NIL);
126 if (!have_addtofunc(n)) {
127 - Printv(f_shadow, "return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
128 + Printv(f_shadow, " return ", funcCallHelper(Swig_name_member(class_name,symname), allow_kwargs), "\n", NIL);
130 Printv(f_shadow, "\n", NIL);
131 if ( have_docstring(n) )
132 Printv(f_shadow, tab8, docstring(n, AUTODOC_METHOD, tab8), "\n", NIL);
133 @@ -2175,12 +2190,9 @@
139 - // static + autodoc/prepend/append + def args not working!!!, disable by now
141 - if (0 && !classic && !Getattr(n,"feature:python:callback") && have_addtofunc(n)) {
142 + if ( !classic && !Getattr(n,"feature:python:callback") && have_addtofunc(n)) {
143 int kw = (check_kwargs(n) && !Getattr(n,"sym:overloaded")) ? 1 : 0;
144 Printv(f_shadow, tab4, "def ", symname, "(*args", (kw ? ", **kwargs" : ""), "):\n", NIL);
145 if ( have_docstring(n) )
146 Printv(f_shadow, tab8, docstring(n, AUTODOC_STATICFUNC, tab8), "\n", NIL);
147 Index: Source/Swig/cwrap.c
148 ===================================================================
149 RCS file: /cvsroot/swig/SWIG/Source/Swig/cwrap.c,v
150 retrieving revision 1.51
151 diff -u -4 -r1.51 cwrap.c
152 --- Source/Swig/cwrap.c 4 Dec 2004 08:33:02 -0000 1.51
153 +++ Source/Swig/cwrap.c 23 Dec 2004 20:14:07 -0000
154 @@ -172,17 +172,26 @@
155 tycode = SwigType_type(type);
156 if (tycode == T_REFERENCE) {
159 - String *defname, *defvalue, *rvalue;
160 + String *defname, *defvalue, *rvalue, *qvalue;
161 rvalue = SwigType_typedef_resolve_all(pvalue);
162 + qvalue = SwigType_typedef_qualified(rvalue);
163 defname = NewStringf("%s_defvalue", lname);
165 SwigType_del_reference(tvalue);
166 - defvalue = NewStringf("%s = %s", SwigType_lstr(tvalue,defname), rvalue);
167 + tycode = SwigType_type(tvalue);
168 + if (tycode != T_USER) {
169 + /* plain primitive type, we copy the the def value */
170 + defvalue = NewStringf("%s = %s", SwigType_lstr(tvalue,defname),qvalue);
172 + /* user type, we copy the reference value */
173 + defvalue = NewStringf("%s = %s",SwigType_str(type,defname),qvalue);
175 Wrapper_add_localv(w,defname, defvalue, NIL);
182 } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) {