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,29 +53,44 @@ extern "C" {
|
|||
SWIGRUNTIME void
|
||||
SWIG_InitializeModule(void *clientdata) {
|
||||
size_t i;
|
||||
swig_module_info *module_head;
|
||||
static int init_run = 0;
|
||||
swig_module_info *module_head, *iter;
|
||||
int found;
|
||||
|
||||
clientdata = clientdata;
|
||||
|
||||
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) {
|
||||
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 */
|
||||
swig_module.type_initial = swig_type_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);
|
||||
|
||||
/* if the is found in the list, then all is done and we may leave */
|
||||
if (found) return;
|
||||
/* otherwise we must add out module into the list */
|
||||
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 */
|
||||
#ifdef SWIGRUNTIME_DEBUG
|
||||
printf("SWIG_InitializeModule: size %d\n", swig_module.size);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue