merge from trunk

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11360 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Baozeng Ding 2009-07-04 06:48:39 +00:00
commit 84aecae48a
44 changed files with 366 additions and 188 deletions

View file

@ -1025,7 +1025,7 @@ Deletes <tt>s</tt>.
</div>
<p>
<b><tt>int Len(String_or_char *s)</tt></b>
<b><tt>int Len(const String_or_char *s)</tt></b>
</p>
<div class="indent">
@ -1033,7 +1033,7 @@ Returns the length of the string.
</div>
<p>
<b><tt>char *Char(String_or_char *s)</tt></b>
<b><tt>char *Char(const String_or_char *s)</tt></b>
</p>
<div class="indent">
@ -1041,7 +1041,7 @@ Returns a pointer to the first character in a string.
</div>
<p>
<b><tt>void Append(String *s, String_or_char *t)</tt></b>
<b><tt>void Append(String *s, const String_or_char *t)</tt></b>
</p>
<div class="indent">
@ -1049,7 +1049,7 @@ Appends <tt>t</tt> to the end of string <tt>s</tt>.
</div>
<p>
<b><tt>void Insert(String *s, int pos, String_or_char *t)</tt></b>
<b><tt>void Insert(String *s, int pos, const String_or_char *t)</tt></b>
</p>
<div class="indent">
@ -1162,7 +1162,7 @@ Returns the number of items in <tt>h</tt>.
</div>
<p>
<b><tt>Object *Getattr(Hash *h, String_or_char *key)</tt></b>
<b><tt>Object *Getattr(Hash *h, const String_or_char *key)</tt></b>
</p>
<div class="indent">
@ -1171,7 +1171,7 @@ a simple <tt>char *</tt> string. Returns NULL if not found.
</div>
<p>
<b><tt>int Setattr(Hash *h, String_or_char *key, Object_or_char *val)</tt></b>
<b><tt>int Setattr(Hash *h, const String_or_char *key, const Object_or_char *val)</tt></b>
</p>
<div class="indent">
@ -1185,7 +1185,7 @@ of <tt>val</tt>. Returns 1 if this operation replaced an existing hash entry,
</div>
<p>
<b><tt>int Delattr(Hash *h, String_or_char *key)</tt></b>
<b><tt>int Delattr(Hash *h, const String_or_char *key)</tt></b>
</p>
<div class="indent">
@ -1249,7 +1249,7 @@ negative, the first item is returned.
</div>
<p>
<b><tt>int *Setitem(List *x, int n, Object_or_char *val)</tt></b>
<b><tt>int *Setitem(List *x, int n, const Object_or_char *val)</tt></b>
</p>
<div class="indent">
@ -1271,7 +1271,7 @@ for <tt>n</tt>.
</div>
<p>
<b><tt>void Append(List *x, Object_or_char *t)</tt></b>
<b><tt>void Append(List *x, const Object_or_char *t)</tt></b>
</p>
<div class="indent">
@ -1281,7 +1281,7 @@ used to create a String object.
</div>
<p>
<b><tt>void Insert(String *s, int pos, Object_or_char *t)</tt></b>
<b><tt>void Insert(String *s, int pos, const Object_or_char *t)</tt></b>
</p>
<div class="indent">
@ -1479,13 +1479,14 @@ Same as the C <tt>tell()</tt> function.
</div>
<p>
<b><tt>File *NewFile(const char *filename, const char *mode)</tt></b>
<b><tt>File *NewFile(const char *filename, const char *mode, List *newfiles)</tt></b>
</p>
<div class="indent">
Create a File object using the <tt>fopen()</tt> library call. This
file differs from <tt>FILE *</tt> in that it can be placed in the standard
SWIG containers (lists, hashes, etc.).
SWIG containers (lists, hashes, etc.). The <tt>filename</tt> is added to the
<tt>newfiles</tt> list if <tt>newfiles</tt> is non-zero and the file was created successfully.
</div>
<p>
@ -1922,7 +1923,7 @@ Adds a reference to <tt>ty</tt>.
</div>
<p>
<b><tt>void SwigType_add_array(SwigType *ty, String_or_char *dim)</tt></b>
<b><tt>void SwigType_add_array(SwigType *ty, const String_or_char *size)</tt></b>
</p>
<div class="indent">
@ -1962,7 +1963,7 @@ Sets <tt>n</tt>th array dimensions of <tt>ty</tt> to <tt>rep</tt>.
</div>
<p>
<b><tt>void SwigType_add_qualifier(SwigType *ty, String_or_char *q)</tt></b>
<b><tt>void SwigType_add_qualifier(SwigType *ty, const String_or_char *q)</tt></b>
</p>
<div class="indent">
@ -1971,7 +1972,7 @@ Adds a type qualifier <tt>q</tt> to <tt>ty</tt>. <tt>q</tt> is typically
</div>
<p>
<b><tt>void SwigType_add_memberpointer(SwigType *ty, String_or_char *cls)</tt></b>
<b><tt>void SwigType_add_memberpointer(SwigType *ty, const String_or_char *cls)</tt></b>
</p>
<div class="indent">
@ -2292,7 +2293,7 @@ The following functions produce strings that are suitable for output.
</p>
<p>
<b><tt>String *SwigType_str(SwigType *ty, String_or_char *id = 0)</tt></b>
<b><tt>String *SwigType_str(SwigType *ty, const String_or_char *id = 0)</tt></b>
</p>
<div class="indent">
@ -2303,7 +2304,7 @@ used to convert string-encoded types back into a form that is valid C syntax.
</div>
<p>
<b><tt>String *SwigType_lstr(SwigType *ty, String_or_char *id = 0)</tt></b>
<b><tt>String *SwigType_lstr(SwigType *ty, const String_or_char *id = 0)</tt></b>
</p>
<div class="indent">
@ -2312,7 +2313,7 @@ is generated from the type's lvalue (as generated from SwigType_ltype).
</div>
<p>
<b><tt>String *SwigType_lcaststr(SwigType *ty, String_or_char *id = 0)</tt></b>
<b><tt>String *SwigType_lcaststr(SwigType *ty, const String_or_char *id = 0)</tt></b>
</p>
<div class="indent">
@ -2323,7 +2324,7 @@ this function produces the string "<tt>(char *) foo</tt>".
</div>
<p>
<b><tt>String *SwigType_rcaststr(SwigType *ty, String_or_char *id = 0)</tt></b>
<b><tt>String *SwigType_rcaststr(SwigType *ty, const String_or_char *id = 0)</tt></b>
</p>
<div class="indent">
@ -2776,6 +2777,7 @@ such as:
class PYTHON : public Language {
protected:
/* General DOH objects used for holding the strings */
File *f_begin;
File *f_runtime;
File *f_header;
File *f_wrappers;
@ -2791,22 +2793,25 @@ int Python::top(Node *n) {
...
/* Initialize I/O */
f_runtime = NewFile(outfile, "w");
if (!f_runtime) {
f_begin = NewFile(outfile, "w", SWIG_output_files());
if (!f_begin) {
FileErrorDisplay(outfile);
SWIG_exit(EXIT_FAILURE);
}
f_runtime = NewString("");
f_init = NewString("");
f_header = NewString("");
f_wrappers = NewString("");
/* Register file targets with the SWIG file handler */
Swig_register_filebyname("begin", f_begin);
Swig_register_filebyname("header", f_header);
Swig_register_filebyname("wrapper", f_wrappers);
Swig_register_filebyname("runtime", f_runtime);
Swig_register_filebyname("init", f_init);
/* Output module initialization code */
Swig_banner(f_begin);
...
/* Emit code for children */
@ -2814,16 +2819,18 @@ int Python::top(Node *n) {
...
/* Write all to the file */
Dump(f_header, f_runtime);
Dump(f_wrappers, f_runtime);
Wrapper_pretty_print(f_init, f_runtime);
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_wrappers, f_begin);
Wrapper_pretty_print(f_init, f_begin);
/* Cleanup files */
Delete(f_runtime);
Delete(f_header);
Delete(f_wrappers);
Delete(f_init);
Close(f_runtime);
Delete(f_runtime);
Close(f_begin);
Delete(f_begin);
return SWIG_OK;
}

View file

@ -339,7 +339,7 @@ python that you run the command with. Taking apart the command line:
setup.py is the tradition)
<li> <tt>build_ext</tt> -- telling distutils to build extensions
<li> <tt>--inplace</tt> -- this tells distutils to put the extension lib in the current dir.
Other wise, it will put it inside a build hierarchy, and you'd have to move it to use it.
Otherwise, it will put it inside a build hierarchy, and you'd have to move it to use it.
</ul>
<p>
@ -363,8 +363,8 @@ program using commands like this (shown for Linux):
<div class="shell"><pre>
$ swig -python example.i
$ gcc -c -fPIC example.c
$ gcc -c -fPIC example_wrap.c -I/usr/local/include/python2.0
$ gcc -O2 -fPIC -c example.c
$ gcc -O2 -fPIC -c example_wrap.c -I/usr/local/include/python2.5
$ gcc -shared example.o example_wrap.o -o _example.so
</pre></div>
@ -654,26 +654,19 @@ compiler. For example:
<div class="shell"><pre>
$ swig -c++ -python example.i
$ g++ -c example.cxx
$ g++ -c example_wrap.cxx -I/usr/local/include/python2.0
$ g++ -O2 -fPIC -c example.cxx
$ g++ -O2 -fPIC -c example_wrap.cxx -I/usr/local/include/python2.5
$ g++ -shared example.o example_wrap.o -o _example.so
</pre></div>
<p>
On some platforms, you could also need to generate
position-independent code (PIC), by using a compiler option such as -fPIC.
Notably, the x86_64 (Opteron and EM64T) platform requires it, and when
using the GNU Compiler Suite, you will need to modify the previous example
as follows:
The -fPIC option tells GCC to generate position-independent code (PIC)
which is required for most architectures (it's not vital on x86, but
still a good idea as it allows code pages from the library to be shared between
processes). Other compilers may need a different option specified instead of
-fPIC.
</p>
<div class="shell"><pre>
$ swig -c++ -python example.i
$ g++ -fPIC -c example.cxx
$ g++ -fPIC -c example_wrap.cxx -I/usr/local/include/python2.0
$ g++ -shared example.o example_wrap.o -o _example.so
</pre></div>
<p>
In addition to this, you may need to include additional library
files to make it work. For example, if you are using the Sun C++ compiler on
@ -683,7 +676,7 @@ Solaris, you often need to add an extra library <tt>-lCrun</tt> like this:
<div class="shell"><pre>
$ swig -c++ -python example.i
$ CC -c example.cxx
$ CC -c example_wrap.cxx -I/usr/local/include/python2.0
$ CC -c example_wrap.cxx -I/usr/local/include/python2.5
$ CC -G example.o example_wrap.o -L/opt/SUNWspro/lib -o _example.so -lCrun
</pre></div>

View file

@ -66,6 +66,7 @@
<ul>
<li><a href="#Tcl_nn45">Proxy classes</a>
</ul>
<li><a href="#Tcl_nn46">Tcl/Tk Stubs</a>
</ul>
</div>
<!-- INDEX -->
@ -3409,5 +3410,26 @@ short, but clever Tcl script can be combined with SWIG to do many
interesting things.
</p>
<H2><a name="Tcl_nn46"></a>33.10 Tcl/Tk Stubs</H2>
<p>
For background information about the Tcl Stubs feature, see
<a href="http://www.tcl.tk/doc/howto/stubs.html">http://www.tcl.tk/doc/howto/stubs.html</a>.
</p>
<p>
As of SWIG 1.3.10, the generated C/C++ wrapper will use the Tcl Stubs
feature if compiled with <tt>-DUSE_TCL_STUBS</tt>.
</p>
<p>
As of SWIG 1.3.40, the generated C/C++ wrapper will use the Tk Stubs
feature if compiled with <tt>-DUSE_TK_STUBS</tt>. Also, you can override
the minimum version to support which is passed to <tt>Tcl_InitStubs()</tt>
and <tt>Tk_InitStubs()</tt> with <tt>-DSWIG_TCL_STUBS_VERSION="8.3"</tt>
or the version being compiled with using
<tt>-DSWIG_TCL_STUBS_VERSION=TCL_VERSION</tt>.
</p>
</body>
</html>