]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/syntax.cpp
Mark constant data as const
[libs/gl.git] / source / glsl / syntax.cpp
index 947b310ef5e528e026dd53dcbd642de96f4923b3..bb8d7dab046f2ea1293927d93aa3e415818e12d4 100644 (file)
@@ -1,3 +1,4 @@
+#include <msp/core/algorithm.h>
 #include <msp/core/maputils.h>
 #include "syntax.h"
 #include "visitor.h"
@@ -69,8 +70,8 @@ template<typename C>
 NodeContainer<C>::NodeContainer(const NodeContainer &c):
        C(c)
 {
-       for(typename C::iterator i=this->begin(); i!=this->end(); ++i)
-               *i = (*i)->clone();
+       for(auto &i: *this)
+               i = i->clone();
 }
 
 
@@ -271,6 +272,7 @@ void InterfaceLayout::visit(NodeVisitor &visitor)
 BasicTypeDeclaration::BasicTypeDeclaration():
        kind(ALIAS),
        size(0),
+       sign(true),
        base_type(0)
 { }
 
@@ -278,6 +280,7 @@ BasicTypeDeclaration::BasicTypeDeclaration(const BasicTypeDeclaration &other):
        TypeDeclaration(other),
        kind(other.kind),
        size(other.size),
+       sign(other.sign),
        base(other.base),
        base_type(0)
 { }
@@ -457,7 +460,7 @@ Stage::Stage(Stage::Type t):
 
 const char *Stage::get_stage_name(Type type)
 {
-       static const char *names[] = { "shared", "vertex", "geometry", "fragment" };
+       static const char *const names[] = { "shared", "vertex", "geometry", "fragment" };
        return names[type];
 }
 
@@ -489,10 +492,8 @@ string get_unused_variable_name(const Block &block, const string &base)
 
 int get_layout_value(const Layout &layout, const string &name, int def_value)
 {
-       for(vector<Layout::Qualifier>::const_iterator i=layout.qualifiers.begin(); i!=layout.qualifiers.end(); ++i)
-               if(i->name==name)
-                       return i->value;
-       return def_value;
+       auto i = find_member(layout.qualifiers, name, &Layout::Qualifier::name);
+       return (i!=layout.qualifiers.end() ? i->value : def_value);
 }
 
 void add_to_chain(Assignment::Target &target, Assignment::Target::ChainType type, unsigned index)