[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-bindings
Subject: Re: [Kde-bindings] Get a pointer to SmokeBinding
From: j j <jerro.public () gmail ! com>
Date: 2013-01-15 16:54:32
Message-ID: CAOYRX8wRr5OLPyyHMdbfCOEDo0jQrZVOgn-=ZhgApRpXvrf52Q () mail ! gmail ! com
[Download RAW message or body]
[Attachment #2 (multipart/alternative)]
> I see. This will be supported in smokev4, but not the current Smoke.
Is it already supported in current versions of smokev4? If so, how do I use
it?
> What are you doing with Smoke? I'm interested in every project using it :)
My goal is to write a program that will automatically generate D (
http://dlang.org) bindings for Smoke libraries such as smokeqt. I'm
currently only learning to use Smoke and trying to come up with a good
design for generating class hierarchies, etc. I can't promise anything will
actually come out of it :D.
On Tue, Jan 15, 2013 at 3:28 PM, Arno Rehn <arno@arnorehn.de> wrote:
> On 15/01/13 00:19, j j wrote:
>
> > But if there's a valid use-case I wouldn't object to implementing this in
> > >
> > smokev4.
> >
> > I'm only learning to use Smoke, so maybe what I want to do can be achieved
> > in some other way. I wan't to be able to call the most derived method
> > given
> > a Smoke object.
> >
> > Say I have a Smoke object foo of type Foo, on which I have set a
> > SmokeBinding bind which overrides bar(). Now say I call foo's method bar()
> > thorugh the Smoke api. It seems that this results in Foo.bar being called
> > directly, without bind->callMethod() being called first. I could call the
> > most derived method if I could get to the binding instance, but if there's
> > a better way to do it, I'd love to hear about it.
> >
> I see. This will be supported in smokev4, but not the current Smoke.
> Currently we assume that if you create a smoke object, the target language
> takes care of virtual method resulution and if you call a virtual method
> through the Smoke API, you really want to call the original C++ method.
>
> Now you could do some nasty pointer arithmetic for the time being. The
> SmokeBinding* pointer is simply appended to the original class and we have
> size information in Smoke. So something like this could work:
>
> char *ptr = reinterpret_cast<char*>(**smokeObject) + smokeClass->size;
> SmokeBinding *bind = *reinterpret_cast<**SmokeBinding**>(ptr);
>
> Note that this is probably undefined behaviour per se ;)
>
> What are you doing with Smoke? I'm interested in every project using it :)
>
>
> --
> Arno Rehn
> ______________________________**_________________
> Kde-bindings mailing list
> Kde-bindings@kde.org
> https://mail.kde.org/mailman/**listinfo/kde-bindings<https://mail.kde.org/mailman/listinfo/kde-bindings>
>
[Attachment #5 (text/html)]
<div dir="ltr">> <span style="font-family:arial,sans-serif;font-size:13px">I see. \
This will be supported in smokev4, but not the current Smoke.</span><div><span \
style="font-family:arial,sans-serif;font-size:13px"><br></span></div> <div \
style><font face="arial, sans-serif">Is it already supported in current versions of \
smokev4? If so, how do I use it?</font></div><div style><font face="arial, \
sans-serif"><br></font></div><div style><font face="arial, sans-serif">> \
</font><span style="font-family:arial,sans-serif;font-size:13px">What are you doing \
with Smoke? I'm interested in every project using it :)</span></div> <div \
style><span style="font-family:arial,sans-serif;font-size:13px"><br></span></div><div \
style><span style="font-family:arial,sans-serif;font-size:13px">My goal is to write a \
program that will automatically generate D (<a \
href="http://dlang.org">http://dlang.org</a>) bindings for Smoke libraries such as \
smokeqt. I'm currently only learning to use Smoke and trying to come up with a \
good design for generating class hierarchies, etc. I can't promise anything will \
actually come out of it :D.</span></div> </div><div class="gmail_extra"><br><br><div \
class="gmail_quote">On Tue, Jan 15, 2013 at 3:28 PM, Arno Rehn <span dir="ltr"><<a \
href="mailto:arno@arnorehn.de" target="_blank">arno@arnorehn.de</a>></span> \
wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px \
#ccc solid;padding-left:1ex"> <div class="im">On 15/01/13 00:19, j j wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex"><blockquote class="gmail_quote" style="margin:0 0 0 \
.8ex;border-left:1px #ccc solid;padding-left:1ex"> But if there's a valid \
use-case I wouldn't object to implementing this in<br> </blockquote>
smokev4.<br>
<br>
I'm only learning to use Smoke, so maybe what I want to do can be achieved<br>
in some other way. I wan't to be able to call the most derived method given<br>
a Smoke object.<br>
<br>
Say I have a Smoke object foo of type Foo, on which I have set a<br>
SmokeBinding bind which overrides bar(). Now say I call foo's method bar()<br>
thorugh the Smoke api. It seems that this results in Foo.bar being called<br>
directly, without bind->callMethod() being called first. I could call the<br>
most derived method if I could get to the binding instance, but if there's<br>
a better way to do it, I'd love to hear about it.<br>
</blockquote></div>
I see. This will be supported in smokev4, but not the current Smoke.<br>
Currently we assume that if you create a smoke object, the target language takes care \
of virtual method resulution and if you call a virtual method through the Smoke API, \
you really want to call the original C++ method.<br>
<br>
Now you could do some nasty pointer arithmetic for the time being. The SmokeBinding* \
pointer is simply appended to the original class and we have size information in \
Smoke. So something like this could work:<br> <br>
char *ptr = reinterpret_cast<char*>(<u></u>smokeObject) + \
smokeClass->size;<br> SmokeBinding *bind = \
*reinterpret_cast<<u></u>SmokeBinding**>(ptr);<br> <br>
Note that this is probably undefined behaviour per se ;)<br>
<br>
What are you doing with Smoke? I'm interested in every project using it :)<div \
class="HOEnZb"><div class="h5"><br> <br>
-- <br>
Arno Rehn<br>
______________________________<u></u>_________________<br>
Kde-bindings mailing list<br>
<a href="mailto:Kde-bindings@kde.org" target="_blank">Kde-bindings@kde.org</a><br>
<a href="https://mail.kde.org/mailman/listinfo/kde-bindings" \
target="_blank">https://mail.kde.org/mailman/<u></u>listinfo/kde-bindings</a><br> \
</div></div></blockquote></div><br></div>
_______________________________________________
Kde-bindings mailing list
Kde-bindings@kde.org
https://mail.kde.org/mailman/listinfo/kde-bindings
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic