]> git.tdb.fi Git - libs/gl.git/blobdiff - source/glsl/output.cpp
Refactor the way of applying visitors to stages
[libs/gl.git] / source / glsl / output.cpp
index dfd93470dd101dfac8ca4c7f8a07be588bb11e9f..6e88fd1f870e6ba554a0fbfa0ddaba93d6347720 100644 (file)
@@ -9,14 +9,17 @@ namespace GL {
 namespace SL {
 
 Formatter::Formatter():
+       stage(0),
        source_index(0),
        source_line(1),
        indent(0),
        parameter_list(false)
 { }
 
-void Formatter::apply(Stage &s)
+const string &Formatter::apply(Stage &s)
 {
+       SetForScope<Stage *> set_stage(stage, &s);
+
        GLApi api = get_gl_api();
        const Version &ver = s.required_version;
 
@@ -33,7 +36,9 @@ void Formatter::apply(Stage &s)
        if(!s.required_extensions.empty())
                formatted += '\n';
 
-       StageVisitor::apply(s);
+       visit(s.content);
+
+       return formatted;
 }
 
 void Formatter::append(const string &text)