Re: [Dbus-cxx-users] Method call which returns signed char (and takes time_t)?
Status: Beta
Brought to you by:
rvinyard
From: Rick L. V. Jr. <rvi...@cs...> - 2009-06-08 22:12:47
|
Hello Patrick: Patrick Allison wrote: > Hi: > > I've just started using dbus-cxx, and I'm having a bit of difficulty. I'm > trying to replicate the "callee_object"/"caller_object" example: in my > case, the class method looks like > > char saw(time_t sec); > > That gave me errors compiling the "callee" portion: > > /usr/local/include/dbus-cxx-0.1/dbus-cxx/method.h: In member function > DBus::HandlerResult DBus::Method<T_return, T_arg1, sigc::nil, sigc::nil, > sigc::nil, sigc::nil, sigc::nil, > sigc::nil>::handle_call_message(std::shared_ptr<DBus::Connection>, > std::shared_ptr<const DBus::CallMessage>) [with T_return = char, T_arg1 = > long int]: > > /usr/local/include/dbus-cxx-0.1/dbus-cxx/method.h:176: error: ambiguous > overload for operator>> in i >> _val_1 > /usr/local/include/dbus-cxx-0.1/dbus-cxx/method.h:176: note: candidates > are: operator>>(int32_t, long int) <built-in> > /usr/local/include/dbus-cxx-0.1/dbus-cxx/method.h:176: note: > operator>>(uint32_t, long int) <built-in> > /usr/local/include/dbus-cxx-0.1/dbus-cxx/method.h:176: note: > operator>>(uint64_t, long int) <built-in> > /usr/local/include/dbus-cxx-0.1/dbus-cxx/method.h:176: note: > operator>>(int64_t, long int) <built-in> > > I got around that problem by replacing "time_t" with an unsigned int, so > that's not that big a deal, though I'd like to know if that can be fixed. > I then hit a snag in the "caller" portion, > > /usr/local/include/dbus-cxx-0.1/dbus-cxx/message.h: In function > DBus::MessageIterator DBus::operator>>(std::shared_ptr<const > DBus::Message>, T&) [with T = signed char]: > /usr/local/include/dbus-cxx-0.1/dbus-cxx/methodproxy.h:109: instantiated > from T_return DBus::MethodProxy<T_return, T_arg1, sigc::nil, sigc::nil, > sigc::nil, sigc::nil, sigc::nil, sigc::nil>::operator()(T_arg1) [with > T_return = signed char, T_arg1 = unsigned int] > > /usr/local/include/dbus-cxx-0.1/dbus-cxx/message.h:182: error: no matching > function for call to DBus::Message::operator>>(signed char&) const > > which then lists a bunch of operator>> with bool, uint8_t, > int16_t,uint16_t,int32_t,uint32_t,int64_t,uint64_t,double, const char*, > and std::string. It looks like int8_t is missing from that list. > > Anyway, I wasn't sure if this was a bug or something related to allowable > DBus types, so I figured I'd ask. I can work around it by passing > something larger than a char, obviously, but it seems strange for int8_t > to be the only one that's missing. > Largely, it's related to the dbus types. DBus doesn't have a direct type for char or int8_t but there is a BYTE type. I added support for both since they are fundamental C types. I also added support for floats. The problem with the long int was due to the fact that nothing in the DBus types maps directly to it. On i386 int32_t maps to to int and int64_t maps to long long skipping long. I added support for long ints on 32-bit architectures only (since they're already supported as int64_t on x86_64). I also added an example that demonstrates how to overload the << and >> operators for MessageIterator and MessageAppendIterator to support additional types. In this example a timeval (with microsecond resolution) is overloaded. --- Rick |