Closed klukaspl closed 6 years ago
Hi Krzysztof,
@mardy has been working on adding "complex" type support to the code generator in the past few days, and we just (a few minutes ago) merged support for that. One of the complex types now supported is structs, such as your (si)
.
The tests now contain a test case for (ss)
, which should be very similar to your (si)
. For the XML, see here: https://github.com/Pelagicore/gdbus-codegen-glibmm/blob/master/test/common/many-types.xml#L45,
For the C++ code which accepts the (ss)
as an input parameter, see here: https://github.com/Pelagicore/gdbus-codegen-glibmm/blob/master/test/stub/teststubmain.cpp#L125 and for returning it, you can see that there is now a auto-generated ret
which takes a std::tuple
: https://github.com/Pelagicore/gdbus-codegen-glibmm/blob/master/test/stub/teststubmain.cpp#L128.
You can also see the latest test run, where we generate code for (ss)
on both stub and proxy side, and make a test run here: https://travis-ci.org/Pelagicore/gdbus-codegen-glibmm/jobs/371881144#L1658
I hope this solves your issue!
Hi,
Thank you for update. I tried new generated function:
void ret(std::tuple<Glib::ustring,gint32> p0)
{
std::vector<Glib::VariantBase> vlist;
vlist.push_back(Glib::Variant<std::tuple<Glib::ustring,gint32> >::create((p0)));
m_message->return_value(Glib::Variant<Glib::VariantBase>::create_tuple(vlist));
}
But have the following problem with compilation:
error: ‘create’ is not a member of ‘Glib::Variant<std::tuple<Glib::ustring, int> >’ vlist.push_back(Glib::Variant<std::tuple<Glib::ustring,gint32> >::create((p0)));
Any ideas?
BR Krzysztof
Hi,
Which version of glibmm are you using?
This has been verified to work on 2.56 (https://travis-ci.org/Pelagicore/gdbus-codegen-glibmm/jobs/371881144#L1546).
Hi, I belive I have glibmm-2.4 2.24.4. The funny thing is that the ide is showing that create is the member function but maybe this is using newer header. EDIT:: And the documentation claims that:
static Variant<std::string> Glib::Variant< std::string >::create ( const std::string & data )
since glibmm 2.28:
So my library is obsolete! That is the answer.
Thank you for your support! BR, Krzysztof
Hi,
the problematic thing was to generate the method that get int as input argument, and output (si) - variant containing string and integer. My solution: In my code I overloaded the ret function in _common.h file to the following:
then in my working class I implemented my example function as that:
I hope this can help someone to get the solution before the generator will be capable to solve that.
BTW: the example function is definied in XML as:
BR Krzysztof