forked from qt-creator/qt-creator
Use QString instead of std::string in GLSL parser
This commit is contained in:
@@ -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;
|
||||
./
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -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"
|
||||
|
||||
@@ -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; }
|
||||
|
||||
Reference in New Issue
Block a user