Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use KDE's Smoke?

I can't get what the Smoke is. I've been expecting that smoke will generate C wrappers for C++ code and create header file with generated functions.

But running smokegen on C++ headers gives me tiny header, which just exports pointer to some Smoke class and <sourcename>_smoke_init() function.

What am i supposed to do with this?

like image 505
arrowd Avatar asked Jun 05 '12 10:06

arrowd


1 Answers

Smoke is a runtime binding generator, kind of like gobject-introspection if you know that.

That means it generates information about the code you are binding and makes it available as a library. In order to use the generated library, you must write code against the Smoke API (which is a C++ API) to get information about the code for which you have generated bindings for, and use the Smoke API to call functions into the code you are wrapping.

The example in the page http://techbase.kde.org/Development/Languages/Smoke shows how you use the API to call into the code you are binding (creating Qt Widgets hello world example here)

Smoke API is introduced here http://techbase.kde.org/Development/Languages/Smoke/API_Documentation for some tricky parts, but the main source of information I found is the smoke.h header.

I have developed a C binding ( https://github.com/pankajp/pysmoke/blob/master/include/smokec.h ) to Smoke in my attempt to write a Qt-python binding based on smoke, which already works for some simple programs. You may find it as a starting point if you want to use Smoke from C.

If, instead, you are just interested in exposing a small simple C++ library to C, without bothering about creating subclasses in C (in any way) and overriding virtual or protected method, that is you just want to use the existing code without extending it in any way, then you might be better off writing the bindings manually (as I did for the Smoke C++ API, though there i also provided a way to implement virtual methods in C by passing a function pointer)

like image 99
pankaj Avatar answered Dec 10 '22 16:12

pankaj