Changes between Initial Version and Version 1 of PerlSwig


Ignore:
Timestamp:
Jan 29, 2009, 9:36:49 AM (15 years ago)
Author:
jmckenna
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • PerlSwig

    v1 v1  
     1= !PerlSwig =
     2
     3== To re-SWIG Mapscript with a different version of SWIG ==
     4<contributed by Stephen Lime>:
     5
     6    (currently (<=3.6, 3.7?) distributed with 1.1)
     7
     8        cd mapscript/perl
     9        swig -perl5 -shadow mapscript.i
     10        (thanks Steve Lime)
     11
     12Then build as usual.
     13
     14[Thu Mar 6 16:04:11 EST 2003] Jason Thaxter notes that the README note for perl says to use SWIG Version 1.1 (Build 883), but that didn't work, while version 1.3.17u (current release) seems to create a working module, though with a number of warnings about deprecated SWIG tags...
     15
     16Patch required to eliminate mod_perl & strict fatal errors
     17
     18http://mapserver.gis.umn.edu/data2/wilma/mapserver-users/0205/msg00068.html
     19
     20    or a direct link to the SWIG archives
     21
     22http://mailman.cs.uchicago.edu/pipermail/swig/2000-March/001227.html
     23
     24Offsite discussion redarding the use of null strings as file names
     25{{{
     26> Steve Lime writes:
     27> > Um, yup it is. Simply switching:
     28> >
     29> > if (arg1->name) free((char*)arg1->name);
     30> > arg1->name = (char *) malloc(strlen(arg2)+1);
     31> > strcpy((char*)arg1->name,arg2);
     32> >
     33> > to:
     34> >
     35> > if (arg1->name) free((char*)arg1->name);
     36> > if(arg2) {
     37> > arg1->name = (char *) malloc(strlen(arg2)+1);
     38> > strcpy((char*)arg1->name,arg2);
     39> > } else
     40> > arg1->name = NULL;
     41> >
     42> > Seems to fix things. Now, how to get these changes made?
     43> >
     44>
     45> This is probably being controlled by a typemap in Lib/swig.swg.
     46> I'll take a look.
     47>
     48}}}
     49You can try sticking this in your interface (or making mods in
     50swig.swg).
     51
     52Cheers,
     53
     54Dave
     55{{{
     56!#perl
     57/* Default typemap for handling char * members */
     58
     59#ifdef __cplusplus
     60%typemap(memberin) char * {
     61if ($1) delete [] $1;
     62if ($input) {
     63$1 = ($1_type) (new char[strlen($input)+1]);
     64strcpy((char *) $1,$input);
     65} else {
     66$1 = 0;
     67}
     68}
     69%typemap(memberin,warning="451:Setting const char * member may leak memory.") const char * {
     70if ($input) {
     71$1 = ($1_type) (new char[strlen($input)+1]);
     72strcpy((char *) $1,$input);
     73} else {
     74$1 = 0;
     75}
     76}
     77%typemap(globalin) char * {
     78if ($1) delete [] $1;
     79if ($input) {
     80$1 = ($1_type) (new char[strlen($input)+1]);
     81strcpy((char *) $1,$input);
     82} else {
     83$1 = 0;
     84}
     85}
     86%typemap(globalin,warning="451:Setting const char * variable may leak memory.") const char * {
     87if ($input) {
     88$1 = ($1_type) (new char[strlen($input)+1]);
     89strcpy((char *) $1,$input);
     90} else {
     91$1 = 0;
     92}
     93}
     94#else
     95%typemap(memberin) char * {
     96if ($1) free((char*)$1);
     97if ($input) {
     98$1 = ($1_type) malloc(strlen($input)+1);
     99strcpy((char*)$1,$input);
     100} else {
     101$1 = 0;
     102}
     103}
     104%typemap(memberin,warning="451:Setting const char * member may leak memory.") const char * {
     105if ($input) {
     106$1 = ($1_type) malloc(strlen($input)+1);
     107strcpy((char*)$1,$input);
     108} else {
     109$1 = 0;
     110}
     111}
     112%typemap(globalin) char * {
     113if ($1) free((char*)$1);
     114if ($input) {
     115$1 = ($1_type) malloc(strlen($input)+1);
     116strcpy((char*)$1,$input);
     117} else {
     118$1 = 0;
     119}
     120}
     121%typemap(globalin,warning="451:Setting const char * variable may leak memory.") const char * {
     122if ($input) {
     123$1 = ($1_type) malloc(strlen($input)+1);
     124strcpy((char*)$1,$input);
     125} else {
     126$1 = 0;
     127}
     128}
     129
     130#endif
     131}}}
     132----
     133back to PerlMapScript