From kde-bindings Tue Jan 15 18:47:59 2013 From: Arno Rehn Date: Tue, 15 Jan 2013 18:47:59 +0000 To: kde-bindings Subject: Re: [Kde-bindings] Get a pointer to SmokeBinding Message-Id: <50F5A45F.3080108 () arnorehn ! de> X-MARC-Message: https://marc.info/?l=kde-bindings&m=135827569914530 On 15/01/13 17:54, j j wrote: >> 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? Yep. When you use SmokeMethod::call to call a method you can pass along a flag which decides whether to use dynamic dispatching or a direct method call. >> 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. Interesting :) So if you're starting from scratch anyway, I'd suggest you use smokev4 right from the beginning. The API might not be stable as of now, but for a new project it should be fine :) > On Tue, Jan 15, 2013 at 3:28 PM, Arno Rehn 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(**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 >> > > > > _______________________________________________ > Kde-bindings mailing list > Kde-bindings@kde.org > https://mail.kde.org/mailman/listinfo/kde-bindings > -- Arno Rehn _______________________________________________ Kde-bindings mailing list Kde-bindings@kde.org https://mail.kde.org/mailman/listinfo/kde-bindings