logo       

RE: [jreed@xxxxxxxxxxxx: Csharp module and memory pressure on GC]: msg#00158

programming.swig

Subject: RE: [jreed@xxxxxxxxxxxx: Csharp module and memory pressure on GC]



>-----Original Message-----
>From: Joel Reed [mailto:jreed@xxxxxxxxxxxx]
>Sent: 23 September 2004 17:08
>To: Fulton, William
>Cc: swig@xxxxxxxxxxxxxxx
>Subject: Re: [jreed@xxxxxxxxxxxx: Csharp module and memory pressure on
>GC]
>
>
>On Thu, Sep 23, 2004 at 10:30:19AM +0100, William.Fulton@xxxxxxx wrote:
>>
>> If you post the diffs between what gets generated by default and the
>> desired code, I can probably set the typemaps up for you.
>
>Here's what i did William to prevent the database connection
>object from being reclaimed too early. I had to patch swig
>though to provide a feature("csconstructor").
>
>code before patch & custom typemap:
>
> public o_ielem(o_dbc db) :
>this(ddidataPINVOKE.new_o_ielem(o_dbc.getCPtr(db)), true) {
> }
>
>code after:
>
> public o_ielem(o_dbc db) :
>this(ddidataPINVOKE.new_o_ielem(o_dbc.getCPtr(db)), true) {
> dbHandleRef = new HandleRef(db, o_dbc.getCPtr(db));
> }
>
>my patch & custom typemap are attached. any better way to do
>this? the approach above is the cleanest i could come up with,
>but does require a feature it didn't seem swig had - to
>customize the body of generated constructors.
>
>jr

The following will achieve this. Bit of a hack, but I plan to implement the
"shadow" feature in the future as per the other language modules. It will allow
one to replace the entire shadow/proxy method with your own code.

William

%csmethodmodifiers o_ielem::create(o_dbc& db) "private"
%typemap(cscode) o_ielem %{
System.Runtime.InteropServices.HandleRef dbHandleRef;
public o_ielem(o_dbc db) :
this(examplePINVOKE.o_ielem_create(o_dbc.getCPtr(db)), true) {
dbHandleRef = new System.Runtime.InteropServices.HandleRef(db,
o_dbc.getCPtr(db));
}
%}
%ignore o_ielem(o_dbc& db);
%extend o_ielem {
static o_ielem* create(o_dbc& db) {
return new o_ielem(db);
}
}


--

Visit our website at http://www.ubs.com

This message contains confidential information and is intended only
for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses. The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission. If
verification is required please request a hard-copy version. This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

_______________________________________________
Swig maillist - Swig@xxxxxxxxxxxxxxx
http://mailman.cs.uchicago.edu/mailman/listinfo/swig



<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise