Time to get rid of the horrible coding style
This commit is contained in:
parent
534ee610d8
commit
efc594f888
53 changed files with 1137 additions and 1136 deletions
|
@ -29,10 +29,10 @@
|
|||
|
||||
DBus::BusDispatcher dispatcher;
|
||||
static bool systembus;
|
||||
static char* path;
|
||||
static char* service;
|
||||
static char *path;
|
||||
static char *service;
|
||||
|
||||
void niam( int sig )
|
||||
void niam(int sig)
|
||||
{
|
||||
DBus::Connection conn = systembus ? DBus::Connection::SystemBus() : DBus::Connection::SessionBus();
|
||||
|
||||
|
@ -43,19 +43,19 @@ void niam( int sig )
|
|||
dispatcher.leave();
|
||||
}
|
||||
|
||||
int main( int argc, char** argv )
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
signal(SIGTERM, niam);
|
||||
signal(SIGINT, niam);
|
||||
signal(SIGALRM, niam);
|
||||
|
||||
if(argc == 1)
|
||||
if (argc == 1)
|
||||
{
|
||||
std::cerr << std::endl << "Usage: " << argv[0] << " [--system] <object_path> [<destination>]" << std::endl << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(strcmp(argv[1], "--system"))
|
||||
if (strcmp(argv[1], "--system"))
|
||||
{
|
||||
systembus = false;
|
||||
path = argv[1];
|
||||
|
|
|
@ -36,7 +36,7 @@ class IntrospectedObject : public DBus::IntrospectableProxy, public DBus::Object
|
|||
{
|
||||
public:
|
||||
|
||||
IntrospectedObject( DBus::Connection& conn, const char* path, const char* service )
|
||||
IntrospectedObject(DBus::Connection &conn, const char *path, const char *service)
|
||||
: DBus::ObjectProxy(conn, path, service)
|
||||
{}
|
||||
};
|
||||
|
|
102
tools/xml.cpp
102
tools/xml.cpp
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include <expat.h>
|
||||
|
||||
std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc )
|
||||
std::istream &operator >> (std::istream &in, DBus::Xml::Document &doc)
|
||||
{
|
||||
std::stringbuf xmlbuf;
|
||||
in.get(xmlbuf, '\0');
|
||||
|
@ -37,7 +37,7 @@ std::istream& operator >> ( std::istream& in, DBus::Xml::Document& doc )
|
|||
return in;
|
||||
}
|
||||
|
||||
std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc )
|
||||
std::ostream &operator << (std::ostream &out, const DBus::Xml::Document &doc)
|
||||
{
|
||||
return out << doc.to_xml();
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ std::ostream& operator << ( std::ostream& out, const DBus::Xml::Document& doc )
|
|||
using namespace DBus;
|
||||
using namespace DBus::Xml;
|
||||
|
||||
Error::Error( const char* error, int line, int column )
|
||||
Error::Error(const char *error, int line, int column)
|
||||
{
|
||||
std::ostringstream estream;
|
||||
|
||||
|
@ -54,11 +54,11 @@ Error::Error( const char* error, int line, int column )
|
|||
_error = estream.str();
|
||||
}
|
||||
|
||||
Node::Node( const char* n, const char** a )
|
||||
Node::Node(const char *n, const char ** a)
|
||||
: name(n)
|
||||
{
|
||||
if(a)
|
||||
for(int i = 0; a[i]; i += 2)
|
||||
if (a)
|
||||
for (int i = 0; a[i]; i += 2)
|
||||
{
|
||||
_attrs[a[i]] = a[i+1];
|
||||
|
||||
|
@ -66,11 +66,11 @@ Node::Node( const char* n, const char** a )
|
|||
}
|
||||
}
|
||||
|
||||
Nodes Nodes::operator[]( const std::string& key )
|
||||
Nodes Nodes::operator[](const std::string &key)
|
||||
{
|
||||
Nodes result;
|
||||
|
||||
for(iterator i = begin(); i != end(); ++i)
|
||||
for (iterator i = begin(); i != end(); ++i)
|
||||
{
|
||||
Nodes part = (**i)[key];
|
||||
|
||||
|
@ -79,43 +79,43 @@ Nodes Nodes::operator[]( const std::string& key )
|
|||
return result;
|
||||
}
|
||||
|
||||
Nodes Nodes::select( const std::string& attr, const std::string& value )
|
||||
Nodes Nodes::select(const std::string &attr, const std::string &value)
|
||||
{
|
||||
Nodes result;
|
||||
|
||||
for(iterator i = begin(); i != end(); ++i)
|
||||
for (iterator i = begin(); i != end(); ++i)
|
||||
{
|
||||
if((*i)->get(attr) == value)
|
||||
if ((*i)->get(attr) == value)
|
||||
result.insert(result.end(), *i);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Nodes Node::operator[]( const std::string& key )
|
||||
Nodes Node::operator[](const std::string &key)
|
||||
{
|
||||
Nodes result;
|
||||
|
||||
if(key.length() == 0) return result;
|
||||
if (key.length() == 0) return result;
|
||||
|
||||
for(Children::iterator i = children.begin(); i != children.end(); ++i)
|
||||
for (Children::iterator i = children.begin(); i != children.end(); ++i)
|
||||
{
|
||||
if(i->name == key)
|
||||
if (i->name == key)
|
||||
result.push_back(&(*i));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
std::string Node::get( const std::string& attribute )
|
||||
std::string Node::get(const std::string &attribute)
|
||||
{
|
||||
if(_attrs.find(attribute) != _attrs.end())
|
||||
if (_attrs.find(attribute) != _attrs.end())
|
||||
return _attrs[attribute];
|
||||
else
|
||||
return "";
|
||||
}
|
||||
|
||||
void Node::set( const std::string& attribute, std::string value )
|
||||
void Node::set(const std::string &attribute, std::string value)
|
||||
{
|
||||
if(value.length())
|
||||
if (value.length())
|
||||
_attrs[attribute] = value;
|
||||
else
|
||||
_attrs.erase(value);
|
||||
|
@ -131,17 +131,17 @@ std::string Node::to_xml() const
|
|||
return xml;
|
||||
}
|
||||
|
||||
void Node::_raw_xml( std::string& xml, int& depth ) const
|
||||
void Node::_raw_xml(std::string &xml, int &depth) const
|
||||
{
|
||||
xml.append(depth*2, ' ');
|
||||
xml.append(depth *2, ' ');
|
||||
xml.append("<"+name);
|
||||
|
||||
for(Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i)
|
||||
for (Attributes::const_iterator i = _attrs.begin(); i != _attrs.end(); ++i)
|
||||
{
|
||||
xml.append(" "+i->first+"=\""+i->second+"\"");
|
||||
}
|
||||
|
||||
if(cdata.length() == 0 && children.size() == 0)
|
||||
if (cdata.length() == 0 && children.size() == 0)
|
||||
{
|
||||
xml.append("/>\n");
|
||||
}
|
||||
|
@ -149,23 +149,23 @@ void Node::_raw_xml( std::string& xml, int& depth ) const
|
|||
{
|
||||
xml.append(">");
|
||||
|
||||
if(cdata.length())
|
||||
if (cdata.length())
|
||||
{
|
||||
xml.append(cdata);
|
||||
}
|
||||
|
||||
if(children.size())
|
||||
if (children.size())
|
||||
{
|
||||
xml.append("\n");
|
||||
depth++;
|
||||
|
||||
for(Children::const_iterator i = children.begin(); i != children.end(); ++i)
|
||||
for (Children::const_iterator i = children.begin(); i != children.end(); ++i)
|
||||
{
|
||||
i->_raw_xml(xml, depth);
|
||||
}
|
||||
|
||||
depth--;
|
||||
xml.append(depth*2, ' ');
|
||||
xml.append(depth *2, ' ');
|
||||
}
|
||||
xml.append("</"+name+">\n");
|
||||
}
|
||||
|
@ -176,7 +176,7 @@ Document::Document()
|
|||
{
|
||||
}
|
||||
|
||||
Document::Document( const std::string& xml )
|
||||
Document::Document(const std::string &xml)
|
||||
: root(0), _depth(0)
|
||||
{
|
||||
from_xml(xml);
|
||||
|
@ -190,15 +190,15 @@ Document::~Document()
|
|||
struct Document::Expat
|
||||
{
|
||||
static void start_doctype_decl_handler(
|
||||
void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset
|
||||
void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset
|
||||
);
|
||||
static void end_doctype_decl_handler( void* data );
|
||||
static void start_element_handler( void *data, const XML_Char *name, const XML_Char **atts );
|
||||
static void character_data_handler( void *data, const XML_Char* chars, int len );
|
||||
static void end_element_handler( void *data, const XML_Char *name );
|
||||
static void end_doctype_decl_handler(void *data);
|
||||
static void start_element_handler(void *data, const XML_Char *name, const XML_Char **atts);
|
||||
static void character_data_handler(void *data, const XML_Char *chars, int len);
|
||||
static void end_element_handler(void *data, const XML_Char *name);
|
||||
};
|
||||
|
||||
void Document::from_xml( const std::string& xml )
|
||||
void Document::from_xml(const std::string &xml)
|
||||
{
|
||||
_depth = 0;
|
||||
delete root;
|
||||
|
@ -227,9 +227,9 @@ void Document::from_xml( const std::string& xml )
|
|||
|
||||
XML_Status status = XML_Parse(parser, xml.c_str(), xml.length(), true);
|
||||
|
||||
if(status == XML_STATUS_ERROR)
|
||||
if (status == XML_STATUS_ERROR)
|
||||
{
|
||||
const char* error = XML_ErrorString(XML_GetErrorCode(parser));
|
||||
const char *error = XML_ErrorString(XML_GetErrorCode(parser));
|
||||
int line = XML_GetCurrentLineNumber(parser);
|
||||
int column = XML_GetCurrentColumnNumber(parser);
|
||||
|
||||
|
@ -249,30 +249,30 @@ std::string Document::to_xml() const
|
|||
}
|
||||
|
||||
void Document::Expat::start_doctype_decl_handler(
|
||||
void* data, const XML_Char* name, const XML_Char* sysid, const XML_Char* pubid, int has_internal_subset
|
||||
void *data, const XML_Char *name, const XML_Char *sysid, const XML_Char *pubid, int has_internal_subset
|
||||
)
|
||||
{
|
||||
}
|
||||
|
||||
void Document::Expat::end_doctype_decl_handler( void* data )
|
||||
void Document::Expat::end_doctype_decl_handler(void *data)
|
||||
{
|
||||
}
|
||||
|
||||
void Document::Expat::start_element_handler( void *data, const XML_Char *name, const XML_Char **atts )
|
||||
void Document::Expat::start_element_handler(void *data, const XML_Char *name, const XML_Char **atts)
|
||||
{
|
||||
Document* doc = (Document*)data;
|
||||
Document *doc = (Document *)data;
|
||||
|
||||
//debug_log("xml:%d -> %s", doc->_depth, name);
|
||||
|
||||
if(!doc->root)
|
||||
if (!doc->root)
|
||||
{
|
||||
doc->root = new Node(name, atts);
|
||||
}
|
||||
else
|
||||
{
|
||||
Node::Children* cld = &(doc->root->children);
|
||||
Node::Children *cld = &(doc->root->children);
|
||||
|
||||
for(int i = 1; i < doc->_depth; ++i)
|
||||
for (int i = 1; i < doc->_depth; ++i)
|
||||
{
|
||||
cld = &(cld->back().children);
|
||||
}
|
||||
|
@ -283,13 +283,13 @@ void Document::Expat::start_element_handler( void *data, const XML_Char *name, c
|
|||
doc->_depth++;
|
||||
}
|
||||
|
||||
void Document::Expat::character_data_handler( void *data, const XML_Char* chars, int len )
|
||||
void Document::Expat::character_data_handler(void *data, const XML_Char *chars, int len)
|
||||
{
|
||||
Document* doc = (Document*)data;
|
||||
Document *doc = (Document *)data;
|
||||
|
||||
Node* nod = doc->root;
|
||||
Node *nod = doc->root;
|
||||
|
||||
for(int i = 1; i < doc->_depth; ++i)
|
||||
for (int i = 1; i < doc->_depth; ++i)
|
||||
{
|
||||
nod = &(nod->children.back());
|
||||
}
|
||||
|
@ -298,15 +298,15 @@ void Document::Expat::character_data_handler( void *data, const XML_Char* chars,
|
|||
x = 0;
|
||||
y = len-1;
|
||||
|
||||
while(isspace(chars[y]) && y > 0) --y;
|
||||
while(isspace(chars[x]) && x < y) ++x;
|
||||
while (isspace(chars[y]) && y > 0) --y;
|
||||
while (isspace(chars[x]) && x < y) ++x;
|
||||
|
||||
nod->cdata = std::string(chars, x, y+1);
|
||||
}
|
||||
|
||||
void Document::Expat::end_element_handler( void *data, const XML_Char *name )
|
||||
void Document::Expat::end_element_handler(void *data, const XML_Char *name)
|
||||
{
|
||||
Document* doc = (Document*)data;
|
||||
Document *doc = (Document *)data;
|
||||
|
||||
//debug_log("xml:%d <- %s", doc->_depth, name);
|
||||
|
||||
|
|
34
tools/xml.h
34
tools/xml.h
|
@ -44,12 +44,12 @@ class Error : public std::exception
|
|||
{
|
||||
public:
|
||||
|
||||
Error( const char* error, int line, int column );
|
||||
Error(const char *error, int line, int column);
|
||||
|
||||
~Error() throw()
|
||||
{}
|
||||
|
||||
const char* what() const throw()
|
||||
const char *what() const throw()
|
||||
{
|
||||
return _error.c_str();
|
||||
}
|
||||
|
@ -61,13 +61,13 @@ private:
|
|||
|
||||
class Node;
|
||||
|
||||
class Nodes : public std::vector<Node*>
|
||||
class Nodes : public std::vector<Node *>
|
||||
{
|
||||
public:
|
||||
|
||||
Nodes operator[]( const std::string& key );
|
||||
Nodes operator[](const std::string &key);
|
||||
|
||||
Nodes select( const std::string& attr, const std::string& value );
|
||||
Nodes select(const std::string &attr, const std::string &value);
|
||||
};
|
||||
|
||||
class Node
|
||||
|
@ -82,21 +82,21 @@ public:
|
|||
std::string cdata;
|
||||
Children children;
|
||||
|
||||
Node( std::string& n, Attributes& a )
|
||||
Node(std::string &n, Attributes &a)
|
||||
: name(n), _attrs(a)
|
||||
{}
|
||||
|
||||
Node( const char* n, const char** a = NULL );
|
||||
Node(const char *n, const char ** a = NULL);
|
||||
|
||||
Nodes operator[]( const std::string& key );
|
||||
Nodes operator[](const std::string &key);
|
||||
|
||||
std::string get( const std::string& attribute );
|
||||
std::string get(const std::string &attribute);
|
||||
|
||||
void set( const std::string& attribute, std::string value );
|
||||
void set(const std::string &attribute, std::string value);
|
||||
|
||||
std::string to_xml() const;
|
||||
|
||||
Node& add( Node child )
|
||||
Node &add(Node child)
|
||||
{
|
||||
children.push_back(child);
|
||||
return children.back();
|
||||
|
@ -104,7 +104,7 @@ public:
|
|||
|
||||
private:
|
||||
|
||||
void _raw_xml( std::string& xml, int& depth ) const;
|
||||
void _raw_xml(std::string &xml, int &depth) const;
|
||||
|
||||
Attributes _attrs;
|
||||
};
|
||||
|
@ -115,15 +115,15 @@ public:
|
|||
|
||||
struct Expat;
|
||||
|
||||
Node* root;
|
||||
Node *root;
|
||||
|
||||
Document();
|
||||
|
||||
Document( const std::string& xml );
|
||||
Document(const std::string &xml);
|
||||
|
||||
~Document();
|
||||
|
||||
void from_xml( const std::string& xml );
|
||||
void from_xml(const std::string &xml);
|
||||
|
||||
std::string to_xml() const;
|
||||
|
||||
|
@ -136,7 +136,7 @@ private:
|
|||
|
||||
} /* namespace DBus */
|
||||
|
||||
std::istream& operator >> ( std::istream&, DBus::Xml::Document& );
|
||||
std::ostream& operator << ( std::ostream&, DBus::Xml::Document& );
|
||||
std::istream &operator >> (std::istream &, DBus::Xml::Document &);
|
||||
std::ostream &operator << (std::ostream &, DBus::Xml::Document &);
|
||||
|
||||
#endif//__DBUSXX_XML_H
|
||||
|
|
|
@ -37,55 +37,55 @@
|
|||
using namespace std;
|
||||
using namespace DBus;
|
||||
|
||||
static const char* tab = " ";
|
||||
static const char *tab = " ";
|
||||
|
||||
static const char* header = "\n\
|
||||
static const char *header = "\n\
|
||||
/*\n\
|
||||
* This file was automatically generated by dbusxx-xml2cpp; DO NOT EDIT!\n\
|
||||
*/\n\
|
||||
\n\
|
||||
";
|
||||
|
||||
static const char* dbus_includes = "\n\
|
||||
static const char *dbus_includes = "\n\
|
||||
#include <dbus-c++/dbus.h>\n\
|
||||
\n\
|
||||
";
|
||||
|
||||
typedef map<string,string> TypeCache;
|
||||
|
||||
void usage( const char* argv0 )
|
||||
void usage(const char *argv0)
|
||||
{
|
||||
cerr << endl << "Usage: " << argv0 << " <xmlfile> [ --proxy=<outfile.h> ] [ --adaptor=<outfile.h> ]"
|
||||
<< endl << endl;
|
||||
exit(-1);
|
||||
}
|
||||
|
||||
void underscorize( string& str )
|
||||
void underscorize(string &str)
|
||||
{
|
||||
for(unsigned int i = 0; i < str.length(); ++i)
|
||||
for (unsigned int i = 0; i < str.length(); ++i)
|
||||
{
|
||||
if(!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_';
|
||||
if (!isalpha(str[i]) && !isdigit(str[i])) str[i] = '_';
|
||||
}
|
||||
}
|
||||
|
||||
string stub_name( string name )
|
||||
string stub_name(string name)
|
||||
{
|
||||
underscorize(name);
|
||||
|
||||
return "_" + name + "_stub";
|
||||
}
|
||||
|
||||
int char_to_atomic_type( char t )
|
||||
int char_to_atomic_type(char t)
|
||||
{
|
||||
if(strchr("ybnqiuxtdsgavre", t))
|
||||
if (strchr("ybnqiuxtdsgavre", t))
|
||||
return t;
|
||||
|
||||
return DBUS_TYPE_INVALID;
|
||||
}
|
||||
|
||||
const char* atomic_type_to_string( char t )
|
||||
const char *atomic_type_to_string(char t)
|
||||
{
|
||||
static struct { char type; const char* name; } atos[] =
|
||||
static struct { char type; const char *name; } atos[] =
|
||||
{
|
||||
{ 'y', "::DBus::Byte" },
|
||||
{ 'b', "::DBus::Bool" },
|
||||
|
@ -104,34 +104,34 @@ const char* atomic_type_to_string( char t )
|
|||
};
|
||||
int i;
|
||||
|
||||
for(i = 0; atos[i].type; ++i)
|
||||
for (i = 0; atos[i].type; ++i)
|
||||
{
|
||||
if(atos[i].type == t) break;
|
||||
if (atos[i].type == t) break;
|
||||
}
|
||||
return atos[i].name;
|
||||
}
|
||||
|
||||
bool is_atomic_type( const string& type )
|
||||
bool is_atomic_type(const string &type)
|
||||
{
|
||||
return type.length() == 1 && char_to_atomic_type(type[0]) != DBUS_TYPE_INVALID;
|
||||
}
|
||||
|
||||
void _parse_signature( const string& signature, string& type, unsigned int& i )
|
||||
void _parse_signature(const string &signature, string &type, unsigned int &i)
|
||||
{
|
||||
for(; i < signature.length(); ++i)
|
||||
for (; i < signature.length(); ++i)
|
||||
{
|
||||
switch(signature[i])
|
||||
switch (signature[i])
|
||||
{
|
||||
case 'a':
|
||||
{
|
||||
switch(signature[++i])
|
||||
switch (signature[++i])
|
||||
{
|
||||
case '{':
|
||||
{
|
||||
type += "std::map< ";
|
||||
|
||||
const char* atom = atomic_type_to_string(signature[++i]);
|
||||
if(!atom)
|
||||
const char *atom = atomic_type_to_string(signature[++i]);
|
||||
if (!atom)
|
||||
{
|
||||
cerr << "invalid signature" << endl;
|
||||
exit(-1);
|
||||
|
@ -157,7 +157,7 @@ void _parse_signature( const string& signature, string& type, unsigned int& i )
|
|||
++i;
|
||||
_parse_signature(signature, type, i);
|
||||
type += " >";
|
||||
if(signature[i+1])
|
||||
if (signature[i+1])
|
||||
{
|
||||
type += ", ";
|
||||
}
|
||||
|
@ -170,15 +170,15 @@ void _parse_signature( const string& signature, string& type, unsigned int& i )
|
|||
}
|
||||
default:
|
||||
{
|
||||
const char* atom = atomic_type_to_string(signature[i]);
|
||||
if(!atom)
|
||||
const char *atom = atomic_type_to_string(signature[i]);
|
||||
if (!atom)
|
||||
{
|
||||
cerr << "invalid signature" << endl;
|
||||
exit(-1);
|
||||
}
|
||||
type += atom;
|
||||
|
||||
if(signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length())
|
||||
if (signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length())
|
||||
{
|
||||
type += ", ";
|
||||
}
|
||||
|
@ -188,7 +188,7 @@ void _parse_signature( const string& signature, string& type, unsigned int& i )
|
|||
}
|
||||
}
|
||||
|
||||
string signature_to_type( const string& signature )
|
||||
string signature_to_type(const string &signature)
|
||||
{
|
||||
string type;
|
||||
unsigned int i = 0;
|
||||
|
@ -196,12 +196,12 @@ string signature_to_type( const string& signature )
|
|||
return type;
|
||||
}
|
||||
|
||||
void generate_proxy( Xml::Document& doc, const char* filename )
|
||||
void generate_proxy(Xml::Document &doc, const char *filename)
|
||||
{
|
||||
cerr << "writing " << filename << endl;
|
||||
|
||||
ofstream file(filename);
|
||||
if(file.bad())
|
||||
if (file.bad())
|
||||
{
|
||||
cerr << "unable to write file " << filename << endl;
|
||||
exit(-1);
|
||||
|
@ -218,12 +218,12 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
|
||||
file << dbus_includes;
|
||||
|
||||
Xml::Node& root = *(doc.root);
|
||||
Xml::Node &root = *(doc.root);
|
||||
Xml::Nodes interfaces = root["interface"];
|
||||
|
||||
for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
||||
for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
||||
{
|
||||
Xml::Node& iface = **i;
|
||||
Xml::Node &iface = **i;
|
||||
Xml::Nodes methods = iface["method"];
|
||||
Xml::Nodes signals = iface["signal"];
|
||||
Xml::Nodes properties = iface["property"];
|
||||
|
@ -232,7 +232,7 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
ms.insert(ms.end(), signals.begin(), signals.end());
|
||||
|
||||
string ifacename = iface.get("name");
|
||||
if(ifacename == "org.freedesktop.DBus.Introspectable"
|
||||
if (ifacename == "org.freedesktop.DBus.Introspectable"
|
||||
||ifacename == "org.freedesktop.DBus.Properties")
|
||||
{
|
||||
cerr << "skipping interface " << ifacename << endl;
|
||||
|
@ -243,7 +243,7 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
string nspace;
|
||||
unsigned int nspaces = 0;
|
||||
|
||||
while(ss.str().find('.', ss.tellg()) != string::npos)
|
||||
while (ss.str().find('.', ss.tellg()) != string::npos)
|
||||
{
|
||||
getline(ss, nspace, '.');
|
||||
|
||||
|
@ -268,9 +268,9 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
<< tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl
|
||||
<< tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
{
|
||||
Xml::Node& signal = **si;
|
||||
Xml::Node &signal = **si;
|
||||
|
||||
string marshname = "_" + signal.get("name") + "_stub";
|
||||
|
||||
|
@ -288,75 +288,75 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
<< tab << " * this functions will invoke the corresponding methods on the remote objects" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
{
|
||||
Xml::Node& method = **mi;
|
||||
Xml::Node &method = **mi;
|
||||
Xml::Nodes args = method["arg"];
|
||||
Xml::Nodes args_in = args.select("direction","in");
|
||||
Xml::Nodes args_out = args.select("direction","out");
|
||||
|
||||
if(args_out.size() == 0 || args_out.size() > 1 )
|
||||
if (args_out.size() == 0 || args_out.size() > 1)
|
||||
{
|
||||
file << tab << "void ";
|
||||
}
|
||||
else if(args_out.size() == 1)
|
||||
else if (args_out.size() == 1)
|
||||
{
|
||||
file << tab << signature_to_type(args_out.front()->get("type")) << " ";
|
||||
}
|
||||
|
||||
file << method.get("name") << "( ";
|
||||
file << method.get("name") << "(";
|
||||
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << arg_name;
|
||||
else
|
||||
file << "argin" << i;
|
||||
|
||||
if((i+1 != args_in.size() || args_out.size() > 1))
|
||||
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||
file << ", ";
|
||||
}
|
||||
|
||||
if(args_out.size() > 1)
|
||||
if (args_out.size() > 1)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ao;
|
||||
Xml::Node &arg = **ao;
|
||||
file << signature_to_type(arg.get("type")) << "&";
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << " " << arg_name;
|
||||
else
|
||||
file << " argout" << i;
|
||||
|
||||
if(i+1 != args_out.size())
|
||||
if (i+1 != args_out.size())
|
||||
file << ", ";
|
||||
}
|
||||
}
|
||||
file << " )" << endl;
|
||||
file << ")" << endl;
|
||||
|
||||
file << tab << "{" << endl
|
||||
<< tab << tab << "::DBus::CallMessage call;" << endl;
|
||||
|
||||
if(args_in.size() > 0)
|
||||
if (args_in.size() > 0)
|
||||
{
|
||||
file << tab << tab << "::DBus::MessageIter wi = call.writer();" << endl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
unsigned int j = 0;
|
||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j)
|
||||
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++j)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << tab << tab << "wi << " << arg_name << ";" << endl;
|
||||
else
|
||||
file << tab << tab << "wi << argin" << j << ";" << endl;
|
||||
|
@ -366,27 +366,27 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
<< tab << tab << "::DBus::Message ret = invoke_method(call);" << endl;
|
||||
|
||||
|
||||
if(args_out.size() > 0)
|
||||
if (args_out.size() > 0)
|
||||
{
|
||||
file << tab << tab << "::DBus::MessageIter ri = ret.reader();" << endl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
if(args_out.size() == 1)
|
||||
if (args_out.size() == 1)
|
||||
{
|
||||
file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout;" << endl;
|
||||
file << tab << tab << "ri >> argout;" << endl;
|
||||
file << tab << tab << "return argout;" << endl;
|
||||
}
|
||||
else if(args_out.size() > 1)
|
||||
else if (args_out.size() > 1)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ao;
|
||||
Xml::Node &arg = **ao;
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << tab << tab << "ri >> " << arg.get("name") << ";" << endl;
|
||||
else
|
||||
file << tab << tab << "ri >> argout" << i << ";" << endl;
|
||||
|
@ -403,29 +403,29 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
<< tab << "/* signal handlers for this interface" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
{
|
||||
Xml::Node& signal = **si;
|
||||
Xml::Node &signal = **si;
|
||||
Xml::Nodes args = signal["arg"];
|
||||
|
||||
file << tab << "virtual void " << signal.get("name") << "( ";
|
||||
file << tab << "virtual void " << signal.get("name") << "(";
|
||||
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
||||
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << arg_name;
|
||||
else
|
||||
file << "argin" << i;
|
||||
|
||||
if((ai+1 != args.end()))
|
||||
if ((ai+1 != args.end()))
|
||||
file << ", ";
|
||||
}
|
||||
file << " ) = 0;" << endl;
|
||||
file << ") = 0;" << endl;
|
||||
}
|
||||
|
||||
file << endl
|
||||
|
@ -434,28 +434,28 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
{
|
||||
Xml::Node& signal = **si;
|
||||
Xml::Node &signal = **si;
|
||||
Xml::Nodes args = signal["arg"];
|
||||
|
||||
file << tab << "void " << stub_name(signal.get("name")) << "( const ::DBus::SignalMessage& sig )" << endl
|
||||
file << tab << "void " << stub_name(signal.get("name")) << "(const ::DBus::SignalMessage &sig)" << endl
|
||||
<< tab << "{" << endl;
|
||||
|
||||
if(args.size() > 0)
|
||||
if (args.size() > 0)
|
||||
{
|
||||
file << tab << tab << "::DBus::MessageIter ri = sig.reader();" << endl
|
||||
<< endl;
|
||||
}
|
||||
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
||||
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
file << tab << tab << signature_to_type(arg.get("type")) << " " ;
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << arg_name << ";" << " ri >> " << arg_name << ";" << endl;
|
||||
else
|
||||
file << "arg" << i << ";" << " ri >> " << "arg" << i << ";" << endl;
|
||||
|
@ -464,17 +464,17 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
file << tab << tab << signal.get("name") << "(";
|
||||
|
||||
unsigned int j = 0;
|
||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j)
|
||||
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++j)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << arg_name;
|
||||
else
|
||||
file << "arg" << j;
|
||||
|
||||
if(ai+1 != args.end())
|
||||
if (ai+1 != args.end())
|
||||
file << ", ";
|
||||
}
|
||||
|
||||
|
@ -487,7 +487,7 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
file << "};" << endl
|
||||
<< endl;
|
||||
|
||||
for(unsigned int i = 0; i < nspaces; ++i)
|
||||
for (unsigned int i = 0; i < nspaces; ++i)
|
||||
{
|
||||
file << "} ";
|
||||
}
|
||||
|
@ -499,12 +499,12 @@ void generate_proxy( Xml::Document& doc, const char* filename )
|
|||
file.close();
|
||||
}
|
||||
|
||||
void generate_adaptor( Xml::Document& doc, const char* filename )
|
||||
void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||
{
|
||||
cerr << "writing " << filename << endl;
|
||||
|
||||
ofstream file(filename);
|
||||
if(file.bad())
|
||||
if (file.bad())
|
||||
{
|
||||
cerr << "unable to write file " << filename << endl;
|
||||
exit(-1);
|
||||
|
@ -521,12 +521,12 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
|
||||
file << dbus_includes;
|
||||
|
||||
Xml::Node& root = *(doc.root);
|
||||
Xml::Node &root = *(doc.root);
|
||||
Xml::Nodes interfaces = root["interface"];
|
||||
|
||||
for(Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
||||
for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i)
|
||||
{
|
||||
Xml::Node& iface = **i;
|
||||
Xml::Node &iface = **i;
|
||||
Xml::Nodes methods = iface["method"];
|
||||
Xml::Nodes signals = iface["signal"];
|
||||
Xml::Nodes properties = iface["property"];
|
||||
|
@ -535,7 +535,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
ms.insert(ms.end(), signals.begin(), signals.end());
|
||||
|
||||
string ifacename = iface.get("name");
|
||||
if(ifacename == "org.freedesktop.DBus.Introspectable"
|
||||
if (ifacename == "org.freedesktop.DBus.Introspectable"
|
||||
||ifacename == "org.freedesktop.DBus.Properties")
|
||||
{
|
||||
cerr << "skipping interface " << ifacename << endl;
|
||||
|
@ -546,7 +546,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
string nspace;
|
||||
unsigned int nspaces = 0;
|
||||
|
||||
while(ss.str().find('.', ss.tellg()) != string::npos)
|
||||
while (ss.str().find('.', ss.tellg()) != string::npos)
|
||||
{
|
||||
getline(ss, nspace, '.');
|
||||
|
||||
|
@ -571,26 +571,26 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
<< tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl
|
||||
<< tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||
for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||
{
|
||||
Xml::Node& property = **pi;
|
||||
Xml::Node &property = **pi;
|
||||
|
||||
file << tab << tab << "bind_property("
|
||||
<< property.get("name") << ", "
|
||||
<< "\"" << property.get("type") << "\", "
|
||||
<< ( property.get("access").find("read") != string::npos
|
||||
<< (property.get("access").find("read") != string::npos
|
||||
? "true"
|
||||
: "false" )
|
||||
: "false")
|
||||
<< ", "
|
||||
<< ( property.get("access").find("write") != string::npos
|
||||
<< (property.get("access").find("write") != string::npos
|
||||
? "true"
|
||||
: "false" )
|
||||
: "false")
|
||||
<< ");" << endl;
|
||||
}
|
||||
|
||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
{
|
||||
Xml::Node& method = **mi;
|
||||
Xml::Node &method = **mi;
|
||||
|
||||
file << tab << tab << "register_method("
|
||||
<< ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
|
||||
|
@ -600,24 +600,24 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file << tab << "}" << endl
|
||||
<< endl;
|
||||
|
||||
file << tab << "::DBus::IntrospectedInterface* const introspect() const " << endl
|
||||
file << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl
|
||||
<< tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
|
||||
for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
|
||||
{
|
||||
Xml::Node& method = **mi;
|
||||
Xml::Node &method = **mi;
|
||||
Xml::Nodes args = method["arg"];
|
||||
|
||||
file << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl
|
||||
<< tab << tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai)
|
||||
for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
|
||||
file << tab << tab << tab << "{ ";
|
||||
|
||||
if(arg.get("name").length())
|
||||
if (arg.get("name").length())
|
||||
{
|
||||
file << "\"" << arg.get("name") << "\", ";
|
||||
}
|
||||
|
@ -626,7 +626,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file << "0, ";
|
||||
}
|
||||
file << "\"" << arg.get("type") << "\", "
|
||||
<< ( arg.get("direction") == "in" ? "true" : "false" )
|
||||
<< (arg.get("direction") == "in" ? "true" : "false")
|
||||
<< " }," << endl;
|
||||
}
|
||||
file << tab << tab << tab << "{ 0, 0, 0 }" << endl
|
||||
|
@ -636,9 +636,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl
|
||||
<< tab << tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
{
|
||||
Xml::Node& method = **mi;
|
||||
Xml::Node &method = **mi;
|
||||
|
||||
file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
|
||||
}
|
||||
|
@ -649,9 +649,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl
|
||||
<< tab << tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
{
|
||||
Xml::Node& method = **si;
|
||||
Xml::Node &method = **si;
|
||||
|
||||
file << tab << tab << tab << "{ \"" << method.get("name") << "\", " << method.get("name") << "_args }," << endl;
|
||||
}
|
||||
|
@ -662,20 +662,20 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl
|
||||
<< tab << tab << "{" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||
for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||
{
|
||||
Xml::Node& property = **pi;
|
||||
Xml::Node &property = **pi;
|
||||
|
||||
file << tab << tab << tab << "{ "
|
||||
<< "\"" << property.get("name") << "\", "
|
||||
<< "\"" << property.get("type") << "\", "
|
||||
<< ( property.get("access").find("read") != string::npos
|
||||
<< (property.get("access").find("read") != string::npos
|
||||
? "true"
|
||||
: "false" )
|
||||
: "false")
|
||||
<< ", "
|
||||
<< ( property.get("access").find("write") != string::npos
|
||||
<< (property.get("access").find("write") != string::npos
|
||||
? "true"
|
||||
: "false" )
|
||||
: "false")
|
||||
<< " }," << endl;
|
||||
}
|
||||
|
||||
|
@ -700,9 +700,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
<< tab << " * property() and property(value) to get and set a particular property" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||
for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||
{
|
||||
Xml::Node& property = **pi;
|
||||
Xml::Node &property = **pi;
|
||||
string name = property.get("name");
|
||||
string type = property.get("type");
|
||||
string type_name = signature_to_type(type);
|
||||
|
@ -718,57 +718,57 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
<< tab << " * you will have to implement them in your ObjectAdaptor" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
{
|
||||
Xml::Node& method = **mi;
|
||||
Xml::Node &method = **mi;
|
||||
Xml::Nodes args = method["arg"];
|
||||
Xml::Nodes args_in = args.select("direction","in");
|
||||
Xml::Nodes args_out = args.select("direction","out");
|
||||
|
||||
file << tab << "virtual ";
|
||||
|
||||
if(args_out.size() == 0 || args_out.size() > 1 )
|
||||
if (args_out.size() == 0 || args_out.size() > 1)
|
||||
{
|
||||
file << "void ";
|
||||
}
|
||||
else if(args_out.size() == 1)
|
||||
else if (args_out.size() == 1)
|
||||
{
|
||||
file << signature_to_type(args_out.front()->get("type")) << " ";
|
||||
}
|
||||
|
||||
file << method.get("name") << "( ";
|
||||
file << method.get("name") << "(";
|
||||
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
file << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << arg_name;
|
||||
|
||||
if((i+1 != args_in.size() || args_out.size() > 1))
|
||||
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||
file << ", ";
|
||||
}
|
||||
|
||||
if(args_out.size() > 1)
|
||||
if (args_out.size() > 1)
|
||||
{
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ao;
|
||||
Xml::Node &arg = **ao;
|
||||
file << signature_to_type(arg.get("type")) << "&";
|
||||
|
||||
string arg_name = arg.get("name");
|
||||
if(arg_name.length())
|
||||
if (arg_name.length())
|
||||
file << " " << arg_name;
|
||||
|
||||
if(i+1 != args_out.size())
|
||||
if (i+1 != args_out.size())
|
||||
file << ", ";
|
||||
}
|
||||
}
|
||||
file << " ) = 0;" << endl;
|
||||
file << ") = 0;" << endl;
|
||||
}
|
||||
|
||||
file << endl
|
||||
|
@ -777,34 +777,34 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
<< tab << "/* signal emitters for this interface" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si)
|
||||
{
|
||||
Xml::Node& signal = **si;
|
||||
Xml::Node &signal = **si;
|
||||
Xml::Nodes args = signal["arg"];
|
||||
|
||||
file << tab << "void " << signal.get("name") << "( ";
|
||||
file << tab << "void " << signal.get("name") << "(";
|
||||
|
||||
unsigned int i = 0;
|
||||
for(Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i)
|
||||
for (Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i)
|
||||
{
|
||||
Xml::Node& arg = **a;
|
||||
Xml::Node &arg = **a;
|
||||
|
||||
file << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
|
||||
|
||||
if(i+1 != args.size())
|
||||
if (i+1 != args.size())
|
||||
file << ", ";
|
||||
}
|
||||
|
||||
file << " )" << endl
|
||||
file << ")" << endl
|
||||
<< tab << "{" << endl
|
||||
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;;
|
||||
|
||||
|
||||
if(args.size() > 0)
|
||||
if (args.size() > 0)
|
||||
{
|
||||
file << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl;
|
||||
|
||||
for(unsigned int i = 0; i < args.size(); ++i)
|
||||
for (unsigned int i = 0; i < args.size(); ++i)
|
||||
{
|
||||
file << tab << tab << "wi << arg" << i+1 << ";" << endl;
|
||||
}
|
||||
|
@ -820,40 +820,40 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl
|
||||
<< tab << " */" << endl;
|
||||
|
||||
for(Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||
{
|
||||
Xml::Node& method = **mi;
|
||||
Xml::Node &method = **mi;
|
||||
Xml::Nodes args = method["arg"];
|
||||
Xml::Nodes args_in = args.select("direction","in");
|
||||
Xml::Nodes args_out = args.select("direction","out");
|
||||
|
||||
file << tab << "::DBus::Message " << stub_name(method.get("name")) << "( const ::DBus::CallMessage& call )" << endl
|
||||
file << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl
|
||||
<< tab << "{" << endl
|
||||
<< tab << tab << "::DBus::MessageIter ri = call.reader();" << endl
|
||||
<< endl;
|
||||
|
||||
unsigned int i = 1;
|
||||
for(Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ai;
|
||||
Xml::Node &arg = **ai;
|
||||
file << tab << tab << signature_to_type(arg.get("type")) << " argin" << i << ";"
|
||||
<< " ri >> argin" << i << ";" << endl;
|
||||
}
|
||||
|
||||
if(args_out.size() == 0)
|
||||
if (args_out.size() == 0)
|
||||
{
|
||||
file << tab << tab;
|
||||
}
|
||||
else if(args_out.size() == 1)
|
||||
else if (args_out.size() == 1)
|
||||
{
|
||||
file << tab << tab << signature_to_type(args_out.front()->get("type")) << " argout1 = ";
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned int i = 1;
|
||||
for(Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
for (Xml::Nodes::iterator ao = args_out.begin(); ao != args_out.end(); ++ao, ++i)
|
||||
{
|
||||
Xml::Node& arg = **ao;
|
||||
Xml::Node &arg = **ao;
|
||||
file << tab << tab << signature_to_type(arg.get("type")) << " argout" << i << ";" << endl;
|
||||
}
|
||||
file << tab << tab;
|
||||
|
@ -861,20 +861,20 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
|
||||
file << method.get("name") << "(";
|
||||
|
||||
for(unsigned int i = 0; i < args_in.size(); ++i)
|
||||
for (unsigned int i = 0; i < args_in.size(); ++i)
|
||||
{
|
||||
file << "argin" << i+1;
|
||||
|
||||
if((i+1 != args_in.size() || args_out.size() > 1))
|
||||
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||
file << ", ";
|
||||
}
|
||||
|
||||
if(args_out.size() > 1)
|
||||
for(unsigned int i = 0; i < args_out.size(); ++i)
|
||||
if (args_out.size() > 1)
|
||||
for (unsigned int i = 0; i < args_out.size(); ++i)
|
||||
{
|
||||
file << "argout" << i+1;
|
||||
|
||||
if(i+1 != args_out.size())
|
||||
if (i+1 != args_out.size())
|
||||
file << ", ";
|
||||
}
|
||||
|
||||
|
@ -882,11 +882,11 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
|
||||
file << tab << tab << "::DBus::ReturnMessage reply(call);" << endl;
|
||||
|
||||
if(args_out.size() > 0)
|
||||
if (args_out.size() > 0)
|
||||
{
|
||||
file << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl;
|
||||
|
||||
for(unsigned int i = 0; i < args_out.size(); ++i)
|
||||
for (unsigned int i = 0; i < args_out.size(); ++i)
|
||||
{
|
||||
file << tab << tab << "wi << argout" << i+1 << ";" << endl;
|
||||
}
|
||||
|
@ -900,7 +900,7 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file << "};" << endl
|
||||
<< endl;
|
||||
|
||||
for(unsigned int i = 0; i < nspaces; ++i)
|
||||
for (unsigned int i = 0; i < nspaces; ++i)
|
||||
{
|
||||
file << "} ";
|
||||
}
|
||||
|
@ -912,9 +912,9 @@ void generate_adaptor( Xml::Document& doc, const char* filename )
|
|||
file.close();
|
||||
}
|
||||
|
||||
int main( int argc, char** argv )
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
if(argc < 2)
|
||||
if (argc < 2)
|
||||
{
|
||||
usage(argv[0]);
|
||||
}
|
||||
|
@ -928,26 +928,26 @@ int main( int argc, char** argv )
|
|||
adaptor_mode = false;
|
||||
adaptor = 0;
|
||||
|
||||
for(int a = 1; a < argc; ++a)
|
||||
for (int a = 1; a < argc; ++a)
|
||||
{
|
||||
if(!strncmp(argv[a], "--proxy=", 8))
|
||||
if (!strncmp(argv[a], "--proxy=", 8))
|
||||
{
|
||||
proxy_mode = true;
|
||||
proxy = argv[a] +8;
|
||||
}
|
||||
else
|
||||
if(!strncmp(argv[a], "--adaptor=", 10))
|
||||
if (!strncmp(argv[a], "--adaptor=", 10))
|
||||
{
|
||||
adaptor_mode = true;
|
||||
adaptor = argv[a] +10;
|
||||
}
|
||||
}
|
||||
|
||||
if(!proxy_mode && !adaptor_mode) usage(argv[0]);
|
||||
if (!proxy_mode && !adaptor_mode) usage(argv[0]);
|
||||
|
||||
ifstream xmlfile(argv[1]);
|
||||
|
||||
if(xmlfile.bad())
|
||||
if (xmlfile.bad())
|
||||
{
|
||||
cerr << "unable to open file " << argv[1] << endl;
|
||||
return -1;
|
||||
|
@ -960,20 +960,20 @@ int main( int argc, char** argv )
|
|||
xmlfile >> doc;
|
||||
//cout << doc.to_xml();
|
||||
}
|
||||
catch(Xml::Error& e)
|
||||
catch(Xml::Error &e)
|
||||
{
|
||||
cerr << "error parsing " << argv[1] << ": " << e.what() << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(!doc.root)
|
||||
if (!doc.root)
|
||||
{
|
||||
cerr << "empty document" << endl;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(proxy_mode) generate_proxy(doc, proxy);
|
||||
if(adaptor_mode) generate_adaptor(doc, adaptor);
|
||||
if (proxy_mode) generate_proxy(doc, proxy);
|
||||
if (adaptor_mode) generate_adaptor(doc, adaptor);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue