added support for multiple modules & multiple interpreters
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9265 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
db5bb83440
commit
7c475898c2
1 changed files with 30 additions and 15 deletions
|
|
@ -53,27 +53,42 @@ extern "C" {
|
||||||
SWIGRUNTIME void
|
SWIGRUNTIME void
|
||||||
SWIG_InitializeModule(void *clientdata) {
|
SWIG_InitializeModule(void *clientdata) {
|
||||||
size_t i;
|
size_t i;
|
||||||
swig_module_info *module_head;
|
swig_module_info *module_head, *iter;
|
||||||
static int init_run = 0;
|
int found;
|
||||||
|
|
||||||
clientdata = clientdata;
|
clientdata = clientdata;
|
||||||
|
|
||||||
if (init_run) return;
|
/* Try and load any already created modules */
|
||||||
init_run = 1;
|
module_head = SWIG_GetModule(clientdata);
|
||||||
|
if (!module_head) {
|
||||||
|
/* This is the first module loaded for this interpreter */
|
||||||
|
/* so set the swig module into the interpreter */
|
||||||
|
SWIG_SetModule(clientdata, &swig_module);
|
||||||
|
module_head = &swig_module;
|
||||||
|
/* check to see if the circular list has been setup, if not, set it up */
|
||||||
|
if (swig_module.next==0) {
|
||||||
/* Initialize the swig_module */
|
/* Initialize the swig_module */
|
||||||
swig_module.type_initial = swig_type_initial;
|
swig_module.type_initial = swig_type_initial;
|
||||||
swig_module.cast_initial = swig_cast_initial;
|
swig_module.cast_initial = swig_cast_initial;
|
||||||
|
swig_module.next = &swig_module;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* the interpreter has loaded a SWIG module, but has it loaded this one? */
|
||||||
|
found=0;
|
||||||
|
iter=module_head;
|
||||||
|
do {
|
||||||
|
if (iter==&swig_module) {
|
||||||
|
found=1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
iter=iter->next;
|
||||||
|
} while (iter!= module_head);
|
||||||
|
|
||||||
/* Try and load any already created modules */
|
/* if the is found in the list, then all is done and we may leave */
|
||||||
module_head = SWIG_GetModule(clientdata);
|
if (found) return;
|
||||||
if (module_head) {
|
/* otherwise we must add out module into the list */
|
||||||
swig_module.next = module_head->next;
|
swig_module.next = module_head->next;
|
||||||
module_head->next = &swig_module;
|
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 */
|
/* Now work on filling in swig_module.types */
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue