SWIG & Tcl: %newobject ignored?

View: New views
2 Messages — Rating Filter:   Alert me  

SWIG & Tcl: %newobject ignored?

by Georgios Petasis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi all,

For some reason swig 1.3.41 seems to ignore the "%newbject foo;" feature
(and its equivalent %feature("new", "1") foo;), which seems strange.
This is because I looked insto Source/Modules/tcl8.cxx and the code
seems to check the "wrap:new" feature, and act accordingly. The code in
tcl8.cxx seems ok, why I don't see the results in the produced wrapper?

George

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user

Re: SWIG & Tcl: %newobject ignored?

by wsfulton :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Georgios Petasis wrote:
> Hi all,
>
> For some reason swig 1.3.41 seems to ignore the "%newbject foo;" feature
> (and its equivalent %feature("new", "1") foo;), which seems strange.
> This is because I looked insto Source/Modules/tcl8.cxx and the code
> seems to check the "wrap:new" feature, and act accordingly. The code in
> tcl8.cxx seems ok, why I don't see the results in the produced wrapper?
>
The appropriate typemaps need a $owner. Below is a diff which provides
what should be needed. However, the SWIG test-suite fails with this and
we have no tcl maintainer at the moment, so I'd rather leave this
leaking memory rather than crashing. If you have any tcl knowledge,
please give us a hand in debugging the two runtime test crashes then we
can add the $owner back in.

William

william@caracal:~/swig/trunk$ svn diff Lib/tcl/
Index: Lib/tcl/tcltypemaps.swg
===================================================================
--- Lib/tcl/tcltypemaps.swg (revision 11750)
+++ Lib/tcl/tcltypemaps.swg (working copy)
@@ -67,18 +67,18 @@
  #if 1
  // Old 1.3.25 typemaps needed to avoid premature object deletion
  %typemap(out,noblock=1) SWIGTYPE *INSTANCE, SWIGTYPE &INSTANCE,
SWIGTYPE INSTANCE[] {
-  Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1),
$1_descriptor,0));
+  Tcl_SetObjResult(interp, SWIG_NewInstanceObj( %as_voidptr($1),
$1_descriptor, $owner));
  }

  %typemap(out) SWIGTYPE *DYNAMIC, SWIGTYPE &DYNAMIC {
    swig_type_info *ty =
SWIG_TypeDynamicCast($1_descriptor,%as_voidptrptr(&$1));
-  Tcl_SetObjResult(interp,SWIG_NewInstanceObj(%as_voidptr($1), ty,0));
+  Tcl_SetObjResult(interp,SWIG_NewInstanceObj(%as_voidptr($1), ty,
$owner));
  }

  #endif

  %typemap(throws,noblock=1) SWIGTYPE CLASS {
-  SWIG_set_result(SWIG_NewInstanceObj(%as_voidptr(SWIG_new_copy($1,
$1_ltype)), $&1_descriptor, 1));
+  SWIG_set_result(SWIG_NewInstanceObj(%as_voidptr(SWIG_new_copy($1,
$1_ltype)), $&1_descriptor, SWIG_POINTER_OWN));
    SWIG_fail;
  }

------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Swig-user mailing list
Swig-user@...
https://lists.sourceforge.net/lists/listinfo/swig-user