New example

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@736 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2000-08-30 20:31:30 +00:00
commit d47e6a185c
7 changed files with 82 additions and 22 deletions

View file

@ -39,20 +39,10 @@ string. However, whenever the value of such a variable is set from Tcl, the ol
value is destroyed using <tt>free()</tt> or <tt>delete</tt> (the choice of which depends
on whether or not SWIG was run with the -c++ option).
<li><tt>signed char</tt> and <tt>unsigned char</tt> are handled as small 8-bit integers.
<li>Array variables such as '<tt>char name[256]</tt>' are read-only variables because
SWIG doesn't really know how to change the "value" of an array. You can work
around this by writing some kind of helper function in the SWIG interface.
For example:
<blockquote>
<pre>
%inline %{
void set_name(char *newname) {
strncpy(name,newname,256);
}
%}
</pre>
</blockquote>
<li>String array variables such as '<tt>char name[256]</tt>' are managed as Tcl strings, but
when setting the value, the result is truncated to the maximum length of the array. Furthermore, the string is assumed to be null-terminated.
<li>When structures and classes are used as global variables, they are mapped into pointers.
Getting the "value" returns a pointer to the global variable. Setting the value of a structure results in a memory copy from a pointer to the global.
</ul>
<h2>Creating read-only variables</h2>