[Kde-bindings] Get a pointer to SmokeBinding

j j jerro.public at gmail.com
Tue Jan 15 16:54:32 UTC 2013


> 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 at 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 at kde.org
> https://mail.kde.org/mailman/**listinfo/kde-bindings<https://mail.kde.org/mailman/listinfo/kde-bindings>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-bindings/attachments/20130115/678c5218/attachment.html>


More information about the Kde-bindings mailing list