formated with astyle for easier merging
This commit is contained in:
parent
7a8c64c2a6
commit
a236363cce
1 changed files with 292 additions and 292 deletions
|
@ -51,7 +51,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
string cond_comp = "__dbusxx__" + filestring + "__ADAPTOR_MARSHAL_H";
|
string cond_comp = "__dbusxx__" + filestring + "__ADAPTOR_MARSHAL_H";
|
||||||
|
|
||||||
head << "#ifndef " << cond_comp << endl
|
head << "#ifndef " << cond_comp << endl
|
||||||
<< "#define " << cond_comp << endl;
|
<< "#define " << cond_comp << endl;
|
||||||
|
|
||||||
head << dbus_includes;
|
head << dbus_includes;
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
|
|
||||||
// these interface names are skipped.
|
// these interface names are skipped.
|
||||||
if (ifacename == "org.freedesktop.DBus.Introspectable"
|
if (ifacename == "org.freedesktop.DBus.Introspectable"
|
||||||
||ifacename == "org.freedesktop.DBus.Properties")
|
||ifacename == "org.freedesktop.DBus.Properties")
|
||||||
{
|
{
|
||||||
cerr << "skipping interface " << ifacename << endl;
|
cerr << "skipping interface " << ifacename << endl;
|
||||||
continue;
|
continue;
|
||||||
|
@ -99,37 +99,37 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
|
|
||||||
getline(ss, ifaceclass);
|
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";
|
ifaceclass += "_adaptor";
|
||||||
|
|
||||||
cerr << "generating code for interface " << ifacename << "..." << endl;
|
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
|
body << "class " << ifaceclass << endl
|
||||||
<< ": public ::DBus::InterfaceAdaptor" << endl
|
<< ": public ::DBus::InterfaceAdaptor" << endl
|
||||||
<< "{" << endl
|
<< "{" << endl
|
||||||
<< "public:" << endl
|
<< "public:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< tab << ifaceclass << "()" << endl
|
<< tab << ifaceclass << "()" << endl
|
||||||
<< tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl
|
<< tab << ": ::DBus::InterfaceAdaptor(\"" << ifacename << "\")" << endl
|
||||||
<< tab << "{" << 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)
|
for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||||
{
|
{
|
||||||
Xml::Node &property = **pi;
|
Xml::Node &property = **pi;
|
||||||
|
|
||||||
body << tab << tab << "bind_property("
|
body << tab << tab << "bind_property("
|
||||||
<< property.get("name") << ", "
|
<< property.get("name") << ", "
|
||||||
<< "\"" << property.get("type") << "\", "
|
<< "\"" << property.get("type") << "\", "
|
||||||
<< (property.get("access").find("read") != string::npos
|
<< (property.get("access").find("read") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false")
|
: "false")
|
||||||
<< ", "
|
<< ", "
|
||||||
<< (property.get("access").find("write") != string::npos
|
<< (property.get("access").find("write") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false")
|
: "false")
|
||||||
<< ");" << endl;
|
<< ");" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate code to register all methods
|
// generate code to register all methods
|
||||||
|
@ -138,15 +138,15 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
Xml::Node &method = **mi;
|
Xml::Node &method = **mi;
|
||||||
|
|
||||||
body << tab << tab << "register_method("
|
body << tab << tab << "register_method("
|
||||||
<< ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
|
<< ifaceclass << ", " << method.get("name") << ", "<< stub_name(method.get("name"))
|
||||||
<< ");" << endl;
|
<< ");" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
body << tab << "}" << endl
|
body << tab << "}" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
body << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl
|
body << tab << "::DBus::IntrospectedInterface *const introspect() const " << endl
|
||||||
<< tab << "{" << endl;
|
<< tab << "{" << endl;
|
||||||
|
|
||||||
// generate the introspect arguments
|
// generate the introspect arguments
|
||||||
for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
|
for (Xml::Nodes::iterator mi = ms.begin(); mi != ms.end(); ++mi)
|
||||||
|
@ -155,7 +155,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
Xml::Nodes args = method["arg"];
|
Xml::Nodes args = method["arg"];
|
||||||
|
|
||||||
body << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl
|
body << tab << tab << "static ::DBus::IntrospectedArgument " << method.get("name") << "_args[] = " << endl
|
||||||
<< tab << tab << "{" << 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)
|
||||||
{
|
{
|
||||||
|
@ -172,15 +172,15 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
body << "0, ";
|
body << "0, ";
|
||||||
}
|
}
|
||||||
body << "\"" << arg.get("type") << "\", "
|
body << "\"" << arg.get("type") << "\", "
|
||||||
<< (arg.get("direction") == "in" ? "true" : "false")
|
<< (arg.get("direction") == "in" ? "true" : "false")
|
||||||
<< " }," << endl;
|
<< " }," << endl;
|
||||||
}
|
}
|
||||||
body << tab << tab << tab << "{ 0, 0, 0 }" << endl
|
body << tab << tab << tab << "{ 0, 0, 0 }" << endl
|
||||||
<< tab << tab << "};" << endl;
|
<< tab << tab << "};" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl
|
body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_methods[] = " << endl
|
||||||
<< tab << tab << "{" << endl;
|
<< tab << tab << "{" << endl;
|
||||||
|
|
||||||
// generate the introspect methods
|
// generate the introspect methods
|
||||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
|
@ -191,10 +191,10 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
body << tab << tab << tab << "{ 0, 0 }" << endl
|
body << tab << tab << tab << "{ 0, 0 }" << endl
|
||||||
<< tab << tab << "};" << endl;
|
<< tab << tab << "};" << endl;
|
||||||
|
|
||||||
body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl
|
body << tab << tab << "static ::DBus::IntrospectedMethod " << ifaceclass << "_signals[] = " << endl
|
||||||
<< tab << tab << "{" << 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)
|
||||||
{
|
{
|
||||||
|
@ -204,49 +204,49 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
body << tab << tab << tab << "{ 0, 0 }" << endl
|
body << tab << tab << tab << "{ 0, 0 }" << endl
|
||||||
<< tab << tab << "};" << endl;
|
<< tab << tab << "};" << endl;
|
||||||
|
|
||||||
body << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl
|
body << tab << tab << "static ::DBus::IntrospectedProperty " << ifaceclass << "_properties[] = " << endl
|
||||||
<< tab << tab << "{" << 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;
|
||||||
|
|
||||||
body << tab << tab << tab << "{ "
|
body << tab << tab << tab << "{ "
|
||||||
<< "\"" << property.get("name") << "\", "
|
<< "\"" << property.get("name") << "\", "
|
||||||
<< "\"" << property.get("type") << "\", "
|
<< "\"" << property.get("type") << "\", "
|
||||||
<< (property.get("access").find("read") != string::npos
|
<< (property.get("access").find("read") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false")
|
: "false")
|
||||||
<< ", "
|
<< ", "
|
||||||
<< (property.get("access").find("write") != string::npos
|
<< (property.get("access").find("write") != string::npos
|
||||||
? "true"
|
? "true"
|
||||||
: "false")
|
: "false")
|
||||||
<< " }," << endl;
|
<< " }," << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
body << tab << tab << tab << "{ 0, 0, 0, 0 }" << endl
|
body << tab << tab << tab << "{ 0, 0, 0, 0 }" << endl
|
||||||
<< tab << tab << "};" << endl;
|
<< tab << tab << "};" << endl;
|
||||||
|
|
||||||
// generate the Introspected interface
|
// generate the Introspected interface
|
||||||
body << tab << tab << "static ::DBus::IntrospectedInterface " << ifaceclass << "_interface = " << endl
|
body << tab << tab << "static ::DBus::IntrospectedInterface " << ifaceclass << "_interface = " << endl
|
||||||
<< tab << tab << "{" << endl
|
<< tab << tab << "{" << endl
|
||||||
<< tab << tab << tab << "\"" << ifacename << "\"," << endl
|
<< tab << tab << tab << "\"" << ifacename << "\"," << endl
|
||||||
<< tab << tab << tab << ifaceclass << "_methods," << endl
|
<< tab << tab << tab << ifaceclass << "_methods," << endl
|
||||||
<< tab << tab << tab << ifaceclass << "_signals," << endl
|
<< tab << tab << tab << ifaceclass << "_signals," << endl
|
||||||
<< tab << tab << tab << ifaceclass << "_properties" << endl
|
<< tab << tab << tab << ifaceclass << "_properties" << endl
|
||||||
<< tab << tab << "};" << endl
|
<< tab << tab << "};" << endl
|
||||||
<< tab << tab << "return &" << ifaceclass << "_interface;" << endl
|
<< tab << tab << "return &" << ifaceclass << "_interface;" << endl
|
||||||
<< tab << "}" << endl
|
<< tab << "}" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
body << "public:" << endl
|
body << "public:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< tab << "/* properties exposed by this interface, use" << endl
|
<< tab << "/* properties exposed by this interface, use" << endl
|
||||||
<< tab << " * property() and property(value) to get and set a particular property" << endl
|
<< tab << " * property() and property(value) to get and set a particular property" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
// generate the properties code
|
// generate the properties code
|
||||||
for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
for (Xml::Nodes::iterator pi = properties.begin(); pi != properties.end(); ++pi)
|
||||||
|
@ -262,10 +262,10 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
body << endl;
|
body << endl;
|
||||||
|
|
||||||
body << "public:" << endl
|
body << "public:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< tab << "/* methods exported by this interface," << endl
|
<< tab << "/* methods exported by this interface," << endl
|
||||||
<< tab << " * you will have to implement them in your ObjectAdaptor" << endl
|
<< tab << " * you will have to implement them in your ObjectAdaptor" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
// generate the methods code
|
// generate the methods code
|
||||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
|
@ -276,7 +276,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
Xml::Nodes args_out = args.select("direction","out");
|
Xml::Nodes args_out = args.select("direction","out");
|
||||||
Xml::Nodes annotations = args["annotation"];
|
Xml::Nodes annotations = args["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
|
||||||
if (annotations_object.size() > 0)
|
if (annotations_object.size() > 0)
|
||||||
{
|
{
|
||||||
|
@ -285,55 +285,55 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
|
|
||||||
body << tab << "virtual ";
|
body << tab << "virtual ";
|
||||||
|
|
||||||
// return type is 'void' if none or multible return values
|
// return type is 'void' if none or multible return values
|
||||||
if (args_out.size() == 0 || args_out.size() > 1)
|
if (args_out.size() == 0 || args_out.size() > 1)
|
||||||
{
|
{
|
||||||
body << "void ";
|
body << "void ";
|
||||||
}
|
}
|
||||||
else if (args_out.size() == 1)
|
else if (args_out.size() == 1)
|
||||||
{
|
{
|
||||||
// generate basic or object return type
|
// generate basic or object return type
|
||||||
if (arg_object.length())
|
if (arg_object.length())
|
||||||
{
|
{
|
||||||
body << arg_object << " ";
|
body << arg_object << " ";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body << signature_to_type(args_out.front()->get("type")) << " ";
|
body << signature_to_type(args_out.front()->get("type")) << " ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate the method name
|
// generate the method name
|
||||||
body << method.get("name") << "(";
|
body << method.get("name") << "(";
|
||||||
|
|
||||||
// generate the methods 'in' variables
|
// generate the methods 'in' variables
|
||||||
unsigned int i = 0;
|
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;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_name = arg.get("name");
|
string arg_name = arg.get("name");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
|
||||||
if (annotations_object.size() > 0)
|
if (annotations_object.size() > 0)
|
||||||
{
|
{
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate basic signature only if no object name available...
|
// generate basic signature only if no object name available...
|
||||||
if (!arg_object.length())
|
if (!arg_object.length())
|
||||||
{
|
{
|
||||||
body << "const " << signature_to_type(arg.get("type")) << "& ";
|
body << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||||
}
|
}
|
||||||
// ...or generate object style if available
|
// ...or generate object style if available
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body << "const " << arg_object << "& ";
|
body << "const " << arg_object << "& ";
|
||||||
|
|
||||||
// store a object name to later generate header includes
|
// store a object name to later generate header includes
|
||||||
include_vector.push_back (arg_object);
|
include_vector.push_back (arg_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_name.length())
|
if (arg_name.length())
|
||||||
body << arg_name;
|
body << arg_name;
|
||||||
|
@ -359,19 +359,19 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate basic signature only if no object name available...
|
// generate basic signature only if no object name available...
|
||||||
if (!arg_object.length())
|
if (!arg_object.length())
|
||||||
{
|
{
|
||||||
body << "const " << signature_to_type(arg.get("type")) << "& ";
|
body << "const " << signature_to_type(arg.get("type")) << "& ";
|
||||||
}
|
}
|
||||||
// ...or generate object style if available
|
// ...or generate object style if available
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body << "const " << arg_object << "& ";
|
body << "const " << arg_object << "& ";
|
||||||
|
|
||||||
// store a object name to later generate header includes
|
// store a object name to later generate header includes
|
||||||
include_vector.push_back (arg_object);
|
include_vector.push_back (arg_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_name.length())
|
if (arg_name.length())
|
||||||
body << " " << arg_name;
|
body << " " << arg_name;
|
||||||
|
@ -384,12 +384,12 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
body << endl
|
body << endl
|
||||||
<< "public:" << endl
|
<< "public:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< tab << "/* signal emitters for this interface" << endl
|
<< tab << "/* signal emitters for this interface" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
// generate the signals code
|
// generate the signals code
|
||||||
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;
|
||||||
|
@ -411,37 +411,37 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate basic signature only if no object name available...
|
// generate basic signature only if no object name available...
|
||||||
if (!arg_object.length())
|
if (!arg_object.length())
|
||||||
{
|
{
|
||||||
body << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
|
body << "const " << signature_to_type(arg.get("type")) << "& arg" << i+1;
|
||||||
}
|
}
|
||||||
// ...or generate object style if available
|
// ...or generate object style if available
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body << "const " << arg_object << "& arg" << i+1;
|
body << "const " << arg_object << "& arg" << i+1;
|
||||||
|
|
||||||
// store a object name to later generate header includes
|
// store a object name to later generate header includes
|
||||||
include_vector.push_back (arg_object);
|
include_vector.push_back (arg_object);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i+1 != args.size())
|
if (i+1 != args.size())
|
||||||
body << ", ";
|
body << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
body << ")" << endl
|
body << ")" << endl
|
||||||
<< tab << "{" << endl
|
<< tab << "{" << endl
|
||||||
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;
|
<< tab << tab << "::DBus::SignalMessage sig(\"" << signal.get("name") <<"\");" << endl;
|
||||||
|
|
||||||
// generate the signal body
|
// generate the signal body
|
||||||
if (args.size() > 0)
|
if (args.size() > 0)
|
||||||
{
|
{
|
||||||
body << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl;
|
body << tab << tab << "::DBus::MessageIter wi = sig.writer();" << endl;
|
||||||
|
|
||||||
unsigned int i = 0;
|
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;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
@ -451,30 +451,30 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_object.length())
|
if (arg_object.length())
|
||||||
{
|
{
|
||||||
body << tab << tab << signature_to_type(arg.get("type")) << " _arg" << i+1 << ";" << endl;
|
body << tab << tab << signature_to_type(arg.get("type")) << " _arg" << i+1 << ";" << endl;
|
||||||
body << tab << tab << "_arg" << i+1 << " << " << "arg" << i+1 << ";" << endl;
|
body << tab << tab << "_arg" << i+1 << " << " << "arg" << i+1 << ";" << endl;
|
||||||
|
|
||||||
body << tab << tab << "wi << _arg" << i+1 << ";" << endl;
|
body << tab << tab << "wi << _arg" << i+1 << ";" << endl;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body << tab << tab << "wi << arg" << i+1 << ";" << endl;
|
body << tab << tab << "wi << arg" << i+1 << ";" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// emit the signal in method body
|
// emit the signal in method body
|
||||||
body << tab << tab << "emit_signal(sig);" << endl
|
body << tab << tab << "emit_signal(sig);" << endl
|
||||||
<< tab << "}" << endl;
|
<< tab << "}" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
body << endl
|
body << endl
|
||||||
<< "private:" << endl
|
<< "private:" << endl
|
||||||
<< endl
|
<< endl
|
||||||
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl
|
<< tab << "/* unmarshalers (to unpack the DBus message before calling the actual interface method)" << endl
|
||||||
<< tab << " */" << endl;
|
<< tab << " */" << endl;
|
||||||
|
|
||||||
// generate the unmarshalers
|
// generate the unmarshalers
|
||||||
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
for (Xml::Nodes::iterator mi = methods.begin(); mi != methods.end(); ++mi)
|
||||||
|
@ -485,9 +485,9 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
Xml::Nodes args_out = args.select("direction","out");
|
Xml::Nodes args_out = args.select("direction","out");
|
||||||
|
|
||||||
body << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl
|
body << tab << "::DBus::Message " << stub_name(method.get("name")) << "(const ::DBus::CallMessage &call)" << endl
|
||||||
<< tab << "{" << endl
|
<< tab << "{" << endl
|
||||||
<< tab << tab << "::DBus::MessageIter ri = call.reader();" << endl
|
<< tab << tab << "::DBus::MessageIter ri = call.reader();" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
// generate the 'in' variables
|
// generate the 'in' variables
|
||||||
unsigned int i = 1;
|
unsigned int i = 1;
|
||||||
|
@ -499,28 +499,28 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
body << "ri >> argin" << i << ";" << endl;
|
body << "ri >> argin" << i << ";" << endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate the 'in' object variables
|
// generate the 'in' object variables
|
||||||
i = 1;
|
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;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
|
||||||
if (annotations_object.size() > 0)
|
if (annotations_object.size() > 0)
|
||||||
{
|
{
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_object.length())
|
if (arg_object.length())
|
||||||
{
|
{
|
||||||
body << tab << tab << arg_object << " _argin" << i << ";";
|
body << tab << tab << arg_object << " _argin" << i << ";";
|
||||||
body << " " << "_argin" << i << " << " << "argin" << i << ";" << endl;
|
body << " " << "_argin" << i << " << " << "argin" << i << ";" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate 'out' variables
|
// generate 'out' variables
|
||||||
if (args_out.size() > 0)
|
if (args_out.size() > 0)
|
||||||
{
|
{
|
||||||
unsigned int i = 1;
|
unsigned int i = 1;
|
||||||
|
@ -528,20 +528,20 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
{
|
{
|
||||||
Xml::Node &arg = **ao;
|
Xml::Node &arg = **ao;
|
||||||
|
|
||||||
body << tab << tab << signature_to_type(arg.get("type")) << " argout" << i;
|
body << tab << tab << signature_to_type(arg.get("type")) << " argout" << i;
|
||||||
|
|
||||||
if (args_out.size() == 1) // a single 'out' parameter will be assigned
|
if (args_out.size() == 1) // a single 'out' parameter will be assigned
|
||||||
{
|
{
|
||||||
body << " = ";
|
body << " = ";
|
||||||
}
|
}
|
||||||
else // multible 'out' parameters will be handled as parameters below
|
else // multible 'out' parameters will be handled as parameters below
|
||||||
{
|
{
|
||||||
body << ";" << endl;
|
body << ";" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate 'out' object variables
|
// generate 'out' object variables
|
||||||
if (args_out.size() > 0)
|
if (args_out.size() > 0)
|
||||||
{
|
{
|
||||||
unsigned int i = 1;
|
unsigned int i = 1;
|
||||||
|
@ -557,70 +557,70 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate object types
|
// generate object types
|
||||||
if (arg_object.length())
|
if (arg_object.length())
|
||||||
{
|
{
|
||||||
body << tab << tab << arg_object << " _argout" << i << ";" << endl;
|
body << tab << tab << arg_object << " _argout" << i << ";" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// generate in '<<' operation
|
// generate in '<<' operation
|
||||||
i = 0;
|
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;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
|
||||||
if (annotations_object.size() > 0)
|
if (annotations_object.size() > 0)
|
||||||
{
|
{
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// do correct indent
|
// do correct indent
|
||||||
if (args_out.size() != 1 )
|
if (args_out.size() != 1 )
|
||||||
{
|
|
||||||
body << tab << tab;
|
|
||||||
}
|
|
||||||
|
|
||||||
body << method.get("name") << "(";
|
|
||||||
|
|
||||||
// generate call stub parameters
|
|
||||||
i = 0;
|
|
||||||
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
|
||||||
{
|
{
|
||||||
Xml::Node &arg = **ai;
|
body << tab << tab;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
}
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
|
||||||
string arg_object;
|
|
||||||
|
|
||||||
if (annotations_object.size() > 0)
|
body << method.get("name") << "(";
|
||||||
{
|
|
||||||
arg_object = annotations_object.front()->get("value");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (arg_object.length())
|
// generate call stub parameters
|
||||||
{
|
i = 0;
|
||||||
body << "_argin" << i+1;
|
for (Xml::Nodes::iterator ai = args_in.begin(); ai != args_in.end(); ++ai, ++i)
|
||||||
}
|
{
|
||||||
else
|
Xml::Node &arg = **ai;
|
||||||
{
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
body << "argin" << i+1;
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
}
|
string arg_object;
|
||||||
|
|
||||||
|
if (annotations_object.size() > 0)
|
||||||
|
{
|
||||||
|
arg_object = annotations_object.front()->get("value");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (arg_object.length())
|
||||||
|
{
|
||||||
|
body << "_argin" << i+1;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
body << "argin" << i+1;
|
||||||
|
}
|
||||||
|
|
||||||
if ((i+1 != args_in.size() || args_out.size() > 1))
|
if ((i+1 != args_in.size() || args_out.size() > 1))
|
||||||
body << ", ";
|
body << ", ";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args_out.size() > 1)
|
if (args_out.size() > 1)
|
||||||
{
|
{
|
||||||
i = 0;
|
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;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
@ -630,19 +630,19 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_object.length())
|
if (arg_object.length())
|
||||||
{
|
{
|
||||||
body << "_argout" << i+1;
|
body << "_argout" << i+1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
body << "argout" << i+1;
|
body << "argout" << i+1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i+1 != args_out.size())
|
if (i+1 != args_out.size())
|
||||||
body << ", ";
|
body << ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
body << ");" << endl;
|
body << ");" << endl;
|
||||||
|
|
||||||
|
@ -652,11 +652,11 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
{
|
{
|
||||||
body << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl;
|
body << tab << tab << "::DBus::MessageIter wi = reply.writer();" << endl;
|
||||||
|
|
||||||
// generate out '<<' operation
|
// generate out '<<' operation
|
||||||
i = 0;
|
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;
|
||||||
Xml::Nodes annotations = arg["annotation"];
|
Xml::Nodes annotations = arg["annotation"];
|
||||||
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
Xml::Nodes annotations_object = annotations.select("name","org.freedesktop.DBus.Object");
|
||||||
string arg_object;
|
string arg_object;
|
||||||
|
@ -666,11 +666,11 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
arg_object = annotations_object.front()->get("value");
|
arg_object = annotations_object.front()->get("value");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (arg_object.length())
|
if (arg_object.length())
|
||||||
{
|
{
|
||||||
body << tab << tab << "argout" << i+1 << " << " << "_argout" << i+1 << ";" << endl;
|
body << tab << tab << "argout" << i+1 << " << " << "_argout" << i+1 << ";" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < args_out.size(); ++i)
|
for (unsigned int i = 0; i < args_out.size(); ++i)
|
||||||
{
|
{
|
||||||
|
@ -684,7 +684,7 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
body << "};" << endl
|
body << "};" << endl
|
||||||
<< endl;
|
<< endl;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < nspaces; ++i)
|
for (unsigned int i = 0; i < nspaces; ++i)
|
||||||
{
|
{
|
||||||
|
@ -695,18 +695,18 @@ void generate_adaptor(Xml::Document &doc, const char *filename)
|
||||||
|
|
||||||
body << "#endif //" << cond_comp << endl;
|
body << "#endif //" << cond_comp << endl;
|
||||||
|
|
||||||
// remove all duplicates in the header include vector
|
// remove all duplicates in the header include vector
|
||||||
vector<string>::const_iterator vec_end_it = unique (include_vector.begin (), include_vector.end ());
|
vector<string>::const_iterator vec_end_it = unique (include_vector.begin (), include_vector.end ());
|
||||||
|
|
||||||
for (vector<string>::const_iterator vec_it = include_vector.begin ();
|
for (vector<string>::const_iterator vec_it = include_vector.begin ();
|
||||||
vec_it != vec_end_it;
|
vec_it != vec_end_it;
|
||||||
++vec_it)
|
++vec_it)
|
||||||
{
|
{
|
||||||
const string &include = *vec_it;
|
const string &include = *vec_it;
|
||||||
|
|
||||||
head << "#include " << "\"" << include << ".h" << "\"" << endl;
|
head << "#include " << "\"" << include << ".h" << "\"" << endl;
|
||||||
}
|
}
|
||||||
head << endl;
|
head << endl;
|
||||||
|
|
||||||
ofstream file(filename);
|
ofstream file(filename);
|
||||||
if (file.bad())
|
if (file.bad())
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue