[Kde-bindings] KDE/kdebindings/generator
Richard Dale
richard.j.dale at gmail.com
Sat Oct 9 10:26:01 UTC 2010
SVN commit 1184166 by rdale:
* Add 'long long' types to the list of scalarTypes so that it will have
a munged type of '$'
* Treat 'size_t' as a special token as the header where it is typedef'd
is built into the compiler
CCMAIL: kde-bindings at kde.org
M +7 -0 generators/smoke/generator_smoke.cpp
M +1 -5 generators/smoke/helpers.cpp
M +1 -0 parser/lexer.cpp
M +3 -0 parser/parser.cpp
M +3 -0 parser/tokens.cpp
M +1 -0 parser/tokens.h
--- trunk/KDE/kdebindings/generator/generators/smoke/generator_smoke.cpp #1184165:1184166
@@ -213,6 +213,7 @@
Options::qtMode = ParserOptions::qtMode;
Options::voidpTypes << "long long" << "long long int" << "unsigned long long" << "unsigned long long int";
+ Options::scalarTypes << "long long" << "long long int" << "unsigned long long" << "unsigned long long int";
// Fill the type map. It maps some long integral types to shorter forms as used in SMOKE.
Util::typeMap["long int"] = "long";
@@ -220,6 +221,12 @@
Util::typeMap["long double"] = "double";
Util::typeMap["wchar_t"] = "int"; // correct?
+ if (sizeof(unsigned int) == sizeof(size_t)) {
+ Util::typeMap["size_t"] = "uint";
+ } else if (sizeof(unsigned long) == sizeof(size_t)) {
+ Util::typeMap["size_t"] = "ulong";
+ }
+
qDebug() << "Generating SMOKE sources...";
SmokeDataFile smokeData;
--- trunk/KDE/kdebindings/generator/generators/smoke/helpers.cpp #1184165:1184166
@@ -458,11 +458,7 @@
return munge(&resolved);
}
- if (type->name().contains("long long") || type->name() == "size_t") {
- // Special case 'long long' types as '$'.
- // Hack: 'size_t' isn't being fully resolved for some reason.
- return '$';
- } else if (type->pointerDepth() > 1 || (type->getClass() && type->getClass()->isTemplate() && (!Options::qtMode || (Options::qtMode && type->getClass()->name() != "QFlags"))) ||
+ if (type->pointerDepth() > 1 || (type->getClass() && type->getClass()->isTemplate() && (!Options::qtMode || (Options::qtMode && type->getClass()->name() != "QFlags"))) ||
(Options::voidpTypes.contains(type->name()) && !Options::scalarTypes.contains(type->name())) )
{
// QString and QStringList are both mapped to Smoke::t_voidp, but QString is a scalar as well
--- trunk/KDE/kdebindings/generator/parser/lexer.cpp #1184165:1184166
@@ -205,6 +205,7 @@
ADD_TOKEN(virtual);
ADD_TOKEN(void);
ADD_TOKEN(volatile);
+ ADD_TOKEN(size_t);
ADD_TOKEN(wchar_t);
ADD_TOKEN(while);
ADD_TOKEN(xor);
--- trunk/KDE/kdebindings/generator/parser/parser.cpp #1184165:1184166
@@ -411,6 +411,7 @@
case Token_identifier:
case Token_operator:
case Token_char:
+ case Token_size_t:
case Token_wchar_t:
case Token_bool:
case Token_short:
@@ -476,6 +477,7 @@
case Token_catch:
case Token_throw:
case Token_char:
+ case Token_size_t:
case Token_wchar_t:
case Token_bool:
case Token_short:
@@ -1199,6 +1201,7 @@
switch(session->token_stream->lookAhead())
{
case Token_char:
+ case Token_size_t:
case Token_wchar_t:
case Token_bool:
case Token_short:
--- trunk/KDE/kdebindings/generator/parser/tokens.cpp #1184165:1184166
@@ -99,6 +99,7 @@
"signals",
"signed",
"sizeof",
+ "size_t",
"slots",
"static",
"static_cast",
@@ -204,6 +205,7 @@
"signals",
"signed",
"sizeof",
+ "size_t",
"slots",
"static",
"static_cast",
@@ -328,6 +330,7 @@
{ char(125), '\0' },
{ char(126), '\0' },
{ char(127), '\0' },
+ { char(128), '\0' },
};
char const *token_name(int token)
--- trunk/KDE/kdebindings/generator/parser/tokens.h #1184165:1184166
@@ -107,6 +107,7 @@
Token_signals,
Token_signed,
Token_sizeof,
+ Token_size_t,
Token_slots,
Token_static,
Token_static_cast,
More information about the Kde-bindings
mailing list