- Improve the runtime type sytesm
- Update all languages to new type system - Add DohSortList function - Fix mzscheme Examples/Makefile git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6930 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
0f2ed8e655
commit
c3338b1a16
48 changed files with 1383 additions and 1021 deletions
|
|
@ -1,6 +1,52 @@
|
|||
Version 1.3.25 (In progress)
|
||||
============================
|
||||
|
||||
01/31/2005: wuzzeb (John Lenz)
|
||||
- Add DohSortList to DOH
|
||||
|
||||
- Improve the runtime type system:
|
||||
+ Speed. Type loading is now O(n log n) instead of O(N^2), which
|
||||
for large modules is a huge improvement.
|
||||
+ A whole bunch of functions in swigrun.swg no longer need the
|
||||
swig_type_list_handle passed to them. The only one left is
|
||||
TypeQuery. This also makes runtime.swg a lot smaller.
|
||||
+ Split up swig_type_info structure into two structures
|
||||
(swig_type_info and swig_cast_info)
|
||||
+ Store a pointer to a swig_type_info rather than just the type
|
||||
name string in the linked list of casts. First off, this makes
|
||||
the guile module a little faster, and second, the
|
||||
SWIG_TypeClientData() function is faster too.
|
||||
+ Add the idea of a module into the type system. Before, all the
|
||||
types were stored in one huge linked list. Now, another level is
|
||||
added, and the type system stores a linked list of modules, each
|
||||
of which stores an array of types associated with it.
|
||||
+ For more information of how the runtime type system now works,
|
||||
please see Doc/Manual/typemaps.html and Doc/Devel/runtime.txt
|
||||
|
||||
- Update all language modules to use the new type system. The changes
|
||||
to each language module are minor. All languages are now able to
|
||||
use runtime.swg for external access to the type system. Before
|
||||
only python and perl did.
|
||||
|
||||
- [guile, mzscheme, ocaml, and php4] These languages opened up the
|
||||
init function inside the .cxx code, and any code in the .swg files
|
||||
in the init section was inside this function. This was a problem
|
||||
for swiginit.swg, which needs to be inserted before the SWIG_init
|
||||
function is opened. Thus I changed these languages to be like
|
||||
python or perl, where the init function is declared in the .swg
|
||||
file.
|
||||
|
||||
- [Ruby] Instead of moving the init function to the .swg file, I
|
||||
added a new section initbeforefunc, and then added
|
||||
%insert(initbeforefunc) "swiginit.swg"
|
||||
|
||||
- [MzScheme] Fix enums and fix Examples/Makefile.in so that if
|
||||
multiple -I arguments are specified in the INCLUDES variable, each
|
||||
gets a ++ccf.
|
||||
|
||||
- [Guile GH] Update Guile GH to use the new type system. See
|
||||
Doc/Devel/Guile.cxx for how smobs are now used.
|
||||
|
||||
01/11/2005: wsfulton
|
||||
[C#] New typemap called 'csconstruct'. The code in this typemaps was previously hard
|
||||
coded and could not be customised by a user. This typemap contains the code that is
|
||||
|
|
|
|||
152
Doc/Devel/runtime.txt
Normal file
152
Doc/Devel/runtime.txt
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
This file describes the necissary functions and interfaces a language module
|
||||
needs to implement to take advantage of the run time type system. I assume you
|
||||
have read the run-time section of the Typemaps chapter in the SWIG
|
||||
documentation.
|
||||
|
||||
Last updated: January 23, 2005
|
||||
|
||||
The file we are concerned with here should be named langrun.swg. A good example
|
||||
of a simple file is the Lib/mzscheme/mzrun.swg file. First, a few requirements
|
||||
and notes:
|
||||
|
||||
1) Every function in this file should be declared static.
|
||||
|
||||
2) It should be inserted into the runtime section of the _wrap file from your
|
||||
config file. The Lib/swigrun.swg file should be included before this file.
|
||||
That is, you need to have
|
||||
%runtime "swigrun.swg"
|
||||
%runtime "langrun.swg"
|
||||
|
||||
3) You must also include the swiginit.swg file in the init section of the
|
||||
wrapper. That is, you should have
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
4) From module.cxx, you need to call the SwigType_emit_type_table function, as
|
||||
well as register types with SwigType_remember or SwigType_remember_clientdata
|
||||
|
||||
5) By convention, all functions in this file are of the form
|
||||
SWIG_Language_Whatever, and #defines are used to rename SWIG API functions to
|
||||
these function names
|
||||
|
||||
6) You need to call void SWIG_InitializeModule(void *clientdata) from your init
|
||||
function.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Required Functions
|
||||
-------------------------------------------------------------------------------
|
||||
swig_module_info *SWIG_GetModule(void *clientdata);
|
||||
void SWIG_SetModule(void *clientdata, swig_module_info *mod);
|
||||
|
||||
The SetModule function should store the mod argument into some globally
|
||||
accessable variable in the target language. The action of these two functions
|
||||
is to provide a way for multiple modules to share information. The SetModule
|
||||
function should create a new global var named something like
|
||||
"swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME
|
||||
SWIG_RUNTIME_VERSION is currently defined as "2", and SWIG_TYPE_TABLE_NAME is
|
||||
defined by the -DSWIG_TYPE_TABLE=mytable option when compiling the wrapper.
|
||||
|
||||
Alternativly, if the language supports modules, a module named
|
||||
"swig_runtime_data" SWIG_RUNTIME_VERSION can be created, and a global variable
|
||||
named "type_table" SWIG_TYPE_TABLE_NAME can be created inside it. The most
|
||||
common approach is to store the mod pointer in some global variable in the
|
||||
target language, but if the language provides an alternative place to store data
|
||||
(like the chicken module), then that is good too.
|
||||
|
||||
The way the code is set up, SetModule should only be called when GetModule
|
||||
returns NULL, and if SetModule is called a second time, the behavior is
|
||||
undefined. Just make sure it doesn't crash in the random chance occurance that
|
||||
SetModule is called twice.
|
||||
|
||||
There are two options here.
|
||||
|
||||
1) The perferred approach is for GetModule and SetModule to not require a
|
||||
clientdata pointer. If you can at all avoid it, please do so. Here, you would
|
||||
write swig_module_info *SWIG_Language_GetModule();
|
||||
void SWIG_Language_SetModule(swig_module_info *mod);
|
||||
and then add
|
||||
#define SWIG_GetModule(clientdata) SWIG_Language_GetModule()
|
||||
#define SWIG_SetModule(cd, ptr) SWIG_Language_SetModule(ptr)
|
||||
You would then call
|
||||
SWIG_InitializeModule(0)
|
||||
|
||||
2) If GetModule and SetModule need to take a custom pointer (most notably an
|
||||
environment pointer, see tcl or mzscheme), then you should write
|
||||
swig_module_info *SWIG_Language_GetModule(void *clientdata)
|
||||
void SWIG_Langauge_SetModule(void *clientdata, swig_module_info *mod);
|
||||
and also define
|
||||
#define SWIG_GetModule(cd) SWIG_Langauge_GetModule(cd)
|
||||
#define SWIG_SetModule(cd, ptr) SWIG_Language_SetModule(cd, ptr)
|
||||
#define SWIG_MODULE_CLIENTDATA_TYPE Whatever
|
||||
SWIG_MODULE_CLIENTDATA_TYPE should be defined to whatever the type of
|
||||
clientdata is.
|
||||
|
||||
You would then call SWIG_InitializeModule(clientdata), and clientdata would get
|
||||
passed to GetModule and SetModule. clientdata will not be stored and will only
|
||||
be referenced during the InitializeModule call. After InitializeModule returns,
|
||||
clientdata does not need to be valid any more.
|
||||
|
||||
This method is not preferred, because it makes external access to the type
|
||||
system more complicated. See the Modules chapter of the documentation, and read
|
||||
the "External access to the run-time" section. Then take a look at
|
||||
Lib/runtime.swg. Anybody that calls SWIG_TypeQuery needs to pass along the
|
||||
clientdata pointer, and that is the reason for defining
|
||||
SWIG_MODULE_CLIENTDATA_TYPE.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
Standard Functions
|
||||
-------------------------------------------------------------------------------
|
||||
These functions are not required and their API is not formalized, but almost all
|
||||
language modules implement them for consistancy across languages. Throughout
|
||||
this discussion, I will use LangType to represent the underlying language type
|
||||
(C_word in chicken, Scheme_Object * in mzscheme, PyObject * in python, etc)
|
||||
|
||||
|
||||
|
||||
LangObj SWIG_NewPointerObj(void *ptr, swig_type_info *type, int flags);
|
||||
Create and return a new pointer object that has both ptr and type. For almost
|
||||
all language modules, flags is used for ownership. If flags==1, then the
|
||||
created pointer should be registered to be garbage collected.
|
||||
|
||||
|
||||
|
||||
int SWIG_ConvertPtr(LangType obj, void **result, swig_type_info *type, int flags);
|
||||
Convert a language wrapped pointer into a void *. The pointer is returned in
|
||||
result, and the function should return 0 on success, non-zero on error.
|
||||
A sample ConvertPtr is given here:
|
||||
|
||||
swig_cast_info *cast;
|
||||
|
||||
if (<obj is a wrapped pointer type>) {
|
||||
cast = SWIG_TypeCheck(<obj type name>, type);
|
||||
cast = SWIG_TypeCheckStruct(<obj type structure>, type);
|
||||
if (cast) {
|
||||
*result = SWIG_TypeCast(cast, <obj pointer>);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 1;
|
||||
|
||||
Either TypeCheck or TypeCheckStruct can be called, depending on how the pointer
|
||||
is wrapped in langtype. If obj stores the void pointer and the type name, then
|
||||
the TypeCheck function should be used, while if obj stores the void pointer and
|
||||
a pointer to the swig_type_info structure, then the TypeCheckStruct function
|
||||
should be called. The TypeCheckStruct is slightly faster, since it does a
|
||||
pointer comparison instead of a strcmp.
|
||||
|
||||
|
||||
|
||||
void *SWIG_MustGetPtr(LangType obj, swig_type_info *type, int flags,
|
||||
int argnum, const char *func_name) {
|
||||
void *result;
|
||||
if (SWIG_ConvertPtr(s, &result, type, flags)) {
|
||||
generate runtime type error ("Error in func_name, expected a" +
|
||||
type->str ? type->str : "void *" +
|
||||
"at argument number" + argnum);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
This function is optional, and the number and type of parameters can be
|
||||
different, but is useful for typemap purposes:
|
||||
%typemap(in) SWIGTYPE *, SWIGTYPE &, SWIGTYPE [] {
|
||||
$1 = ($1_ltype)SWIG_MustGetPtr($input, $descriptor, 0, $argnum, FUNC_NAME);
|
||||
}
|
||||
|
|
@ -388,28 +388,36 @@ If the Scheme object passed was not a SWIG smob representing a compatible
|
|||
pointer, a <code>wrong-type-arg</code> exception is raised.
|
||||
|
||||
<H3><a name="Guile_nn13"></a>18.6.1 GH Smobs</H3>
|
||||
|
||||
|
||||
<p>
|
||||
In earlier versions of SWIG, C pointers were represented as Scheme
|
||||
strings containing a hexadecimal rendering of the pointer value and a
|
||||
mangled type name. As Guile allows registering user types, so-called
|
||||
"smobs" (small objects), a much cleaner representation has been
|
||||
implemented now. The details will be discussed in the following.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
A smob is a cons cell where the lower half of the CAR contains the
|
||||
smob type tag, while the upper half of the CAR and the whole CDR are
|
||||
available. <code>SWIG_Guile_Init()</code> registers a smob type named
|
||||
"swig" with Guile; its type tag is stored in the variable
|
||||
<code>swig_tag</code>. The upper half of the CAR store an index into
|
||||
a table of all C pointer types seen so far, to which new types seen
|
||||
are appended. The CDR stores the pointer value.
|
||||
<p> A smob is a cons cell where the lower half of the CAR contains the smob type
|
||||
tag, while the upper half of the CAR and the whole CDR are available. Every
|
||||
module creates its own smob type in the clientdata field of the module. So the
|
||||
lower 16 bits of the car of the smob store the tag and the upper 16 bits store
|
||||
the index this type is in the array. We can then, given a smob, find its
|
||||
swig_type_info struct by using the tag (lower 16 bits of car) to find which
|
||||
module this type is in (since each tag is unique for the module). Then we use
|
||||
the upper 16 bits to index into the array of types attached to this module.
|
||||
Looking up the module from the tag is worst case O(# of modules) but average
|
||||
case O(1). This is because the modules are stored in a circularly linked list,
|
||||
and when we start searching the modules for the tag, we start looking with the
|
||||
module that the function doing the lookup is in. SWIG_Guile_ConvertPtr() takes
|
||||
as its first argument the swig_module_info * of the calling function, which is
|
||||
where we start comparing tags. Most types will be looked up in the same module
|
||||
that created them, so the first module we check will most likely be correct.
|
||||
Once we have a swig_type_info structure, we loop through the linked list of
|
||||
casts, using pointer comparisons.</p>
|
||||
|
||||
<H3><a name="Guile_nn14"></a>18.6.2 SCM Smobs</H3>
|
||||
|
||||
|
||||
<p>The SCM interface (using the "-scm" argument to swig) uses common.swg.
|
||||
<p>The SCM interface (using the "-scm" argument to swig) uses swigrun.swg.
|
||||
The whole type system, when it is first initialized, creates two smobs named "swig" and "collected_swig".
|
||||
The swig smob is used for non-garbage collected smobs, while the collected_swig smob is used as described
|
||||
below. Each smob has the same format, which is a double cell created by SCM_NEWSMOB2()
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@
|
|||
<!-- INDEX -->
|
||||
<ul>
|
||||
<li><a href="#Modules_nn2">The SWIG runtime code</a>
|
||||
<li><a href="#Modules_nn3">A word of caution about static libraries</a>
|
||||
<li><a href="#Modules_nn4">References</a>
|
||||
<li><a href="#Modules_nn5">Reducing the wrapper file size</a>
|
||||
<li><a href="#external_run_time">External access to runtime system</a>
|
||||
<li><a href="#Modules_nn4">A word of caution about static libraries</a>
|
||||
<li><a href="#Modules_nn5">References</a>
|
||||
<li><a href="#Modules_nn6">Reducing the wrapper file size</a>
|
||||
</ul>
|
||||
<!-- INDEX -->
|
||||
|
||||
|
|
@ -68,7 +69,52 @@ Be careful if you use threads and the automatic module loading that some scripti
|
|||
languages provide. One solution is to load all modules before spawning any threads.
|
||||
</p>
|
||||
|
||||
<H2><a name="Modules_nn3"></a>15.2 A word of caution about static libraries</H2>
|
||||
<H2><a name="external_run_time"></a>15.2 External access to the run-time system</a></H2>
|
||||
|
||||
<p>As described in <a href="Typemaps.html#runtime_type_checker">The run-time type checker</a>,
|
||||
the functions <tt>SWIG_TypeQuery</tt>, <tt>SWIG_NewPointerObj</tt>, and others sometimes need
|
||||
to be called. Calling these functions from a typemap is supported, since the typemap code
|
||||
is embedded into the <tt>_wrap.c</tt> file, which has those declerations available. If you need
|
||||
to call the SWIG run-time functions from another C file, there are three headers you need
|
||||
to include. They are located in the Lib directory in the SWIG source, or wherever the
|
||||
SWIG Library was installed. You can see the current library path by running
|
||||
<tt>swig -swiglib</tt>.</p>
|
||||
|
||||
<blockquote><pre>
|
||||
#include <swigrun.swg>
|
||||
#include <python/pyrun.swg> /* Or other header, see below */
|
||||
#include <runtime.swg>
|
||||
</pre></blockquote>
|
||||
|
||||
<p>After including these three headers, your code should be able to call <tt>SWIG_TypeQuery</tt>,
|
||||
<tt>SWIG_NewPointerObj</tt>, <tt>SWIG_ConvertPtr</tt> and others. The exact argument paramaters
|
||||
for these functions might differ between language modules; please check the language module chapters
|
||||
for more information.</p>
|
||||
|
||||
<p>Inside these headers the functions are declared static and are included inline into the file,
|
||||
and thus the file does not need to be linked against any SWIG libraries or code (you might still
|
||||
need to link against the language libraries like libpython-2.3). Data is shared between this
|
||||
file and the _wrap.c files through a global variable in the wrapping language. It is also
|
||||
possible to copy these three header files into your own package for distribution along with
|
||||
the generated wrapper files, so that you can distribute a package that can be compiled
|
||||
without SWIG installed (this works because the header files are self contained, and do not
|
||||
need to link with anything).</p>
|
||||
|
||||
<p>The headers that should be included in place of the #include <python/pyrun.swg>
|
||||
for the different language modules are:</p>
|
||||
<ul>
|
||||
<li>Chicken - <chicken/chickenrun.swg></li>
|
||||
<li>Guile (scm) - <guile/guile_scm_run.swg></li>
|
||||
<li>Guile (gh) - This does not work with the -gh API, use the -scm API</li>
|
||||
<li>MzScheme - <mzscheme/mzrun.swg></li>
|
||||
<li>Ocaml - <ocaml/ocaml.swg></li>
|
||||
<li>Python - <python/pyrun.swg></li>
|
||||
<li>Perl5 - <perl5/perlrun.swg></li>
|
||||
<li>Ruby - <ruby/rubydef.swg></li>
|
||||
<li>Tcl - <tcl/swigtcl8.swg></li>
|
||||
</ul>
|
||||
|
||||
<H2><a name="Modules_nn4"></a>15.3 A word of caution about static libraries</H2>
|
||||
|
||||
|
||||
When working with multiple SWIG modules, you should take care not to use static
|
||||
|
|
@ -77,13 +123,13 @@ of SWIG modules with that library, each module will get its own private copy of
|
|||
into it. This is very often <b>NOT</b> what you want and it can lead to unexpected or bizarre program
|
||||
behavior. When working with dynamically loadable modules, you should try to work exclusively with shared libaries.
|
||||
|
||||
<H2><a name="Modules_nn4"></a>15.3 References</H2>
|
||||
<H2><a name="Modules_nn5"></a>15.4 References</H2>
|
||||
|
||||
|
||||
Due to the complexity of working with shared libraries and multiple modules, it might be a good idea to consult
|
||||
an outside reference. John Levine's "Linkers and Loaders" is highly recommended.
|
||||
|
||||
<H2><a name="Modules_nn5"></a>15.4 Reducing the wrapper file size</H2>
|
||||
<H2><a name="Modules_nn6"></a>15.5 Reducing the wrapper file size</H2>
|
||||
|
||||
|
||||
<p>
|
||||
|
|
|
|||
|
|
@ -2540,6 +2540,24 @@ ordering (and perform conversions if needed).
|
|||
|
||||
<H2><a name="runtime_type_checker"></a>10.8 The run-time type checker</H2>
|
||||
|
||||
Most scripting languages need type information at run-time. This type information
|
||||
can include how to construct types, how to garbage collect types, and the inheritance
|
||||
relationships between types. If the language interface does not provide its own type
|
||||
information storage, the generated SWIG code needs to provide it.<br><br>
|
||||
|
||||
Requirements for the type system:<br>
|
||||
<li>Store inheritance and type equivalence information and be able to correctly
|
||||
re-create the type pointer.</li>
|
||||
<li>Share type information between modules.</li>
|
||||
<li>Modules can be loaded in any order, irregardless of actual type
|
||||
dependency.</li>
|
||||
<li>Avoid the use of dynamically allocated memory, and library/system calls in general.</li>
|
||||
<li>Provide a reasonably fast implementation, minimizing the lookup time for all
|
||||
language modules.</li>
|
||||
<li>Custom, language specific information can be attached to types.</li>
|
||||
<li>Modules can be unloaded from the type system.</li>
|
||||
|
||||
<H3>8.8.1 Implementation</H3>
|
||||
|
||||
<p>
|
||||
The run-time type checker is used by many, but not all, of SWIG's supported target languages.
|
||||
|
|
@ -2628,7 +2646,90 @@ pointer. However, the exact name and calling conventions of the conversion
|
|||
function depends on the target language (see language specific chapters for details).
|
||||
|
||||
<p>
|
||||
When pointers are converted in a typemap, the typemap code often looks
|
||||
The actual type code is in swigrun.swg, and gets inserted near the top of the generated
|
||||
swig wrapper file. The phrase "a type X that can cast into a type Y" means
|
||||
that given a type X, it can be converted into a type Y. In other words, X is a derived
|
||||
class of Y or X is a typedef of Y. The structure to store type information looks like this:
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
/* Structure to store information on one type */
|
||||
typedef struct swig_type_info {
|
||||
const char *name; /* mangled name of this type */
|
||||
const char *str; /* human readable name for this type */
|
||||
swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
|
||||
struct swig_cast_info *cast; /* Linked list of types that can cast into this type */
|
||||
void *clientdata; /* Language specific type data */
|
||||
} swig_type_info;
|
||||
|
||||
/* Structure to store a type and conversion function used for casting */
|
||||
typedef struct swig_cast_info {
|
||||
swig_type_info *type; /* pointer to type that is equivalent to this type */
|
||||
swig_converter_func converter; /* function to cast the void pointers */
|
||||
struct swig_cast_info *next; /* pointer to next cast in linked list */
|
||||
struct swig_cast_info *prev; /* pointer to the previous cast */
|
||||
} swig_cast_info;
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
Each <tt>swig_type_info</tt> stores a linked list of types that it is equivalent to. Each entry in this
|
||||
doubly linked list stores a pointer back to another swig_type_info structure,
|
||||
along with a pointer to a conversion function. This conversion function is used
|
||||
to solve the above problem of the FooBar class, correctly returning a pointer to
|
||||
the type we want.
|
||||
|
||||
<p>
|
||||
The basic problem we need to solve is verifying and building arguments passed to functions.
|
||||
So going back to the <tt>SWIG_ConvertPtr()</tt> function example from above, we are
|
||||
expecting a <tt>Foo *</tt> and need to
|
||||
check if <tt>obj0</tt> is in fact a <tt>Foo *</tt>. From before, <tt>SWIGTYPE_p_Foo</tt> is just
|
||||
a pointer to the <tt>swig_type_info</tt> structure describing <tt>Foo *</tt>. So we loop though the
|
||||
linked list of <tt>swig_cast_info</tt> structures attached to <tt>SWIGTYPE_p_Foo</tt>. If we see that the type of <tt>obj0</tt> is in the
|
||||
linked list, we pass the object through the associated conversion function and
|
||||
then return a positive. If we reach the end of the linked list without a match,
|
||||
then <tt>obj0</tt> can not be converted to a <tt>Foo *</tt> and an error is generated.
|
||||
|
||||
<p>
|
||||
Another issue needing to be addressed is sharing type information between multiple modules.
|
||||
More explicitly, we need
|
||||
to have ONE <tt>swig_type_info</tt> for each type. If two modules both use the type, the
|
||||
second module loaded must lookup and use the swig_type_info structure from the module already loaded.
|
||||
Because no dynamic memory is used and the circular dependencies of the
|
||||
casting information, loading the type information is somewhat tricky, and not explained here.
|
||||
A complete description is in the <tt>common.swg</tt> file (and near the top of any generated file).
|
||||
<br><br>
|
||||
Each module has one swig_module_info structure which looks like this:
|
||||
|
||||
<blockquote>
|
||||
<pre>
|
||||
/* Structure used to store module information
|
||||
* Each module generates one structure like this, and the runtime collects
|
||||
* all of these structures and stores them in a circularly linked list.*/
|
||||
typedef struct swig_module_info {
|
||||
swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
|
||||
int size; /* Number of types in this module */
|
||||
struct swig_module_info *next; /* Pointer to next element in circularly linked list */
|
||||
swig_type_info **type_initial; /* Array of initially generated type structures */
|
||||
swig_cast_info **cast_initial; /* Array of initially generated casting structures */
|
||||
void *clientdata; /* Language specific module data */
|
||||
} swig_module_info;
|
||||
</pre>
|
||||
</blockquote>
|
||||
|
||||
Each module stores an array of pointers to <tt>swig_type_info</tt> structures and the number of
|
||||
types in this module. So when a second module is loaded, it finds the <tt>swig_module_info</tt>
|
||||
structure for the first module and searches the array of types. If any of its own
|
||||
types are in the first module and have already been loaded, it uses those <tt>swig_type_info</tt>
|
||||
structures rather than creating new ones. These <tt>swig_module_info</tt>
|
||||
structures are chained together in a circularly linked list.
|
||||
|
||||
<a name="n43"></a><H3>8.8.2 Usage</H3>
|
||||
<p>This section covers how to use these functions from typemaps. To learn how to
|
||||
call these functions from external files (not the generated _wrap.c file), see
|
||||
the <a href="Modules.html#external_run_time">External access to the run-time system</a>
|
||||
section.</p>
|
||||
|
||||
<p>When pointers are converted in a typemap, the typemap code often looks
|
||||
similar to this:
|
||||
</p>
|
||||
|
||||
|
|
|
|||
|
|
@ -433,12 +433,12 @@ MZSCHEME_SO = @MZSCHEME_SO@
|
|||
|
||||
mzscheme: $(SRCS)
|
||||
$(SWIG) -mzscheme $(SWIGOPT) $(INTERFACE)
|
||||
$(MZC) ++ccf "$(INCLUDES)" --cc $(ISRCS) $(SRCS)
|
||||
$(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ISRCS) $(SRCS)
|
||||
$(MZC) --ld $(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS)
|
||||
|
||||
mzscheme_cpp: $(SRCS)
|
||||
$(SWIG) -mzscheme -c++ $(SWIGOPT) $(INTERFACE)
|
||||
$(MZC) ++ccf "$(INCLUDES)" --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(MZC) `echo $(INCLUDES) | sed 's/-I/++ccf -I/g'` --cc $(ICXXSRCS) $(SRCS) $(CXXSRCS)
|
||||
$(CXXSHARED) -o $(LIBPREFIX)$(TARGET)$(MZSCHEME_SO) $(OBJS) $(IOBJS) $(MZDYNOBJ) $(CPP_DLLIBS)
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; // Common C API type-checking code
|
||||
%insert(runtime) "common.swg"; // Common type-checking code
|
||||
%insert(runtime) "chickenrun.swg"; // CHICKEN run-time code
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -583,12 +582,12 @@ SWIGEXPORT(void) SWIG_init(int, C_word, C_word) C_noret;
|
|||
|
||||
%insert(closprefix) "swigclosprefix.scm"
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%insert(init) %{
|
||||
/* CHICKEN initialization function */
|
||||
static char *swig_type_ptr_name = "type_pointer" SWIG_TYPE_TABLE_NAME;
|
||||
SWIGEXPORT(void)
|
||||
SWIG_init(int argc, C_word closure, C_word continuation) {
|
||||
static int typeinit = 0;
|
||||
int i;
|
||||
C_word sym;
|
||||
C_word tmp;
|
||||
|
|
@ -596,32 +595,9 @@ SWIG_init(int argc, C_word closure, C_word continuation) {
|
|||
C_word ret;
|
||||
C_word *return_vec;
|
||||
|
||||
if (!typeinit) {
|
||||
/* lookup the type pointer... it is stored in it's own symbol table */
|
||||
C_SYMBOL_TABLE *stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION);
|
||||
if (stable != NULL) {
|
||||
sym = SWIG_Chicken_LookupSymbol(swig_type_ptr_name, stable);
|
||||
if (C_truep(sym) && C_swig_is_ptr(sym)) {
|
||||
swig_type_list_handle = (swig_type_info **) C_block_item(sym, 0);
|
||||
}
|
||||
} else {
|
||||
C_word *a = C_alloc(C_SIZEOF_POINTER + C_SIZEOF_INTERNED_SYMBOL(C_strlen(swig_type_ptr_name)));
|
||||
stable = C_new_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION, 16);
|
||||
sym = C_intern_in(&a, C_strlen(swig_type_ptr_name), swig_type_ptr_name, stable);
|
||||
C_mutate(&C_block_item(sym, 0), C_mpointer(&a, (void *) swig_type_list_handle));
|
||||
}
|
||||
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
SWIG_PropagateClientData(swig_types[i]);
|
||||
}
|
||||
typeinit = 1;
|
||||
ret = C_SCHEME_TRUE;
|
||||
} else {
|
||||
ret = C_SCHEME_FALSE;
|
||||
}
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_PropagateClientData();
|
||||
ret = C_SCHEME_TRUE;
|
||||
|
||||
#if $veclength
|
||||
return_vec = C_alloc(C_SIZEOF_VECTOR($veclength));
|
||||
|
|
|
|||
|
|
@ -28,6 +28,10 @@ extern "C" {
|
|||
SWIG_Chicken_NewPointerObj((void*)ptr, type, owner, &known_space)
|
||||
#define swig_barf SWIG_Chicken_Barf
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Chicken_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Chicken_SetModule(pointer)
|
||||
|
||||
#define C_swig_is_bool(x) C_truep (C_booleanp (x))
|
||||
#define C_swig_is_char(x) C_truep (C_charp (x))
|
||||
#define C_swig_is_fixnum(x) C_truep (C_fixnump (x))
|
||||
|
|
@ -186,7 +190,7 @@ SWIG_Chicken_NewPointerObj(void *ptr, swig_type_info *type, int owner, C_word **
|
|||
static int
|
||||
SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags)
|
||||
{
|
||||
swig_type_info *cast;
|
||||
swig_cast_info *cast;
|
||||
swig_type_info *from;
|
||||
|
||||
if (s == C_SCHEME_FALSE) {
|
||||
|
|
@ -196,7 +200,7 @@ SWIG_Chicken_ConvertPtr(C_word s, void **result, swig_type_info *type, int flags
|
|||
from = (swig_type_info *) C_block_item(s, 1);
|
||||
if (!from) return 1;
|
||||
if (type) {
|
||||
cast = SWIG_TypeCheck((char*)from->name, type);
|
||||
cast = SWIG_TypeCheckStruct(from, type);
|
||||
if (cast) {
|
||||
*result = SWIG_TypeCast(cast, (void *) C_block_item(s, 0));
|
||||
return 0;
|
||||
|
|
@ -223,6 +227,48 @@ SWIG_Chicken_MustGetPtr (C_word s, swig_type_info *type, int argnum, int flags)
|
|||
return result;
|
||||
}
|
||||
|
||||
static char *chicken_runtimevar_name = "type_pointer" SWIG_TYPE_TABLE_NAME;
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_Chicken_GetModule() {
|
||||
swig_module_info *ret = 0;
|
||||
C_word sym;
|
||||
|
||||
/* lookup the type pointer... it is stored in it's own symbol table */
|
||||
C_SYMBOL_TABLE *stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION);
|
||||
if (stable != NULL) {
|
||||
sym = SWIG_Chicken_LookupSymbol(chicken_runtimevar_name, stable);
|
||||
if (C_truep(sym) && C_swig_is_ptr(sym)) {
|
||||
ret = (swig_module_info *) C_block_item(sym, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Chicken_SetModule(swig_module_info *module) {
|
||||
C_word *a;
|
||||
C_SYMBOL_TABLE *stable;
|
||||
C_word sym;
|
||||
C_word pointer;
|
||||
static C_word *space = 0;
|
||||
|
||||
/* type pointer is stored in it's own symbol table */
|
||||
stable = C_find_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION);
|
||||
if (stable == NULL) {
|
||||
stable = C_new_symbol_table("swig_runtime_data" SWIG_RUNTIME_VERSION, 16);
|
||||
}
|
||||
|
||||
if (!space) {
|
||||
space = (C_word *) C_malloc((C_SIZEOF_POINTER + C_SIZEOF_INTERNED_SYMBOL(C_strlen(chicken_runtimevar_name))) * sizeof(C_word));
|
||||
}
|
||||
a = space;
|
||||
pointer = C_mpointer(&a, (void *) module);
|
||||
sym = C_intern_in(&a, C_strlen(chicken_runtimevar_name), chicken_runtimevar_name, stable);
|
||||
C_set_block_item(sym, 0, pointer);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,71 +0,0 @@
|
|||
/***********************************************************************
|
||||
* common.swg
|
||||
*
|
||||
* This file contains generic SWIG runtime support for pointer
|
||||
* type checking as well as a few commonly used macros to control
|
||||
* external linkage.
|
||||
*
|
||||
* Author : David Beazley (beazley@cs.uchicago.edu)
|
||||
*
|
||||
* Copyright (c) 1999-2000, The University of Chicago
|
||||
*
|
||||
* This file may be freely redistributed without license or fee provided
|
||||
* this copyright message remains intact.
|
||||
************************************************************************/
|
||||
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if !defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
/*************************************************************************/
|
||||
|
||||
|
||||
/* The static type info list */
|
||||
|
||||
static swig_type_info *swig_type_list = 0;
|
||||
static swig_type_info **swig_type_list_handle = &swig_type_list;
|
||||
|
||||
|
||||
/* Register a type mapping with the type-checking */
|
||||
static swig_type_info *
|
||||
SWIG_TypeRegister(swig_type_info *ti) {
|
||||
return SWIG_TypeRegisterTL(swig_type_list_handle, ti);
|
||||
}
|
||||
|
||||
/* Search for a swig_type_info structure */
|
||||
static swig_type_info *
|
||||
SWIG_TypeQuery(const char *name) {
|
||||
return SWIG_TypeQueryTL(*swig_type_list_handle, name);
|
||||
}
|
||||
|
||||
/* Set the clientdata field for a type */
|
||||
static void
|
||||
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
|
||||
SWIG_TypeClientDataTL(*swig_type_list_handle, ti, clientdata);
|
||||
}
|
||||
|
||||
/* This function will propagate the clientdata field of type to
|
||||
* any new swig_type_info structures that have been added into the list
|
||||
* of equivalent types. It is like calling
|
||||
* SWIG_TypeClientData(type, clientdata) a second time.
|
||||
*/
|
||||
static void
|
||||
SWIG_PropagateClientData(swig_type_info *type) {
|
||||
SWIG_PropagateClientDataTL(*swig_type_list_handle, type);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -5,16 +5,48 @@
|
|||
|
||||
#define SWIGGUILE_GH
|
||||
|
||||
%runtime "swigrun.swg"
|
||||
%runtime "guile_gh_run.swg"
|
||||
%include "guile.i"
|
||||
|
||||
%init %{
|
||||
static int _swig_init = 0;
|
||||
%runtime %{
|
||||
|
||||
if (!_swig_init) {
|
||||
SWIG_Guile_RegisterTypes(swig_types, swig_types_initial);
|
||||
_swig_init = 1;
|
||||
}
|
||||
/* scm_values was implemented on C level in 1.4.1, and the prototype
|
||||
is not included in libguile.h, so play safe and lookup `values'... */
|
||||
#define GUILE_MAYBE_VALUES \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_apply(gh_lookup("values"), gswig_result);
|
||||
|
||||
#define GUILE_MAYBE_VECTOR \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_list_to_vector(gswig_result);
|
||||
|
||||
#define SWIG_APPEND_VALUE(object) \
|
||||
if (gswig_result == SCM_UNSPECIFIED) { \
|
||||
gswig_result = object; \
|
||||
} else { \
|
||||
if (!gswig_list_p) { \
|
||||
gswig_list_p = 1; \
|
||||
gswig_result = gh_list(gswig_result, object, SCM_UNDEFINED); \
|
||||
} \
|
||||
else \
|
||||
gswig_result = gh_append2(gswig_result, \
|
||||
gh_list(object, SCM_UNDEFINED)); \
|
||||
}
|
||||
|
||||
SWIG_Guile_Init();
|
||||
%}
|
||||
|
||||
%init "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
static int _swig_module_smob_tag;
|
||||
|
||||
SWIG_GUILE_INIT_STATIC void
|
||||
SWIG_init(void)
|
||||
{
|
||||
|
||||
SWIG_InitializeModule(0);
|
||||
swig_module.clientdata = (void *) &_swig_module_smob_tag;
|
||||
|
||||
SWIG_Guile_Init(&swig_module);
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@
|
|||
* Lib/guile/guile_gh_run.swg
|
||||
*
|
||||
* Guile GH runtime file
|
||||
* Copyright (C) 2000 Matthias Koeppe
|
||||
* Copyright (C) 2004 John Lenz <lenz@cs.wisc.edu>
|
||||
* ----------------------------------------------------------------------- */
|
||||
|
||||
#define SWIGGUILE
|
||||
#include "guile/gh.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
|
@ -15,16 +16,20 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef SCM (*swig_guile_proc)();
|
||||
|
||||
#define SWIG_malloc(size) \
|
||||
SCM_MUST_MALLOC(size)
|
||||
#define SWIG_free(mem) \
|
||||
scm_must_free(mem)
|
||||
#define SWIG_ConvertPtr(s, result, type, flags) \
|
||||
SWIG_Guile_GetPtr(s, result, type)
|
||||
SWIG_Guile_ConvertPtr(&swig_module, s, result, type, flags)
|
||||
#define SWIG_MustGetPtr(s, type, argnum, flags) \
|
||||
SWIG_Guile_MustGetPtr(s, type, argnum, FUNC_NAME)
|
||||
SWIG_Guile_MustGetPtr(&swig_module, s, type, argnum, flags, FUNC_NAME)
|
||||
#define SWIG_NewPointerObj(ptr, type, owner) \
|
||||
SWIG_Guile_MakePtr((void*)ptr, type)
|
||||
SWIG_Guile_NewPointerObj(&swig_module, (void*)ptr, type, owner)
|
||||
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
|
||||
|
||||
/* Ignore object-ownership changes in gh mode */
|
||||
#define SWIG_Guile_MarkPointerNoncollectable(s) (s)
|
||||
|
|
@ -36,50 +41,24 @@ extern "C" {
|
|||
(char *) FUNC_NAME, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F); else
|
||||
|
||||
#if defined(SWIG_NOINCLUDE)
|
||||
# define SWIGSTATIC
|
||||
#elif defined(SWIG_GLOBAL)
|
||||
# define SWIGSTATIC
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if defined(_MSC_VER) || defined(__GNUC__)
|
||||
# if defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# endif
|
||||
# else
|
||||
# if defined(__BORLANDC__)
|
||||
# define SWIGEXPORT(a) a _export
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
# endif
|
||||
#else
|
||||
# define SWIGSTATIC static
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
#define GH_NOT_PASSED SCM_UNDEFINED
|
||||
#define GH_UNSPECIFIED SCM_UNSPECIFIED
|
||||
|
||||
#define SWIG_APPEND_VALUE(object) \
|
||||
if (gswig_result == GH_UNSPECIFIED) \
|
||||
gswig_result = object; \
|
||||
else { \
|
||||
if (!gswig_list_p) { \
|
||||
gswig_list_p = 1; \
|
||||
gswig_result = gh_list(gswig_result, object, GH_NOT_PASSED); \
|
||||
} \
|
||||
else \
|
||||
gswig_result = gh_append2(gswig_result, \
|
||||
gh_list(object, GH_NOT_PASSED)); \
|
||||
}
|
||||
|
||||
#define GUILE_APPEND_RESULT SWIG_APPEND_VALUE
|
||||
|
||||
/* scm_values was implemented on C level in 1.4.1, and the prototype
|
||||
is not included in libguile.h, so play safe and lookup `values'... */
|
||||
#define GUILE_MAYBE_VALUES \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_apply(gh_lookup("values"), gswig_result);
|
||||
|
||||
#define GUILE_MAYBE_VECTOR \
|
||||
if (gswig_list_p) \
|
||||
gswig_result = gh_list_to_vector(gswig_result);
|
||||
|
||||
static char *
|
||||
SWIG_scm2str (SCM s)
|
||||
{
|
||||
return gh_scm2newstr (s, NULL);
|
||||
}
|
||||
|
||||
#define GSWIG_scm2str SWIG_scm2str
|
||||
|
||||
/* SCM_CHAR and SCM_CHARP were introduced in Guile 1.4; the following is for
|
||||
1.3.4 compatibility. */
|
||||
#ifndef SCM_CHAR
|
||||
|
|
@ -98,298 +77,86 @@ GSWIG_scm2char (SCM s)
|
|||
}
|
||||
#define gh_scm2char GSWIG_scm2char
|
||||
|
||||
/* Interface function */
|
||||
#define SWIG_scm2str(x) gh_scm2newstr(x, NULL)
|
||||
|
||||
/* More 1.3.4 compatibility */
|
||||
#ifndef SCM_INPUT_PORT_P
|
||||
# define SCM_INPUT_PORT_P SCM_INPORTP
|
||||
# define SCM_OUTPUT_PORT_P SCM_OUTPORTP
|
||||
#endif
|
||||
|
||||
/* Type system */
|
||||
|
||||
typedef void *(*swig_converter_func)(void *);
|
||||
typedef struct swig_type_info *(*swig_dycast_func)(void **);
|
||||
|
||||
typedef struct SwigPtrType SwigPtrType;
|
||||
|
||||
typedef struct swig_type_info {
|
||||
const char *name;
|
||||
swig_converter_func converter;
|
||||
const char *str;
|
||||
void *clientdata;
|
||||
swig_dycast_func dcast;
|
||||
size_t tag;
|
||||
int dummy;
|
||||
} swig_type_info;
|
||||
|
||||
SWIGSTATIC void
|
||||
SWIG_Guile_RegisterTypes (swig_type_info **table,
|
||||
swig_type_info **init);
|
||||
|
||||
/* Register a new type-mapping with the type-checker. origtype is the
|
||||
original datatype and newtype is an equivalent type. cast is optional
|
||||
pointer to a function to cast pointer values between types (this is
|
||||
typically used to cast pointers from derived classes to base classes in
|
||||
C++). */
|
||||
|
||||
SWIGSTATIC void
|
||||
SWIG_RegisterMapping (const char *origtype, const char *newtype,
|
||||
swig_converter_func cast);
|
||||
|
||||
|
||||
/* Dynamic pointer casting. Down an inheritance hierarchy */
|
||||
SWIGSTATIC swig_type_info *
|
||||
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr);
|
||||
|
||||
/* Register SWIG smobs with Guile. */
|
||||
SWIGSTATIC void
|
||||
SWIG_Guile_Init();
|
||||
|
||||
/* Initialization function for this SWIG module; actually renamed by a
|
||||
#define */
|
||||
/* extern void SWIG_init(); */
|
||||
|
||||
/* Get a pointer value from a smob. If there is a type-mismatch,
|
||||
return nonzero; on success, return 0. */
|
||||
SWIGSTATIC int
|
||||
SWIG_Guile_GetPtr (SCM s, void **result, swig_type_info *type);
|
||||
|
||||
/* Get a pointer value from a smob. If there is a type-mismatch,
|
||||
signal a wrong-type-arg error for the given argument number. */
|
||||
SWIGSTATIC void *
|
||||
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
|
||||
int argnum, const char *func_name);
|
||||
|
||||
/* Make a smob from a pointer and typeinfo. */
|
||||
SWIGSTATIC SCM
|
||||
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type);
|
||||
|
||||
/* Get arguments from an argument list */
|
||||
SWIGSTATIC int
|
||||
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
||||
int reqargs, int optargs,
|
||||
const char *procname);
|
||||
|
||||
typedef SCM (*swig_guile_proc)();
|
||||
|
||||
#ifdef __cplusplus
|
||||
static swig_type_info *SWIG_Guile_LookupType(swig_module_info *module, SCM s, int normal) {
|
||||
swig_module_info *iter;
|
||||
if (!module) return 0;
|
||||
iter = module;
|
||||
do {
|
||||
if ((normal && (unsigned long) SCM_TYP16(s) == *((int *)iter->clientdata))) {
|
||||
|
||||
return iter->types[(long) SCM_CAR(s) >> 16];
|
||||
}
|
||||
iter = iter->next;
|
||||
} while (iter != module);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef SWIG_GLOBAL
|
||||
#define SWIG_GUILE_MODULE_STATIC
|
||||
#elif !defined(SWIG_NOINCLUDE)
|
||||
#define SWIG_GUILE_MODULE_STATIC static
|
||||
#endif
|
||||
|
||||
/* guiledec.swg ends here */
|
||||
|
||||
#ifndef SWIG_NOINCLUDE
|
||||
/* SWIG pointer structure */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#ifdef SWIG_GUILE_MODULE_STATIC
|
||||
static swig_module_info *swig_guile_module = 0;
|
||||
SWIG_GUILE_MODULE_STATIC swig_module_info *SWIG_Guile_GetModule() {
|
||||
return swig_guile_module;
|
||||
}
|
||||
SWIG_GUILE_MODULE_STATIC void SWIG_Guile_SetModule(swig_module_info *pointer) {
|
||||
swig_guile_module = pointer;
|
||||
}
|
||||
#else
|
||||
SWIGEXPORT(swig_module_info *) SWIG_Guile_GetModule();
|
||||
SWIGEXPORT(void) SWIG_Guile_SetModule(swig_module_info *pointer);
|
||||
#endif
|
||||
|
||||
struct SwigCast {
|
||||
unsigned short type; /* Index into SwigPtrTbl */
|
||||
void *(*cast)(void *); /* Pointer casting function */
|
||||
struct SwigCast *next; /* Linked list pointer */
|
||||
};
|
||||
|
||||
struct SwigPtrType {
|
||||
const char *name; /* Datatype name */
|
||||
const char *prettyname; /* Pretty datatype name */
|
||||
unsigned short tag; /* Index in SwigPtrTable */
|
||||
struct SwigCast *cast; /* List of compatible types */
|
||||
};
|
||||
|
||||
/* Some variables */
|
||||
|
||||
static int SwigPtrMax = 64; /* Max entries that can be held */
|
||||
/* (may be adjusted dynamically) */
|
||||
static int SwigPtrN = 0; /* Current number of entries */
|
||||
static int SwigPtrSort = 0; /* Status flag indicating sort */
|
||||
|
||||
/* Pointer table */
|
||||
static SwigPtrType *SwigPtrList = 0; /* Table containing types and
|
||||
equivalences; items will only
|
||||
be appended */
|
||||
static size_t *SwigPtrTbl = 0; /* Sorted indirect table; items will
|
||||
be inserted */
|
||||
|
||||
/* Sort comparison function */
|
||||
static int
|
||||
swigsort (const void *data1, const void *data2)
|
||||
{
|
||||
size_t index1 = * (size_t *) data1;
|
||||
size_t index2 = * (size_t *) data2;
|
||||
return strcmp(SwigPtrList[index1].name, SwigPtrList[index2].name);
|
||||
}
|
||||
|
||||
/* Register a new datatype with the type-checker */
|
||||
SWIGSTATIC size_t
|
||||
SWIG_RegisterType (const char *type, const char *prettyname)
|
||||
{
|
||||
int i;
|
||||
|
||||
/* Allocate the pointer table if necessary */
|
||||
if (!SwigPtrList) {
|
||||
SwigPtrList = (SwigPtrType *) malloc(SwigPtrMax*sizeof(SwigPtrType));
|
||||
SwigPtrTbl = (size_t *) malloc(SwigPtrMax*sizeof(size_t));
|
||||
SwigPtrN = 0;
|
||||
}
|
||||
/* Grow the table if necessary */
|
||||
if (SwigPtrN >= SwigPtrMax) {
|
||||
SwigPtrMax = 2*SwigPtrMax;
|
||||
SwigPtrList = (SwigPtrType *) realloc((char *) SwigPtrList,
|
||||
SwigPtrMax*sizeof(SwigPtrType));
|
||||
SwigPtrTbl = (size_t *) realloc((char *) SwigPtrTbl,
|
||||
SwigPtrMax*sizeof(size_t));
|
||||
}
|
||||
/* Look up type */
|
||||
for (i = 0; i < SwigPtrN; i++)
|
||||
if (strcmp(SwigPtrList[i].name,type) == 0) {
|
||||
if (prettyname!=NULL)
|
||||
SwigPtrList[i].prettyname = prettyname;
|
||||
return i;
|
||||
}
|
||||
{
|
||||
struct SwigPtrType *t;
|
||||
size_t tag;
|
||||
#if 0
|
||||
fprintf(stderr, "New type: %s\n", type);
|
||||
#endif
|
||||
tag = SwigPtrTbl[SwigPtrN] = SwigPtrN;
|
||||
t = &SwigPtrList[tag];
|
||||
t->name = type;
|
||||
t->prettyname = prettyname;
|
||||
t->tag = SwigPtrN;
|
||||
t->cast = NULL;
|
||||
SwigPtrN++;
|
||||
SwigPtrSort = 0;
|
||||
return tag;
|
||||
}
|
||||
}
|
||||
|
||||
/* Register two data types and their mapping with the type checker. */
|
||||
SWIGSTATIC void
|
||||
SWIG_RegisterMapping (const char *origtype, const char *newtype,
|
||||
swig_converter_func cast)
|
||||
{
|
||||
size_t t = SWIG_RegisterType(origtype, NULL);
|
||||
|
||||
if (newtype!=NULL) {
|
||||
size_t t1 = SWIG_RegisterType(newtype, NULL);
|
||||
struct SwigCast *c;
|
||||
/* Check for existing cast */
|
||||
for (c = SwigPtrList[t].cast; c && c->type!=t1; c=c->next) /* nothing */;
|
||||
if (c) {
|
||||
if (cast) c->cast = cast;
|
||||
}
|
||||
else {
|
||||
c = (struct SwigCast *) malloc(sizeof(struct SwigCast));
|
||||
c->type = t1;
|
||||
c->cast = cast;
|
||||
c->next = SwigPtrList[t].cast;
|
||||
SwigPtrList[t].cast = c;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Sort table */
|
||||
|
||||
static void
|
||||
SWIG_SortTable (void)
|
||||
{
|
||||
qsort ((void *) SwigPtrTbl, SwigPtrN, sizeof(size_t), swigsort);
|
||||
/* Indicate that everything is sorted */
|
||||
SwigPtrSort = 1;
|
||||
}
|
||||
|
||||
/* Look up pointer-type entry in table */
|
||||
|
||||
static int
|
||||
swigcmp (const void *key, const void *data)
|
||||
{
|
||||
char *k = (char *) key;
|
||||
size_t index = *(size_t *)data;
|
||||
return strcmp(k, SwigPtrList[index].name);
|
||||
}
|
||||
|
||||
static SwigPtrType *
|
||||
SWIG_GetPtrType (const char *_t)
|
||||
{
|
||||
size_t *result;
|
||||
if (!SwigPtrSort) SWIG_SortTable();
|
||||
result = (size_t *) bsearch(_t, SwigPtrTbl, SwigPtrN, sizeof(size_t), swigcmp);
|
||||
if (result!=NULL) return SwigPtrList+*result;
|
||||
else return NULL;
|
||||
}
|
||||
|
||||
/* Cast a pointer if possible; returns 1 if successful */
|
||||
|
||||
static int
|
||||
SWIG_Cast (void *source, size_t source_type,
|
||||
void **ptr, size_t dest_type)
|
||||
{
|
||||
if (dest_type != source_type) {
|
||||
/* We have a type mismatch. Will have to look through our type
|
||||
mapping table to figure out whether or not we can accept this
|
||||
datatype. */
|
||||
struct SwigCast *c;
|
||||
for (c = SwigPtrList[dest_type].cast;
|
||||
c && c->type!=source_type; c = c->next) /* nothing */;
|
||||
if (c) {
|
||||
/* Get pointer value. */
|
||||
if (c->cast) *ptr = (*(c->cast))(source);
|
||||
else *ptr = source;
|
||||
return 1;
|
||||
}
|
||||
/* Didn't find any sort of match for this data.
|
||||
Get the pointer value and return false. */
|
||||
*ptr = source;
|
||||
return 0;
|
||||
} else {
|
||||
/* Found a match on the first try. Return pointer value. */
|
||||
*ptr = source;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* Dynamic pointer casting. Down an inheritance hierarchy */
|
||||
SWIGSTATIC swig_type_info *
|
||||
SWIG_TypeDynamicCast(swig_type_info *ty, void **ptr)
|
||||
{
|
||||
swig_type_info *lastty = ty;
|
||||
if (!ty || !ty->dcast) return ty;
|
||||
while (ty && (ty->dcast)) {
|
||||
ty = (*ty->dcast)(ptr);
|
||||
if (ty) lastty = ty;
|
||||
}
|
||||
return lastty;
|
||||
}
|
||||
|
||||
/* Function for getting a pointer value */
|
||||
|
||||
static unsigned long swig_tag = 0;
|
||||
|
||||
SWIGSTATIC SCM
|
||||
SWIG_Guile_MakePtr (void *ptr, swig_type_info *type)
|
||||
static SCM
|
||||
SWIG_Guile_NewPointerObj(swig_module_info *module, void *ptr, swig_type_info *type, int owner)
|
||||
{
|
||||
unsigned long tag;
|
||||
if (ptr==NULL) return SCM_EOL;
|
||||
SCM_RETURN_NEWSMOB((((unsigned long)type->tag << 16) | swig_tag),
|
||||
ptr);
|
||||
if (!module) return SCM_EOL;
|
||||
for (tag = 0; tag < module->size; ++tag) {
|
||||
if (module->types[tag] == type)
|
||||
break;
|
||||
}
|
||||
if (tag >= module->size)
|
||||
return SCM_EOL;
|
||||
|
||||
|
||||
SCM_RETURN_NEWSMOB( ((tag << 16) | *((int *)module->clientdata)), ptr);
|
||||
}
|
||||
|
||||
/* Return 0 if successful. */
|
||||
SWIGSTATIC int
|
||||
SWIG_Guile_GetPtr(SCM s, void **result, swig_type_info *type)
|
||||
static int
|
||||
SWIG_Guile_ConvertPtr(swig_module_info *module, SCM s, void **result, swig_type_info *type, int flags)
|
||||
{
|
||||
swig_cast_info *cast;
|
||||
swig_type_info *from;
|
||||
if (SCM_NULLP(s)) {
|
||||
*result = NULL;
|
||||
return 0;
|
||||
}
|
||||
else if (SCM_NIMP(s)
|
||||
&& (unsigned long) SCM_TYP16(s) == swig_tag) {
|
||||
if (type)
|
||||
return !SWIG_Cast((void *) SCM_CDR(s),
|
||||
(long) SCM_CAR(s) >> 16,
|
||||
result, type->tag);
|
||||
else {
|
||||
} else if (SCM_NIMP(s)) {
|
||||
from = SWIG_Guile_LookupType(module, s, 1);
|
||||
if (!from) return 1;
|
||||
if (type) {
|
||||
cast = SWIG_TypeCheckStruct(from, type);
|
||||
if (cast) {
|
||||
*result = SWIG_TypeCast(cast, (void *) SCM_CDR(s));
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
} else {
|
||||
*result = (void *) SCM_CDR(s);
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -397,12 +164,12 @@ SWIG_Guile_GetPtr(SCM s, void **result, swig_type_info *type)
|
|||
return 1;
|
||||
}
|
||||
|
||||
SWIGSTATIC void *
|
||||
SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
|
||||
int argnum, const char *func_name)
|
||||
static void *
|
||||
SWIG_Guile_MustGetPtr (swig_module_info *module, SCM s, swig_type_info *type,
|
||||
int argnum, int flags, const char *func_name)
|
||||
{
|
||||
void *result;
|
||||
if (SWIG_Guile_GetPtr(s, &result, type)) {
|
||||
if (SWIG_Guile_ConvertPtr(module, s, &result, type, flags)) {
|
||||
/* type mismatch */
|
||||
scm_wrong_type_arg((char *) func_name, argnum, s);
|
||||
}
|
||||
|
|
@ -414,15 +181,21 @@ SWIG_Guile_MustGetPtr (SCM s, swig_type_info *type,
|
|||
static int
|
||||
print_swig (SCM swig_smob, SCM port, scm_print_state *pstate)
|
||||
{
|
||||
scm_puts((char *) "#<swig ", port);
|
||||
if (SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].prettyname != NULL)
|
||||
scm_puts((char*) SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].prettyname, port);
|
||||
else scm_puts((char*) SwigPtrList[(long) SCM_CAR(swig_smob) >> 16].name, port);
|
||||
scm_puts((char *) " ", port);
|
||||
scm_intprint((long) SCM_CDR(swig_smob), 16, port);
|
||||
scm_puts((char *) ">", port);
|
||||
/* non-zero means success */
|
||||
return 1;
|
||||
swig_type_info *type = SWIG_Guile_LookupType(0, swig_smob, 1);
|
||||
if (type) {
|
||||
scm_puts((char *) "#<swig ", port);
|
||||
if (type->str != NULL)
|
||||
scm_puts((char *) type->str, port);
|
||||
else
|
||||
scm_puts((char *) type->name, port);
|
||||
scm_puts((char *) " ", port);
|
||||
scm_intprint((long) SCM_CDR(swig_smob), 16, port);
|
||||
scm_puts((char *) ">", port);
|
||||
/* non-zero means success */
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static SCM
|
||||
|
|
@ -434,33 +207,14 @@ equalp_swig (SCM A, SCM B)
|
|||
else return SCM_BOOL_F;
|
||||
}
|
||||
|
||||
SWIGSTATIC void
|
||||
SWIG_Guile_Init (void)
|
||||
static void
|
||||
SWIG_Guile_Init (swig_module_info *module)
|
||||
{
|
||||
if (swig_tag == 0) {
|
||||
swig_tag = scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL,
|
||||
print_swig, equalp_swig);
|
||||
}
|
||||
*((int *)module->clientdata) =
|
||||
scm_make_smob_type_mfpe((char *) "swig", 0, NULL, NULL, print_swig, equalp_swig);
|
||||
}
|
||||
|
||||
/* Convert datatype table */
|
||||
|
||||
SWIGSTATIC
|
||||
void SWIG_Guile_RegisterTypes(swig_type_info **table,
|
||||
swig_type_info **init)
|
||||
{
|
||||
for (; *init; table++, init++) {
|
||||
swig_type_info *type = *table = *init;
|
||||
const char *origname = type->name;
|
||||
/* Register datatype itself and store pointer back */
|
||||
type->tag = SWIG_RegisterType(origname, type->str);
|
||||
/* Register compatible types */
|
||||
for (type++; type->name; type++)
|
||||
SWIG_RegisterMapping(origname, type->name, type->converter);
|
||||
}
|
||||
}
|
||||
|
||||
SWIGSTATIC int
|
||||
static int
|
||||
SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
||||
int reqargs, int optargs,
|
||||
const char *procname)
|
||||
|
|
@ -480,7 +234,7 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
|||
num_args_passed++;
|
||||
}
|
||||
for (; i<optargs; i++)
|
||||
*dest++ = GH_NOT_PASSED;
|
||||
*dest++ = SCM_UNDEFINED;
|
||||
if (!SCM_NULLP(rest))
|
||||
scm_wrong_num_args(gh_str02scm((char *) procname));
|
||||
return num_args_passed;
|
||||
|
|
@ -491,5 +245,3 @@ SWIG_Guile_GetArgs (SCM *dest, SCM rest,
|
|||
#endif
|
||||
|
||||
/* guile.swg ends here */
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@
|
|||
#define SWIGGUILE_SCM
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "common.swg"
|
||||
|
||||
%runtime "guile_scm_run.swg"
|
||||
%include "ghinterface.i"
|
||||
|
|
@ -38,19 +37,12 @@
|
|||
|
||||
%}
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
static int _swig_init = 0;
|
||||
|
||||
SWIG_Guile_Init();
|
||||
|
||||
if (!_swig_init) {
|
||||
int i;
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
SWIG_PropagateClientData(swig_types[i]);
|
||||
}
|
||||
_swig_init = 1;
|
||||
}
|
||||
SWIG_GUILE_INIT_STATIC void
|
||||
SWIG_init(void)
|
||||
{
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_PropagateClientData();
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -47,6 +47,10 @@ typedef struct swig_guile_clientdata {
|
|||
scm_error(scm_str2symbol("swig-contract-assertion-failed"), \
|
||||
(char *) FUNC_NAME, (char *) msg, \
|
||||
SCM_EOL, SCM_BOOL_F); else
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Guile_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Guile_SetModule(pointer)
|
||||
|
||||
static char *
|
||||
SWIG_Guile_scm2newstr(SCM str, size_t *len) {
|
||||
|
|
@ -138,7 +142,7 @@ SWIG_Guile_PointerType(SCM object)
|
|||
static int
|
||||
SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
|
||||
{
|
||||
swig_type_info *cast;
|
||||
swig_cast_info *cast;
|
||||
swig_type_info *from;
|
||||
SCM smob = SWIG_Guile_GetSmob(s);
|
||||
|
||||
|
|
@ -150,7 +154,7 @@ SWIG_Guile_ConvertPtr(SCM s, void **result, swig_type_info *type, int flags)
|
|||
from = (swig_type_info *) SCM_CELL_WORD_2(smob);
|
||||
if (!from) return 1;
|
||||
if (type) {
|
||||
cast = SWIG_TypeCheck((char*)from->name, type);
|
||||
cast = SWIG_TypeCheckStruct(from, type);
|
||||
if (cast) {
|
||||
*result = SWIG_TypeCast(cast, (void *) SCM_CELL_WORD_1(smob));
|
||||
return 0;
|
||||
|
|
@ -304,12 +308,12 @@ ensure_smob_tag(SCM swig_module,
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
static SCM
|
||||
SWIG_Guile_Init ()
|
||||
{
|
||||
SCM swig_module;
|
||||
static SCM swig_module;
|
||||
|
||||
if (swig_initialized) return;
|
||||
if (swig_initialized) return swig_module;
|
||||
swig_initialized = 1;
|
||||
|
||||
swig_module = scm_c_resolve_module("Swig swigrun");
|
||||
|
|
@ -329,19 +333,6 @@ SWIG_Guile_Init ()
|
|||
scm_set_smob_print(swig_destroyed_tag, print_destroyed_swig);
|
||||
scm_set_smob_equalp(swig_destroyed_tag, equalp_swig);
|
||||
}
|
||||
{
|
||||
SCM variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
|
||||
scm_module_lookup_closure(swig_module),
|
||||
SCM_BOOL_T);
|
||||
if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
|
||||
SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_type_list_handle));
|
||||
}
|
||||
else {
|
||||
swig_type_list_handle
|
||||
= (swig_type_info **) scm_num2ulong(SCM_VARIABLE_REF(variable), 0,
|
||||
"SWIG_Guile_Init");
|
||||
}
|
||||
}
|
||||
swig_make_func = scm_permanent_object(
|
||||
scm_variable_ref(scm_c_module_lookup(scm_c_resolve_module("oop goops"), "make")));
|
||||
swig_keyword = scm_permanent_object(scm_c_make_keyword((char*) "init-smob"));
|
||||
|
|
@ -349,6 +340,41 @@ SWIG_Guile_Init ()
|
|||
#ifdef SWIG_INIT_RUNTIME_MODULE
|
||||
SWIG_INIT_RUNTIME_MODULE
|
||||
#endif
|
||||
|
||||
return swig_module;
|
||||
}
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_Guile_GetModule()
|
||||
{
|
||||
SCM module;
|
||||
SCM variable;
|
||||
|
||||
module = SWIG_Guile_Init();
|
||||
|
||||
variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
|
||||
scm_module_lookup_closure(module),
|
||||
SCM_BOOL_T);
|
||||
if (SCM_UNBNDP(SCM_VARIABLE_REF(variable))) {
|
||||
return NULL;
|
||||
} else {
|
||||
return (swig_module_info *) scm_num2ulong(SCM_VARIABLE_REF(variable), 0, "SWIG_Guile_Init");
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Guile_SetModule(swig_module_info *swig_module)
|
||||
{
|
||||
SCM module;
|
||||
SCM variable;
|
||||
|
||||
module = SWIG_Guile_Init();
|
||||
|
||||
variable = scm_sym2var(scm_str2symbol("swig-type-list-address" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME),
|
||||
scm_module_lookup_closure(module),
|
||||
SCM_BOOL_T);
|
||||
|
||||
SCM_VARIABLE_SET(variable, scm_ulong2num((unsigned long) swig_module));
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
|||
|
|
@ -23,6 +23,11 @@ extern "C" {
|
|||
#define SWIG_MustGetPtr(s, type, argnum, flags) \
|
||||
SWIG_MzScheme_MustGetPtr(s, type, argnum, flags, FUNC_NAME, argc, argv)
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_MzScheme_GetModule((Scheme_Env *)(clientdata))
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_MzScheme_SetModule((Scheme_Env *) (clientdata), pointer)
|
||||
#define SWIG_MODULE_CLIENTDATA_TYPE Scheme_Env *
|
||||
|
||||
/* MzScheme-specific SWIG API */
|
||||
|
||||
#define SWIG_malloc(size) SWIG_MzScheme_Malloc(size, FUNC_NAME)
|
||||
|
|
@ -39,42 +44,8 @@ struct swig_mz_proxy {
|
|||
void *object;
|
||||
};
|
||||
|
||||
/* The interpreter will store a pointer to this structure in a global
|
||||
variable called swig-runtime-data-type-pointer. The instance of this
|
||||
struct is only used if no other module has yet been loaded */
|
||||
struct swig_mzscheme_runtime_data {
|
||||
swig_type_info **handle;
|
||||
Scheme_Type type;
|
||||
};
|
||||
static struct swig_mzscheme_runtime_data swig_mzscheme_runtime_data;
|
||||
|
||||
static Scheme_Type swig_type;
|
||||
|
||||
static void
|
||||
SWIG_MzScheme_LookupTypePointer(Scheme_Env *env) {
|
||||
Scheme_Object *pointer, *symbol;
|
||||
struct swig_mzscheme_runtime_data *data;
|
||||
|
||||
/* first check if pointer already created */
|
||||
symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
||||
pointer = scheme_lookup_global(symbol, env);
|
||||
if (pointer && SCHEME_CPTRP(pointer)) {
|
||||
data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer);
|
||||
swig_type_list_handle = data->handle;
|
||||
swig_type = data->type;
|
||||
} else {
|
||||
/* create a new type for wrapped pointer values */
|
||||
swig_type = scheme_make_type((char *)"swig");
|
||||
swig_mzscheme_runtime_data.handle = swig_type_list_handle;
|
||||
swig_mzscheme_runtime_data.type = swig_type;
|
||||
|
||||
/* create a new pointer */
|
||||
pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, "swig_mzscheme_runtime_data");
|
||||
scheme_add_global_symbol(symbol, pointer, env);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
mz_free_swig(void *p, void *data) {
|
||||
struct swig_mz_proxy *proxy = (struct swig_mz_proxy *) p;
|
||||
|
|
@ -102,7 +73,7 @@ SWIG_MzScheme_NewPointerObj(void *ptr, swig_type_info *type, int owner) {
|
|||
|
||||
static int
|
||||
SWIG_MzScheme_ConvertPtr(Scheme_Object *s, void **result, swig_type_info *type, int flags) {
|
||||
swig_type_info *cast;
|
||||
swig_cast_info *cast;
|
||||
|
||||
if (SCHEME_NULLP(s)) {
|
||||
*result = NULL;
|
||||
|
|
@ -192,7 +163,58 @@ SWIG_MzScheme_new_scheme_struct (Scheme_Env* env, const char* basename,
|
|||
|
||||
return new_type;
|
||||
}
|
||||
|
||||
/* The interpreter will store a pointer to this structure in a global
|
||||
variable called swig-runtime-data-type-pointer. The instance of this
|
||||
struct is only used if no other module has yet been loaded */
|
||||
struct swig_mzscheme_runtime_data {
|
||||
swig_module_info *module_head;
|
||||
Scheme_Type type;
|
||||
};
|
||||
static struct swig_mzscheme_runtime_data swig_mzscheme_runtime_data;
|
||||
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_MzScheme_GetModule(Scheme_Env *env) {
|
||||
Scheme_Object *pointer, *symbol;
|
||||
struct swig_mzscheme_runtime_data *data;
|
||||
|
||||
/* first check if pointer already created */
|
||||
symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
||||
pointer = scheme_lookup_global(symbol, env);
|
||||
if (pointer && SCHEME_CPTRP(pointer)) {
|
||||
data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer);
|
||||
swig_type = data->type;
|
||||
return data->module_head;
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_MzScheme_SetModule(Scheme_Env *env, swig_module_info *module) {
|
||||
Scheme_Object *pointer, *symbol;
|
||||
struct swig_mzscheme_runtime_data *data;
|
||||
|
||||
/* first check if pointer already created */
|
||||
symbol = scheme_intern_symbol("swig-runtime-data-type-pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
||||
pointer = scheme_lookup_global(symbol, env);
|
||||
if (pointer && SCHEME_CPTRP(pointer)) {
|
||||
data = (struct swig_mzscheme_runtime_data *) SCHEME_CPTR_VAL(pointer);
|
||||
swig_type = data->type;
|
||||
data->module_head = module;
|
||||
} else {
|
||||
/* create a new type for wrapped pointer values */
|
||||
swig_type = scheme_make_type((char *)"swig");
|
||||
swig_mzscheme_runtime_data.module_head = module;
|
||||
swig_mzscheme_runtime_data.type = swig_type;
|
||||
|
||||
/* create a new pointer */
|
||||
pointer = scheme_make_cptr((void *) &swig_mzscheme_runtime_data, "swig_mzscheme_runtime_data");
|
||||
scheme_add_global_symbol(symbol, pointer, env);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
/* Include headers */
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "common.swg"
|
||||
%runtime "mzrun.swg"
|
||||
|
||||
%define SWIG_APPEND_VALUE(value)
|
||||
|
|
@ -22,15 +21,11 @@
|
|||
/* Read in standard typemaps. */
|
||||
%include "typemaps.i"
|
||||
|
||||
%init %{
|
||||
static int _swig_init = 0;
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
if (!_swig_init) {
|
||||
int i;
|
||||
SWIG_MzScheme_LookupTypePointer(env);
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
_swig_init = 1;
|
||||
}
|
||||
%init %{
|
||||
Scheme_Object *scheme_reload(Scheme_Env *env) {
|
||||
Scheme_Env *menv = SWIG_MZSCHEME_CREATE_MENV(env);
|
||||
|
||||
SWIG_InitializeModule((void *) env);
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -91,7 +91,7 @@
|
|||
%typemap(in) enum SWIGTYPE {
|
||||
if (!SCHEME_INTP($input))
|
||||
scheme_wrong_type(FUNC_NAME, "integer", $argnum - 1, argc, argv);
|
||||
$1 = SCHEME_INT_VAL($input);
|
||||
$1 = ($1_type) SCHEME_INT_VAL($input);
|
||||
}
|
||||
|
||||
%typemap(varin) enum SWIGTYPE {
|
||||
|
|
|
|||
|
|
@ -3,14 +3,18 @@
|
|||
This file is parsed by SWIG before reading any other interface
|
||||
file. */
|
||||
|
||||
%runtime %{
|
||||
#define SWIGSTATIC static
|
||||
%}
|
||||
|
||||
/* Insert common stuff */
|
||||
%insert(runtime) "swigrun.swg"
|
||||
%insert(runtime) "common.swg"
|
||||
|
||||
/* Include headers */
|
||||
%insert(runtime) "ocamldec.swg"
|
||||
|
||||
/* Type registration */
|
||||
%insert(init) "swiginit.swg"
|
||||
%insert(init) "typeregister.swg"
|
||||
|
||||
%insert(mlitail) %{
|
||||
|
|
|
|||
|
|
@ -58,8 +58,8 @@ extern "C" {
|
|||
*ptr = source;
|
||||
return 0;
|
||||
} else {
|
||||
swig_type_info *tc =
|
||||
SWIG_TypeCheck( (char *)source_type->name, dest_type );
|
||||
swig_cast_info *tc =
|
||||
SWIG_TypeCheckStruct(source_type, dest_type );
|
||||
#ifdef TYPE_CAST_VERBOSE
|
||||
fprintf( stderr, "Typecheck -> %s\n",
|
||||
tc ? tc->str : "<none>" );
|
||||
|
|
@ -371,11 +371,12 @@ extern "C" {
|
|||
CAMLreturn(vv);
|
||||
}
|
||||
|
||||
SWIGSTATIC CAML_VALUE caml_val_obj( void *v, char *object_type ) {
|
||||
#define caml_val_obj(v, name) caml_val_obj_helper(v, SWIG_TypeQuery((name)), name)
|
||||
SWIGSTATIC CAML_VALUE caml_val_obj_helper( void *v, swig_type_info *type, char *name) {
|
||||
CAMLparam0();
|
||||
CAMLreturn(callback2(*caml_named_value("caml_create_object_fn"),
|
||||
caml_val_ptr(v,SWIG_TypeQuery(object_type)),
|
||||
copy_string(object_type)));
|
||||
caml_val_ptr(v,type),
|
||||
copy_string(name)));
|
||||
}
|
||||
|
||||
SWIGSTATIC long caml_long_val_full( CAML_VALUE v, char *name ) {
|
||||
|
|
@ -575,14 +576,21 @@ extern "C" {
|
|||
}
|
||||
}
|
||||
|
||||
static void SWIG_Ocaml_LookupTypePointer() {
|
||||
CAML_VALUE mod_pointer, pointer;
|
||||
static swig_module_info *SWIG_Ocaml_GetModule() {
|
||||
CAML_VALUE pointer;
|
||||
|
||||
mod_pointer = caml_val_ptr(swig_type_list_handle, NULL);
|
||||
pointer = callback(*caml_named_value("swig_find_type_info"), mod_pointer);
|
||||
if (SWIG_Tag_val(pointer) == C_ptr) {
|
||||
swig_type_list_handle = (swig_type_info **)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0));
|
||||
pointer = callback(*caml_named_value("swig_find_type_info"), caml_val_int(0));
|
||||
if (Is_block(pointer) && SWIG_Tag_val(pointer) == C_ptr) {
|
||||
return (swig_module_info *)(void *)(long)SWIG_Int64_val(SWIG_Field(pointer,0));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SWIG_Ocaml_SetModule(swig_module_info *pointer) {
|
||||
CAML_VALUE mod_pointer;
|
||||
|
||||
mod_pointer = caml_val_ptr(pointer, NULL);
|
||||
callback(*caml_named_value("swig_set_type_info"), mod_pointer);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -590,7 +598,7 @@ extern "C" {
|
|||
#endif
|
||||
#undef value
|
||||
|
||||
|
||||
/* ocaml keywords */
|
||||
/* please test and activate */
|
||||
/* There's no need to use this, because of my rewriting machinery. C++
|
||||
* words never collide with ocaml keywords */
|
||||
//%include "ocamlkw.swg"
|
||||
|
|
|
|||
|
|
@ -81,14 +81,9 @@ CAMLextern int64 Int64_val(caml_value_t v);
|
|||
#define SWIG_Int64_val(v) Int64_val(v)
|
||||
#endif
|
||||
|
||||
#ifdef __GNUC__
|
||||
# define SWIGSTATIC static inline
|
||||
#else
|
||||
# define SWIGSTATIC static
|
||||
#endif
|
||||
|
||||
|
||||
#define SWIG_NewPointerObj(p,type,flags) caml_val_ptr(p,type)
|
||||
#define SWIG_GetModule(clientdata) SWIG_Ocaml_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Ocaml_SetModule(pointer)
|
||||
|
||||
#define SWIG_contract_assert(expr, msg) if(!(expr)) {failwith(msg);} else
|
||||
|
||||
|
|
|
|||
|
|
@ -143,16 +143,14 @@ let new_derived_object cfun x_class args =
|
|||
end
|
||||
|
||||
let swig_current_type_info = ref C_void
|
||||
let find_type_info obj =
|
||||
match obj with
|
||||
C_ptr _ -> if !swig_current_type_info = C_void
|
||||
then begin
|
||||
swig_current_type_info := obj ;
|
||||
obj
|
||||
end else
|
||||
!swig_current_type_info
|
||||
| _ -> raise (Failure "Internal error: passed non pointer to find_type_info")
|
||||
let find_type_info obj = !swig_current_type_info
|
||||
let _ = Callback.register "swig_find_type_info" find_type_info
|
||||
let set_type_info obj =
|
||||
match obj with
|
||||
C_ptr _ -> swig_current_type_info := obj ;
|
||||
obj
|
||||
| _ -> raise (Failure "Internal error: passed non pointer to set_type_info")
|
||||
let _ = Callback.register "swig_set_type_info" set_type_info
|
||||
|
||||
let class_master_list = Hashtbl.create 20
|
||||
let register_class_byname nm co =
|
||||
|
|
|
|||
|
|
@ -1,12 +1,2 @@
|
|||
/* Code ripped from python implementation */
|
||||
{
|
||||
static int typeinit = 0;
|
||||
int i;
|
||||
if (!typeinit) {
|
||||
SWIG_Ocaml_LookupTypePointer();
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
typeinit = 1;
|
||||
}
|
||||
}
|
||||
SWIGEXT void SWIG_init() {
|
||||
SWIG_InitializeModule(0);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "common.swg" // common type checking code
|
||||
%runtime "perlrun.swg" // Perl runtime functions
|
||||
%runtime "noembed.h" // undefine Perl5 macros
|
||||
|
||||
|
|
|
|||
|
|
@ -17,32 +17,10 @@ SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *);
|
|||
|
||||
/* Module initialization function */
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
|
||||
static void SWIG_Perl_SetTypeListHandle(swig_type_info **handle) {
|
||||
SV *pointer;
|
||||
|
||||
/* create a new pointer */
|
||||
pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE);
|
||||
sv_setiv(pointer, PTR2IV(swig_type_list_handle));
|
||||
}
|
||||
|
||||
static swig_type_info **
|
||||
SWIG_Perl_LookupTypePointer(swig_type_info **type_list_handle) {
|
||||
swig_type_info **type_pointer;
|
||||
|
||||
/* first check if module already created */
|
||||
type_pointer = SWIG_Perl_GetTypeListHandle();
|
||||
if (type_pointer) {
|
||||
return type_pointer;
|
||||
} else {
|
||||
/* create a new module and variable */
|
||||
SWIG_Perl_SetTypeListHandle(type_list_handle);
|
||||
return type_list_handle;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
|
|
@ -50,14 +28,8 @@ extern "C"
|
|||
XS(SWIG_init) {
|
||||
dXSARGS;
|
||||
int i;
|
||||
static int _init = 0;
|
||||
if (!_init) {
|
||||
swig_type_list_handle = SWIG_Perl_LookupTypePointer(swig_type_list_handle);
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
_init = 1;
|
||||
}
|
||||
|
||||
SWIG_InitializeModule(0);
|
||||
|
||||
/* Install commands */
|
||||
for (i = 0; swig_commands[i].name; i++) {
|
||||
|
|
|
|||
|
|
@ -142,6 +142,10 @@ extern "C" {
|
|||
SWIG_Perl_ConvertPacked(obj, p, s, type, flags)
|
||||
#endif
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Perl_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Perl_SetModule(pointer)
|
||||
|
||||
/* Perl-specific API */
|
||||
#ifdef PERL_OBJECT
|
||||
# define SWIG_MakePtr(sv, ptr, type, flags) \
|
||||
|
|
@ -166,63 +170,16 @@ extern "C" {
|
|||
# define SWIG_MAYBE_PERL_OBJECT
|
||||
#endif
|
||||
|
||||
static swig_type_info **
|
||||
SWIG_Perl_GetTypeListHandle() {
|
||||
static void *type_pointer = (void *)0;
|
||||
SV *pointer;
|
||||
|
||||
/* first check if pointer already created */
|
||||
if (!type_pointer) {
|
||||
pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE);
|
||||
if (pointer && SvOK(pointer)) {
|
||||
type_pointer = INT2PTR(swig_type_info **, SvIV(pointer));
|
||||
}
|
||||
}
|
||||
|
||||
return (swig_type_info **) type_pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
Search for a swig_type_info structure
|
||||
*/
|
||||
SWIGRUNTIMEINLINE swig_type_info *
|
||||
SWIG_Perl_GetTypeList() {
|
||||
swig_type_info **tlh = SWIG_Perl_GetTypeListHandle();
|
||||
return tlh ? *tlh : (swig_type_info*)0;
|
||||
}
|
||||
|
||||
#define SWIG_Runtime_GetTypeList SWIG_Perl_GetTypeList
|
||||
|
||||
static swig_type_info *
|
||||
static swig_cast_info *
|
||||
SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) {
|
||||
swig_type_info *s;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element always just a name */
|
||||
do {
|
||||
if (sv_derived_from(rv, (char *) s->name)) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
s->prev = ty;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
} while (s && (s != ty->next));
|
||||
return 0;
|
||||
SWIG_TypeCheck_Template(sv_derived_from(rv, (char *) iter->type->name), ty);
|
||||
}
|
||||
|
||||
/* Function for getting a pointer value */
|
||||
|
||||
static int
|
||||
SWIG_Perl_ConvertPtr(SWIG_MAYBE_PERL_OBJECT SV *sv, void **ptr, swig_type_info *_t, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
void *voidptr = (void *)0;
|
||||
|
||||
/* If magical, apply more magic */
|
||||
|
|
@ -332,7 +289,7 @@ static void
|
|||
/* Convert a packed value value */
|
||||
static int
|
||||
SWIG_Perl_ConvertPacked(SWIG_MAYBE_PERL_OBJECT SV *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
const char *c = 0;
|
||||
|
||||
if ((!obj) || (!SvOK(obj))) return -1;
|
||||
|
|
@ -437,6 +394,27 @@ static void _swig_create_magic(CPerlObj *pPerl, SV *sv, const char *name, int (C
|
|||
}
|
||||
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_Perl_GetModule() {
|
||||
static void *type_pointer = (void *)0;
|
||||
SV *pointer;
|
||||
|
||||
/* first check if pointer already created */
|
||||
if (!type_pointer) {
|
||||
pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE);
|
||||
if (pointer && SvOK(pointer)) {
|
||||
type_pointer = INT2PTR(swig_type_info **, SvIV(pointer));
|
||||
}
|
||||
}
|
||||
|
||||
return (swig_module_info *) type_pointer;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Perl_SetModule(swig_module_info *module) {
|
||||
SV *pointer;
|
||||
|
||||
/* create a new pointer */
|
||||
pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TRUE);
|
||||
sv_setiv(pointer, PTR2IV(module));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,10 +6,11 @@
|
|||
*/
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "common.swg" // common type checking code
|
||||
%runtime "php4run.swg" // Php4 runtime functions
|
||||
%include "utils.i" // building blocks
|
||||
|
||||
%init "swiginit.swg"
|
||||
|
||||
/* Typemaps for input parameters by value */
|
||||
|
||||
%typemap(in) int, unsigned int, unsigned short, short, unsigned short, long, unsigned long, signed char, unsigned char, enum SWIGTYPE %{
|
||||
|
|
@ -502,6 +503,11 @@ deliberate error cos this code looks bogus to me
|
|||
|
||||
%apply unsigned long { size_t };
|
||||
|
||||
%init %{
|
||||
SWIG_php_minit {
|
||||
SWIG_InitializeModule(0);
|
||||
%}
|
||||
|
||||
/* php kewords */
|
||||
/* please test and activate */
|
||||
//%include "phpkw.swg"
|
||||
|
|
|
|||
|
|
@ -31,6 +31,10 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
/* Standard SWIG API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Php4_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Php4_SetModule(pointer)
|
||||
|
||||
/* used to wrap returned objects in so we know whether they are newobject
|
||||
and need freeing, or not */
|
||||
typedef struct _swig_object_wrapper {
|
||||
|
|
@ -106,7 +110,7 @@ static int
|
|||
SWIG_ConvertPtr_(char *c, void **ptr, swig_type_info *ty) {
|
||||
register int d;
|
||||
unsigned long p;
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
|
||||
if(c == NULL) {
|
||||
*ptr = 0;
|
||||
|
|
@ -161,7 +165,7 @@ type_error:
|
|||
with the type name hard wired in. */
|
||||
static int
|
||||
SWIG_ZTS_ConvertResourceData(void * p, int type, const char *type_name, void **ptr, swig_type_info *ty TSRMLS_DC) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
|
||||
if (ty) {
|
||||
if (! type_name) {
|
||||
|
|
@ -238,3 +242,22 @@ type_error:
|
|||
|
||||
return -1;
|
||||
}
|
||||
|
||||
static char const_name[] = "swig_runtime_data_type_pointer";
|
||||
static swig_module_info *SWIG_Php4_GetModule() {
|
||||
zval *pointer;
|
||||
swig_module_info *ret = 0;
|
||||
|
||||
MAKE_STD_ZVAL(pointer);
|
||||
|
||||
if (zend_get_constant(const_name, sizeof(const_name), pointer)) {
|
||||
if (pointer->type == IS_LONG) {
|
||||
ret = (swig_module_info *) pointer->value.lval;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SWIG_Php4_SetModule(swig_module_info *pointer) {
|
||||
REGISTER_MAIN_LONG_CONSTANT(const_name, (long) pointer, 0);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%insert(runtime) "swigrun.swg"; // Common C API type-checking code
|
||||
%insert(runtime) "common.swg"; // Common type-checking code
|
||||
%insert(runtime) "pikerun.swg"; // Pike run-time code
|
||||
|
||||
%insert(runtime) %{
|
||||
|
|
@ -319,6 +318,8 @@ extern "C" {
|
|||
* The start of the Pike initialization function
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%init "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
|
@ -331,10 +332,7 @@ extern "C"
|
|||
PIKE_MODULE_INIT
|
||||
{
|
||||
struct program *pr;
|
||||
int i;
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
SWIG_InitializeModule(0);
|
||||
%}
|
||||
|
||||
/* pike keywords */
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ extern "C" {
|
|||
/* Stores information about a wrapped object */
|
||||
typedef struct swig_object_wrapper {
|
||||
void *self;
|
||||
swig_type_info *type;
|
||||
} swig_object_wrapper;
|
||||
|
||||
#ifdef THIS
|
||||
|
|
@ -29,18 +30,34 @@ typedef struct swig_object_wrapper {
|
|||
|
||||
#define SWIG_ConvertPtr SWIG_Pike_ConvertPtr
|
||||
#define SWIG_NewPointerObj SWIG_Pike_NewPointerObj
|
||||
#define SWIG_GetModule(clientdata) SWIG_Pike_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Pike_SetModule(pointer)
|
||||
|
||||
/* These need to be filled in before type sharing between modules will work */
|
||||
static swig_module_info *SWIG_Pike_GetModule() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void SWIG_Pike_SetModule(swig_module_info *pointer) {
|
||||
|
||||
}
|
||||
|
||||
/* Convert a pointer value */
|
||||
static int
|
||||
SWIG_Pike_ConvertPtr(struct object *obj, void **ptr, swig_type_info *ty, int flags) {
|
||||
char *storage;
|
||||
struct program *pr;
|
||||
swig_cast_info *tc;
|
||||
swig_object_wrapper *obj_wrapper;
|
||||
|
||||
if (ty) {
|
||||
pr = (struct program *) ty->clientdata;
|
||||
storage = get_storage(obj, pr);
|
||||
if (storage) {
|
||||
*ptr = ((swig_object_wrapper *) storage)->self;
|
||||
return 0;
|
||||
obj_wrapper = (swig_object_wrapper *) get_storage(obj, pr);
|
||||
if (obj_wrapper && obj_wrapper->type) {
|
||||
tc = SWIG_TypeCheckStruct(obj_wrapper->type, ty);
|
||||
if (tc) {
|
||||
*ptr = SWIG_TypeCast(tc, obj_wrapper->self);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
* The start of the Python initialization function
|
||||
* ------------------------------------------------------------ */
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
@ -263,33 +265,6 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
|
|||
}
|
||||
#endif
|
||||
|
||||
static swig_type_info **
|
||||
SWIG_Python_SetTypeListHandle(swig_type_info **type_list_handle) {
|
||||
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
|
||||
|
||||
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||
swig_empty_runtime_method_table);
|
||||
PyObject *pointer = PyCObject_FromVoidPtr((void *) type_list_handle, NULL);
|
||||
if (pointer && module) {
|
||||
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
||||
}
|
||||
return type_list_handle;
|
||||
}
|
||||
|
||||
static swig_type_info **
|
||||
SWIG_Python_LookupTypePointer(swig_type_info **type_list_handle) {
|
||||
swig_type_info **type_pointer;
|
||||
|
||||
/* first check if module already created */
|
||||
type_pointer = SWIG_Python_GetTypeListHandle();
|
||||
if (type_pointer) {
|
||||
return type_pointer;
|
||||
} else {
|
||||
/* create a new module and variable */
|
||||
return SWIG_Python_SetTypeListHandle(type_list_handle);
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
@ -298,42 +273,22 @@ SWIG_Python_LookupTypePointer(swig_type_info **type_list_handle) {
|
|||
* Partial Init method
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef SWIG_LINK_RUNTIME
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT(void *) SWIG_ReturnGlobalTypeList(void *);
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
#endif
|
||||
SWIGEXPORT(void) SWIG_init(void) {
|
||||
static PyObject *SWIG_globals = 0;
|
||||
static int typeinit = 0;
|
||||
PyObject *m, *d;
|
||||
int i;
|
||||
if (!SWIG_globals) SWIG_globals = SWIG_newvarlink();
|
||||
|
||||
/* Fix SwigMethods to carry the callback ptrs when needed */
|
||||
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_types_initial);
|
||||
SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
|
||||
|
||||
m = Py_InitModule((char *) SWIG_name, SwigMethods);
|
||||
d = PyModule_GetDict(m);
|
||||
|
||||
if (!typeinit) {
|
||||
#ifdef SWIG_LINK_RUNTIME
|
||||
swig_type_list_handle = (swig_type_info **) SWIG_ReturnGlobalTypeList(swig_type_list_handle);
|
||||
#else
|
||||
# ifndef SWIG_STATIC_RUNTIME
|
||||
swig_type_list_handle = SWIG_Python_LookupTypePointer(swig_type_list_handle);
|
||||
# endif
|
||||
#endif
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
typeinit = 1;
|
||||
}
|
||||
SWIG_InitializeModule(0);
|
||||
SWIG_InstallConstants(d,swig_const_table);
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@
|
|||
#define SWIG_ConvertPacked(obj, ptr, sz, ty, flags) SWIG_Python_ConvertPacked(obj, ptr, sz, ty, flags)
|
||||
#define SWIG_NewPackedObj(ptr, sz, type) SWIG_Python_NewPackedObj(ptr, sz, type)
|
||||
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Python_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Python_SetModule(pointer)
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Pointer declarations
|
||||
|
|
@ -522,7 +525,7 @@ SWIG_Python_ArgFail(int argnum)
|
|||
/* Convert a pointer value */
|
||||
SWIGRUNTIME int
|
||||
SWIG_Python_ConvertPtr(PyObject *obj, void **ptr, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
const char *c = 0;
|
||||
static PyObject *SWIG_this = 0;
|
||||
int newref = 0;
|
||||
|
|
@ -629,7 +632,7 @@ SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags)
|
|||
/* Convert a packed value value */
|
||||
SWIGRUNTIME int
|
||||
SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
const char *c = 0;
|
||||
|
||||
#if defined(SWIG_COBJECT_TYPES) && !defined(SWIG_COBJECT_PYTHON)
|
||||
|
|
@ -720,8 +723,8 @@ SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
|
|||
void *SWIG_ReturnGlobalTypeList(void *);
|
||||
#endif
|
||||
|
||||
SWIGRUNTIME swig_type_info **
|
||||
SWIG_Python_GetTypeListHandle() {
|
||||
SWIGRUNTIME swig_module_info *
|
||||
SWIG_Python_GetModule() {
|
||||
static void *type_pointer = (void *)0;
|
||||
/* first check if module already created */
|
||||
if (!type_pointer) {
|
||||
|
|
@ -736,19 +739,21 @@ SWIG_Python_GetTypeListHandle() {
|
|||
}
|
||||
}
|
||||
#endif
|
||||
return (swig_type_info **) type_pointer;
|
||||
return (swig_module_info *) type_pointer;
|
||||
}
|
||||
|
||||
/*
|
||||
Search for a swig_type_info structure
|
||||
*/
|
||||
SWIGRUNTIMEINLINE swig_type_info *
|
||||
SWIG_Python_GetTypeList() {
|
||||
swig_type_info **tlh = SWIG_Python_GetTypeListHandle();
|
||||
return tlh ? *tlh : (swig_type_info*)0;
|
||||
}
|
||||
static void
|
||||
SWIG_Python_SetModule(swig_module_info *swig_module) {
|
||||
static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
|
||||
|
||||
PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
|
||||
swig_empty_runtime_method_table);
|
||||
PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, NULL);
|
||||
if (pointer && module) {
|
||||
PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
|
||||
}
|
||||
}
|
||||
|
||||
#define SWIG_Runtime_GetTypeList SWIG_Python_GetTypeList
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,5 @@
|
|||
%}
|
||||
|
||||
%insert(runtime) "swigrun.swg"; /* Common C API type-checking code */
|
||||
%insert(runtime) "common.swg"; /* Common type-checking code */
|
||||
%insert(runtime) "pyapi.swg"; /* SWIG/Pyton API */
|
||||
%insert(runtime) "pyrun.swg"; /* Python run-time code */
|
||||
|
|
|
|||
|
|
@ -6,9 +6,10 @@
|
|||
|
||||
%runtime "rubyhead.swg"
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "common.swg"
|
||||
%runtime "rubydef.swg"
|
||||
|
||||
%insert(initbeforefunc) "swiginit.swg"
|
||||
|
||||
#define %alias %feature("alias")
|
||||
#define %freefunc %feature("freefunc")
|
||||
#define %markfunc %feature("markfunc")
|
||||
|
|
|
|||
|
|
@ -5,6 +5,10 @@
|
|||
SWIG_Ruby_NewPointerObj(p, type, flags)
|
||||
#define SWIG_MustGetPtr(p, type, argnum, flags) \
|
||||
SWIG_Ruby_MustGetPtr(p, type, argnum, flags)
|
||||
#define SWIG_GetModule(clientdata) \
|
||||
SWIG_Ruby_GetModule()
|
||||
#define SWIG_SetModule(clientdata, pointer) \
|
||||
SWIG_Ruby_SetModule(pointer)
|
||||
|
||||
/* Ruby-specific SWIG API */
|
||||
|
||||
|
|
@ -36,23 +40,9 @@ static VALUE swig_runtime_data_type_pointer = Qnil;
|
|||
static void
|
||||
SWIG_Ruby_InitRuntime(void)
|
||||
{
|
||||
VALUE pointer;
|
||||
|
||||
if (_mSWIG == Qnil) {
|
||||
_mSWIG = rb_define_module("SWIG");
|
||||
}
|
||||
|
||||
/* first check if pointer already created */
|
||||
pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
||||
if (pointer != Qnil) {
|
||||
Data_Get_Struct(pointer, swig_type_info *, swig_type_list_handle);
|
||||
} else {
|
||||
/* register a new class */
|
||||
VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
|
||||
/* create and store the structure pointer to a global variable */
|
||||
swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, swig_type_list_handle);
|
||||
rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
|
||||
}
|
||||
}
|
||||
|
||||
/* Define Ruby class for C type */
|
||||
|
|
@ -120,7 +110,7 @@ static int
|
|||
SWIG_Ruby_ConvertPtr(VALUE obj, void **ptr, swig_type_info *ty, int flags)
|
||||
{
|
||||
char *c;
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
|
||||
/* Grab the pointer */
|
||||
if (NIL_P(obj)) {
|
||||
|
|
@ -190,7 +180,7 @@ SWIG_Ruby_NewPackedObj(void *ptr, int sz, swig_type_info *type) {
|
|||
/* Convert a packed value value */
|
||||
static void
|
||||
SWIG_Ruby_ConvertPacked(VALUE obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
const char *c;
|
||||
|
||||
if (TYPE(obj) != T_STRING) goto type_error;
|
||||
|
|
@ -216,6 +206,26 @@ type_error:
|
|||
}
|
||||
}
|
||||
|
||||
static swig_module_info *SWIG_Ruby_GetModule() {
|
||||
VALUE pointer;
|
||||
swig_module_info *ret = 0;
|
||||
|
||||
/* first check if pointer already created */
|
||||
pointer = rb_gv_get("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME);
|
||||
if (pointer != Qnil) {
|
||||
Data_Get_Struct(pointer, swig_module_info, ret);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void SWIG_Ruby_SetModule(swig_module_info *pointer) {
|
||||
/* register a new class */
|
||||
VALUE cl = rb_define_class("swig_runtime_data", rb_cObject);
|
||||
/* create and store the structure pointer to a global variable */
|
||||
swig_runtime_data_type_pointer = Data_Wrap_Struct(cl, 0, 0, pointer);
|
||||
rb_define_readonly_variable("$swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, &swig_runtime_data_type_pointer);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -15,32 +15,32 @@
|
|||
|
||||
* -----------------------------------------------------------------------------*/
|
||||
|
||||
#ifdef SWIG_MODULE_CLIENTDATA_TYPE
|
||||
|
||||
SWIGRUNTIMEINLINE swig_type_info *
|
||||
SWIG_Runtime_TypeQuery(const char *name) {
|
||||
swig_type_info *tl = SWIG_Runtime_GetTypeList();
|
||||
return SWIG_TypeQueryTL(tl, name);
|
||||
SWIG_TypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
|
||||
swig_module_info *module = SWIG_Runtime_GetModule(clientdata);
|
||||
return SWIG_TypeQueryModule(module, module, name);
|
||||
}
|
||||
|
||||
SWIGRUNTIMEINLINE swig_type_info *
|
||||
SWIG_Runtime_TypeRegister(swig_type_info *ti) {
|
||||
swig_type_info *tl = SWIG_Runtime_GetTypeList();
|
||||
return SWIG_TypeRegisterTL(&tl, ti);
|
||||
SWIG_MangledTypeQuery(SWIG_MODULE_CLIENTDATA_TYPE clientdata, const char *name) {
|
||||
swig_module_info *module = SWIG_Runtime_GetModule(clientdata);
|
||||
return SWIG_MangledTypeQueryModule(module, module, name);
|
||||
}
|
||||
|
||||
SWIGRUNTIMEINLINE void
|
||||
SWIG_Runtime_TypeClientData(swig_type_info *ti, void *clientdata) {
|
||||
swig_type_info *tl = SWIG_Runtime_GetTypeList();
|
||||
SWIG_TypeClientDataTL(tl, ti, clientdata);
|
||||
#else
|
||||
|
||||
SWIGRUNTIMEINLINE swig_type_info *
|
||||
SWIG_TypeQuery(const char *name) {
|
||||
swig_module_info *module = SWIG_Runtime_GetModule();
|
||||
return SWIG_TypeQueryModule(module, module, name);
|
||||
}
|
||||
|
||||
SWIGRUNTIMEINLINE void
|
||||
SWIG_Runtime_PropagateClientData(swig_type_info *type) {
|
||||
swig_type_info *tl = SWIG_Runtime_GetTypeList();
|
||||
SWIG_PropagateClientDataTL(tl, type);
|
||||
SWIGRUNTIMEINLINE swig_type_info *
|
||||
SWIG_MangledTypeQuery(const char *name) {
|
||||
swig_module_info *module = SWIG_Runtime_GetModule();
|
||||
return SWIG_MangledTypeQueryModule(module, module, name);
|
||||
}
|
||||
|
||||
#define SWIG_GetTypeList() SWIG_Runtime_GetTypeList()
|
||||
#define SWIG_TypeQuery(name) SWIG_Runtime_TypeQuery(name)
|
||||
#define SWIG_TypeRegister(ti) SWIG_Runtime_TypeRegister(ti)
|
||||
#define SWIG_TypeClientData(ti, cd) SWIG_Runtime_TypeClientData(ti, cd)
|
||||
#define SWIG_PropagateClientData(ti) SWIG_Runtime_PropagateClientData(ti)
|
||||
#endif
|
||||
|
|
|
|||
147
Lib/swiginit.swg
Normal file
147
Lib/swiginit.swg
Normal file
|
|
@ -0,0 +1,147 @@
|
|||
/*************************************************************************
|
||||
* Type initialization:
|
||||
* This problem is tough by the requirement that no dynamic
|
||||
* memory is used. Also, since swig_type_info structures store pointers to
|
||||
* swig_cast_info structures and swig_cast_info structures store pointers back
|
||||
* to swig_type_info structures, we need some lookup code at initialization.
|
||||
* The idea is that swig generates all the structures that are needed.
|
||||
* The runtime then collects these partially filled structures.
|
||||
* The SWIG_InitializeModule function takes these initial arrays out of
|
||||
* swig_module, and does all the lookup, filling in the swig_module.types
|
||||
* array with the correct data and linking the correct swig_cast_info
|
||||
* structures together.
|
||||
|
||||
* The generated swig_type_info structures are assigned staticly to an initial
|
||||
* array. We just loop though that array, and handle each type individually.
|
||||
* First we lookup if this type has been already loaded, and if so, use the
|
||||
* loaded structure instead of the generated one. Then we have to fill in the
|
||||
* cast linked list. The cast data is initially stored in something like a
|
||||
* two-dimensional array. Each row corresponds to a type (there are the same
|
||||
* number of rows as there are in the swig_type_initial array). Each entry in
|
||||
* a column is one of the swig_cast_info structures for that type.
|
||||
* The cast_initial array is actually an array of arrays, because each row has
|
||||
* a variable number of columns. So to actually build the cast linked list,
|
||||
* we find the array of casts associated with the type, and loop through it
|
||||
* adding the casts to the list. The one last trick we need to do is making
|
||||
* sure the type pointer in the swig_cast_info struct is correct.
|
||||
|
||||
* First off, we lookup the cast->type name to see if it is already loaded.
|
||||
* There are three cases to handle:
|
||||
* 1) If the cast->type has already been loaded AND the type we are adding
|
||||
* casting info to has not been loaded (it is in this module), THEN we
|
||||
* replace the cast->type pointer with the type pointer that has already
|
||||
* been loaded.
|
||||
* 2) If BOTH types (the one we are adding casting info to, and the
|
||||
* cast->type) are loaded, THEN the cast info has already been loaded by
|
||||
* the previous module so we just ignore it.
|
||||
* 3) Finally, if cast->type has not already been loaded, then we add that
|
||||
* swig_cast_info to the linked list (because the cast->type) pointer will
|
||||
* be correct.
|
||||
**/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
SWIGRUNTIME void
|
||||
SWIG_InitializeModule(void *clientdata) {
|
||||
swig_type_info *type, *ret;
|
||||
swig_cast_info *cast;
|
||||
int i;
|
||||
swig_module_info *module_head;
|
||||
static int init_run = 0;
|
||||
|
||||
if (init_run) return;
|
||||
init_run = 1;
|
||||
|
||||
/* Initialize the swig_module */
|
||||
swig_module.type_initial = swig_type_initial;
|
||||
swig_module.cast_initial = swig_cast_initial;
|
||||
|
||||
/* Try and load any already created modules */
|
||||
module_head = SWIG_GetModule(clientdata);
|
||||
if (module_head) {
|
||||
swig_module.next = module_head->next;
|
||||
module_head->next = &swig_module;
|
||||
} else {
|
||||
/* This is the first module loaded */
|
||||
swig_module.next = &swig_module;
|
||||
SWIG_SetModule(clientdata, &swig_module);
|
||||
}
|
||||
|
||||
/* Now work on filling in swig_module.types */
|
||||
for (i = 0; i < swig_module.size; ++i) {
|
||||
type = 0;
|
||||
|
||||
/* if there is another module already loaded */
|
||||
if (swig_module.next != &swig_module) {
|
||||
type = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, swig_module.type_initial[i]->name);
|
||||
}
|
||||
if (type) {
|
||||
/* Overwrite clientdata field */
|
||||
if (swig_module.type_initial[i]->clientdata) type->clientdata = swig_module.type_initial[i]->clientdata;
|
||||
} else {
|
||||
type = swig_module.type_initial[i];
|
||||
}
|
||||
|
||||
/* Insert casting types */
|
||||
cast = swig_module.cast_initial[i];
|
||||
while (cast->type) {
|
||||
|
||||
/* Don't need to add information already in the list */
|
||||
ret = 0;
|
||||
if (swig_module.next != &swig_module) {
|
||||
ret = SWIG_MangledTypeQueryModule(swig_module.next, &swig_module, cast->type->name);
|
||||
}
|
||||
if (ret && type == swig_module.type_initial[i]) {
|
||||
cast->type = ret;
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
if (!ret) {
|
||||
if (type->cast) {
|
||||
type->cast->prev = cast;
|
||||
cast->next = type->cast;
|
||||
}
|
||||
type->cast = cast;
|
||||
}
|
||||
|
||||
cast++;
|
||||
}
|
||||
|
||||
/* Set entry in modules->types array equal to the type */
|
||||
swig_module.types[i] = type;
|
||||
}
|
||||
}
|
||||
|
||||
/* This function will propagate the clientdata field of type to
|
||||
* any new swig_type_info structures that have been added into the list
|
||||
* of equivalent types. It is like calling
|
||||
* SWIG_TypeClientData(type, clientdata) a second time.
|
||||
*/
|
||||
SWIGRUNTIME void
|
||||
SWIG_PropagateClientData() {
|
||||
int i;
|
||||
swig_cast_info *equiv;
|
||||
static int init_run = 0;
|
||||
|
||||
if (init_run) return;
|
||||
init_run = 1;
|
||||
|
||||
for (i = 0; i < swig_module.size; i++) {
|
||||
if (swig_module.types[i]->clientdata) {
|
||||
equiv = swig_module.types[i]->cast;
|
||||
while (equiv) {
|
||||
if (!equiv->converter) {
|
||||
if (equiv->type && !equiv->type->clientdata)
|
||||
SWIG_TypeClientData(equiv->type, swig_module.types[i]->clientdata);
|
||||
}
|
||||
equiv = equiv->next;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
300
Lib/swigrun.swg
300
Lib/swigrun.swg
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* This should only be incremented when either the layout of swig_type_info changes,
|
||||
or for whatever reason, the runtime changes incompatibly */
|
||||
#define SWIG_RUNTIME_VERSION "1"
|
||||
#define SWIG_RUNTIME_VERSION "2"
|
||||
|
||||
/* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
|
||||
#ifdef SWIG_TYPE_TABLE
|
||||
|
|
@ -44,6 +44,17 @@
|
|||
#define SWIGRUNTIMEINLINE SWIGRUNTIME SWIGINLINE
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
|
||||
# if !defined(STATIC_LINKED)
|
||||
# define SWIGEXPORT(a) __declspec(dllexport) a
|
||||
# else
|
||||
# define SWIGEXPORT(a) a
|
||||
# endif
|
||||
#else
|
||||
# define SWIGEXPORT(a) a
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
|
@ -51,16 +62,36 @@ extern "C" {
|
|||
typedef void *(*swig_converter_func)(void *);
|
||||
typedef struct swig_type_info *(*swig_dycast_func)(void **);
|
||||
|
||||
/* Structure to store inforomation on one type */
|
||||
typedef struct swig_type_info {
|
||||
const char *name;
|
||||
swig_converter_func converter;
|
||||
const char *str;
|
||||
void *clientdata;
|
||||
swig_dycast_func dcast;
|
||||
struct swig_type_info *next;
|
||||
struct swig_type_info *prev;
|
||||
const char *name; /* mangled name of this type */
|
||||
const char *str; /* human readable name of this type */
|
||||
swig_dycast_func dcast; /* dynamic cast function down a hierarchy */
|
||||
struct swig_cast_info *cast; /* linked list of types that can cast into this type */
|
||||
void *clientdata; /* language specific type data */
|
||||
} swig_type_info;
|
||||
|
||||
/* Structure to store a type and conversion function used for casting */
|
||||
typedef struct swig_cast_info {
|
||||
swig_type_info *type; /* pointer to type that is equivalent to this type */
|
||||
swig_converter_func converter; /* function to cast the void pointers */
|
||||
struct swig_cast_info *next; /* pointer to next cast in linked list */
|
||||
struct swig_cast_info *prev; /* pointer to the previous cast */
|
||||
} swig_cast_info;
|
||||
|
||||
/* Structure used to store module information
|
||||
* Each module generates one structure like this, and the runtime collects
|
||||
* all of these structures and stores them in a circularly linked list.*/
|
||||
typedef struct swig_module_info {
|
||||
swig_type_info **types; /* Array of pointers to swig_type_info structures that are in this module */
|
||||
int size; /* Number of types in this module */
|
||||
struct swig_module_info *next; /* Pointer to next element in circularly linked list */
|
||||
swig_type_info **type_initial; /* Array of initially generated type structures */
|
||||
swig_cast_info **cast_initial; /* Array of initially generated casting structures */
|
||||
void *clientdata; /* Language specific module data */
|
||||
} swig_module_info;
|
||||
|
||||
|
||||
/*
|
||||
Compare two type names skipping the space characters, therefore
|
||||
"char*" == "char *" and "Class<int>" == "Class<int >", etc.
|
||||
|
|
@ -81,6 +112,7 @@ SWIG_TypeNameComp(const char *f1, const char *l1,
|
|||
|
||||
/*
|
||||
Check type equivalence in a name list like <name1>|<name2>|...
|
||||
Return 0 if not equal, 1 if equal
|
||||
*/
|
||||
SWIGRUNTIME int
|
||||
SWIG_TypeEquiv(const char *nb, const char *tb) {
|
||||
|
|
@ -98,89 +130,70 @@ SWIG_TypeEquiv(const char *nb, const char *tb) {
|
|||
}
|
||||
|
||||
/*
|
||||
Register a type mapping with the type-checking
|
||||
Check type equivalence in a name list like <name1>|<name2>|...
|
||||
Return 0 if equal, -1 if nb < tb, 1 if nb > tb
|
||||
*/
|
||||
SWIGRUNTIME swig_type_info *
|
||||
SWIG_TypeRegisterTL(swig_type_info **tl, swig_type_info *ti) {
|
||||
swig_type_info *tc, *head, *ret, *next;
|
||||
/* Check to see if this type has already been registered */
|
||||
tc = *tl;
|
||||
while (tc) {
|
||||
/* check simple type equivalence */
|
||||
int typeequiv = (strcmp(tc->name, ti->name) == 0);
|
||||
/* check full type equivalence, resolving typedefs */
|
||||
if (!typeequiv) {
|
||||
/* only if tc is not a typedef (no '|' on it) */
|
||||
if (tc->str && ti->str && !strstr(tc->str,"|")) {
|
||||
typeequiv = SWIG_TypeEquiv(ti->str,tc->str);
|
||||
}
|
||||
SWIGRUNTIME int
|
||||
SWIG_TypeCompare(const char *nb, const char *tb) {
|
||||
int equiv = 0;
|
||||
const char* te = tb + strlen(tb);
|
||||
const char* ne = nb;
|
||||
while (!equiv && *ne) {
|
||||
for (nb = ne; *ne; ++ne) {
|
||||
if (*ne == '|') break;
|
||||
}
|
||||
if (typeequiv) {
|
||||
/* Already exists in the table. Just add additional types to the list */
|
||||
if (ti->clientdata) tc->clientdata = ti->clientdata;
|
||||
head = tc;
|
||||
next = tc->next;
|
||||
goto l1;
|
||||
}
|
||||
tc = tc->prev;
|
||||
equiv = SWIG_TypeNameComp(nb, ne, tb, te) == 0;
|
||||
if (*ne) ++ne;
|
||||
}
|
||||
head = ti;
|
||||
next = 0;
|
||||
|
||||
/* Place in list */
|
||||
ti->prev = *tl;
|
||||
*tl = ti;
|
||||
|
||||
/* Build linked lists */
|
||||
l1:
|
||||
ret = head;
|
||||
tc = ti + 1;
|
||||
/* Patch up the rest of the links */
|
||||
while (tc->name) {
|
||||
head->next = tc;
|
||||
tc->prev = head;
|
||||
head = tc;
|
||||
tc++;
|
||||
}
|
||||
if (next) next->prev = head;
|
||||
head->next = next;
|
||||
|
||||
return ret;
|
||||
return equiv;
|
||||
}
|
||||
|
||||
|
||||
/* think of this as a c++ template<> or a scheme macro */
|
||||
#define SWIG_TypeCheck_Template(comparison, ty) \
|
||||
do { \
|
||||
swig_cast_info *iter; \
|
||||
if (!ty) return 0; \
|
||||
iter = ty->cast; \
|
||||
while (iter) { \
|
||||
if (comparison) { \
|
||||
if (iter == ty->cast) return iter; \
|
||||
\
|
||||
/* Move iter to the top of the linked list */ \
|
||||
iter->prev->next = iter->next; \
|
||||
if (iter->next) \
|
||||
iter->next->prev = iter->prev; \
|
||||
iter->next = ty->cast; \
|
||||
iter->prev = 0; \
|
||||
if (ty->cast) ty->cast->prev = iter; \
|
||||
ty->cast = iter; \
|
||||
\
|
||||
return iter; \
|
||||
} \
|
||||
iter = iter->next; \
|
||||
} \
|
||||
return 0; \
|
||||
} while(0)
|
||||
|
||||
/*
|
||||
Check the typename
|
||||
*/
|
||||
SWIGRUNTIME swig_type_info *
|
||||
SWIGRUNTIME swig_cast_info *
|
||||
SWIG_TypeCheck(const char *c, swig_type_info *ty) {
|
||||
swig_type_info *s;
|
||||
if (!ty) return 0; /* Void pointer */
|
||||
s = ty->next; /* First element always just a name */
|
||||
do {
|
||||
if (strcmp(s->name,c) == 0) {
|
||||
if (s == ty->next) return s;
|
||||
/* Move s to the top of the linked list */
|
||||
s->prev->next = s->next;
|
||||
if (s->next) {
|
||||
s->next->prev = s->prev;
|
||||
}
|
||||
/* Insert s as second element in the list */
|
||||
s->next = ty->next;
|
||||
if (ty->next) ty->next->prev = s;
|
||||
ty->next = s;
|
||||
s->prev = ty;
|
||||
return s;
|
||||
}
|
||||
s = s->next;
|
||||
} while (s && (s != ty->next));
|
||||
return 0;
|
||||
SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
|
||||
}
|
||||
|
||||
/* Same as previous function, except strcmp is replaced with a pointer comparison */
|
||||
SWIGRUNTIME swig_cast_info *
|
||||
SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
|
||||
SWIG_TypeCheck_Template(iter->type == from, into);
|
||||
}
|
||||
|
||||
/*
|
||||
Cast a pointer up an inheritance hierarchy
|
||||
*/
|
||||
SWIGRUNTIMEINLINE void *
|
||||
SWIG_TypeCast(swig_type_info *ty, void *ptr) {
|
||||
SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
|
||||
return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
|
||||
}
|
||||
|
||||
|
|
@ -227,43 +240,100 @@ SWIG_TypePrettyName(const swig_type_info *type) {
|
|||
return type->name;
|
||||
}
|
||||
|
||||
/*
|
||||
Search for a swig_type_info structure
|
||||
*/
|
||||
SWIGRUNTIME swig_type_info *
|
||||
SWIG_TypeQueryTL(swig_type_info *tl, const char *name) {
|
||||
swig_type_info *ty = tl;
|
||||
while (ty) {
|
||||
if (ty->str && (SWIG_TypeEquiv(ty->str,name))) return ty;
|
||||
if (ty->name && (strcmp(name,ty->name) == 0)) return ty;
|
||||
ty = ty->prev;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Set the clientdata field for a type
|
||||
*/
|
||||
SWIGRUNTIME void
|
||||
SWIG_TypeClientDataTL(swig_type_info *tl, swig_type_info *ti, void *clientdata) {
|
||||
swig_type_info *tc, *equiv;
|
||||
SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
|
||||
swig_cast_info *cast;
|
||||
|
||||
if (ti->clientdata) return;
|
||||
/* if (ti->clientdata == clientdata) return; */
|
||||
ti->clientdata = clientdata;
|
||||
equiv = ti->next;
|
||||
while (equiv) {
|
||||
if (!equiv->converter) {
|
||||
tc = tl;
|
||||
while (tc) {
|
||||
if ((strcmp(tc->name, equiv->name) == 0))
|
||||
SWIG_TypeClientDataTL(tl,tc,clientdata);
|
||||
tc = tc->prev;
|
||||
}
|
||||
}
|
||||
equiv = equiv->next;
|
||||
|
||||
cast = ti->cast;
|
||||
while (cast) {
|
||||
if (!cast->converter)
|
||||
SWIG_TypeClientData(cast->type, clientdata);
|
||||
cast = cast->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Search for a swig_type_info structure only by mangled name
|
||||
Search is a O(log #types)
|
||||
|
||||
We start searching at module start, and finish searching when start == end.
|
||||
Note: if start == end at the beginning of the function, we go all the way around
|
||||
the circular list.
|
||||
*/
|
||||
SWIGRUNTIME swig_type_info *
|
||||
SWIG_MangledTypeQueryModule(swig_module_info *start,
|
||||
swig_module_info *end,
|
||||
const char *name) {
|
||||
swig_module_info *iter;
|
||||
int l, r, i, compare;
|
||||
|
||||
iter = start;
|
||||
do {
|
||||
l = 0;
|
||||
r = iter->size - 1;
|
||||
while (l <= r) {
|
||||
i = (l + r) / 2;
|
||||
|
||||
if (!(iter->types[i]->name)) break; /* should never happen */
|
||||
|
||||
compare = strcmp(name, iter->types[i]->name);
|
||||
if (compare == 0)
|
||||
return iter->types[i];
|
||||
else if (compare < 0)
|
||||
r = i - 1;
|
||||
else if (compare > 0)
|
||||
l = i + 1;
|
||||
}
|
||||
iter = iter->next;
|
||||
} while (iter != end);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
Search for a swig_type_info structure for either a mangled name or a human readable name.
|
||||
It first searches the mangled names of the types, which is a O(log #types)
|
||||
If a type is not found it then searches the human readable names, which is O(#types).
|
||||
|
||||
We start searching at module start, and finish searching when start == end.
|
||||
Note: if start == end at the beginning of the function, we go all the way around
|
||||
the circular list.
|
||||
*/
|
||||
SWIGRUNTIME swig_type_info *
|
||||
SWIG_TypeQueryModule(swig_module_info *start,
|
||||
swig_module_info *end,
|
||||
const char *name) {
|
||||
swig_module_info *iter;
|
||||
swig_type_info *ret;
|
||||
int i;
|
||||
|
||||
/* STEP 1: Search the name field using binary search */
|
||||
ret = SWIG_MangledTypeQueryModule(start, end, name);
|
||||
if (ret) return ret;
|
||||
|
||||
/* STEP 2: If the type hasn't been found, do a complete search
|
||||
of the str field (the human readable name) */
|
||||
iter = start;
|
||||
do {
|
||||
for (i = 0; i < iter->size; ++i) {
|
||||
if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
|
||||
return iter->types[i];
|
||||
}
|
||||
iter = iter->next;
|
||||
} while (iter != end);
|
||||
|
||||
/* neither found a match */
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Pack binary data into a string
|
||||
*/
|
||||
|
|
@ -309,30 +379,6 @@ SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
|
|||
return c;
|
||||
}
|
||||
|
||||
/*
|
||||
This function will propagate the clientdata field of type to any new
|
||||
swig_type_info structures that have been added into the list of
|
||||
equivalent types. It is like calling SWIG_TypeClientData(type,
|
||||
clientdata) a second time.
|
||||
*/
|
||||
SWIGRUNTIME void
|
||||
SWIG_PropagateClientDataTL(swig_type_info *tl, swig_type_info *type) {
|
||||
swig_type_info *equiv = type->next;
|
||||
swig_type_info *tc;
|
||||
if (!type->clientdata) return;
|
||||
while (equiv) {
|
||||
if (!equiv->converter) {
|
||||
tc = tl;
|
||||
while (tc) {
|
||||
if ((strcmp(tc->name, equiv->name) == 0) && !tc->clientdata)
|
||||
SWIG_TypeClientDataTL(tl,tc, type->clientdata);
|
||||
tc = tc->prev;
|
||||
}
|
||||
}
|
||||
equiv = equiv->next;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Pack 'void *' into a string buffer.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -64,6 +64,7 @@ typedef struct swig_class {
|
|||
swig_attribute *attributes;
|
||||
struct swig_class **bases;
|
||||
char **base_names;
|
||||
swig_module_info *module;
|
||||
} swig_class;
|
||||
|
||||
typedef struct swig_instance {
|
||||
|
|
@ -105,22 +106,10 @@ typedef struct swig_instance {
|
|||
#define SWIG_MethodCommand SWIG_Tcl_MethodCommand
|
||||
#define SWIG_ObjectDelete SWIG_Tcl_ObjectDelete
|
||||
|
||||
static void
|
||||
SWIG_Tcl_LookupTypePointer(Tcl_Interp *interp) {
|
||||
char buf[512];
|
||||
char *data;
|
||||
|
||||
/* first check if pointer already created */
|
||||
data = (char *) Tcl_GetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY);
|
||||
if (data) {
|
||||
SWIG_UnpackData(data, &swig_type_list_handle, sizeof(swig_type_info **));
|
||||
} else {
|
||||
/* create a new pointer */
|
||||
data = SWIG_PackData(buf, &swig_type_list_handle, sizeof(swig_type_info **));
|
||||
*data = 0;
|
||||
Tcl_SetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0);
|
||||
}
|
||||
}
|
||||
/* Runtime API */
|
||||
#define SWIG_GetModule(clientdata) SWIG_Tcl_GetModule((Tcl_Interp *) (clientdata))
|
||||
#define SWIG_SetModule(clientdata, pointer) SWIG_Tcl_SetModule((Tcl_Interp *) (clientdata), pointer)
|
||||
#define SWIG_MODULE_CLIENTDATA_TYPE Tcl_Interp *
|
||||
|
||||
/* Object support */
|
||||
static Tcl_HashTable swigobjectTable;
|
||||
|
|
@ -163,7 +152,7 @@ SWIG_Tcl_Thisown(void *ptr) {
|
|||
/* Convert a pointer value */
|
||||
static int
|
||||
SWIG_Tcl_ConvertPtrFromString(Tcl_Interp *interp, const char *c, void **ptr, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
/* Pointer values must start with leading underscore */
|
||||
while (*c != '_') {
|
||||
*ptr = (void *) 0;
|
||||
|
|
@ -225,7 +214,7 @@ SWIG_Tcl_PointerTypeFromString(char *c) {
|
|||
/* Convert a packed value value */
|
||||
static int
|
||||
SWIG_Tcl_ConvertPacked(Tcl_Interp *interp, Tcl_Obj *obj, void *ptr, int sz, swig_type_info *ty, int flags) {
|
||||
swig_type_info *tc;
|
||||
swig_cast_info *tc;
|
||||
const char *c;
|
||||
|
||||
if (!obj) goto type_error;
|
||||
|
|
@ -505,7 +494,7 @@ SWIG_Tcl_MethodCommand(ClientData clientData, Tcl_Interp *interp, int objc, Tcl_
|
|||
if (bi != -1) {
|
||||
if (!cls->bases[bi] && cls->base_names[bi]) {
|
||||
/* lookup and cache the base class */
|
||||
swig_type_info *info = SWIG_TypeQuery(cls->base_names[bi]);
|
||||
swig_type_info *info = SWIG_TypeQueryModule(cls->module, cls->module, cls->base_names[bi]);
|
||||
if (info) cls->bases[bi] = (swig_class *) info->clientdata;
|
||||
}
|
||||
cls = cls->bases[bi];
|
||||
|
|
@ -750,6 +739,31 @@ typedef struct {
|
|||
|
||||
#define SWIG_contract_assert(expr, msg) if (!(expr)) { Tcl_SetResult(interp, (char *) msg, TCL_STATIC ); goto fail; } else
|
||||
|
||||
static swig_module_info *
|
||||
SWIG_Tcl_GetModule(Tcl_Interp *interp) {
|
||||
char *data;
|
||||
swig_module_info *ret = 0;
|
||||
|
||||
/* first check if pointer already created */
|
||||
data = (char *) Tcl_GetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, TCL_GLOBAL_ONLY);
|
||||
if (data) {
|
||||
SWIG_UnpackData(data, &ret, sizeof(swig_type_info **));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void
|
||||
SWIG_Tcl_SetModule(Tcl_Interp *interp, swig_module_info *module) {
|
||||
char buf[512];
|
||||
char *data;
|
||||
|
||||
/* create a new pointer */
|
||||
data = SWIG_PackData(buf, &module, sizeof(swig_type_info **));
|
||||
*data = 0;
|
||||
Tcl_SetVar(interp, "swig_runtime_data_type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, buf, 0);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
%runtime "swigrun.swg" // Common C API type-checking code
|
||||
%runtime "common.swg"
|
||||
%runtime "swigtcl8.swg"
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -632,10 +631,11 @@ SWIGEXPORT(int) SWIG_init(Tcl_Interp *);
|
|||
|
||||
/* Start the initialization function */
|
||||
|
||||
%insert(init) "swiginit.swg"
|
||||
|
||||
%init %{
|
||||
SWIGEXPORT(int) SWIG_init(Tcl_Interp *interp) {
|
||||
int i;
|
||||
static int _init = 0;
|
||||
if (interp == 0) return TCL_ERROR;
|
||||
#ifdef USE_TCL_STUBS
|
||||
if (Tcl_InitStubs(interp, (char*)"8.1", 0) == NULL) {
|
||||
|
|
@ -648,16 +648,10 @@ SWIGEXPORT(int) SWIG_init(Tcl_Interp *interp) {
|
|||
#ifdef SWIG_namespace
|
||||
Tcl_Eval(interp, "namespace eval " SWIG_namespace " { }");
|
||||
#endif
|
||||
if (!_init) {
|
||||
SWIG_Tcl_LookupTypePointer(interp);
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);
|
||||
}
|
||||
for (i = 0; swig_types_initial[i]; i++) {
|
||||
SWIG_PropagateClientData(swig_types[i]);
|
||||
}
|
||||
_init = 1;
|
||||
}
|
||||
|
||||
SWIG_InitializeModule((void *) interp);
|
||||
SWIG_PropagateClientData();
|
||||
|
||||
for (i = 0; swig_commands[i].name; i++) {
|
||||
Tcl_CreateObjCommand(interp, (char *) swig_commands[i].name, (swig_wrapper_func) swig_commands[i].wrapper, swig_commands[i].clientdata, NULL);
|
||||
}
|
||||
|
|
|
|||
7
README
7
README
|
|
@ -70,6 +70,13 @@ Information about SWIG is also available in Japanese translation at
|
|||
What's New?
|
||||
===========
|
||||
|
||||
SWIG-1.3.25 summary:
|
||||
- Improved runtime type system. Speed of module loading improved in
|
||||
modules with lots of types. SWIG_RUNTIME_VERSION has been increaced
|
||||
from 1 to 2, but the API is exactly the same; only internal changes
|
||||
were made.
|
||||
- All languages now support external access to the runtime type system.
|
||||
|
||||
SWIG-1.3.24 summary:
|
||||
- Improved enum handling
|
||||
- More runtime library options
|
||||
|
|
|
|||
|
|
@ -292,6 +292,7 @@ extern int DohCopyto(DOHFile *input, DOHFile *output);
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
extern DOHList *DohNewList();
|
||||
extern void DohSortList(DOH *lo, int (*cmp)(DOH *, DOH *));
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Hash
|
||||
|
|
@ -388,6 +389,7 @@ extern void DohMemoryDebug(void);
|
|||
#define First DohFirst
|
||||
#define Next DohNext
|
||||
#define Iterator DohIterator
|
||||
#define SortList DohSortList
|
||||
#endif
|
||||
|
||||
#ifdef NIL
|
||||
|
|
|
|||
|
|
@ -361,3 +361,18 @@ DohNewList() {
|
|||
return DohObjMalloc(&DohListType,l);
|
||||
}
|
||||
|
||||
static int (*List_sort_compare_func)(DOH *, DOH *);
|
||||
static int List_qsort_compare(const void *a, const void *b) {
|
||||
return List_sort_compare_func(*((DOH **)a), *((DOH **)b));
|
||||
}
|
||||
|
||||
/* Sort a list */
|
||||
void DohSortList(DOH *lo, int (*cmp)(DOH *, DOH *)) {
|
||||
List *l = (List *) ObjData(lo);
|
||||
if (cmp) {
|
||||
List_sort_compare_func = cmp;
|
||||
} else {
|
||||
List_sort_compare_func = DohCmp;
|
||||
}
|
||||
qsort(l->items, l->nitems, sizeof(DOH *), List_qsort_compare);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -377,12 +377,12 @@ public:
|
|||
/* Simple linkage; we have to export the SWIG_init function. The user can
|
||||
rename the function by a #define. */
|
||||
Printf (f_runtime, "extern void\nSWIG_init (void)\n;\n");
|
||||
Printf (f_init, "extern void\nSWIG_init (void)\n{\n");
|
||||
Printf (f_init, "#define SWIG_GUILE_INIT_STATIC static\n");
|
||||
break;
|
||||
default:
|
||||
/* Other linkage; we make the SWIG_init function static */
|
||||
Printf (f_runtime, "static void\nSWIG_init (void)\n;\n");
|
||||
Printf (f_init, "static void\nSWIG_init (void)\n{\n");
|
||||
Printf (f_init, "#define SWIG_GUILE_INIT_STATIC extern\n");
|
||||
break;
|
||||
}
|
||||
if (CPlusPlus) {
|
||||
|
|
|
|||
|
|
@ -155,30 +155,28 @@ public:
|
|||
|
||||
SwigType_emit_type_table (f_runtime, f_wrappers);
|
||||
if (!noinit) {
|
||||
Printf(f_init, "Scheme_Object *scheme_reload(Scheme_Env *env) {\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "\tScheme_Env *menv = scheme_primitive_module(scheme_intern_symbol(\"%s\"), env);\n", module);
|
||||
}
|
||||
else {
|
||||
Printf(f_init, "\tScheme_Env *menv = env;\n");
|
||||
}
|
||||
Printf(f_init, "%s\n", Char(init_func_def));
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "\tscheme_finish_primitive_module(menv);\n");
|
||||
}
|
||||
Printf (f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf (f_init, "}\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "#define SWIG_MZSCHEME_CREATE_MENV(env) scheme_primitive_module(scheme_intern_symbol(\"%s\"), env)\n", module);
|
||||
}
|
||||
else {
|
||||
Printf(f_init,"#define SWIG_MZSCHEME_CREATE_MENV(env) (env)\n");
|
||||
}
|
||||
Printf(f_init, "%s\n", Char(init_func_def));
|
||||
if (declaremodule) {
|
||||
Printf(f_init, "\tscheme_finish_primitive_module(menv);\n");
|
||||
}
|
||||
Printf (f_init, "\treturn scheme_void;\n}\n");
|
||||
Printf(f_init, "Scheme_Object *scheme_initialize(Scheme_Env *env) {\n");
|
||||
Printf(f_init, "\treturn scheme_reload(env);\n");
|
||||
Printf (f_init, "}\n");
|
||||
|
||||
Printf(f_init,"Scheme_Object *scheme_module_name(void) {\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, " return scheme_intern_symbol((char*)\"%s\");\n", module);
|
||||
}
|
||||
else {
|
||||
Printf(f_init," return scheme_make_symbol((char*)\"%s\");\n", module);
|
||||
}
|
||||
Printf(f_init,"}\n");
|
||||
Printf(f_init,"Scheme_Object *scheme_module_name(void) {\n");
|
||||
if (declaremodule) {
|
||||
Printf(f_init, " return scheme_intern_symbol((char*)\"%s\");\n", module);
|
||||
} else {
|
||||
Printf(f_init," return scheme_make_symbol((char*)\"%s\");\n", module);
|
||||
}
|
||||
Printf(f_init,"}\n");
|
||||
}
|
||||
|
||||
/* Close all of the files */
|
||||
|
|
|
|||
|
|
@ -337,7 +337,7 @@ public:
|
|||
Printf( f_mlibody,
|
||||
"val int_to_enum : c_enum_type -> int -> c_obj\n" );
|
||||
Printf( f_init,
|
||||
"SWIGEXT void f_%s_init() {\n"
|
||||
"#define SWIG_init f_%s_init\n"
|
||||
"%s"
|
||||
"}\n",
|
||||
module, init_func_def );
|
||||
|
|
|
|||
|
|
@ -733,12 +733,8 @@ public:
|
|||
* things are being called in the wrong order
|
||||
*/
|
||||
|
||||
Printf(s_init,"PHP_MINIT_FUNCTION(%s)\n{\n", module);
|
||||
Printf(s_init,
|
||||
" int i;\n"
|
||||
" for (i = 0; swig_types_initial[i]; i++) {\n"
|
||||
" swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);\n"
|
||||
" }\n");
|
||||
Printf(s_init,"#define SWIG_php_minit PHP_MINIT_FUNCTION(%s)\n", module);
|
||||
|
||||
/* Emit all of the code */
|
||||
Language::top(n);
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,7 @@ private:
|
|||
File *f_header;
|
||||
File *f_wrappers;
|
||||
File *f_init;
|
||||
File *f_initbeforefunc;
|
||||
|
||||
bool useGlobalModule;
|
||||
bool multipleInheritance;
|
||||
|
|
@ -185,6 +186,7 @@ public:
|
|||
f_header = 0;
|
||||
f_wrappers = 0;
|
||||
f_init = 0;
|
||||
f_initbeforefunc = 0;
|
||||
useGlobalModule = false;
|
||||
multipleInheritance = false;
|
||||
director_prot_ctor_code = NewString("");
|
||||
|
|
@ -391,6 +393,7 @@ public:
|
|||
f_wrappers = NewString("");
|
||||
f_directors_h = NewString("");
|
||||
f_directors = NewString("");
|
||||
f_initbeforefunc = NewString("");
|
||||
|
||||
/* Register file targets with the SWIG file handler */
|
||||
Swig_register_filebyname("header",f_header);
|
||||
|
|
@ -399,6 +402,7 @@ public:
|
|||
Swig_register_filebyname("init",f_init);
|
||||
Swig_register_filebyname("director",f_directors);
|
||||
Swig_register_filebyname("director_h",f_directors_h);
|
||||
Swig_register_filebyname("initbeforefunc", f_initbeforefunc);
|
||||
|
||||
modvar = 0;
|
||||
current = NO_CPP;
|
||||
|
|
@ -457,9 +461,9 @@ public:
|
|||
|
||||
Printv(f_init,
|
||||
"\n",
|
||||
"for (i = 0; swig_types_initial[i]; i++) {\n",
|
||||
"swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]);\n",
|
||||
"SWIG_define_class(swig_types[i]);\n",
|
||||
"SWIG_InitializeModule(0);\n",
|
||||
"for (i = 0; i < swig_module.size; i++) {\n",
|
||||
"SWIG_define_class(swig_module.types[i]);\n",
|
||||
"}\n",
|
||||
NIL);
|
||||
Printf(f_init,"\n");
|
||||
|
|
@ -482,11 +486,13 @@ public:
|
|||
}
|
||||
|
||||
Dump(f_wrappers,f_runtime);
|
||||
Dump(f_initbeforefunc, f_runtime);
|
||||
Wrapper_pretty_print(f_init,f_runtime);
|
||||
|
||||
Delete(f_header);
|
||||
Delete(f_wrappers);
|
||||
Delete(f_init);
|
||||
Delete(f_initbeforefunc);
|
||||
Close(f_runtime);
|
||||
Delete(f_runtime);
|
||||
|
||||
|
|
|
|||
|
|
@ -896,7 +896,7 @@ public:
|
|||
Delete(base_class);
|
||||
Delete(base_class_names);
|
||||
|
||||
Printv(f_wrappers, "swig_class _wrap_class_", mangled_classname, " = { \"", class_name,
|
||||
Printv(f_wrappers, "static swig_class _wrap_class_", mangled_classname, " = { \"", class_name,
|
||||
"\", &SWIGTYPE", SwigType_manglestr(t), ",",NIL);
|
||||
|
||||
if (have_constructor) {
|
||||
|
|
@ -912,7 +912,7 @@ public:
|
|||
Printf(f_wrappers,",0");
|
||||
}
|
||||
Printv(f_wrappers, ", swig_", mangled_classname, "_methods, swig_", mangled_classname, "_attributes, swig_", mangled_classname,"_bases,",
|
||||
"swig_", mangled_classname, "_base_names };\n", NIL);
|
||||
"swig_", mangled_classname, "_base_names, &swig_module };\n", NIL);
|
||||
|
||||
if( !itcl ) {
|
||||
Printv(cmd_tab, tab4, "{ SWIG_prefix \"", class_name, "\", (swig_wrapper_func) SWIG_ObjectConstructor, &_wrap_class_", mangled_classname, "},\n", NIL);
|
||||
|
|
|
|||
|
|
@ -1745,6 +1745,24 @@ void SwigType_inherit_equiv(File *out) {
|
|||
}
|
||||
}
|
||||
|
||||
/* Helper function to sort the mangled list */
|
||||
static int SwigType_compare_mangled(DOH *a, DOH *b) {
|
||||
return strcmp(DohData(a), DohData(b));
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_get_sorted_mangled_list()
|
||||
*
|
||||
* Returns the sorted list of mangled type names that should be exported into the
|
||||
* wrapper file.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
List *SwigType_get_sorted_mangled_list() {
|
||||
List *l = Keys(r_mangled);
|
||||
SortList(l, SwigType_compare_mangled);
|
||||
return l;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* SwigType_type_table()
|
||||
*
|
||||
|
|
@ -1754,7 +1772,9 @@ void SwigType_inherit_equiv(File *out) {
|
|||
void
|
||||
SwigType_emit_type_table(File *f_forward, File *f_table) {
|
||||
Iterator ki;
|
||||
String *types, *table;
|
||||
String *types, *table, *cast, *cast_init, *cast_temp;
|
||||
Hash *imported_types;
|
||||
List *mangled_list;
|
||||
int i = 0;
|
||||
|
||||
if (!r_mangled) {
|
||||
|
|
@ -1789,11 +1809,17 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
#endif
|
||||
table = NewString("");
|
||||
types = NewString("");
|
||||
Printf(table,"static swig_type_info *swig_types_initial[] = {\n");
|
||||
|
||||
ki = First(r_mangled);
|
||||
cast = NewString("");
|
||||
cast_init = NewString("");
|
||||
imported_types = NewHash("");
|
||||
|
||||
Printf(table,"static swig_type_info *swig_type_initial[] = {\n");
|
||||
Printf(cast_init, "static swig_cast_info *swig_cast_initial[] = {\n");
|
||||
|
||||
Printf(f_forward,"\n/* -------- TYPES TABLE (BEGIN) -------- */\n\n");
|
||||
while (ki.key) {
|
||||
|
||||
mangled_list = SwigType_get_sorted_mangled_list();
|
||||
for (ki = First(mangled_list); ki.item; ki = Next(ki)) {
|
||||
List *el;
|
||||
Iterator ei;
|
||||
SwigType *lt;
|
||||
|
|
@ -1803,12 +1829,19 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
String *rn;
|
||||
const String *cd;
|
||||
|
||||
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d] \n", ki.key, i);
|
||||
Printv(types,"static swig_type_info _swigt_", ki.key, "[] = {", NIL);
|
||||
cast_temp = NewString("");
|
||||
|
||||
cd = SwigType_clientdata_collect(ki.key);
|
||||
Printf(f_forward,"#define SWIGTYPE%s swig_types[%d]\n", ki.item, i);
|
||||
Printv(types,"static swig_type_info _swigt_", ki.item, " = {", NIL);
|
||||
Printf(table, " &_swigt_%s,\n", ki.item);
|
||||
Printf(cast_temp, "static swig_cast_info _swigc_%s[] = {", ki.item);
|
||||
Printf(cast_init, " _swigc_%s,\n", ki.item);
|
||||
i++;
|
||||
|
||||
cd = SwigType_clientdata_collect(ki.item);
|
||||
if (!cd) cd = "0";
|
||||
lt = Getattr(r_ltype,ki.key);
|
||||
|
||||
lt = Getattr(r_ltype,ki.item);
|
||||
rt = SwigType_typedef_resolve_all(lt);
|
||||
/* we save the original type and the fully resolved version */
|
||||
ln = SwigType_lstr(lt,0);
|
||||
|
|
@ -1818,35 +1851,58 @@ SwigType_emit_type_table(File *f_forward, File *f_table) {
|
|||
} else {
|
||||
nt = NewStringf("%s|%s", rn, ln);
|
||||
}
|
||||
Printv(types,"{\"", ki.key, "\", 0, \"",nt,"\", ", cd, ", 0, 0, 0},", NIL);
|
||||
el = SwigType_equivalent_mangle(ki.key,0,0);
|
||||
Printf(types, "\"%s\", \"%s\", 0, 0, %s};\n", ki.item, nt, cd);
|
||||
|
||||
el = SwigType_equivalent_mangle(ki.item,0,0);
|
||||
for (ei = First(el); ei.item; ei = Next(ei)) {
|
||||
String *ckey;
|
||||
String *conv;
|
||||
ckey = NewStringf("%s+%s", ei.item, ki.key);
|
||||
ckey = NewStringf("%s+%s", ei.item, ki.item);
|
||||
conv = Getattr(conversions,ckey);
|
||||
if (conv) {
|
||||
Printf(types,"{\"%s\", %s, 0, 0, 0, 0, 0},", ei.item, conv);
|
||||
Printf(cast_temp," {&_swigt_%s, %s, 0, 0},", ei.item, conv);
|
||||
} else {
|
||||
Printf(types,"{\"%s\", 0, 0, 0, 0, 0, 0},", ei.item);
|
||||
Printf(cast_temp," {&_swigt_%s, 0, 0, 0},", ei.item);
|
||||
}
|
||||
Delete(ckey);
|
||||
|
||||
if (!Getattr(r_mangled, ei.item) && !Getattr(imported_types, ei.item)) {
|
||||
Printf(f_forward, "#define SWIGTYPE%s swig_types[%i]\n", ei.item, i);
|
||||
Printf(types, "static swig_type_info _swigt_%s = {\"%s\", 0, 0, 0, 0};\n", ei.item, ei.item);
|
||||
Printf(table, " &_swigt_%s,\n", ei.item);
|
||||
Printf(cast, "static swig_cast_info _swigc_%s[] = {{&_swigt_%s, 0, 0, 0},{0, 0, 0, 0}};\n",
|
||||
ei.item, ei.item);
|
||||
Printf(cast_init, " _swigc_%s,\n", ei.item);
|
||||
i++;
|
||||
|
||||
Setattr(imported_types, ei.item, "1");
|
||||
}
|
||||
}
|
||||
Delete(el);
|
||||
Printf(cast,"%s{0, 0, 0, 0}};\n", cast_temp);
|
||||
Delete(cast_temp);
|
||||
Delete(nt);
|
||||
Delete(rt);
|
||||
Printf(types,"{0, 0, 0, 0, 0, 0, 0}};\n");
|
||||
Printv(table, "_swigt_", ki.key, ", \n", NIL);
|
||||
ki = Next(ki);
|
||||
i++;
|
||||
}
|
||||
Delete(mangled_list);
|
||||
|
||||
Printf(table, "0\n};\n");
|
||||
Printf(f_forward,"static swig_type_info *swig_types[%d];\n", i+1);
|
||||
Printf(f_forward,"\n/* -------- TYPES TABLE (END) -------- */\n\n");
|
||||
Printf(table, "};\n");
|
||||
Printf(cast_init, "};\n");
|
||||
Printf(f_table,"%s\n", types);
|
||||
Printf(f_table,"%s\n", table);
|
||||
Printf(f_table,"%s\n", cast);
|
||||
Printf(f_table,"%s\n", cast_init);
|
||||
Printf(f_table,"\n/* -------- TYPE CONVERSION AND EQUIVALENCE RULES (END) -------- */\n\n");
|
||||
|
||||
Printf(f_forward,"static swig_type_info *swig_types[%d];\n", i);
|
||||
Printf(f_forward,"static swig_module_info swig_module = {swig_types, %d, 0, 0, 0, 0};\n", i);
|
||||
Printf(f_forward,"#define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)\n");
|
||||
Printf(f_forward,"#define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)\n");
|
||||
Printf(f_forward,"\n/* -------- TYPES TABLE (END) -------- */\n\n");
|
||||
|
||||
Delete(types);
|
||||
Delete(table);
|
||||
Delete(cast);
|
||||
Delete(cast_init);
|
||||
Delete(imported_types);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue