diff options
author | Andreas Volz <andreas@frodo.mittelerde> | 2009-03-29 14:19:05 +0200 |
---|---|---|
committer | Andreas Volz <andreas@frodo.mittelerde> | 2009-03-29 14:19:05 +0200 |
commit | 38e25a847ffb48472adaf2e65dde63e63ad3781b (patch) | |
tree | 01d5fa5e4409cf34e5b2c8cb2e4c471924ab55d5 | |
parent | f88e32ba324d356e1d97cea35be635a53cb89725 (diff) | |
download | dbus-c++-38e25a847ffb48472adaf2e65dde63e63ad3781b.tar.gz |
only some comment
-rw-r--r-- | tools/generate_adaptor.cpp | 30 | ||||
-rw-r--r-- | tools/generate_proxy.cpp | 91 | ||||
-rw-r--r-- | tools/generator_utils.cpp | 2 |
3 files changed, 73 insertions, 50 deletions
diff --git a/tools/generate_adaptor.cpp b/tools/generate_adaptor.cpp index 92f252b..346982e 100644 --- a/tools/generate_adaptor.cpp +++ b/tools/generate_adaptor.cpp @@ -99,12 +99,12 @@ void generate_adaptor(Xml::Document &doc, const char *filename) getline(ss, ifaceclass); - // a "_adaptor" is added to class name to distinguish between proxy and adaptor + // a "_adaptor" is added to class name to distinguish between proxy and adaptor ifaceclass += "_adaptor"; cerr << "generating code for interface " << ifacename << "..." << endl; - // the code from class definiton up to opening of the constructor is generated... + // the code from class definiton up to opening of the constructor is generated... body << "class " << ifaceclass << endl << ": public ::DBus::InterfaceAdaptor" << endl << "{" << endl @@ -114,7 +114,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) << tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl << tab << "{" << endl; - // generates code to bind the properties + // generates code to bind the properties for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) { Xml::Node &property = **pi; @@ -132,7 +132,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) << ");" << endl; } - // generate code to register all methods + // generate code to register all methods for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { Xml::Node &method = **mi; @@ -148,7 +148,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) body << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl << tab << "{" << endl; - // generate the introspect arguments + // generate the introspect arguments for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi) { Xml::Node &method = **mi; @@ -182,7 +182,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl << tab << tab << "{" << endl; - // generate the introspect methods + // generate the introspect methods for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { Xml::Node &method = **mi; @@ -230,7 +230,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) body << tab << tab << tab << "{ 0, 0, 0, 0 }" << endl << tab << tab << "};" << endl; - // generate the Introspected interface + // generate the Introspected interface body << tab << tab << "static ::DBus::IntrospectedInterface " << ifaceclass << "_interface = " << endl << tab << tab << "{" << endl << tab << tab << tab << "\"" << ifacename << "\"," << endl @@ -248,7 +248,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) << tab << " * property() and property(value) to get and set a particular property" << endl << tab << " */" << endl; - // generate the properties code + // generate the properties code for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi) { Xml::Node &property = **pi; @@ -267,7 +267,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) << tab << " * you will have to implement them in your ObjectAdaptor" << endl << tab << " */" << endl; - // generate the methods code + // generate the methods code for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { Xml::Node &method = **mi; @@ -342,7 +342,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) body << ", "; } - // generate the method 'out' variables if multibe 'out' values exist + // generate the method 'out' variables if multibe 'out' values exist if (args_out.size() > 1) { unsigned int i = 0; @@ -389,7 +389,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) << tab << "/* signal emitters for this interface" << endl << tab << " */" << endl; - // generate the signals code + // generate the signals code for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { Xml::Node &signal = **si; @@ -397,7 +397,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) body << tab << "void " << signal.get("name") << "("; - // generate the signal arguments + // generate the signal arguments unsigned int i = 0; for (Xml::Nodes::iterator a = args.begin(); a != args.end(); ++a, ++i) { @@ -476,7 +476,7 @@ 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; - // generate the unmarshalers + // generate the unmarshalers for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { Xml::Node &method = **mi; @@ -489,7 +489,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename) << tab << tab << "::DBus::MessageIter ri = call.reader();" << endl << endl; - // generate the 'in' variables + // generate the 'in' variables unsigned int i = 1; for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) { @@ -718,5 +718,5 @@ void generate_adaptor(Xml::Document &doc, const char *filename) file << head.str (); file << body.str (); - file.close(); + file.close(); } diff --git a/tools/generate_proxy.cpp b/tools/generate_proxy.cpp index 386a62e..f3615a0 100644 --- a/tools/generate_proxy.cpp +++ b/tools/generate_proxy.cpp @@ -1,3 +1,26 @@ +/* + * + * D-Bus++ - C++ bindings for D-Bus + * + * Copyright (C) 2005-2007 Paolo Durante <shackan@gmail.com> + * + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + */ + #include <iostream> #include <fstream> #include <cstdlib> @@ -35,7 +58,7 @@ void generate_proxy(Xml::Document &doc, const char *filename) Xml::Node &root = *(doc.root); Xml::Nodes interfaces = root["interface"]; - // iterate over all interface definitions + // iterate over all interface definitions for (Xml::Nodes::iterator i = interfaces.begin(); i != interfaces.end(); ++i) { Xml::Node &iface = **i; @@ -46,10 +69,10 @@ void generate_proxy(Xml::Document &doc, const char *filename) ms.insert(ms.end(), methods.begin(), methods.end()); ms.insert(ms.end(), signals.begin(), signals.end()); - // gets the name of a interface: <interface name="XYZ"> + // gets the name of a interface: <interface name="XYZ"> string ifacename = iface.get("name"); - // these interface names are skipped. + // these interface names are skipped. if (ifacename == "org.freedesktop.DBus.Introspectable" ||ifacename == "org.freedesktop.DBus.Properties") { @@ -60,8 +83,8 @@ void generate_proxy(Xml::Document &doc, const char *filename) istringstream ss(ifacename); string nspace; unsigned int nspaces = 0; - - // prints all the namespaces defined with <interface name="X.Y.Z"> + + // prints all the namespaces defined with <interface name="X.Y.Z"> while (ss.str().find('.', ss.tellg()) != string::npos) { getline(ss, nspace, '.'); @@ -75,13 +98,13 @@ void generate_proxy(Xml::Document &doc, const char *filename) string ifaceclass; getline(ss, ifaceclass); - - // a "_proxy" is added to class name to distinguish between proxy and adaptor + + // a "_proxy" is added to class name to distinguish between proxy and adaptor ifaceclass += "_proxy"; cerr << "generating code for interface " << ifacename << "..." << endl; - - // the code from class definiton up to opening of the constructor is generated... + + // the code from class definiton up to opening of the constructor is generated... body << "class " << ifaceclass << endl << ": public ::DBus::InterfaceProxy" << endl << "{" << endl @@ -90,8 +113,8 @@ void generate_proxy(Xml::Document &doc, const char *filename) << tab << ifaceclass << "()" << endl << tab << ": ::DBus::InterfaceProxy(\"" << ifacename << "\")" << endl << tab << "{" << endl; - - // generates code to connect all the signal stubs; this is still inside the constructor + + // generates code to connect all the signal stubs; this is still inside the constructor for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { Xml::Node &signal = **si; @@ -102,16 +125,16 @@ void generate_proxy(Xml::Document &doc, const char *filename) << ifaceclass << ", " << signal.get("name") << ", " << stub_name(signal.get("name")) << ");" << endl; } - - // the constructor ends here + + // the constructor ends here body << tab << "}" << endl << endl; - - // write public block header for properties + + // write public block header for properties body << "public:" << endl << endl << tab << "/* properties exported by this interface */" << endl; - - // this loop generates all properties + + // this loop generates all properties for (Xml::Nodes::iterator pi = properties.begin (); pi != properties.end (); ++pi) { @@ -138,7 +161,7 @@ void generate_proxy(Xml::Document &doc, const char *filename) body << tab << tab << tab << "wi << property_name;" << endl; body << tab << tab << tab << "::DBus::Message ret = this->invoke_method (call);" << endl; - // TODO: support invoke_method_NoReply for properties + // TODO: support invoke_method_NoReply for properties body << tab << tab << tab << "::DBus::MessageIter ri = ret.reader ();" << endl; body << tab << tab << tab << "::DBus::Variant argout; " << endl; @@ -161,20 +184,20 @@ void generate_proxy(Xml::Document &doc, const char *filename) body << tab << tab << tab <<"wi << interface_name;" << endl; body << tab << tab << tab <<"wi << property_name;" << endl; body << tab << tab << tab <<"wi << value;" << endl; - body << tab << tab << tab <<"::DBus::Message ret = this->invoke_method (call);" << endl; - // TODO: support invoke_method_noreply for properties + body << tab << tab << tab <<"::DBus::Message ret = this->invoke_method (call);" << endl; + // TODO: support invoke_method_noreply for properties body << tab << tab << "};" << endl; - } + } } - - // write public block header for methods + + // write public block header for methods body << "public:" << endl << endl << tab << "/* methods exported by this interface," << endl << tab << " * this functions will invoke the corresponding methods on the remote objects" << endl << tab << " */" << endl; - - // this loop generates all methods + + // this loop generates all methods for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi) { Xml::Node &method = **mi; @@ -222,7 +245,7 @@ void generate_proxy(Xml::Document &doc, const char *filename) body << method.get("name") << "("; - // generate all 'in' arguments for a method signature + // generate all 'in' arguments for a method signature unsigned int i = 0; for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i) { @@ -449,15 +472,15 @@ void generate_proxy(Xml::Document &doc, const char *filename) body << tab << "}" << endl << endl; } - - // write public block header for signals + + // write public block header for signals body << endl << "public:" << endl << endl << tab << "/* signal handlers for this interface" << endl << tab << " */" << endl; - - // this loop generates all signals + + // this loop generates all signals for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { Xml::Node &signal = **si; @@ -465,7 +488,7 @@ void generate_proxy(Xml::Document &doc, const char *filename) body << tab << "virtual void " << signal.get("name") << "("; - // this loop generates all argument for a signal + // this loop generates all argument for a signal unsigned int i = 0; for (Xml::Nodes::iterator ai = args.begin(); ai != args.end(); ++ai, ++i) { @@ -504,15 +527,15 @@ void generate_proxy(Xml::Document &doc, const char *filename) } body << ") = 0;" << endl; } - - // write private block header for unmarshalers + + // write private block header for unmarshalers body << endl << "private:" << endl << endl << tab << "/* unmarshalers (to unpack the DBus message before calling the actual signal handler)" << endl << tab << " */" << endl; - // generate all the unmarshalers + // generate all the unmarshalers for (Xml::Nodes::iterator si = signals.begin(); si != signals.end(); ++si) { Xml::Node &signal = **si; diff --git a/tools/generator_utils.cpp b/tools/generator_utils.cpp index cb87f69..a1fe09c 100644 --- a/tools/generator_utils.cpp +++ b/tools/generator_utils.cpp @@ -39,7 +39,7 @@ const char *header = "\n\ const char *dbus_includes = "\n\ #include <dbus-c++/dbus.h>\n\ -#include <cassert>\n\n\ +#include <cassert> \n\ "; |