fixed SF bug:

ID: 2991229
Summary: nested type wrong generation
This commit is contained in:
Andreas Volz 2011-02-14 23:27:32 +01:00
parent 9e25833870
commit 796c96d34e
4 changed files with 113 additions and 10 deletions

2
README
View file

@ -1,6 +1,6 @@
Debugging 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: BUGS:

View file

@ -26,5 +26,10 @@
<method name="Info"> <method name="Info">
<arg type="a{ss}" name="info" direction="out"/> <arg type="a{ss}" name="info" direction="out"/>
</method> </method>
<method name="Foo">
<arg type="a(a(uu)s)" name="array" direction="out" />
</method>
</interface> </interface>
</node> </node>

View file

@ -24,6 +24,8 @@ public:
int32_t Sum(const std::vector<int32_t> & ints); int32_t Sum(const std::vector<int32_t> & ints);
std::map< std::string, std::string > Info(); 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 #endif//__DEMO_ECHO_SERVER_H

View file

@ -87,6 +87,10 @@ const char *atomic_type_to_string(char t)
void _parse_signature(const string &signature, string &type, unsigned int &i) 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) for (; i < signature.length(); ++i)
{ {
switch (signature[i]) switch (signature[i])
@ -98,39 +102,38 @@ void _parse_signature(const string &signature, string &type, unsigned int &i)
case '{': case '{':
{ {
type += "std::map< "; type += "std::map< ";
const char *atom = atomic_type_to_string(signature[++i]);
if (!atom)
{
cerr << "invalid signature" << endl;
exit(-1);
}
type += atom;
type += ", ";
++i; ++i;
_parse_signature(signature, type, i);
type += " >";
break;
}
case '(':
{
type += "std::vector< ::DBus::Struct< ";
++i;
_parse_signature(signature, type, i);
type += " > >";
break; break;
} }
default: default:
{ {
type += "std::vector< "; type += "std::vector< ";
_parse_signature(signature, type, i);
type += " >";
break; break;
} }
} }
_parse_signature(signature, type, i);
type += " >"; if (i+1 < signature.length() && signature[i+1] != ')' && signature[i+1] != '}')
continue;
}
case '(':
{
type += "::DBus::Struct< ";
++i;
_parse_signature(signature, type, i);
type += " >";
if (signature[i+1])
{ {
type += ", "; type += ", ";
} }
continue;
break;
} }
case ')': case ')':
case '}': case '}':
@ -147,7 +150,7 @@ void _parse_signature(const string &signature, string &type, unsigned int &i)
} }
type += atom; 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 += ", "; type += ", ";
} }
@ -157,6 +160,99 @@ void _parse_signature(const string &signature, string &type, unsigned int &i)
} }
} }
/*{
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 '{':
{
type += "std::map< ";
const char *atom = atomic_type_to_string(signature[++i]);
if (!atom)
{
cerr << "invalid signature" << endl;
exit(-1);
}
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;
}
}
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 '(':
{
type += "::DBus::Struct< ";
++i;
_parse_signature(signature, type, i);
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;
}
case ')':
case '}':
{
type += " >?";
cout << "close tag>" << endl;
cout << "type3: " << type << endl;
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;
}
}
}
}*/
string signature_to_type(const string &signature) string signature_to_type(const string &signature)
{ {
string type; string type;