<!DOCTYPE html><html><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<p>Sorry for the formatting -- dunno what happened. Let me try
again:<br>
</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">Hi
Lain, this is some interesting work. When looking at the
documentation, and at the examples provided, it is not clear to me
how some features of C++ are supported. E.g. it seems to me that
the bindings you create (esp. downcall handles) are completely
static. That is, if you have B extends A, and both A and B define
a virtual method, you will add a downcall handle in both classes,
one for A and the other for B. Then you kind of rely on <em>Java's</em>
(not C++'s !!) dynamic dispatch to make things work -- e.g. when
you call A on an instance of B, the JVM will call B -- which will
result in the correct C++ method being invoked. While this works
for simple examples -- I'm a bit skeptical about the generality of
this approach. Of course, as long as there's no multiple
inheritance, and as long as all the C++ classes are created from
the Java side of the fence, this might even work correctly.</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">But
if some C++ method returns some A* -- what Java wrapper will we
create? The problem here is that the choice of the wrapper (A vs.
B) determines which set of methods will be invoked on that
instance (because we're effectively bypassing C++'s virtual
dispatch).</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">All
things considered, this approach doesn't seem very different from
the jextract PoC I shared -- in the sense that it models some C++
features <em>to some degree</em> without really providing full
language interop support which, IMHO, is not possible w/o having a
C++ compiler on your side (inline functions are another issue).
But maybe, what you are trying to say is that, even with a simple
PoC like the one I provided, it's possible to provide meaningful
interop for at least <em>some</em> C++ libraries (like eigen) ?</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">Cheers
Maurizio</p>
<p></p>
<div class="moz-cite-prefix">On 04/03/2025 12:19, Maurizio
Cimadamore wrote:<br>
</div>
<blockquote type="cite" cite="mid:d6eae7e2-0240-42ff-8b59-6dc1d4c0434e@oracle.com">
<title></title>
<div class="markdown-here-wrapper">
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">Hi
Lain, this is some interesting work. When looking at the
documentation, and at the examples provided, it is not clear
to me how some features of C++ are supported. E.g. it seems to
me that the bindings you create (esp. downcall handles) are
completely static. That is, if you have B extends A, and both
A and B define a virtual method, you will add a downcall
handle in both classes, one for A</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">
and the other for B</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">.
Then you kind of rely on <em>Java's</em> (not C++'s !!)
dynamic dispatch to make things work -- e.g. when you call A</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">
on an instance of B, the JVM will call B</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">
-- which will result in the correct C++ method being invoked.
While this works for simple examples -- I'm a bit skeptical
about the generality of this approach. Of course, as long as
there's no multiple inheritance, and as long as all the C++
classes are created from the Java side of the fence, this
might even work correctly.</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">But
if some C++ method returns some A* -- what Java wrapper will
we create? The problem here is that the choice of the wrapper
(A vs. B) determines which set of methods will be invoked on
that instance (because we're effectively bypassing C++'s
virtual dispatch).</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">All
things considered, this approach doesn't seem very different
from the jextract PoC I shared -- in the sense that it models
some C++ features <em>to some degree</em> without really
providing full language interop support which, IMHO, is not
possible w/o having a C++ compiler on your side (inline
functions are another issue). But maybe, what you are trying
to say is that, even with a simple PoC like the one I
provided, it's possible to provide meaningful interop for at
least <em>some</em> C++ libraries (like eigen) ?</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">Cheers
Maurizio</p>
<p style="margin-block: 0px 19.2px; margin-bottom: 19.2px; margin-top: 0px;">On
26/02/2025 02:13, Lain Lain wrote:</p>
<blockquote type="cite" style="border-block-color: rgb(119, 119, 119); border-bottom-color: rgb(119, 119, 119); border-inline-color: rgb(114, 159, 207) rgb(119, 119, 119); border-inline-start: 2px solid rgb(114, 159, 207); border-left: 2px solid rgb(114, 159, 207); border-right-color: rgb(119, 119, 119); border-top-color: rgb(119, 119, 119); caret-color: rgb(119, 119, 119); color: rgb(119, 119, 119); column-rule-color: rgb(119, 119, 119); margin-block: 8px; margin-bottom: 8px; margin-inline: 0px; margin-left: 0px; margin-right: 0px; margin-top: 8px; outline-color: rgb(119, 119, 119); padding-block: 3.2px; padding-bottom: 3.2px; padding-inline: 8px; padding-left: 8px; padding-right: 8px; padding-top: 3.2px; quotes: none; text-decoration-color: rgb(119, 119, 119); text-emphasis-color: rgb(119, 119, 119);">
<div class="external-content" id="extcontent-0" style="border-block-color: rgb(119, 119, 119); border-bottom-color: rgb(119, 119, 119); border-inline-color: rgb(119, 119, 119); border-left-color: rgb(119, 119, 119); border-right-color: rgb(119, 119, 119); border-top-color: rgb(119, 119, 119); caret-color: rgb(119, 119, 119); color: rgb(119, 119, 119); column-rule-color: rgb(119, 119, 119); outline-color: rgb(119, 119, 119); quotes: none; text-decoration-color: rgb(119, 119, 119); text-emphasis-color: rgb(119, 119, 119);">
<div style="font-family: Verdana;font-size: 12.0px;">
<div>Hi,</div>
<div>We would like to present you ffmbindings project
which helps to do manual bindings to C++ libraries from
Java using FFM.</div>
<div>Currently it contains bindings to eigen C++ library
but we are going to publish few more this month.</div>
<div> </div>
<div>Source code: <a class="moz-txt-link-freetext" href="https://bitbucket.org/ffmbindings" moz-do-not-send="true">https://bitbucket.org/ffmbindings</a><br>
Documentation: <a class="moz-txt-link-freetext" href="https://ffmbindings.onrender.com" moz-do-not-send="true">https://ffmbindings.onrender.com</a></div>
<div> </div>
<div>Any feedback are welcome.</div>
<div> </div>
<div>Thank you,</div>
</div>
</div>
</blockquote>
<div title="MDH:PHA+SGkgTGFpbiw8YnI+dGhpcyBpcyBzb21lIGludGVyZXN0aW5nIHdvcmsuIFdoZW4gbG9va2luZyBhdCB0aGUgZG9jdW1lbnRhdGlvbiwgYW5kIGF0IHRoZS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jwvZGl2PgoKPGRpdj4mbmJzcDs8L2Rpdj4KCjxkaXY+VGhhbmsgeW91LDwvZGl2PjwvZGl2Pgo8L2Jsb2NrcXVvdGU+" aria-hidden="true" style="font-size: 0px; padding: 0px; margin: 0px; block-size: 0px; height: 0px; inline-size: 0px; max-block-size: 0px; max-height: 0px; max-inline-size: 0px; max-width: 0px; overflow-block: hidden; overflow-inline: hidden; overflow: hidden; width: 0px;" class="mdhr-raw">​</div>
</div>
</blockquote>
</body>
</html>