[lua] updated configure script yet again

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10218 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Mark Gossage 2008-01-24 06:16:45 +00:00
commit 09113cc0bf
4 changed files with 50 additions and 8 deletions

View file

@ -172,16 +172,25 @@ void SWIG_write_NAME_num_array(lua_State* L,TYPE *array,int size);
int SWIG_read_NAME_num_array(lua_State* L,int index,TYPE *array,int size);
*/
%{
#ifdef __cplusplus /* generic alloc/dealloc fns*/
/* Reported that you don't need to check for NULL for delete & free
There probably is some compiler that its not true for, so the code is left here just in case.
#ifdef __cplusplus
#define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN]
#define SWIG_FREE_ARRAY(PTR) if(PTR){delete[] PTR;}
#else
#define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE))
#define SWIG_FREE_ARRAY(PTR) if(PTR){free(PTR);}
#endif
*/
%{
#ifdef __cplusplus /* generic alloc/dealloc fns*/
#define SWIG_ALLOC_ARRAY(TYPE,LEN) new TYPE[LEN]
#define SWIG_FREE_ARRAY(PTR) delete[] PTR;
#else
#define SWIG_ALLOC_ARRAY(TYPE,LEN) (TYPE *)malloc(LEN*sizeof(TYPE))
#define SWIG_FREE_ARRAY(PTR) free(PTR);
#endif
/* counting the size of arrays:*/
int SWIG_itable_size(lua_State* L, int index)
{

View file

@ -55,7 +55,7 @@ SWIGRUNTIME void
SWIG_InitializeModule(void *clientdata) {
size_t i;
swig_module_info *module_head, *iter;
int found;
int found, init;
clientdata = clientdata;
@ -65,6 +65,9 @@ SWIG_InitializeModule(void *clientdata) {
swig_module.type_initial = swig_type_initial;
swig_module.cast_initial = swig_cast_initial;
swig_module.next = &swig_module;
init = 1;
} else {
init = 0;
}
/* Try and load any already created modules */
@ -93,6 +96,12 @@ SWIG_InitializeModule(void *clientdata) {
module_head->next = &swig_module;
}
/* When multiple interpeters are used, a module could have already been initialized in
a different interpreter, but not yet have a pointer in this interpreter.
In this case, we do not want to continue adding types... everything should be
set up already */
if (init == 0) return;
/* Now work on filling in swig_module.types */
#ifdef SWIGRUNTIME_DEBUG
printf("SWIG_InitializeModule: size %d\n", swig_module.size);