summaryrefslogtreecommitdiff
path: root/src/libs/glsl
diff options
context:
space:
mode:
authorRhys Weatherley <rhys.weatherley@nokia.com>2010-11-18 15:57:44 +1000
committerRhys Weatherley <rhys.weatherley@nokia.com>2010-11-18 17:40:09 +1000
commit2d4e75101e65286d9bb59e56c868ec972ed66eb5 (patch)
treebd51291aefb13e32e5333518469f0c8b410a1358 /src/libs/glsl
parent1370d1d796b4e62d65aac953bc62006945fef7b4 (diff)
downloadqt-creator-2d4e75101e65286d9bb59e56c868ec972ed66eb5.tar.gz
Use QString instead of std::string in GLSL parser
Diffstat (limited to 'src/libs/glsl')
-rw-r--r--src/libs/glsl/glsl.g12
-rw-r--r--src/libs/glsl/glslast.h58
-rw-r--r--src/libs/glsl/glslengine.cpp8
-rw-r--r--src/libs/glsl/glslengine.h10
-rw-r--r--src/libs/glsl/glsllexer.cpp5
-rw-r--r--src/libs/glsl/glsllexer.h6
-rw-r--r--src/libs/glsl/glslparser.cpp6
-rw-r--r--src/libs/glsl/glslparser.h6
8 files changed, 56 insertions, 55 deletions
diff --git a/src/libs/glsl/glsl.g b/src/libs/glsl/glsl.g
index a30376f934..c594c77358 100644
--- a/src/libs/glsl/glsl.g
+++ b/src/libs/glsl/glsl.g
@@ -253,7 +253,7 @@ class GLSL_EXPORT Parser: public $table
public:
union Value {
void *ptr;
- const std::string *string;
+ const QString *string;
AST *ast;
List<AST *> *ast_list;
Declaration *declaration;
@@ -290,7 +290,7 @@ public:
} type_qualifier;
struct {
Type *type;
- const std::string *name;
+ const QString *name;
} param_declarator;
ParameterDeclaration *param_declaration;
FunctionDeclaration *function_declaration;
@@ -305,7 +305,7 @@ private:
// 1-based
Value &sym(int n) { return _symStack[_tos + n - 1]; }
AST *&ast(int n) { return _symStack[_tos + n - 1].ast; }
- const std::string *&string(int n) { return _symStack[_tos + n - 1].string; }
+ const QString *&string(int n) { return _symStack[_tos + n - 1].string; }
Expression *&expression(int n) { return _symStack[_tos + n - 1].expression; }
Statement *&statement(int n) { return _symStack[_tos + n - 1].statement; }
Type *&type(int n) { return _symStack[_tos + n - 1].type; }
@@ -1312,7 +1312,7 @@ case $rule_number: {
(makeAstNode<QualifiedType>
(sym(1).qualifier, type(3), (List<LayoutQualifier *> *)0),
ParameterDeclaration::Qualifier(sym(2).qualifier),
- (const std::string *)0);
+ (const QString *)0);
} break;
./
@@ -1321,7 +1321,7 @@ parameter_declaration ::= parameter_qualifier parameter_type_specifier ;
case $rule_number: {
ast(1) = makeAstNode<ParameterDeclaration>
(type(2), ParameterDeclaration::Qualifier(sym(1).qualifier),
- (const std::string *)0);
+ (const QString *)0);
} break;
./
@@ -1565,7 +1565,7 @@ case $rule_number: {
layout_qualifier_id ::= IDENTIFIER ;
/.
case $rule_number: {
- sym(1).layout = makeAstNode<LayoutQualifier>(string(1), (const std::string *)0);
+ sym(1).layout = makeAstNode<LayoutQualifier>(string(1), (const QString *)0);
} break;
./
diff --git a/src/libs/glsl/glslast.h b/src/libs/glsl/glslast.h
index 3c5ce980dc..0fd95d7b87 100644
--- a/src/libs/glsl/glslast.h
+++ b/src/libs/glsl/glslast.h
@@ -31,7 +31,7 @@
#include "glsl.h"
#include "glslmemorypool.h"
-#include <string>
+#include <QtCore/qstring.h>
namespace GLSL {
@@ -324,7 +324,7 @@ public:
class GLSL_EXPORT IdentifierExpression: public Expression
{
public:
- IdentifierExpression(const std::string *_name)
+ IdentifierExpression(const QString *_name)
: Expression(Kind_Identifier), name(_name) {}
virtual IdentifierExpression *asIdentifierExpression() { return this; }
@@ -332,13 +332,13 @@ public:
virtual void accept0(Visitor *visitor);
public: // attributes
- const std::string *name;
+ const QString *name;
};
class GLSL_EXPORT LiteralExpression: public Expression
{
public:
- LiteralExpression(const std::string *_value)
+ LiteralExpression(const QString *_value)
: Expression(Kind_Literal), value(_value) {}
virtual LiteralExpression *asLiteralExpression() { return this; }
@@ -346,7 +346,7 @@ public:
virtual void accept0(Visitor *visitor);
public: // attributes
- const std::string *value;
+ const QString *value;
};
class GLSL_EXPORT BinaryExpression: public Expression
@@ -412,7 +412,7 @@ public: // attributes
class GLSL_EXPORT MemberAccessExpression: public Expression
{
public:
- MemberAccessExpression(Expression *_expr, const std::string *_field)
+ MemberAccessExpression(Expression *_expr, const QString *_field)
: Expression(Kind_MemberAccess), expr(_expr), field(_field) {}
virtual MemberAccessExpression *asMemberAccessExpression() { return this; }
@@ -421,7 +421,7 @@ public:
public: // attributes
Expression *expr;
- const std::string *field;
+ const QString *field;
};
class GLSL_EXPORT FunctionCallExpression: public Expression
@@ -449,7 +449,7 @@ public: // attributes
class GLSL_EXPORT FunctionIdentifier: public AST
{
public:
- FunctionIdentifier(const std::string *_name)
+ FunctionIdentifier(const QString *_name)
: AST(Kind_FunctionIdentifier), name(_name), type(0) {}
FunctionIdentifier(Type *_type)
: AST(Kind_FunctionIdentifier), name(0), type(_type) {}
@@ -459,14 +459,14 @@ public:
virtual void accept0(Visitor *visitor);
public: // attributes
- const std::string *name;
+ const QString *name;
Type *type;
};
class GLSL_EXPORT DeclarationExpression: public Expression
{
public:
- DeclarationExpression(Type *_type, const std::string *_name,
+ DeclarationExpression(Type *_type, const QString *_name,
Expression *_initializer)
: Expression(Kind_DeclarationExpression), type(_type)
, name(_name), initializer(_initializer) {}
@@ -477,7 +477,7 @@ public:
public: // attributes
Type *type;
- const std::string *name;
+ const QString *name;
Expression *initializer;
};
@@ -734,7 +734,7 @@ public: // attributes
class GLSL_EXPORT NamedType: public Type
{
public:
- NamedType(const std::string *_name) : Type(Kind_NamedType), name(_name) {}
+ NamedType(const QString *_name) : Type(Kind_NamedType), name(_name) {}
virtual NamedType *asNamedType() { return this; }
@@ -746,7 +746,7 @@ public:
virtual Category category() const { return Struct; }
public: // attributes
- const std::string *name;
+ const QString *name;
};
class GLSL_EXPORT ArrayType: public Type
@@ -777,26 +777,26 @@ public:
class Field: public AST
{
public:
- Field(const std::string *_name)
+ Field(const QString *_name)
: AST(Kind_StructField), name(_name), type(0) {}
// Takes the outer shell of an array type with the innermost
// element type set to null. The fixInnerTypes() method will
// set the innermost element type to a meaningful value.
- Field(const std::string *_name, Type *_type)
+ Field(const QString *_name, Type *_type)
: AST(Kind_StructField), name(_name), type(_type) {}
virtual void accept0(Visitor *visitor);
void setInnerType(Type *innerType);
- const std::string *name;
+ const QString *name;
Type *type;
};
StructType(List<Field *> *_fields)
: Type(Kind_AnonymousStructType), fields(finish(_fields)) {}
- StructType(const std::string *_name, List<Field *> *_fields)
+ StructType(const QString *_name, List<Field *> *_fields)
: Type(Kind_StructType), name(_name), fields(finish(_fields)) {}
virtual StructType *asStructType() { return this; }
@@ -813,19 +813,19 @@ public:
virtual Category category() const { return Struct; }
public: // attributes
- const std::string *name;
+ const QString *name;
List<Field *> *fields;
};
class GLSL_EXPORT LayoutQualifier
{
public:
- LayoutQualifier(const std::string *_name, const std::string *_number)
+ LayoutQualifier(const QString *_name, const QString *_number)
: name(_name), number(_number), lineno(0) {}
public: // attributes
- const std::string *name;
- const std::string *number;
+ const QString *name;
+ const QString *number;
int lineno;
};
@@ -911,7 +911,7 @@ public:
InOut
};
ParameterDeclaration(Type *_type, Qualifier _qualifier,
- const std::string *_name)
+ const QString *_name)
: Declaration(Kind_ParameterDeclaration), type(_type)
, qualifier(_qualifier), name(_name) {}
@@ -922,13 +922,13 @@ public:
public: // attributes
Type *type;
Qualifier qualifier;
- const std::string *name;
+ const QString *name;
};
class VariableDeclaration: public Declaration
{
public:
- VariableDeclaration(Type *_type, const std::string *_name,
+ VariableDeclaration(Type *_type, const QString *_name,
Expression *_initializer = 0)
: Declaration(Kind_VariableDeclaration), type(_type)
, name(_name), initializer(_initializer) {}
@@ -941,7 +941,7 @@ public:
public: // attributes
Type *type;
- const std::string *name;
+ const QString *name;
Expression *initializer;
};
@@ -979,7 +979,7 @@ public: // attributes
class InvariantDeclaration: public Declaration
{
public:
- InvariantDeclaration(const std::string *_name)
+ InvariantDeclaration(const QString *_name)
: Declaration(Kind_InvariantDeclaration), name(_name) {}
virtual InvariantDeclaration *asInvariantDeclaration() { return this; }
@@ -987,7 +987,7 @@ public:
virtual void accept0(Visitor *visitor);
public: // attributes
- const std::string *name;
+ const QString *name;
};
class InitDeclaration: public Declaration
@@ -1007,7 +1007,7 @@ public: // attributes
class FunctionDeclaration : public Declaration
{
public:
- FunctionDeclaration(Type *_returnType, const std::string *_name)
+ FunctionDeclaration(Type *_returnType, const QString *_name)
: Declaration(Kind_FunctionDeclaration), returnType(_returnType)
, name(_name), params(0), body(0) {}
@@ -1021,7 +1021,7 @@ public:
public: // attributes
Type *returnType;
- const std::string *name;
+ const QString *name;
List<ParameterDeclaration *> *params;
Statement *body;
};
diff --git a/src/libs/glsl/glslengine.cpp b/src/libs/glsl/glslengine.cpp
index e8a82d78ec..fc157d2eda 100644
--- a/src/libs/glsl/glslengine.cpp
+++ b/src/libs/glsl/glslengine.cpp
@@ -10,14 +10,14 @@ Engine::~Engine()
{
}
-const std::string *Engine::identifier(const std::string &s)
+const QString *Engine::identifier(const QString &s)
{
- return &*_identifiers.insert(s).first;
+ return &(*_identifiers.insert(s));
}
-const std::string *Engine::identifier(const char *s, int n)
+const QString *Engine::identifier(const char *s, int n)
{
- return &*_identifiers.insert(std::string(s, n)).first;
+ return &(*_identifiers.insert(QString::fromLatin1(s, n)));
}
MemoryPool *Engine::pool()
diff --git a/src/libs/glsl/glslengine.h b/src/libs/glsl/glslengine.h
index a84d45e0af..890dec37e5 100644
--- a/src/libs/glsl/glslengine.h
+++ b/src/libs/glsl/glslengine.h
@@ -3,8 +3,8 @@
#include "glsl.h"
#include "glslmemorypool.h"
-#include <set>
-#include <string>
+#include <QtCore/qstring.h>
+#include <QtCore/qset.h>
namespace GLSL {
@@ -14,13 +14,13 @@ public:
Engine();
~Engine();
- const std::string *identifier(const std::string &s);
- const std::string *identifier(const char *s, int n);
+ const QString *identifier(const QString &s);
+ const QString *identifier(const char *s, int n);
MemoryPool *pool();
private:
- std::set<std::string> _identifiers;
+ QSet<QString> _identifiers;
MemoryPool _pool;
};
diff --git a/src/libs/glsl/glsllexer.cpp b/src/libs/glsl/glsllexer.cpp
index 05f99f2ba9..8227dbdba3 100644
--- a/src/libs/glsl/glsllexer.cpp
+++ b/src/libs/glsl/glsllexer.cpp
@@ -30,6 +30,7 @@
#include "glsllexer.h"
#include "glslparser.h"
#include "glslengine.h"
+#include <QtCore/qbytearray.h>
#include <cctype>
#include <iostream>
#include <cstdio>
@@ -393,9 +394,9 @@ int Lexer::findKeyword(const char *word, int length) const
return t;
if ((_variant & t & Variant_Mask) == 0) {
// TODO: issue a proper error for the unsupported keyword
- std::string keyword(word, length);
+ QByteArray keyword(word, length);
fprintf(stderr, "unsupported keyword `%s' at line %d\n",
- keyword.c_str(), _lineno);
+ keyword.constData(), _lineno);
}
return t & ~Variant_Mask;
}
diff --git a/src/libs/glsl/glsllexer.h b/src/libs/glsl/glsllexer.h
index dcdd4f5d29..c8f0bcf92e 100644
--- a/src/libs/glsl/glsllexer.h
+++ b/src/libs/glsl/glsllexer.h
@@ -31,7 +31,7 @@
#define GLSLLEXER_H
#include "glsl.h"
-#include <string>
+#include <QtCore/qstring.h>
namespace GLSL {
@@ -46,7 +46,7 @@ public:
union {
int matchingBrace;
int i; // integer value
- const std::string *string; // string value
+ const QString *string; // string value
void *ptr;
};
@@ -80,7 +80,7 @@ public:
union Value {
int i;
- const std::string *string;
+ const QString *string;
void *ptr;
};
diff --git a/src/libs/glsl/glslparser.cpp b/src/libs/glsl/glslparser.cpp
index 78f5810c7f..92f50cfa2f 100644
--- a/src/libs/glsl/glslparser.cpp
+++ b/src/libs/glsl/glslparser.cpp
@@ -831,7 +831,7 @@ case 99: {
(makeAstNode<QualifiedType>
(sym(1).qualifier, type(3), (List<LayoutQualifier *> *)0),
ParameterDeclaration::Qualifier(sym(2).qualifier),
- (const std::string *)0);
+ (const QString *)0);
} break;
#line 1320 "./glsl.g"
@@ -839,7 +839,7 @@ case 99: {
case 100: {
ast(1) = makeAstNode<ParameterDeclaration>
(type(2), ParameterDeclaration::Qualifier(sym(1).qualifier),
- (const std::string *)0);
+ (const QString *)0);
} break;
#line 1329 "./glsl.g"
@@ -1053,7 +1053,7 @@ case 129: {
#line 1566 "./glsl.g"
case 130: {
- sym(1).layout = makeAstNode<LayoutQualifier>(string(1), (const std::string *)0);
+ sym(1).layout = makeAstNode<LayoutQualifier>(string(1), (const QString *)0);
} break;
#line 1573 "./glsl.g"
diff --git a/src/libs/glsl/glslparser.h b/src/libs/glsl/glslparser.h
index 772a96ae5a..fe476702fc 100644
--- a/src/libs/glsl/glslparser.h
+++ b/src/libs/glsl/glslparser.h
@@ -44,7 +44,7 @@ class GLSL_EXPORT Parser: public GLSLParserTable
public:
union Value {
void *ptr;
- const std::string *string;
+ const QString *string;
AST *ast;
List<AST *> *ast_list;
Declaration *declaration;
@@ -81,7 +81,7 @@ public:
} type_qualifier;
struct {
Type *type;
- const std::string *name;
+ const QString *name;
} param_declarator;
ParameterDeclaration *param_declaration;
FunctionDeclaration *function_declaration;
@@ -96,7 +96,7 @@ private:
// 1-based
Value &sym(int n) { return _symStack[_tos + n - 1]; }
AST *&ast(int n) { return _symStack[_tos + n - 1].ast; }
- const std::string *&string(int n) { return _symStack[_tos + n - 1].string; }
+ const QString *&string(int n) { return _symStack[_tos + n - 1].string; }
Expression *&expression(int n) { return _symStack[_tos + n - 1].expression; }
Statement *&statement(int n) { return _symStack[_tos + n - 1].statement; }
Type *&type(int n) { return _symStack[_tos + n - 1].type; }