From: John L. <wu...@us...> - 2004-11-29 23:14:09
|
Update of /cvsroot/swig/SWIG/Lib/perl5 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23579/perl5 Modified Files: perl5.swg perlrun.swg Added Files: perlinit.swg Log Message: perl module now supports runtime.swg + split up Perl_LookupTypePointer into two functions like python module + added a perlinit.swg file with the code from the bottom of perl5.swg --- NEW FILE: perlinit.swg --- /* Export the SWIG initialization function */ %header %{ #ifdef __cplusplus extern "C" #endif #ifndef PERL_OBJECT #ifndef MULTIPLICITY SWIGEXPORT(void) SWIG_init (CV* cv); #else SWIGEXPORT(void) SWIG_init (pTHXo_ CV* cv); #endif #else SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *); #endif %} /* Module initialization function */ %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 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; } /* Install commands */ for (i = 0; swig_commands[i].name; i++) { newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); } /* Install variables */ for (i = 0; swig_variables[i].name; i++) { SV *sv; sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2); if (swig_variables[i].type) { SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); } else { sv_setiv(sv,(IV) 0); } swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); } /* Install constant */ for (i = 0; swig_constants[i].type; i++) { SV *sv; sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2); switch(swig_constants[i].type) { case SWIG_INT: sv_setiv(sv, (IV) swig_constants[i].lvalue); break; case SWIG_FLOAT: sv_setnv(sv, (double) swig_constants[i].dvalue); break; case SWIG_STRING: sv_setpv(sv, (char *) swig_constants[i].pvalue); break; case SWIG_POINTER: SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); break; case SWIG_BINARY: SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); break; default: break; } SvREADONLY_on(sv); } %} Index: perlrun.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/perl5/perlrun.swg,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** perlrun.swg 21 Nov 2004 19:30:54 -0000 1.19 --- perlrun.swg 29 Nov 2004 23:13:57 -0000 1.20 *************** *** 167,185 **** #endif ! /* load the swig_runtime_list_handle variable from the interpreter */ ! static void SWIG_Perl_LookupTypePointer() { SV *pointer; /* first check if pointer already created */ ! pointer = get_sv("swig_runtime_data::type_pointer" SWIG_RUNTIME_VERSION SWIG_TYPE_TABLE_NAME, FALSE); ! if (pointer && SvOK(pointer)) { ! swig_type_list_handle = INT2PTR(swig_type_info **, SvIV(pointer)); ! } else { ! /* 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_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) { --- 167,197 ---- #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 * SWIG_Perl_TypeCheckRV(SWIG_MAYBE_PERL_OBJECT SV *rv, swig_type_info *ty) { Index: perl5.swg =================================================================== RCS file: /cvsroot/swig/SWIG/Lib/perl5/perl5.swg,v retrieving revision 1.27 retrieving revision 1.28 diff -C2 -d -r1.27 -r1.28 *** perl5.swg 28 Nov 2004 19:16:07 -0000 1.27 --- perl5.swg 29 Nov 2004 23:13:56 -0000 1.28 *************** *** 566,648 **** } ! /* Export the SWIG initialization function */ ! %header %{ ! #ifdef __cplusplus ! extern "C" ! #endif ! #ifndef PERL_OBJECT ! #ifndef MULTIPLICITY ! SWIGEXPORT(void) SWIG_init (CV* cv); ! #else ! SWIGEXPORT(void) SWIG_init (pTHXo_ CV* cv); ! #endif ! #else ! SWIGEXPORT(void) SWIG_init (CV *cv, CPerlObj *); ! #endif ! %} ! ! /* Module initialization function */ ! ! %init %{ ! #ifdef __cplusplus ! extern "C" ! #endif ! ! XS(SWIG_init) { ! dXSARGS; ! int i; ! static int _init = 0; ! if (!_init) { ! SWIG_Perl_LookupTypePointer(); ! for (i = 0; swig_types_initial[i]; i++) { ! swig_types[i] = SWIG_TypeRegister(swig_types_initial[i]); ! } ! _init = 1; ! } ! ! /* Install commands */ ! for (i = 0; swig_commands[i].name; i++) { ! newXS((char*) swig_commands[i].name,swig_commands[i].wrapper, (char*)__FILE__); ! } ! ! /* Install variables */ ! for (i = 0; swig_variables[i].name; i++) { ! SV *sv; ! sv = perl_get_sv((char*) swig_variables[i].name, TRUE | 0x2); ! if (swig_variables[i].type) { ! SWIG_MakePtr(sv,(void *)1, *swig_variables[i].type,0); ! } else { ! sv_setiv(sv,(IV) 0); ! } ! swig_create_magic(sv, (char *) swig_variables[i].name, swig_variables[i].set, swig_variables[i].get); ! } ! ! /* Install constant */ ! for (i = 0; swig_constants[i].type; i++) { ! SV *sv; ! sv = perl_get_sv((char*)swig_constants[i].name, TRUE | 0x2); ! switch(swig_constants[i].type) { ! case SWIG_INT: ! sv_setiv(sv, (IV) swig_constants[i].lvalue); ! break; ! case SWIG_FLOAT: ! sv_setnv(sv, (double) swig_constants[i].dvalue); ! break; ! case SWIG_STRING: ! sv_setpv(sv, (char *) swig_constants[i].pvalue); ! break; ! case SWIG_POINTER: ! SWIG_MakePtr(sv, swig_constants[i].pvalue, *(swig_constants[i].ptype),0); ! break; ! case SWIG_BINARY: ! SWIG_MakePackedObj(sv, swig_constants[i].pvalue, swig_constants[i].lvalue, *(swig_constants[i].ptype)); ! break; ! default: ! break; ! } ! SvREADONLY_on(sv); ! } ! %} ! ! ! --- 566,568 ---- } ! %include "perlinit.swg" |