Re: how to map 'new' to 'CUSTOM_NEW_T'
Ephraim Yawitz <[email protected]> Thu, 19 Dec 2024 17:57:15 +0200
| Newsgroups | gmane.comp.programming.swig |
|---|---|
| Message-ID | <CAP-4f0JDuH6m9e9MTkSbH_0+Kkxaw-bayUMSHSuUyjOX3f5TOA@mail.gmail.com> |
--===============2237986204883698273==
Content-Type: multipart/alternative; boundary="0000000000002c77370629a1968f"
--0000000000002c77370629a1968f
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
I see no one has followed this up, but in the meantime I have tried a
little example of what I suggested and it didn't work, i.e., it still used
"new" instead of "CUSTOM_NEW_T", so I guess the issue is more complicated
than I thought, although it might just need a small tweak in the typemap.
On Tue, Dec 17, 2024 at 11:58=E2=80=AFAM Ephraim Yawitz <ephraim@excalibur.=
co.il>
wrote:
> I'm no SWIG expert, but from the little bit I understand, the code for
> this C++ constructor is created based on the following lines in
> Lib/csharp/csharp.swg in the SWIG installation directory:
>
> %typemap(out) SWIGTYPE
> #ifdef __cplusplus
> %{ $result =3D new $1_ltype($1); %}
> #else
> {
> $&1_ltype $1ptr =3D ($&1_ltype) malloc(sizeof($1_ltype));
> memmove($1ptr, &$1, sizeof($1_type));
> $result =3D $1ptr;
> }
> #endif
>
> I'm guessing that perhaps creating a %typemap of your own with
> "CUSTOM_NEW_T" instead of "new" might do the trick.
> Again, I'm just posting this to try to get the attention of the guys who
> really know what they're doing.
>
> On Mon, Dec 16, 2024 at 4:53=E2=80=AFAM Jim <[email protected]> wrote:
>
>> Hi all,
>> I am using swig to generate csharp code, here is the default
>> implementation of the constructor:
>> I want change the 'new' operator to my custom 'CUSTOM_NEW_T'=EF=BC=8Cli=
ke
>> 'result=3DCUSTOM_NEW_T(Bar)'. I have read the doc for SWIG, but it see=
ms
>> that does not contain any relevant content.
>>
>> Thank you so much, have a nice day!
>> _______________________________________________
>> Swig-user mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/swig-user
>>
>
--0000000000002c77370629a1968f
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
<div dir=3D"ltr">I see no one has followed this up, but in the meantime I h=
ave tried a little example of what I suggested and it didn't work, i.e.=
, it still used "new" instead of "CUSTOM_NEW_T", so I g=
uess the issue is more complicated than I thought, although it might just n=
eed a small tweak in the typemap.<br></div><br><div class=3D"gmail_quote gm=
ail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">On Tue, Dec 17, =
2024 at 11:58=E2=80=AFAM Ephraim Yawitz <<a href=3D"mailto:ephraim@excal=
ibur.co.il">[email protected]</a>> wrote:<br></div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex"><div dir=3D"ltr"><div>I'm no SWIG ex=
pert, but from the little bit I understand, the code for this C++ construct=
or is created based on the following lines in Lib/csharp/csharp.swg in the =
SWIG installation directory:</div><div><br></div><div>%typemap(out) SWIGTYP=
E <br>#ifdef __cplusplus<br>%{ $result =3D new $1_ltype($1); %}<br>#else<br=
>{<br>=C2=A0 $&1_ltype $1ptr =3D ($&1_ltype) malloc(sizeof($1_ltype=
));<br>=C2=A0 memmove($1ptr, &$1, sizeof($1_type));<br>=C2=A0 $result =
=3D $1ptr;<br>}<br>#endif</div><div><br></div><div>I'm guessing that pe=
rhaps creating a %typemap of your own with=20
"CUSTOM_NEW_T" instead of "new" might do the trick.</di=
v><div>Again, I'm just posting this to try to get the attention of the =
guys who really know what they're doing.<br></div><br><div class=3D"gma=
il_quote"><div dir=3D"ltr" class=3D"gmail_attr">On Mon, Dec 16, 2024 at 4:5=
3=E2=80=AFAM Jim <<a href=3D"mailto:[email protected]" target=3D"_bla=
nk">[email protected]</a>> wrote:<br></div><blockquote class=3D"gmail=
_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204=
,204);padding-left:1ex"><div style=3D"line-height:1.7;color:rgb(0,0,0);font=
-size:14px;font-family:Arial"><div style=3D"margin:0px">Hi all,</div><div s=
tyle=3D"margin:0px">=C2=A0 =C2=A0 I am using swig to generate csharp code, =
here is the default implementation of the constructor:</div><div style=3D"m=
argin:0px"><img style=3D"width: 636px; height: 182px;"></div><div style=3D"=
margin:0px">=C2=A0I want change the 'new' operator to my custom =
9;CUSTOM_NEW_T'=EF=BC=8Clike 'result=3DCUSTOM_NEW_T(Bar)'.=C2=
=A0 =C2=A0I have read the doc for SWIG, but it seems that does not contain =
any relevant content.</div><div style=3D"margin:0px"><br></div><div style=
=3D"margin:0px">=C2=A0Thank you so much, have a nice day!</div></div><img s=
tyle=3D"width: 1px; height: 1px;" src=3D"https://count.mail.163.com/beacon/=
webmail.gif?type=3Dwebmail_mailtrace&guid=3Dpre_1c51cbb92865f663cb929be=
752099cea">_______________________________________________<br>
Swig-user mailing list<br>
<a href=3D"mailto:[email protected]" target=3D"_blank">Swig-u=
[email protected]</a><br>
<a href=3D"https://lists.sourceforge.net/lists/listinfo/swig-user" rel=3D"n=
oreferrer" target=3D"_blank">https://lists.sourceforge.net/lists/listinfo/s=
wig-user</a><br>
</blockquote></div></div>
</blockquote></div>
--0000000000002c77370629a1968f--
--===============2237986204883698273==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
--===============2237986204883698273==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
_______________________________________________
Swig-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/swig-user
--===============2237986204883698273==--