Chromium Code Reviews| Index: src/sksl/ast/SkSLASTInterfaceBlock.h |
| diff --git a/src/sksl/ast/SkSLASTInterfaceBlock.h b/src/sksl/ast/SkSLASTInterfaceBlock.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..70353567b33c58f8027c2cd90dbda210e453d63a |
| --- /dev/null |
| +++ b/src/sksl/ast/SkSLASTInterfaceBlock.h |
| @@ -0,0 +1,57 @@ |
| +/* |
| + * Copyright 2016 Google Inc. |
| + * |
| + * Use of this source code is governed by a BSD-style license that can be |
| + * found in the LICENSE file. |
| + */ |
| + |
| +#ifndef SKSL_ASTINTERFACEBLOCK |
| +#define SKSL_ASTINTERFACEBLOCK |
| + |
| +#include "SkSLASTVarDeclaration.h" |
| + |
| +namespace SkSL { |
| + |
| +/** |
| + * An interface block, as in: |
| + * |
| + * out gl_PerVertex { |
| + * layout(builtin=0) vec4 gl_Position; |
| + * layout(builtin=1) float gl_PointSize; |
| + * }; |
| + */ |
|
dogben
2016/06/20 16:23:18
nit: mention that fValueName can be empty.
|
| +struct ASTInterfaceBlock : public ASTDeclaration { |
| + ASTInterfaceBlock(Position position, |
| + ASTModifiers modifiers, |
|
dogben
2016/06/20 16:23:18
nit: seems inconsistent that this is not std::uniq
ethannicholas
2016/06/20 17:45:49
Statements and expressions are both recursive stru
|
| + std::string interfaceName, |
| + std::string valueName, |
| + std::vector<std::unique_ptr<ASTVarDeclaration>> declarations) |
| + : INHERITED(position, kInterfaceBlock_Kind) |
| + , fModifiers(modifiers) |
| + , fInterfaceName(interfaceName) |
| + , fValueName(valueName) |
| + , fDeclarations(std::move(declarations)) {} |
| + |
| + std::string description() const override { |
| + std::string result = fModifiers.description() + fInterfaceName + " {\n"; |
| + for (size_t i = 0; i < fDeclarations.size(); i++) { |
| + result += fDeclarations[i]->description() + "\n"; |
| + } |
| + result += "}"; |
| + if (fValueName.length()) { |
| + result += " " + fValueName; |
| + } |
| + return result + ";"; |
| + } |
| + |
| + const ASTModifiers fModifiers; |
| + const std::string fInterfaceName; |
| + const std::string fValueName; |
| + const std::vector<std::unique_ptr<ASTVarDeclaration>> fDeclarations; |
| + |
| + typedef ASTDeclaration INHERITED; |
| +}; |
| + |
| +} // namespace |
| + |
| +#endif |