diff options
author | Andreas Volz <andreas@er00923n.(none)> | 2011-02-14 23:27:32 +0100 |
---|---|---|
committer | Andreas Volz <andreas@er00923n.(none)> | 2011-02-14 23:27:32 +0100 |
commit | 796c96d34e10337a784a04200894f208ecde4e59 (patch) | |
tree | d182dad77620ccd3a0a1ab5a0133689283f6378e | |
parent | 9e25833870ed8281fab00d7f9eac5755c6798c57 (diff) | |
download | dbus-c++-796c96d34e10337a784a04200894f208ecde4e59.tar.gz |
fixed SF bug:
ID: 2991229
Summary: nested type wrong generation
-rw-r--r-- | README | 2 | ||||
-rw-r--r-- | examples/echo/echo-introspect.xml | 5 | ||||
-rw-r--r-- | examples/echo/echo-server.h | 2 | ||||
-rw-r--r-- | tools/generator_utils.cpp | 112 |
4 files changed, 112 insertions, 9 deletions
@@ -1,6 +1,6 @@ Debugging --------- -To compile debugging code configure the project with the --enable-debug option. Then at runtime you may set the environment variable "DBUSXX_VERBOSE=1" to activate debugging and to '0' to deactivate debugging. +To compile debugging code configure the project with the --enable-debug option. Then at runtime you may export the environment variable "DBUSXX_VERBOSE" to any value. BUGS: diff --git a/examples/echo/echo-introspect.xml b/examples/echo/echo-introspect.xml index 7d415ab..8a4ded5 100644 --- a/examples/echo/echo-introspect.xml +++ b/examples/echo/echo-introspect.xml @@ -26,5 +26,10 @@ <method name="Info"> <arg type="a{ss}" name="info" direction="out"/> </method> + + <method name="Foo"> + <arg type="a(a(uu)s)" name="array" direction="out" /> + </method> + </interface> </node> diff --git a/examples/echo/echo-server.h b/examples/echo/echo-server.h index 3f0be58..d0a3a0a 100644 --- a/examples/echo/echo-server.h +++ b/examples/echo/echo-server.h @@ -24,6 +24,8 @@ public: int32_t Sum(const std::vector<int32_t> & ints); std::map< std::string, std::string > Info(); + + std::vector< ::DBus::Struct< std::vector< ::DBus::Struct< uint32_t, uint32_t > >, std::string > > Foo() {}; }; #endif//__DEMO_ECHO_SERVER_H diff --git a/tools/generator_utils.cpp b/tools/generator_utils.cpp index e08ad27..3c121af 100644 --- a/tools/generator_utils.cpp +++ b/tools/generator_utils.cpp @@ -87,12 +87,90 @@ const char *atomic_type_to_string(char t) void _parse_signature(const string &signature, string &type, unsigned int &i) { + cout << "signature: " << signature << endl; + cout << "type: " << type << endl; + cout << "i: " << i << ", signature[i]: " << signature[i] << endl; + + for (; i < signature.length(); ++i) + { + switch (signature[i]) + { + case 'a': + { + switch (signature[++i]) + { + case '{': + { + type += "std::map< "; + ++i; + _parse_signature(signature, type, i); + type += " >"; + + break; + } + case '(': + { + type += "std::vector< ::DBus::Struct< "; + ++i; + _parse_signature(signature, type, i); + type += " > >"; + + break; + } + default: + { + type += "std::vector< "; + _parse_signature(signature, type, i); + + type += " >"; + + break; + } + } + + if (i+1 < signature.length() && signature[i+1] != ')' && signature[i+1] != '}') + { + type += ", "; + } + + break; + } + case ')': + case '}': + { + return; + } + default: + { + const char *atom = atomic_type_to_string(signature[i]); + if (!atom) + { + cerr << "invalid signature" << endl; + exit(-1); + } + type += atom; + + if (i+1 < signature.length() && signature[i+1] != ')' && signature[i+1] != '}') + { + type += ", "; + } + break; + } + } + } +} + +/*{ for (; i < signature.length(); ++i) { + cout << "i: " << i << ", sig(i): " << signature[i] << endl; + cout << "Type: " << type << endl; + switch (signature[i]) { case 'a': { + bool multi = false; switch (signature[++i]) { case '{': @@ -108,16 +186,27 @@ void _parse_signature(const string &signature, string &type, unsigned int &i) type += atom; type += ", "; ++i; + _parse_signature(signature, type, i); + multi = true; break; } default: { type += "std::vector< "; + _parse_signature(signature, type, i); + type += " >V"; + multi = true; break; } } - _parse_signature(signature, type, i); - type += " >"; + if (!multi) + { + _parse_signature(signature, type, i); + } + cout << "signature1: " << signature << endl; + cout << "type1: " << type << endl; + cout << "i1: " << i << ", sig(i): " << signature[i-1] << endl; + continue; } case '(': @@ -125,9 +214,12 @@ void _parse_signature(const string &signature, string &type, unsigned int &i) type += "::DBus::Struct< "; ++i; _parse_signature(signature, type, i); - type += " >"; - if (signature[i+1]) - { + type += " >S"; + cout << "signature2: " << signature << endl; + cout << "type2: " << type << endl; + cout << "i2: " << i << ", sig(i): " << signature[i] << endl; + if ((i+1 < signature.length()) && (signature[i+1] != ')') ) + { type += ", "; } continue; @@ -135,7 +227,11 @@ void _parse_signature(const string &signature, string &type, unsigned int &i) case ')': case '}': { - return; + type += " >?"; + cout << "close tag>" << endl; + cout << "type3: " << type << endl; + + return; } default: { @@ -147,7 +243,7 @@ void _parse_signature(const string &signature, string &type, unsigned int &i) } type += atom; - if (signature[i+1] != ')' && signature[i+1] != '}' && i+1 < signature.length()) + if (i+1 < signature.length() && signature[i+1] != ')' && signature[i+1] != '}') { type += ", "; } @@ -155,7 +251,7 @@ void _parse_signature(const string &signature, string &type, unsigned int &i) } } } -} +}*/ string signature_to_type(const string &signature) { |