Re: Example with boost::intrusive_ptr and Java ?

Martin Quinson <[email protected]> Tue, 19 Nov 2024 09:17:17 +0100
Newsgroups gmane.comp.programming.swig
Message-ID <[email protected]>
--===============7594358627378490016==
Content-Type: multipart/signed; micalg="pgp-sha512";
	protocol="application/pgp-signature"; boundary="=-OkqtyveRp+Y7hF6zABZD"


--=-OkqtyveRp+Y7hF6zABZD
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hello,

for the record, my issue came from the fact that I was using the wrong name=
 as
an argument to the intrusive_ptr macro. Writing
`%intrusive_ptr(simgrid::s4u::Activity)` instead (i.e., using the fully
qualified name of the type) fixed my issue. The generated code now compiles=
.

So it was my fault, and I'm doing this email for the next one doing this
mistake, as it took me a while to pinpoint my bug.

The example in Examples/test-suite/java/li_boost_intrusive_ptr_runme.java i=
s a
bit complex (as it also tests internal stuff which are not interesting to
regular users), but it's helpful when you finally understand it.

Thanks for the fish,
Mt

Le vendredi 15 novembre 2024 =C3=A0 01:34 +0100, Martin Quinson a =C3=A9cri=
t=C2=A0:
> Hello there,
>=20
> I'm trying to generate the bindings of a library that heavily rely on
> boost::intrusive_ptr internally. My swig file reads:
>=20
> %include <boost_intrusive_ptr.i>
> %intrusive_ptr(Activity)
> %ignore intrusive_ptr_add_ref;
> %ignore intrusive_ptr_release;
>=20
> but the compilation of the generated file fails as follows:
>=20
> simgrid_java_wrap.cxx: In function =E2=80=98void
> Java_org_simgrid_s4u_simgridJNI_delete_1Activity(JNIEnv*, jclass, jlong)=
=E2=80=99:
> simgrid_java_wrap.cxx:1031:22: error: =E2=80=98smartarg1=E2=80=99 was not=
 declared in this
> scope
> =C2=A01031 |=C2=A0=C2=A0 (void)arg1; delete smartarg1;
> =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 |=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=
=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=
=C2=A0=C2=A0 ^~~~~~~~~
>=20
> This error seem to come from=C2=A0
> https://github.com/swig/swig/blob/master/Lib/java/boost_intrusive_ptr.i#L=
21
> but I fail to understand what's wrong here. The full swig file is attache=
d
> and
> the code I'm trying to bind is https://github.com/simgrid/simgrid/=C2=A0b=
ut I do
> not
> expect anyone to debug my code directly.
>=20
> Instead, I'd really appreciate if anyone could point me to a working,
> possibly
> minimal, example of code using boost::intrusive_ptr and binded to Java wi=
th
> SWIG, please. It'd be great if such an example could be included in the
> official example suite, by the way.
>=20
> Thanks in advance,
> Mt
>=20


--=-OkqtyveRp+Y7hF6zABZD
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: This is a digitally signed message part

-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEET76cTupS7xPVQWYSmL2XJE9zvqcFAmc8SY0ACgkQmL2XJE9z
vqfjHg/9F4YmAGnjU/vlq8yC2C6pfnuywfJBhCdVGTuwev4gYL3pxkOH5xR6SR47
7jbGzU9V2mPKZc8crE+lRDKEN/UAEWd2LmgFNcrTA+z6pDA623oiTicbE6xQkI/Z
gtgAi7nogpZsoUtMslPWqGF992P7J6CS85DnmdJvRwmt/iGt/ntJY54oTOUeWFze
gAVVLzKsrEya6EruvAdLwRm+y3MqJuAQpqm7U/dA1qd93p+Yv7LDSoYV6vLPrFHW
xQCzx3iT59kH49ctdLwFNNojcsk/O7mQOfd4YCMiyxPRqQFLp+YyXbHiNPGmlS++
+OAEw0eN+7/VLD2JaMdeho9NlmhDUYPZqH1MuMxCHNth10K2K02mJZSoHQTPT9rG
v214yDxWrb3XvWI4nq/53NHWMIGmaDSHmiVXI8CrNdA0y7IhZNZWZJKrOQcC9yWA
xiovKs6QXk/qRnUR4HmPwvpXVzeWGYF/jBeAJZa5/uHsFMQJvkiXjfHqpRhF7lzD
qz940NxqnACi5H9Lajemq8WspEMzo0x9i5odNrAMlp+c+bJrqWcUqCsAXqwx2Bex
KoHWdUQgRa0nIuHyRFy5PpH/J7cWMg66Ul507tulv+3r3i2bQvTG0HzPoOuZ70nG
yrTR7eYNUI+dftSx3N83DCG8hPFFzXlJKQdbPXVVvaTPA9Navuw=
=y/r9
-----END PGP SIGNATURE-----

--=-OkqtyveRp+Y7hF6zABZD--


--===============7594358627378490016==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--===============7594358627378490016==
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

--===============7594358627378490016==--