]>
Commit | Line | Data |
---|---|---|
3c1705d9 RD |
1 | ? .configure |
2 | ? .emacs.desktop | |
3 | ? .test | |
4 | ? mytests | |
5 | ? switch_cvs.py | |
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 @@ | |
15 | ||
16 | <H2><a name="Python_nn65"></a>26.10 Docstring Features</H2> | |
17 | ||
18 | ||
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 | |
34 | @@ -74,9 +74,9 @@ | |
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"; | |
44 | ||
45 | @@ -749,10 +749,15 @@ | |
46 | ||
47 | // Do the param type too? | |
48 | if (showTypes) { | |
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"); | |
55 | + else { | |
56 | + lookup = Swig_symbol_clookup(type, 0); | |
57 | + if (lookup) type = Getattr(lookup, "sym:name"); | |
58 | + } | |
59 | Printf(doc, "%s ", type); | |
60 | } | |
61 | ||
62 | if (name) { | |
63 | @@ -853,13 +858,19 @@ | |
64 | } | |
65 | ||
66 | switch ( ad_type ) { | |
67 | case AUTODOC_CLASS: | |
68 | - if (CPlusPlus) { | |
69 | - Printf(doc, "Proxy of C++ %s class", class_name); | |
70 | - } else { | |
71 | - Printf(doc, "Proxy of C %s struct", class_name); | |
72 | - } | |
73 | + { | |
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) { | |
77 | + if (CPlusPlus) { | |
78 | + Printf(doc, "Proxy of C++ %s class", class_name); | |
79 | + } else { | |
80 | + Printf(doc, "Proxy of C %s struct", class_name); | |
81 | + } | |
82 | + } | |
83 | + } | |
84 | break; | |
85 | case AUTODOC_CTOR: | |
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); | |
90 | ||
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), | |
97 | + ds, | |
98 | Getattr(n,"feature:callback:name")); | |
99 | } else { | |
100 | Printf(methods,"(char *)\"swig_ptr: %s\"",Getattr(n,"feature:callback:name")); | |
101 | } | |
102 | @@ -1950,11 +1963,13 @@ | |
103 | Printf(f_shadow, modern ? "(object)" : "(_object)"); | |
104 | } | |
105 | } | |
106 | Printf(f_shadow,":\n"); | |
107 | - if ( have_docstring(n) ) | |
108 | - Printv(f_shadow, tab4, docstring(n, AUTODOC_CLASS, tab4), "\n", NIL); | |
109 | - | |
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); | |
114 | + } | |
115 | if (!modern) { | |
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); | |
121 | Delete(pyaction); | |
122 | Printv(f_shadow,pycode,"\n",NIL); | |
123 | } else { | |
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); | |
129 | } else { | |
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 @@ | |
134 | return SWIG_OK; | |
135 | } | |
136 | ||
137 | if (shadow) { | |
138 | - // | |
139 | - // static + autodoc/prepend/append + def args not working!!!, disable by now | |
140 | - // | |
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) { | |
157 | if (pvalue) { | |
158 | SwigType *tvalue; | |
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); | |
164 | tvalue = Copy(type); | |
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); | |
171 | + } else { | |
172 | + /* user type, we copy the reference value */ | |
173 | + defvalue = NewStringf("%s = %s",SwigType_str(type,defname),qvalue); | |
174 | + } | |
175 | Wrapper_add_localv(w,defname, defvalue, NIL); | |
176 | Delete(tvalue); | |
177 | Delete(rvalue); | |
178 | + Delete(qvalue); | |
179 | Delete(defname); | |
180 | Delete(defvalue); | |
181 | } | |
182 | } else if (!pvalue && ((tycode == T_POINTER) || (tycode == T_STRING))) { |