[Fxruby-commits] CVS: FXRuby/swig-interfaces freefuncs.i,1.2.2.1,1.2.2.2 typemaps.i,1.35.2.5,1.35.2.
Status: Inactive
Brought to you by:
lyle
From: Lyle J. <ly...@us...> - 2002-05-24 17:36:19
|
Update of /cvsroot/fxruby/FXRuby/swig-interfaces In directory usw-pr-cvs1:/tmp/cvs-serv31799/swig-interfaces Modified Files: Tag: release10 freefuncs.i typemaps.i Log Message: Removed the typemaps for FXTableRange and FXTablePos output values which would previously have tried to look up existing Ruby references to the same C++ pointers and return those. This practice (which works fine in most cases) was leading to an obscure bug (see SF Bug #560128). The sequence of events would go something like this: 1. We create a Ruby FXTableRange instance associated with the C++ FXTableRange instance which lives at memory location 'x'. 2. We next attempt to create a Ruby FXTablePos instance associated with the C++ FXTablePos instance which is the first member of the previous FXTableRange struct. Since it's the first member, its memory address is the same as that of the FXTableRange itself. 3. We look up the address of this FXTablePos object and of course the address *is* already there; we stored it when we looked up the enclosing FXTableRange object. So we return a reference to that FXTableRange instead of a new reference to an FXTablePos. For now, I've just modified the typemaps for these two structs so that you always get a new reference (i.e. it doesn't attempt to look up previously returned refs.) But since this could happen again the correct fix is probably to store both the pointer and the type in our hash table to be more safe. Index: freefuncs.i =================================================================== RCS file: /cvsroot/fxruby/FXRuby/swig-interfaces/freefuncs.i,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** freefuncs.i 25 Apr 2002 16:48:34 -0000 1.2.2.1 --- freefuncs.i 24 May 2002 17:36:16 -0000 1.2.2.2 *************** *** 68,73 **** %freefunc FXStringDict "FXRbUnregisterRubyObj"; %freefunc FXTableItem "FXRbUnregisterRubyObj"; ! %freefunc FXTablePos "FXRbUnregisterRubyObj"; ! %freefunc FXTableItem "FXRbUnregisterRubyObj"; %freefunc FXTimer "FXRbUnregisterRubyObj"; %freefunc FXTreeItem "FXRbUnregisterRubyObj"; --- 68,73 ---- %freefunc FXStringDict "FXRbUnregisterRubyObj"; %freefunc FXTableItem "FXRbUnregisterRubyObj"; ! // %freefunc FXTablePos "FXRbUnregisterRubyObj"; ! // %freefunc FXTableRange "FXRbUnregisterRubyObj"; %freefunc FXTimer "FXRbUnregisterRubyObj"; %freefunc FXTreeItem "FXRbUnregisterRubyObj"; Index: typemaps.i =================================================================== RCS file: /cvsroot/fxruby/FXRuby/swig-interfaces/typemaps.i,v retrieving revision 1.35.2.5 retrieving revision 1.35.2.6 diff -C2 -d -r1.35.2.5 -r1.35.2.6 *** typemaps.i 10 May 2002 20:12:29 -0000 1.35.2.5 --- typemaps.i 24 May 2002 17:36:16 -0000 1.35.2.6 *************** *** 460,464 **** /* Output typemap for FXTablePos instances */ ! %typemap(ruby, out) FXTablePos* "$result = FXRbGetRubyObj($1, \"$1_ltype\");"; /* Output typemap for FXTimer instances */ --- 460,467 ---- /* Output typemap for FXTablePos instances */ ! // %typemap(ruby, out) FXTablePos* "$result = FXRbGetRubyObj($1, \"$1_ltype\");"; ! ! /* Output typemap for FXTableRange instances */ ! // %typemap(ruby, out) FXTableRange* "$result = FXRbGetRubyObj($1, \"$1_ltype\");"; /* Output typemap for FXTimer instances */ |