NO FUNCTIONAL CHANGES!!
Only reformated stupid astyle formating; it seems the code inside a string confused astyle...
This commit is contained in:
parent
0522a1eb29
commit
cee7aaca54
1 changed files with 121 additions and 121 deletions
|
@ -42,140 +42,140 @@ const char *dbus_includes = "\n\
|
||||||
#include <cassert>\n\
|
#include <cassert>\n\
|
||||||
";
|
";
|
||||||
|
|
||||||
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);
|
underscorize(name);
|
||||||
|
|
||||||
return "_" + name + "_stub";
|
return "_" + name + "_stub";
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *atomic_type_to_string(char t)
|
const char *atomic_type_to_string(char t)
|
||||||
{
|
{
|
||||||
static struct
|
static struct
|
||||||
{
|
{
|
||||||
char type;
|
char type;
|
||||||
const char *name;
|
const char *name;
|
||||||
} atos[] =
|
} atos[] =
|
||||||
{
|
{
|
||||||
{ 'y', "uint8_t" },
|
{ 'y', "uint8_t" },
|
||||||
{ 'b', "bool" },
|
{ 'b', "bool" },
|
||||||
{ 'n', "int16_t" },
|
{ 'n', "int16_t" },
|
||||||
{ 'q', "uint16_t" },
|
{ 'q', "uint16_t" },
|
||||||
{ 'i', "int32_t" },
|
{ 'i', "int32_t" },
|
||||||
{ 'u', "uint32_t" },
|
{ 'u', "uint32_t" },
|
||||||
{ 'x', "int64_t" },
|
{ 'x', "int64_t" },
|
||||||
{ 't', "uint64_t" },
|
{ 't', "uint64_t" },
|
||||||
{ 'd', "double" },
|
{ 'd', "double" },
|
||||||
{ 's', "std::string" },
|
{ 's', "std::string" },
|
||||||
{ 'o', "::DBus::Path" },
|
{ 'o', "::DBus::Path" },
|
||||||
{ 'g', "::DBus::Signature" },
|
{ 'g', "::DBus::Signature" },
|
||||||
{ 'v', "::DBus::Variant" },
|
{ 'v', "::DBus::Variant" },
|
||||||
{ '\0', "" }
|
{ '\0', "" }
|
||||||
};
|
};
|
||||||
int i;
|
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;
|
return atos[i].name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void _parse_signature(const string &signature, string &type, unsigned int &i, bool only_once = false)
|
static void _parse_signature(const string &signature, string &type, unsigned int &i, bool only_once = false)
|
||||||
{
|
{
|
||||||
/*cout << "signature: " << signature << endl;
|
/*cout << "signature: " << signature << endl;
|
||||||
cout << "type: " << type << endl;
|
cout << "type: " << type << endl;
|
||||||
cout << "i: " << i << ", signature[i]: " << signature[i] << 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])
|
||||||
{
|
{
|
||||||
case 'a':
|
case 'a':
|
||||||
{
|
{
|
||||||
switch (signature[++i])
|
switch (signature[++i])
|
||||||
{
|
{
|
||||||
case '{':
|
case '{':
|
||||||
{
|
{
|
||||||
type += "std::map< ";
|
type += "std::map< ";
|
||||||
++i;
|
++i;
|
||||||
_parse_signature(signature, type, i);
|
_parse_signature(signature, type, i);
|
||||||
type += " >";
|
type += " >";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '(':
|
case '(':
|
||||||
{
|
{
|
||||||
type += "std::vector< ::DBus::Struct< ";
|
type += "std::vector< ::DBus::Struct< ";
|
||||||
++i;
|
++i;
|
||||||
_parse_signature(signature, type, i);
|
_parse_signature(signature, type, i);
|
||||||
type += " > >";
|
type += " > >";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
type += "std::vector< ";
|
type += "std::vector< ";
|
||||||
_parse_signature(signature, type, i, true);
|
_parse_signature(signature, type, i, true);
|
||||||
|
|
||||||
type += " >";
|
type += " >";
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case '(':
|
case '(':
|
||||||
{
|
{
|
||||||
type += "::DBus::Struct< ";
|
type += "::DBus::Struct< ";
|
||||||
++i;
|
++i;
|
||||||
|
|
||||||
_parse_signature(signature, type, i);
|
_parse_signature(signature, type, i);
|
||||||
|
|
||||||
type += " >";
|
type += " >";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case ')':
|
case ')':
|
||||||
case '}':
|
case '}':
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
const char *atom = atomic_type_to_string(signature[i]);
|
const char *atom = atomic_type_to_string(signature[i]);
|
||||||
if (!atom)
|
if (!atom)
|
||||||
{
|
{
|
||||||
cerr << "invalid signature" << endl;
|
cerr << "invalid signature" << endl;
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
type += atom;
|
type += atom;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (only_once)
|
if (only_once)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (i + 1 < signature.length() && signature[i + 1] != ')' && signature[i + 1] != '}')
|
if (i + 1 < signature.length() && signature[i + 1] != ')' && signature[i + 1] != '}')
|
||||||
{
|
{
|
||||||
type += ", ";
|
type += ", ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string signature_to_type(const string &signature)
|
string signature_to_type(const string &signature)
|
||||||
{
|
{
|
||||||
string type;
|
string type;
|
||||||
unsigned int i = 0;
|
unsigned int i = 0;
|
||||||
_parse_signature(signature, type, i);
|
_parse_signature(signature, type, i);
|
||||||
return type;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue