Put all glslang internals (but not the external interface) into the glslang namespace.
authorJohn Kessenich <cepheus@frii.com>
Thu, 29 Aug 2013 00:39:25 +0000 (00:39 +0000)
committerJohn Kessenich <cepheus@frii.com>
Thu, 29 Aug 2013 00:39:25 +0000 (00:39 +0000)
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22882 e7fa87d3-cd2b-0410-9028-fcbf551c1848

55 files changed:
OGLCompilersDLL/InitializeDll.cpp
OGLCompilersDLL/InitializeDll.h
StandAlone/StandAlone.cpp
StandAlone/Worklist.h
Todo.txt
glslang.vcxproj
glslang.vcxproj.filters
glslang/Include/BaseTypes.h
glslang/Include/Common.h
glslang/Include/ConstantUnion.h
glslang/Include/InfoSink.h
glslang/Include/InitializeGlobals.h
glslang/Include/PoolAlloc.h
glslang/Include/ResourceLimits.h
glslang/Include/ShHandle.h
glslang/Include/Types.h
glslang/Include/intermediate.h
glslang/MachineIndependent/Constant.cpp
glslang/MachineIndependent/InfoSink.cpp
glslang/MachineIndependent/Initialize.cpp
glslang/MachineIndependent/Initialize.h
glslang/MachineIndependent/IntermTraverse.cpp
glslang/MachineIndependent/Intermediate.cpp
glslang/MachineIndependent/MMap.h [deleted file]
glslang/MachineIndependent/ParseHelper.cpp
glslang/MachineIndependent/ParseHelper.h
glslang/MachineIndependent/PoolAlloc.cpp
glslang/MachineIndependent/QualifierAlive.cpp
glslang/MachineIndependent/QualifierAlive.h
glslang/MachineIndependent/RemoveTree.cpp
glslang/MachineIndependent/RemoveTree.h
glslang/MachineIndependent/Scan.cpp
glslang/MachineIndependent/Scan.h
glslang/MachineIndependent/ScanContext.h
glslang/MachineIndependent/ShaderLang.cpp
glslang/MachineIndependent/SymbolTable.cpp
glslang/MachineIndependent/SymbolTable.h
glslang/MachineIndependent/Versions.cpp
glslang/MachineIndependent/glslang.y
glslang/MachineIndependent/intermOut.cpp
glslang/MachineIndependent/localintermediate.h
glslang/MachineIndependent/parseConst.cpp
glslang/MachineIndependent/preprocessor/Pp.cpp
glslang/MachineIndependent/preprocessor/PpAtom.cpp
glslang/MachineIndependent/preprocessor/PpContext.cpp
glslang/MachineIndependent/preprocessor/PpContext.h
glslang/MachineIndependent/preprocessor/PpMemory.cpp
glslang/MachineIndependent/preprocessor/PpScanner.cpp
glslang/MachineIndependent/preprocessor/PpSymbols.cpp
glslang/MachineIndependent/preprocessor/PpTokens.cpp
glslang/OSDependent/Linux/osinclude.h
glslang/OSDependent/Linux/ossource.cpp
glslang/OSDependent/Windows/main.cpp
glslang/OSDependent/Windows/osinclude.h
glslang/OSDependent/Windows/ossource.cpp

index 01125ce..5f5ec3a 100644 (file)
@@ -41,6 +41,8 @@
 
 #include "Public/ShaderLang.h"
 
+namespace glslang {
+
 OS_TLSIndex ThreadInitializeIndex = OS_INVALID_TLS_INDEX;
 
 bool InitProcess()
@@ -144,3 +146,5 @@ bool DetachProcess()
 
     return success;
 }
+
+} // end namespace glslang
index f1ea567..8a29679 100644 (file)
 
 #include "osinclude.h"
 
+namespace glslang {
 
 bool InitProcess();
 bool InitThread();
 bool DetachThread();
 bool DetachProcess();
 
+} // end namespace glslang
+
 #endif // __INITIALIZEDLL_H
 
index ec493fd..a14a2db 100644 (file)
@@ -72,7 +72,7 @@ ShBinding FixedAttributeBindings[] = {
 
 ShBindingTable FixedAttributeTable = { 3, FixedAttributeBindings };
 
-static EShLanguage FindLanguage(const std::string& name);
+EShLanguage FindLanguage(const std::string& name);
 bool CompileFile(const char *fileName, ShHandle, int options, const TBuiltInResource*);
 void usage();
 void FreeFileData(char **data);
@@ -232,7 +232,7 @@ int C_DECL main(int argc, char* argv[])
 //   .geom = geometry
 //   .frag = fragment
 //
-static EShLanguage FindLanguage(const std::string& name)
+EShLanguage FindLanguage(const std::string& name)
 {
     size_t ext = name.rfind('.');
     if (ext == std::string::npos) {
index 7f6cff9..e5c35bd 100644 (file)
@@ -78,6 +78,6 @@ namespace glslang {
         std::list<std::string> worklist;
     };
 
-};
+} // end namespace glslang
 
 #endif // WORKLIST_H_INCLUDED
index e01ad4e..19ac666 100644 (file)
--- a/Todo.txt
+++ b/Todo.txt
@@ -9,40 +9,43 @@ Performance
 Testing
   - thread safety
 
-Interfacing
-  - finish putting into a glslang namespace
-
-Shader Linking Validation
+Link Validation
     - ensure no static references thrown away
-       Cross-stage linking
-         - type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching
-         - location/binding/index check
-         - matching initializers for uniforms
-         - mixed es/non-es profiles
-         - statically consumed input not produced by previous stage
-         - matching between gl_PerVertex blocks and gl_PerFragment blocks
-         - compute shader not with other stages
-       Intra-stage linking
-         - exactly one main
-         - type consistency check of uniforms, globals, ins, and outs, both variables and blocks
-         - location/component/binding/index/offset match check
-         - location/component aliasing (except desktop vertex shader inputs)
-         - geometry shader input array sizes and input layout qualifier declaration
-         - compute shader layout(local_size_*) matching
-         - mixed es/non-es profiles
-         - matching initializers for globals
-         - recursion for both functions and subroutines
-         - matching redeclarations of interface blocks
-         - read or write to both gl_ClipVertex and gl_ClipDistance
-         - write to only one of gl_FragColor, gl_FragData, or user-declared
-         - 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching
+    Cross-stage linking
+      - type consistency check of uniform and ins <-> outs, both variables and blocks, stage-specific arrayness matching
+      - location/binding/index check
+      - matching initializers for uniforms
+      - mixed es/non-es profiles
+      - statically consumed input not produced by previous stage
+      - matching between gl_PerVertex blocks and gl_PerFragment blocks
+      - compute shader not with other stages
+      - 1.3: deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
+      - 4.3: remove cross-version linking restrictions.
+      - 4.3: Allow mismatches in interpolation and auxiliary qualification across stages.
+    Intra-stage linking
+      - exactly one main
+      - type consistency check of uniforms, globals, ins, and outs, both variables and blocks
+      - location/component/binding/index/offset match check
+      - location/component aliasing (except desktop vertex shader inputs)
+      - geometry shader input array sizes and input layout qualifier declaration
+      - compute shader layout(local_size_*) matching
+      - mixed es/non-es profiles
+      - matching initializers for globals
+      - recursion for both functions and subroutines
+          - Even the potential for recursion through subroutine uniforms is an error.
+      - matching redeclarations of interface blocks
+      - read or write to both gl_ClipVertex and gl_ClipDistance
+      - write to only one of gl_FragColor, gl_FragData, or user-declared
+      - 4.3: Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
+      - 4.3: Be clear that implicit array sizing is only within a stage, not cross stage.
+      - 4.4: overlapping transform/feedback offsets, offset/stride overflow checks, and stride matching
 
-Functionality to Implement/Finish
+Shader Functionality to Implement/Finish
     ESSL 3.0
       - "const" compile-time constant propagation in the front-end has to be complete, for all built-in functions
     GLSL 1.2
       - Handle multiple compilation units per stage
-      - Allow initializers on uniform declarations.  The value is set at link time.
+      - Allow initializers on uniform declarations
       - signature matching takes type conversions into account, ambiguity is an error
     GLSL 1.3
       . flat is for both user and predeclared built-in in/out variables
@@ -51,7 +54,6 @@ Functionality to Implement/Finish
       - non-perspective (linear) interpolation (noperspective)
       - add gl_ClipDistance[] to both vertex and fragment shaders
       - only statically used built-ins have to be redeclared as flat
-      - Link: Deprecated mixing fixed vertex/fragment stage with programmable fragment/vertex stage.
       - Deprecated gl_ClipVertex
       - deprecate almost all built-in state
       - ftransform() is deprecated
@@ -71,14 +73,13 @@ Functionality to Implement/Finish
                 rather than relying on gl_MaxVaryingComponents.  Also, corrected gl_MaxVaryingComponents to be 60 instead of 64.
       - Added gl_PrimitiveID as an input to fragment shaders.
       - Added gl_FragCoord qualifiers origin_upper_left, and pixel_center_integer to modify the values returned by gl_FragCoord (and have no affect on any other aspect of the pipeline or language).
-           - including redeclaration of gl_FragCoord that adds nothing
+        - including redeclaration of gl_FragCoord that adds nothing
       - Added support for multi-sample textures through sampler2DMS and sampler2DMSArray support in texelFetch() and textureSize().
       - Broadened interface blocks from just uniforms to in and out interfaces as well.
       - Broaden array usage to include vertex shader inputs (vertex in).
       - Added geometry shaders.  This includes targeting layers in FBO rendering.
       - geometry shader layouts: they must be declared, telling the system the primitive input and output types and maximum number of vertices.
       - Added geometry shader constants.
-      - gl_FragCoord qualifiers use the layout(): origin_upper_left and pixel_center_integer.
       - Broaden structure usage to include geometry inputs and geometry outputs.
     GLSL 4.0
       - tessellation control stage and tessellation evaluation stage. Includes barrier() built-in for synchronization.
@@ -93,7 +94,7 @@ Functionality to Implement/Finish
       - Sampler arrays can take a variable index now, as long as it's value is uniform for all uses.
       - Per-sample shading. Including sample input mask gl_SampleMaskIn[] and per-sample interpolation, with explicit interpolation built-ins interpolateAtCentroid(), interpolateAtSample(), and interpolateAtOffset().
       - New precise qualifier to disallow optimizations that re-order operations or treat different instances of the same operator with different precision.
-      - Add a fused multiply andadd built-in, fma(), in relation to the new precise qualifier. (Because \93a * b + c\94 will require two operations under new rules for precise.)
+      - Add a fused multiply and add built-in, fma(), in relation to the new precise qualifier. (Because \93a * b + c\94 will require two operations under new rules for precise.)
       - Added new built-in floating-point functions 
          - frexp() and ldexp()
          - packUnorm2x16(), packUnorm4x8(),packSnorm4x8(), and packDouble2x32()
@@ -115,13 +116,13 @@ Functionality to Implement/Finish
     GLSL 4.1
       - Support for partitioning shaders into multiple programs to provide light-weight mixing of different shader stages.
             (GL_ARB_separate_shader_objects)
-               - layout qualifiers
-               - redeclaration of input/output blocks
-               - ...
+        - layout qualifiers
+        - redeclaration of input/output blocks
+        - ...
       - Add 64-bit floating-point attributes for vertex shader inputs.
       - Support viewport arrays so where the geometry shader selects which viewport array will transform its output.
     GLSL 4.2
-         - Add 420-style function signature matching rules
+      - Add 420-style function signature matching rules (or did this start in 4.0?)
       + Move these previously deprecated features to be only in the compatibility profile:
         + The keyword attribute for vertex shader inputs. (Use in instead.)
         + The keyword varying for inputs and outputs. (Use in and out instead.)
@@ -129,7 +130,7 @@ Functionality to Implement/Finish
         + The built-in variables gl_FragColor and gl_FragData. (Use out instead.)
         + Built-in constants related to these.
       + Change from ASCII to UTF-8 for the language character set and also allow any characters inside comments (except the byte value 0), 
-           including '\'.
+        including '\'.
       + Add line-continuation using '\', as in C++.
       + ES convergence
         + Clarify that .xyzwxy.xy is illegal, as it temporarily makes a \93vec6\94.
@@ -140,7 +141,7 @@ Functionality to Implement/Finish
         - can read/write/modify images from a shader, through new built-in functions
         - qualifiers can act independently on the opaque shader variable and the backing image, so extra qualifiers can be used to separately qualify these
       + Variables declared in if and else statements are scoped only to the end of those statements, especially for non-compound statements
-           Note, this is not backward compatible, it may depend on #version.
+        Note, this is not backward compatible, it may depend on #version.
       - Allow implicit conversions of return values to the declared type of the function.
       - The const keyword can be used to declare variables within a function body with initializer expressions that are not constant expressions.
       + Qualifiers on variable declarations no longer have to follow a strict order. The layout qualifier can be used multiple times, and multiple parameter qualifiers can be used.
@@ -156,7 +157,6 @@ Functionality to Implement/Finish
       - Allow .length() to be applied to vectors and matrices, returning the number of components or columns.
       + Clarify that .length() returns an int type and can be used as a constant integer expression.
       - Allow swizzle operations on scalars.
-      - Even the potential for recursion through subroutine uniforms is an error.
       - Positive signed decimal literals, as well as octal and hexadecimal, can set all 32 bits. This includes setting the sign bit to create a negative value.
       - Make GLSL consistent with the API regarding user clipping, by no longer referring to gl_Positionwhen gl_ClipVertex is not written. Rather, user clipping becomes undefined.
       - Minor consistency fixes, corrections
@@ -188,38 +188,29 @@ Functionality to Implement/Finish
         GL_ARB_explicit_uniform_location extension.
       - Accept ES GLSL shader #version statements, which will request ES functionality for ES GLSL 
         versions 100 and 300, as per the GL_ARB_ES3_compatibility extension.
-      - Clarified about 90 errors as being either compile time, link time, or either.
       - Clarify and correct scoping rules to what would normally be expected and what was intended. 
         (Function parameters and body nest inside global space. Loop variables and body nest inside 
         loop scope.)
       - There are no digraphs (trigraphs were already disallowed).
       - Remove the CPP difference that it is a compile-time error to use #if or #elif on expressions 
         containing undefined macro names. This reverts back to following expected CPP behavior.
-      - Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniformsto 8.
+      - Set both gl_MaxFragmentImageUniformsand gl_MaxCombinedImageUniforms to 8.
       - Clarify textureSize() for cube map arrays.
       - For layout qualifiers,
             - make negative output locations a compile-time error, and
             - make indexes outside the range [0,1] a compile-time error.
-      - Allow mismatches in interpolation and auxiliary qualification across stages.
-      - Remove cross-version linking restrictions.
       - Add textureQueryLevels() built-ins to query the number of mipmap levels, as per the 
         GL_ARB_texture_query_levels extension.
       - Make gl_Layer and gl_ViewportIndex also be inputs to the fragment shader, as per the 
         GL_ARB_fragment_layer_viewport extension.
-      - Be explicit that compile-time constant expressions evaluating on the host may get a different 
-        value than the same expression on the target. Also reinforce that compile-time constant 
-        expressions are evaluated as if precise and invariantwere used.
       - Add more examples and rules to be more specific about the required behavior of the precise 
         qualifier.
       - Clarify fragment output variables cannot be double precision.
-      - Clarify that \93floating-point\94 generally means both single- and double-precision and be more 
-        consistent with that.
-      - Be clear that early_fragment_tests is only needed in one fragment-stage compilation unit.
       - Allow the new shared keyword to be in layout-qualifier-id, allowing backward compatibility 
         with the shared identifier that was previously used.
       + Added overlooked texture function float textureOffset (sampler2DArrayShadow sampler, vec4 P, vec2 offset [, float bias] ).
       + Add missing type in grammar, ATOMIC_UINT, and missing qualifiers COHERENT, VOLATILE, RESTRICT, READONLY, and WRITEONLY.
-         - do version checking for the above
+      - do version checking for the above
       + Add missing initializer lists to grammar.
     GLSL 4.4
       - Incorporate the ARB_enhanced_layouts extension, which adds
index 45b81d8..dd6f5bb 100644 (file)
@@ -188,7 +188,6 @@ xcopy /y $(IntDir)$(TargetName)$(TargetExt) Test</Command>
   <ItemGroup>\r
     <ClInclude Include="glslang\MachineIndependent\glslang_tab.cpp.h" />\r
     <ClInclude Include="glslang\MachineIndependent\Initialize.h" />\r
-    <ClInclude Include="glslang\MachineIndependent\MMap.h" />\r
     <ClInclude Include="glslang\MachineIndependent\ParseHelper.h" />\r
     <ClInclude Include="glslang\MachineIndependent\preprocessor\PpContext.h" />\r
     <ClInclude Include="glslang\MachineIndependent\preprocessor\PpTokens.h" />\r
index fa45e1f..8e98fe6 100644 (file)
     <ClInclude Include="glslang\MachineIndependent\Initialize.h">\r
       <Filter>Machine Independent</Filter>\r
     </ClInclude>\r
-    <ClInclude Include="glslang\MachineIndependent\MMap.h">\r
-      <Filter>Machine Independent</Filter>\r
-    </ClInclude>\r
     <ClInclude Include="glslang\MachineIndependent\ParseHelper.h">\r
       <Filter>Machine Independent</Filter>\r
     </ClInclude>\r
index b3f592a..965c4bd 100644 (file)
@@ -37,6 +37,8 @@
 #ifndef _BASICTYPES_INCLUDED_
 #define _BASICTYPES_INCLUDED_
 
+namespace glslang {
+
 //
 // Basic type.  Arrays, vectors, sampler details, etc., are orthogonal to this.
 //
@@ -97,7 +99,7 @@ enum TStorageQualifier {
 };
 
 // These will show up in error messages
-__inline const char* getStorageQualifierString(TStorageQualifier q) 
+__inline const char* GetStorageQualifierString(TStorageQualifier q) 
 {
     switch (q) {
     case EvqTemporary:      return "temporary";      break;
@@ -133,7 +135,7 @@ enum TPrecisionQualifier {
     EpqHigh
 };
 
-__inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
+__inline const char* GetPrecisionQualifierString(TPrecisionQualifier p)
 {
     switch(p) {
     case EpqNone:   return "";        break;
@@ -144,4 +146,6 @@ __inline const char* getPrecisionQualifierString(TPrecisionQualifier p)
     }
 }
 
+} // end namespace glslang
+
 #endif // _BASICTYPES_INCLUDED_
index ee1bc75..fcfe1e2 100644 (file)
@@ -85,6 +85,8 @@
 #define TBaseList std::list
 #define TBaseSet std::set
 
+namespace glslang {
+
 //
 // Pool version of string.
 //
@@ -170,4 +172,6 @@ typedef TMap<TString, TString>::tAllocator TPragmaTableAllocator;
 
 const int GlslangMaxTokenLength = 1024;
 
+} // end namespace glslang
+
 #endif // _COMMON_INCLUDED_
index b50b230..6868d11 100644 (file)
@@ -37,8 +37,9 @@
 #ifndef _CONSTANT_UNION_INCLUDED_
 #define _CONSTANT_UNION_INCLUDED_
 
+namespace glslang {
 
-class constUnion {
+class TConstUnion {
 public:
 
     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@@ -103,7 +104,7 @@ public:
         return false;
     }
 
-    bool operator==(const constUnion& constant) const
+    bool operator==(const TConstUnion& constant) const
     {
         if (constant.type != type)
             return false;
@@ -156,12 +157,12 @@ public:
         return !operator==(b);
     }
 
-    bool operator!=(const constUnion& constant) const
+    bool operator!=(const TConstUnion& constant) const
     {
         return !operator==(constant);
     }
 
-    bool operator>(const constUnion& constant) const
+    bool operator>(const TConstUnion& constant) const
     { 
         assert(type == constant.type);
         switch (type) {
@@ -188,7 +189,7 @@ public:
         return false;
     }
 
-    bool operator<(const constUnion& constant) const
+    bool operator<(const TConstUnion& constant) const
     { 
         assert(type == constant.type);
         switch (type) {
@@ -215,9 +216,9 @@ public:
         return false;
     }
 
-    constUnion operator+(const constUnion& constant) const
+    TConstUnion operator+(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt: returnValue.setIConst(iConst + constant.iConst); break;
@@ -229,9 +230,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator-(const constUnion& constant) const
+    TConstUnion operator-(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt: returnValue.setIConst(iConst - constant.iConst); break;
@@ -243,9 +244,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator*(const constUnion& constant) const
+    TConstUnion operator*(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt: returnValue.setIConst(iConst * constant.iConst); break;
@@ -257,9 +258,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator%(const constUnion& constant) const
+    TConstUnion operator%(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt:  returnValue.setIConst(iConst % constant.iConst); break;
@@ -270,9 +271,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator>>(const constUnion& constant) const
+    TConstUnion operator>>(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         switch (type) {
         case EbtInt:
             switch (constant.type) {
@@ -294,9 +295,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator<<(const constUnion& constant) const
+    TConstUnion operator<<(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         switch (type) {
         case EbtInt:
             switch (constant.type) {
@@ -318,9 +319,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator&(const constUnion& constant) const
+    TConstUnion operator&(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt:  returnValue.setIConst(iConst & constant.iConst); break;
@@ -331,9 +332,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator|(const constUnion& constant) const
+    TConstUnion operator|(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt:  returnValue.setIConst(iConst | constant.iConst); break;
@@ -344,9 +345,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator^(const constUnion& constant) const
+    TConstUnion operator^(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtInt:  returnValue.setIConst(iConst ^ constant.iConst); break;
@@ -357,9 +358,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator~() const
+    TConstUnion operator~() const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         switch (type) {
         case EbtInt:  returnValue.setIConst(~iConst); break;
         case EbtUint: returnValue.setUConst(~uConst); break;
@@ -369,9 +370,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator&&(const constUnion& constant) const
+    TConstUnion operator&&(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtBool: returnValue.setBConst(bConst && constant.bConst); break;
@@ -381,9 +382,9 @@ public:
         return returnValue;
     }
 
-    constUnion operator||(const constUnion& constant) const
+    TConstUnion operator||(const TConstUnion& constant) const
     { 
-        constUnion returnValue;
+        TConstUnion returnValue;
         assert(type == constant.type);
         switch (type) {
         case EbtBool: returnValue.setBConst(bConst || constant.bConst); break;
@@ -406,4 +407,6 @@ private:
     TBasicType type;
 };
 
+} // end namespace glslang
+
 #endif // _CONSTANT_UNION_INCLUDED_
index a251182..7c988d5 100644 (file)
@@ -38,6 +38,8 @@
 #include "../Include/Common.h"
 #include <math.h>
 
+namespace glslang {
+
 //
 // TPrefixType is used to centralize how info log messages start.
 // See below.
@@ -131,10 +133,12 @@ protected:
     int outputStream;
 };
 
+} // end namespace glslang
+
 class TInfoSink {
 public:
-    TInfoSinkBase info;
-    TInfoSinkBase debug;
+    glslang::TInfoSinkBase info;
+    glslang::TInfoSinkBase debug;
 };
 
 #endif // _INFOSINK_INCLUDED_
index dc1ef91..b9a8304 100644 (file)
 #ifndef __INITIALIZE_GLOBALS_INCLUDED_
 #define __INITIALIZE_GLOBALS_INCLUDED_
 
+namespace glslang {
+
 void InitializeGlobalPools();
 void FreeGlobalPools();
 bool InitializePoolIndex();
 void FreePoolIndex();
 
+} // end namespace glslang
+
 #endif // __INITIALIZE_GLOBALS_INCLUDED_
index 5d222fc..34d494f 100644 (file)
@@ -65,6 +65,8 @@
 #include <string.h>
 #include <vector>
 
+namespace glslang {
+
 // If we are using guard blocks, we must track each indivual
 // allocation.  If we aren't using guard blocks, these
 // never get instantiated, so won't have any impact.
@@ -316,4 +318,6 @@ protected:
     TPoolAllocator& allocator;
 };
 
+} // end namespace glslang
+
 #endif // _POOLALLOC_INCLUDED_
index bc60592..70ff2a1 100644 (file)
@@ -58,4 +58,5 @@ struct TBuiltInResource {
     int minProgramTexelOffset;
     int maxProgramTexelOffset;
 };
+
 #endif // _RESOURCE_LIMITS_INCLUDED_
index 3a8420a..659dbec 100644 (file)
@@ -52,7 +52,6 @@ class TCompiler;
 class TLinker;
 class TUniformMap;
 
-
 //
 // The base class used to back handles returned to the driver.
 //
@@ -78,6 +77,7 @@ public:
     virtual TInfoSink& getInfoSink() { return infoSink; }
     TInfoSink infoSink;
 };
+
 class TIntermNode;
 
 //
@@ -105,8 +105,8 @@ protected:
 //
 // Link operations are base on a list of compile results...
 //
-typedef TVector<TCompiler*> TCompilerList;
-typedef TVector<TShHandleBase*> THandleList;
+typedef glslang::TVector<TCompiler*> TCompilerList;
+typedef glslang::TVector<TShHandleBase*> THandleList;
 
 //
 // The base class for the machine dependent linker to derive from
index f8427b9..6ff2ba9 100644 (file)
@@ -40,6 +40,8 @@
 #include "../Include/Common.h"
 #include "../Include/BaseTypes.h"
 
+namespace glslang {
+
 const int GlslangMaxTypeLength = 200;
 
 //
@@ -680,8 +682,8 @@ public:
             return getBasicString();
     }
 
-    const char* getStorageQualifierString() const { return ::getStorageQualifierString(qualifier.storage); }
-    const char* getPrecisionQualifierString() const { return ::getPrecisionQualifierString(qualifier.precision); }
+    const char* getStorageQualifierString() const { return GetStorageQualifierString(qualifier.storage); }
+    const char* getPrecisionQualifierString() const { return GetPrecisionQualifierString(qualifier.precision); }
     TTypeList* getStruct() { return structure; }
     TTypeList* getStruct() const { return structure; }
 
@@ -753,4 +755,6 @@ protected:
        TString *typeName;          // for structure field type name
 };
 
+} // end namespace glslang
+
 #endif // _TYPES_INCLUDED_
index 4c7cf1c..50ec8e4 100644 (file)
@@ -50,6 +50,8 @@
 #include "../Include/Types.h"
 #include "../Include/ConstantUnion.h"
 
+namespace glslang {
+
 //
 // Operators used by the high-level (parse tree) representation.
 //
@@ -324,34 +326,41 @@ class TIntermBranch;
 class TIntermTyped;
 class TIntermMethod;
 class TIntermSymbol;
-class TInfoSink;
+
+} // end namespace glslang
 
 //
 // Base class for the tree nodes
 //
+// (Put outside the glslang namespace, as it's used as part of the external interface.)
+//
 class TIntermNode {
 public:
-    POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
+    POOL_ALLOCATOR_NEW_DELETE(glslang::GetThreadPoolAllocator())
 
     TIntermNode() { loc.line = 0; loc.string = 0; }
-    virtual TSourceLoc getLoc() const { return loc; }
-    virtual void setLoc(TSourceLoc l) { loc = l; }
-    virtual void traverse(TIntermTraverser*) = 0;
-    virtual TIntermTyped*     getAsTyped()         { return 0; }
-    virtual TIntermConstantUnion*     getAsConstantUnion()         { return 0; }
-    virtual TIntermAggregate* getAsAggregate()     { return 0; }
-    virtual TIntermUnary*     getAsUnaryNode()     { return 0; }
-    virtual TIntermBinary*    getAsBinaryNode()    { return 0; }
-    virtual TIntermSelection* getAsSelectionNode() { return 0; }
-    virtual TIntermSwitch*    getAsSwitchNode()    { return 0; }
-    virtual TIntermMethod*    getAsMethodNode()    { return 0; }
-    virtual TIntermSymbol*    getAsSymbolNode()    { return 0; }
-    virtual TIntermBranch*    getAsBranchNode()    { return 0; }
+    virtual glslang::TSourceLoc getLoc() const { return loc; }
+    virtual void setLoc(glslang::TSourceLoc l) { loc = l; }
+    virtual void traverse(glslang::TIntermTraverser*) = 0;
+    virtual glslang::TIntermTyped*     getAsTyped()         { return 0; }
+    virtual glslang::TIntermConstantUnion*     getAsConstantUnion()         { return 0; }
+    virtual glslang::TIntermAggregate* getAsAggregate()     { return 0; }
+    virtual glslang::TIntermUnary*     getAsUnaryNode()     { return 0; }
+    virtual glslang::TIntermBinary*    getAsBinaryNode()    { return 0; }
+    virtual glslang::TIntermSelection* getAsSelectionNode() { return 0; }
+    virtual glslang::TIntermSwitch*    getAsSwitchNode()    { return 0; }
+    virtual glslang::TIntermMethod*    getAsMethodNode()    { return 0; }
+    virtual glslang::TIntermSymbol*    getAsSymbolNode()    { return 0; }
+    virtual glslang::TIntermBranch*    getAsBranchNode()    { return 0; }
     virtual ~TIntermNode() { }
 protected:
-    TSourceLoc loc;
+    glslang::TSourceLoc loc;
 };
 
+class TInfoSink;
+
+namespace glslang {
+
 //
 // This is just to help yacc.
 //
@@ -465,15 +474,15 @@ protected:
 
 class TIntermConstantUnion : public TIntermTyped {
 public:
-    TIntermConstantUnion(constUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
-    constUnion* getUnionArrayPointer() const { return unionArrayPointer; }
-    void setUnionArrayPointer(constUnion *c) { unionArrayPointer = c; }
+    TIntermConstantUnion(TConstUnion *unionPointer, const TType& t) : TIntermTyped(t), unionArrayPointer(unionPointer) { }
+    TConstUnion* getUnionArrayPointer() const { return unionArrayPointer; }
+    void setUnionArrayPointer(TConstUnion *c) { unionArrayPointer = c; }
     virtual TIntermConstantUnion* getAsConstantUnion()  { return this; }
     virtual void traverse(TIntermTraverser* );
     virtual TIntermTyped* fold(TOperator, TIntermTyped*, TInfoSink&);
     virtual TIntermTyped* fold(TOperator, const TType&, TInfoSink&);
 protected:
-    constUnion *unionArrayPointer;
+    TConstUnion *unionArrayPointer;
 };
 
 //
@@ -646,4 +655,6 @@ public:
     bool rightToLeft;
 };
 
+} // end namespace glslang
+
 #endif // __INTERMEDIATE_H
index d110513..dcccf16 100644 (file)
 #include <cfloat>
 #include <cstdlib>
 
-namespace glslang {
+namespace {
+
+using namespace glslang;
+
+// Some helper functions
 
 bool isNan(double x)
 {
@@ -59,17 +63,12 @@ bool isInf(double x)
            (bitPatternH & 0xFFFFF) == 0 && bitPatternL == 0;
 }
 
-};
-
-namespace {
-
-// Some helper functions
-
 const double pi = 3.1415926535897932384626433832795;
 
-bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray);
+// forward reference for mutual recursion
+bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray);
 
-bool CompareStructure(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray)
+bool CompareStructure(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
 {
     if (leftNodeType.isArray()) {
         TType typeWithoutArrayness(leftNodeType);
@@ -88,7 +87,7 @@ bool CompareStructure(const TType& leftNodeType, constUnion* rightUnionArray, co
     return true;
 }
 
-bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, constUnion* leftUnionArray)
+bool CompareStruct(const TType& leftNodeType, TConstUnion* rightUnionArray, TConstUnion* leftUnionArray)
 {
     TTypeList* fields = leftNodeType.getStruct();
 
@@ -112,7 +111,10 @@ bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, const
     return true;
 }
 
-}; // end anonymous namespace
+} // end anonymous namespace
+
+
+namespace glslang {
 
 //
 // The fold functions see if an operation on a constant can be done in place,
@@ -129,9 +131,9 @@ bool CompareStruct(const TType& leftNodeType, constUnion* rightUnionArray, const
 //
 TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNode, TInfoSink& infoSink)
 {
-    constUnion *unionArray = getUnionArrayPointer();
+    TConstUnion *unionArray = getUnionArrayPointer();
     int objectSize = getType().getObjectSize();
-    constUnion* newConstArray = 0;
+    TConstUnion* newConstArray = 0;
 
     // For most cases, the return type matches the argument type, so set that
     // up and just code to exceptions below.
@@ -142,17 +144,17 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
     //
 
     TIntermConstantUnion *node = constantNode->getAsConstantUnion();
-    constUnion *rightUnionArray = node->getUnionArrayPointer();
+    TConstUnion *rightUnionArray = node->getUnionArrayPointer();
 
     if (constantNode->getType().getObjectSize() == 1 && objectSize > 1) {
         // for a case like float f = vec4(2,3,4,5) + 1.2;
-        rightUnionArray = new constUnion[objectSize];
+        rightUnionArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; ++i)
             rightUnionArray[i] = *node->getUnionArrayPointer();
     } else if (constantNode->getType().getObjectSize() > 1 && objectSize == 1) {
         // for a case like float f = 1.2 + vec4(2,3,4,5);
         rightUnionArray = node->getUnionArrayPointer();
-        unionArray = new constUnion[constantNode->getType().getObjectSize()];
+        unionArray = new TConstUnion[constantNode->getType().getObjectSize()];
         for (int i = 0; i < constantNode->getType().getObjectSize(); ++i)
             unionArray[i] = *getUnionArrayPointer();
         returnType = node->getType();
@@ -163,12 +165,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
     bool boolNodeFlag = false;
     switch(op) {
     case EOpAdd:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] + rightUnionArray[i];
         break;
     case EOpSub:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] - rightUnionArray[i];
         break;
@@ -176,12 +178,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
     case EOpMul:
     case EOpVectorTimesScalar:
     case EOpMatrixTimesScalar:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] * rightUnionArray[i];
         break;
     case EOpMatrixTimesMatrix:
-        newConstArray = new constUnion[getMatrixRows() * node->getMatrixCols()];
+        newConstArray = new TConstUnion[getMatrixRows() * node->getMatrixCols()];
         for (int row = 0; row < getMatrixRows(); row++) {
             for (int column = 0; column < node->getMatrixCols(); column++) {
                 double sum = 0.0f;
@@ -193,7 +195,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
         returnType = TType(getType().getBasicType(), EvqConst, 0, getMatrixRows(), node->getMatrixCols());
         break;
     case EOpDiv:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++) {
             switch (getType().getBasicType()) {
             case EbtFloat:
@@ -221,7 +223,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
         break;
 
     case EOpMatrixTimesVector:
-        newConstArray = new constUnion[getMatrixRows()];
+        newConstArray = new TConstUnion[getMatrixRows()];
         for (int i = 0; i < getMatrixRows(); i++) {
             double sum = 0.0f;
             for (int j = 0; j < node->getVectorSize(); j++) {
@@ -234,7 +236,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
         break;
 
     case EOpVectorTimesMatrix:
-        newConstArray = new constUnion[node->getMatrixCols()];
+        newConstArray = new TConstUnion[node->getMatrixCols()];
         for (int i = 0; i < node->getMatrixCols(); i++) {
             double sum = 0.0f;
             for (int j = 0; j < getVectorSize(); j++)
@@ -246,53 +248,53 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
         break;
 
     case EOpMod:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] % rightUnionArray[i];
         break;
 
     case EOpRightShift:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] >> rightUnionArray[i];
         break;
 
     case EOpLeftShift:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] << rightUnionArray[i];
         break;
 
     case EOpAnd:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] & rightUnionArray[i];
         break;
     case EOpInclusiveOr:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] | rightUnionArray[i];
         break;
     case EOpExclusiveOr:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] ^ rightUnionArray[i];
         break;
 
     case EOpLogicalAnd: // this code is written for possible future use, will not get executed currently
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] && rightUnionArray[i];
         break;
 
     case EOpLogicalOr: // this code is written for possible future use, will not get executed currently
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++)
             newConstArray[i] = unionArray[i] || rightUnionArray[i];
         break;
 
     case EOpLogicalXor:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
         for (int i = 0; i < objectSize; i++) {
             switch (getType().getBasicType()) {
             case EbtBool: newConstArray[i].setBConst((unionArray[i] == rightUnionArray[i]) ? false : true); break;
@@ -303,22 +305,22 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
 
     case EOpLessThan:
         assert(objectSize == 1);
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         newConstArray->setBConst(*unionArray < *rightUnionArray);
         returnType = TType(EbtBool, EvqConst);
         break;
     case EOpGreaterThan:
         assert(objectSize == 1);
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         newConstArray->setBConst(*unionArray > *rightUnionArray);
         returnType = TType(EbtBool, EvqConst);
         break;
     case EOpLessThanEqual:
     {
         assert(objectSize == 1);
-        constUnion constant;
+        TConstUnion constant;
         constant.setBConst(*unionArray > *rightUnionArray);
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         newConstArray->setBConst(!constant.getBConst());
         returnType = TType(EbtBool, EvqConst);
         break;
@@ -326,9 +328,9 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
     case EOpGreaterThanEqual:
     {
         assert(objectSize == 1);
-        constUnion constant;
+        TConstUnion constant;
         constant.setBConst(*unionArray < *rightUnionArray);
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         newConstArray->setBConst(!constant.getBConst());
         returnType = TType(EbtBool, EvqConst);
         break;
@@ -347,7 +349,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
             }
         }
 
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         newConstArray->setBConst(! boolNodeFlag);
         returnType = TType(EbtBool, EvqConst);
         break;
@@ -365,7 +367,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
             }
         }
 
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         newConstArray->setBConst(! boolNodeFlag);
         returnType = TType(EbtBool, EvqConst);
         break;
@@ -387,19 +389,19 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, TIntermTyped* constantNod
 //
 TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType, TInfoSink& infoSink)
 {
-    constUnion *unionArray = getUnionArrayPointer();
+    TConstUnion *unionArray = getUnionArrayPointer();
     int objectSize = getType().getObjectSize();
 
     // First, size the result, which is mostly the same as the argument's size,
     // but not always.
-    constUnion* newConstArray;
+    TConstUnion* newConstArray;
     switch (op) {
     // TODO: functionality: constant folding: finish listing exceptions to size here
     case EOpDeterminant:
     case EOpAny:
     case EOpAll:
     case EOpLength:
-        newConstArray = new constUnion[1];
+        newConstArray = new TConstUnion[1];
         break;
 
     case EOpEmitStreamVertex:
@@ -408,7 +410,7 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
         return 0;
 
     default:
-        newConstArray = new constUnion[objectSize];
+        newConstArray = new TConstUnion[objectSize];
     }
 
     // Process non-component-wise operations
@@ -565,12 +567,12 @@ TIntermTyped* TIntermConstantUnion::fold(TOperator op, const TType& returnType,
 
         case EOpIsNan:
         {
-            newConstArray[i].setBConst(glslang::isNan(unionArray[i].getDConst()));
+            newConstArray[i].setBConst(isNan(unionArray[i].getDConst()));
             break;
         }
         case EOpIsInf:
         {
-            newConstArray[i].setBConst(glslang::isInf(unionArray[i].getDConst()));
+            newConstArray[i].setBConst(isInf(unionArray[i].getDConst()));
             break;
         }
 
@@ -664,9 +666,9 @@ TIntermTyped* TIntermediate::fold(TIntermAggregate* aggrNode)
     default:
         return aggrNode;
     }
-    constUnion* newConstArray = new constUnion[objectSize];
+    TConstUnion* newConstArray = new TConstUnion[objectSize];
 
-    TVector<constUnion*> childConstUnions;
+    TVector<TConstUnion*> childConstUnions;
     for (unsigned int i = 0; i < children.size(); ++i)
         childConstUnions.push_back(children[i]->getAsConstantUnion()->getUnionArrayPointer());
 
@@ -736,7 +738,7 @@ TIntermTyped* TIntermediate::foldConstructor(TIntermAggregate* aggrNode)
 {
     bool returnVal = false;
 
-    constUnion* unionArray = new constUnion[aggrNode->getType().getObjectSize()];
+    TConstUnion* unionArray = new TConstUnion[aggrNode->getType().getObjectSize()];
     if (aggrNode->getSequence().size() == 1)
         returnVal = parseConstTree(aggrNode->getLoc(), aggrNode, unionArray, aggrNode->getOp(), aggrNode->getType(), true);
     else
@@ -747,3 +749,5 @@ TIntermTyped* TIntermediate::foldConstructor(TIntermAggregate* aggrNode)
 
     return addConstantUnion(unionArray, aggrNode->getType(), aggrNode->getLoc());
 }
+
+} // end namespace glslang
index 17a906d..3a4175b 100644 (file)
@@ -36,6 +36,8 @@
 
 #include <string.h>
 
+namespace glslang {
+
 void TInfoSinkBase::append(const char *s)           
 {
     if (outputStream & EString) {
@@ -103,3 +105,5 @@ void TInfoSinkBase::append(const TString& t)
     if (outputStream & EStdOut)
         fprintf(stdout, "%s", t.c_str());
 }
+
+} // end namespace glslang
index e1f8b6c..16ccd96 100644 (file)
@@ -43,6 +43,8 @@
 #include "../Include/intermediate.h"
 #include "Initialize.h"
 
+namespace glslang {
+
 const int FirstProfileVersion = 150;
 const bool ForwardCompatibility = false;
 
@@ -1663,3 +1665,5 @@ void IdentifyBuiltIns(int version, EProfile profile, EShLanguage language, TSymb
         break;
     }
 }
+
+} // end namespace glslang
index ef2986d..52deee4 100644 (file)
@@ -43,6 +43,8 @@
 #include "SymbolTable.h"
 #include "Versions.h"
 
+namespace glslang {
+
 class TBuiltIns {
 public:
     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@@ -71,4 +73,6 @@ protected:
 void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&);
 void IdentifyBuiltIns(int version, EProfile profile, EShLanguage, TSymbolTable&, const TBuiltInResource &resources);
 
+} // end namespace glslang
+
 #endif // _INITIALIZE_INCLUDED_
index 5659867..f609ff7 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "../Include/intermediate.h"
 
+namespace glslang {
+
 //
 // Traverse the intermediate representation tree, and
 // call a node type specific function for each node.
@@ -275,3 +277,5 @@ void TIntermSwitch::traverse(TIntermTraverser* it)
     if (visit && it->postVisit && it->visitSwitch)
         it->visitSwitch(false, this, it);
 }
+
+} // end namespace glslang
index c8faade..ea5b08c 100644 (file)
@@ -43,6 +43,8 @@
 #include "RemoveTree.h"
 #include <float.h>
 
+namespace glslang {
+
 ////////////////////////////////////////////////////////////////////////////
 //
 // First set of functions are to help build the intermediate representation.
@@ -794,7 +796,7 @@ TIntermTyped* TIntermediate::addSelection(TIntermTyped* cond, TIntermTyped* true
 // Returns the constant union node created.
 //
 
-TIntermConstantUnion* TIntermediate::addConstantUnion(constUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
+TIntermConstantUnion* TIntermediate::addConstantUnion(TConstUnion* unionArrayPointer, const TType& t, TSourceLoc loc)
 {
     TIntermConstantUnion* node = new TIntermConstantUnion(unionArrayPointer, t);
     node->setLoc(loc);
@@ -810,10 +812,10 @@ TIntermTyped* TIntermediate::addSwizzle(TVectorFields& fields, TSourceLoc loc)
     node->setLoc(loc);
     TIntermConstantUnion* constIntNode;
     TIntermSequence &sequenceVector = node->getSequence();
-    constUnion* unionArray;
+    TConstUnion* unionArray;
 
     for (int i = 0; i < fields.num; i++) {
-        unionArray = new constUnion[1];
+        unionArray = new TConstUnion[1];
         unionArray->setIConst(fields.offsets[i]);
         constIntNode = addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
         sequenceVector.push_back(constIntNode);
@@ -1398,10 +1400,10 @@ TIntermTyped* TIntermediate::promoteConstantUnion(TBasicType promoteTo, TIntermC
     if (node->getType().isArray())
         infoSink.info.message(EPrefixInternalError, "Cannot promote array", node->getLoc());
 
-    constUnion *rightUnionArray = node->getUnionArrayPointer();
+    TConstUnion *rightUnionArray = node->getUnionArrayPointer();
     int size = node->getType().getObjectSize();
 
-    constUnion *leftUnionArray = new constUnion[size];
+    TConstUnion *leftUnionArray = new TConstUnion[size];
 
     for (int i=0; i < size; i++) {        
         switch (promoteTo) {
@@ -1526,3 +1528,4 @@ void TIntermAggregate::addToPragmaTable(const TPragmaTable& pTable)
     *pragmaTable = pTable;
 }
 
+} // end namespace glslang
diff --git a/glslang/MachineIndependent/MMap.h b/glslang/MachineIndependent/MMap.h
deleted file mode 100644 (file)
index 82254f0..0000000
+++ /dev/null
@@ -1,84 +0,0 @@
-//
-//Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
-//All rights reserved.
-//
-//Redistribution and use in source and binary forms, with or without
-//modification, are permitted provided that the following conditions
-//are met:
-//
-//    Redistributions of source code must retain the above copyright
-//    notice, this list of conditions and the following disclaimer.
-//
-//    Redistributions in binary form must reproduce the above
-//    copyright notice, this list of conditions and the following
-//    disclaimer in the documentation and/or other materials provided
-//    with the distribution.
-//
-//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
-//    contributors may be used to endorse or promote products derived
-//    from this software without specific prior written permission.
-//
-//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
-//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
-//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
-//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
-//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
-//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
-//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-//POSSIBILITY OF SUCH DAMAGE.
-//
-
-#ifndef _MMAP_INCLUDED_
-#define _MMAP_INCLUDED_
-
-//
-// Encapsulate memory mapped files
-//
-
-class TMMap {
-public:
-    TMMap(const char* fileName) : 
-        fSize(-1), // -1 is the error value returned by GetFileSize()
-        fp(NULL),
-        fBuff(0)   // 0 is the error value returned by MapViewOfFile()
-    {
-        if ((fp = fopen(fileName, "r")) == NULL)
-            return;
-        char c = getc(fp);
-        fSize = 0;
-        while (c != EOF) {
-            fSize++;
-            c = getc(fp);
-        }
-        if (c == EOF)
-            fSize++;
-        rewind(fp);
-        fBuff = (char*)malloc(sizeof(char) * fSize);
-        int count = 0;
-        c = getc(fp);
-        while (c != EOF) {
-            fBuff[count++] = c;
-            c = getc(fp);
-        }
-        fBuff[count++] = c;
-    }
-
-    char* getData() { return fBuff; }
-    int   getSize() { return fSize; }
-
-    ~TMMap() {
-        if (fp != NULL)
-            fclose(fp);
-    }
-    
-private:
-    int             fSize;      // size of file to map in
-    FILE *fp;
-    char*           fBuff;      // the actual data;
-};
-
-#endif // _MMAP_INCLUDED_
index 88eeaba..f2429ae 100644 (file)
 
 #include "preprocessor/PpContext.h"
 
+extern int yyparse(void*);
+
+namespace glslang {
+
 TParseContext::TParseContext(TSymbolTable& symt, TIntermediate& interm, bool pb, int v, EProfile p, EShLanguage L, TInfoSink& is,                             
                              bool fc, EShMessages m) : 
             intermediate(interm), symbolTable(symt), infoSink(is), language(L), treeRoot(0), linkage(0),
@@ -104,8 +108,6 @@ const char* TParseContext::getPreamble()
         return 0;
 }
 
-extern int yyparse(void*);
-
 //
 // Parse an array of strings using yyparse, going through the
 // preprocessor to tokenize the shader strings, then through
@@ -458,7 +460,7 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
         // it was a member of an anonymous container, have to insert its dereference
         TVariable* variable = anon->getAnonContainer().getAsVariable();
         TIntermTyped* container = intermediate.addSymbol(variable->getUniqueId(), variable->getName(), variable->getType(), loc);
-        constUnion* unionArray = new constUnion[1];
+        TConstUnion* unionArray = new TConstUnion[1];
         unionArray->setUConst(anon->getMemberNumber());
         TIntermTyped* constNode = intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), loc);
 
@@ -478,7 +480,7 @@ TIntermTyped* TParseContext::handleVariable(TSourceLoc loc, TSymbol* symbol, TSt
         // pop will reclaim the memory
 
         if (variable->getType().getQualifier().storage == EvqConst ) {
-            constUnion* constArray = variable->getConstUnionPointer();
+            TConstUnion* constArray = variable->getConstUnionPointer();
             TType t(variable->getType());
             node = intermediate.addConstantUnion(constArray, t, loc);
         } else
@@ -547,7 +549,7 @@ TIntermTyped* TParseContext::handleBracketDereference(TSourceLoc loc, TIntermTyp
     }
 
     if (result == 0) {
-        constUnion *unionArray = new constUnion[1];
+        TConstUnion *unionArray = new TConstUnion[1];
         unionArray->setDConst(0.0);
         result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
     } else {
@@ -595,7 +597,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
                 result->setType(TType(base->getBasicType(), EvqConst, (int) (field).size()));
         } else {
             if (fields.num == 1) {
-                constUnion *unionArray = new constUnion[1];
+                TConstUnion *unionArray = new TConstUnion[1];
                 unionArray->setIConst(fields.offsets[0]);
                 TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
                 result = intermediate.addIndex(EOpIndexDirect, base, index, loc);
@@ -634,7 +636,7 @@ TIntermTyped* TParseContext::handleDotDereference(TSourceLoc loc, TIntermTyped*
                         result->getTypePointer()->getQualifier().storage = EvqConst;
                     }
                 } else {
-                    constUnion *unionArray = new constUnion[1];
+                    TConstUnion *unionArray = new TConstUnion[1];
                     unionArray->setIConst(i);
                     TIntermTyped* index = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
                     result = intermediate.addIndex(EOpIndexDirectStruct, base, index, loc);
@@ -756,7 +758,7 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* fnCal
         } else
             length = intermNode->getAsTyped()->getType().getArraySize();
 
-        constUnion *unionArray = new constUnion[1];
+        TConstUnion *unionArray = new TConstUnion[1];
         unionArray->setIConst(length);
         result = intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), loc);
     } else if (op != EOpNull) {
@@ -831,7 +833,7 @@ TIntermTyped* TParseContext::handleFunctionCall(TSourceLoc loc, TFunction* fnCal
         } else {
             // error message was put out by PaFindFunction()
             // Put on a dummy node for error recovery
-            constUnion *unionArray = new constUnion[1];
+            TConstUnion *unionArray = new TConstUnion[1];
             unionArray->setDConst(0.0);
             result = intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), loc);
         }
@@ -1408,14 +1410,14 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
     // now, knowing it is a shader in/out, do all the in/out semantic checks
 
     if (publicType.basicType == EbtBool) {
-        error(loc, "cannot be bool",  getStorageQualifierString(qualifier.storage), "");
+        error(loc, "cannot be bool", GetStorageQualifierString(qualifier.storage), "");
 
         return;
     }
 
     if (language == EShLangVertex && qualifier.storage == EvqVaryingIn) {
         if (publicType.basicType == EbtStruct) {
-            error(loc, "cannot be a structure or array",  getStorageQualifierString(qualifier.storage), "");
+            error(loc, "cannot be a structure or array", GetStorageQualifierString(qualifier.storage), "");
 
             return;
         }
@@ -1428,7 +1430,7 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
     if (language == EShLangFragment && qualifier.storage == EvqVaryingOut) {
         profileRequires(loc, EEsProfile, 300, 0, "fragment shader output");
         if (publicType.basicType == EbtStruct) {
-            error(loc, "cannot be a structure",  getStorageQualifierString(qualifier.storage), "");
+            error(loc, "cannot be a structure", GetStorageQualifierString(qualifier.storage), "");
 
             return;
         }
@@ -1438,7 +1440,7 @@ void TParseContext::globalQualifierFix(TSourceLoc loc, TQualifier& qualifier, co
         profileRequires(loc, EEsProfile, 300, 0, "shader input/output");
         if (language != EShLangVertex   && qualifier.storage == EvqVaryingIn  && ! qualifier.flat ||
             language != EShLangFragment && qualifier.storage == EvqVaryingOut && ! qualifier.flat) {
-            error(loc, "must be qualified as 'flat'", getStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
+            error(loc, "must be qualified as 'flat'", GetStorageQualifierString(qualifier.storage), TType::getBasicString(publicType.basicType));
          
             return;
         }
@@ -1498,11 +1500,11 @@ void TParseContext::mergeQualifiers(TSourceLoc loc, TQualifier& dst, const TQual
              dst.storage == EvqConst && src.storage == EvqIn)
         dst.storage = EvqConstReadOnly;
     else if (src.storage != EvqTemporary)
-        error(loc, "too many storage qualifiers", getStorageQualifierString(src.storage), "");
+        error(loc, "too many storage qualifiers", GetStorageQualifierString(src.storage), "");
 
     // Precision qualifiers
     if (! force && src.precision != EpqNone && dst.precision != EpqNone)
-        error(loc, "only one precision qualifier allowed", getPrecisionQualifierString(src.precision), "");
+        error(loc, "only one precision qualifier allowed", GetPrecisionQualifierString(src.precision), "");
     if (dst.precision == EpqNone || force && src.precision != EpqNone)
         dst.precision = src.precision;
 
@@ -1882,7 +1884,7 @@ void TParseContext::paramCheck(TSourceLoc loc, TStorageQualifier qualifier, TTyp
         break;
     default:
         type->getQualifier().storage = EvqIn;
-        error(loc, "qualifier not allowed on function parameter", getStorageQualifierString(qualifier), "");
+        error(loc, "qualifier not allowed on function parameter", GetStorageQualifierString(qualifier), "");
         break;
     }
 }
@@ -2050,7 +2052,7 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier,
             return true;
         }
         if (initializer->getAsConstantUnion()) { 
-            constUnion* unionArray = variable->getConstUnionPointer();
+            TConstUnion* unionArray = variable->getConstUnionPointer();
 
             if (type.getObjectSize() == 1 && type.getBasicType() != EbtStruct) {
                    *unionArray = (initializer->getAsConstantUnion()->getUnionArrayPointer())[0];
@@ -2060,7 +2062,7 @@ bool TParseContext::executeInitializerError(TSourceLoc loc, TString& identifier,
         } else if (initializer->getAsSymbolNode()) {
             TSymbol* symbol = symbolTable.find(initializer->getAsSymbolNode()->getName());
             if (TVariable* tVar = symbol->getAsVariable()) {
-                constUnion* constArray = tVar->getConstUnionPointer();
+                TConstUnion* constArray = tVar->getConstUnionPointer();
                 variable->shareConstPointer(constArray);
             } else {
                 error(loc, "expected variable", initializer->getAsSymbolNode()->getName().c_str(), "");
@@ -2563,12 +2565,12 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
     TIntermTyped* typedNode;
     TIntermConstantUnion* tempConstantNode = node->getAsConstantUnion();
 
-    constUnion *unionArray;
+    TConstUnion *unionArray;
     if (tempConstantNode) {
         unionArray = tempConstantNode->getUnionArrayPointer();
 
         if (!unionArray) {  // this error message should never be raised
-            infoSink.info.message(EPrefixInternalError, "constUnion not initialized in addConstVectorNode function", loc);
+            infoSink.info.message(EPrefixInternalError, "TConstUnion not initialized in addConstVectorNode function", loc);
 
             return node;
         }
@@ -2578,7 +2580,7 @@ TIntermTyped* TParseContext::addConstVectorNode(TVectorFields& fields, TIntermTy
         return 0;
     }
 
-    constUnion* constArray = new constUnion[fields.num];
+    TConstUnion* constArray = new TConstUnion[fields.num];
 
     for (int i = 0; i < fields.num; i++) {
         if (fields.offsets[i] >= node->getType().getObjectSize()) {
@@ -2610,7 +2612,7 @@ TIntermTyped* TParseContext::addConstMatrixNode(int index, TIntermTyped* node, T
     }
 
     if (tempConstantNode) {
-         constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
+         TConstUnion* unionArray = tempConstantNode->getUnionArrayPointer();
          int size = tempConstantNode->getType().getMatrixRows();
          // Note: the type is corrected (dereferenced) by the caller
          typedNode = intermediate.addConstantUnion(&unionArray[size*index], tempConstantNode->getType(), loc);
@@ -2646,7 +2648,7 @@ TIntermTyped* TParseContext::addConstArrayNode(int index, TIntermTyped* node, TS
     int arrayElementSize = arrayElementType.getObjectSize();
 
     if (tempConstantNode) {
-         constUnion* unionArray = tempConstantNode->getUnionArrayPointer();
+         TConstUnion* unionArray = tempConstantNode->getUnionArrayPointer();
          typedNode = intermediate.addConstantUnion(&unionArray[arrayElementSize * index], tempConstantNode->getType(), loc);
     } else {
         error(loc, "Cannot offset into the array", "Error", "");
@@ -2680,7 +2682,7 @@ TIntermTyped* TParseContext::addConstStruct(TString& identifier, TIntermTyped* n
     }
 
     if (tempConstantNode) {
-         constUnion* constArray = tempConstantNode->getUnionArrayPointer();
+         TConstUnion* constArray = tempConstantNode->getUnionArrayPointer();
 
          typedNode = intermediate.addConstantUnion(constArray+instanceSize, tempConstantNode->getType(), loc); // type will be changed in the calling function
     } else {
@@ -2704,3 +2706,5 @@ void TParseContext::initializeExtensionBehavior()
     extensionBehavior["GL_ARB_texture_rectangle"] = EBhDisable;
     extensionBehavior["GL_3DL_array_objects"] = EBhDisable;
 }
+
+} // end namespace glslang
index 68b8b01..78357d8 100644 (file)
@@ -41,6 +41,8 @@
 #include "SymbolTable.h"
 #include "localintermediate.h"
 
+namespace glslang {
+
 typedef enum {
     EBhRequire,
     EBhEnable,
@@ -55,12 +57,9 @@ struct TPragma {
        TPragmaTable pragmaTable;
 };
 
+class TScanContext;
 class TPpContext;
 
-namespace glslang {
-    class TScanContext;
-};
-
 //
 // The following are extra variables needed during parsing, grouped together so
 // they can be passed to the parser without needing a global.
@@ -70,7 +69,7 @@ public:
     TParseContext(TSymbolTable&, TIntermediate&, bool parsingBuiltins, int version, EProfile, EShLanguage, TInfoSink&,
                   bool forwardCompatible = false, EShMessages messages = EShMsgDefault);
 
-    glslang::TScanContext* scanContext;
+    TScanContext* scanContext;
     TPpContext* ppContext;
     TIntermediate& intermediate; // to hold and build a parse tree
     TSymbolTable& symbolTable;   // symbol table that goes with the current language, version, and profile
@@ -200,4 +199,6 @@ public:
     void doubleCheck(TSourceLoc, const char* op);
 };
 
+} // end namespace glslang
+
 #endif // _PARSER_HELPER_INCLUDED_
index 4a88429..1554624 100644 (file)
@@ -38,6 +38,8 @@
 #include "Include/InitializeGlobals.h"
 #include "osinclude.h"
 
+namespace glslang {
+
 OS_TLSIndex PoolIndex;
 
 void InitializeGlobalPools()
@@ -333,3 +335,5 @@ void TAllocation::checkAllocList() const
     for (const TAllocation* alloc = this; alloc != 0; alloc = alloc->prevAlloc)
         alloc->check();
 }
+
+} // end namespace glslang
index ea56fa3..e6c632f 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "../Include/intermediate.h"
 
+namespace glslang {
+
 class TAliveTraverser : public TIntermTraverser {
 public:
     TAliveTraverser(TStorageQualifier q) : TIntermTraverser(), found(false), qualifier(q)
@@ -92,4 +94,6 @@ bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
     return true;
 }
 
+} // end namespace glslang
+
 #endif
index eb777e2..ac172da 100644 (file)
@@ -32,4 +32,8 @@
 //POSSIBILITY OF SUCH DAMAGE.
 //
 
+namespace glslang {
+
 bool QualifierWritten(TIntermNode* root, TStorageQualifier);
+
+} // end namespace glslang
index 2b1d8f9..8b5220d 100644 (file)
@@ -36,6 +36,9 @@
 
 #include "../Include/intermediate.h"
 #include "RemoveTree.h"
+
+namespace glslang {
+
 //
 // Code to recursively delete the intermediate tree.
 //
@@ -106,3 +109,4 @@ void RemoveAllTreeNodes(TIntermNode* root)
     root->traverse(&it);
 }
 
+} // end namespace glslang
index a6d70b4..483b25d 100644 (file)
@@ -32,4 +32,8 @@
 //POSSIBILITY OF SUCH DAMAGE.
 //
 
+namespace glslang {
+
 void RemoveAllTreeNodes(TIntermNode*);
+
+} // end namespace glslang
index 1017431..d13e566 100644 (file)
@@ -230,10 +230,6 @@ bool ScanVersion(TInputScanner& input, int& version, EProfile& profile)
     return foundNonSpaceTab;
 }
 
-}; // end glslang namespace
-
-namespace glslang {
-
 // Fill this in when doing glslang-level scanning, to hand back to the parser.
 class TParserToken {
 public:
@@ -242,10 +238,10 @@ public:
     YYSTYPE& sType;
 };
 
-} // end namespace glslang
+} // end namespace glslang
 
 // This is the function the glslang parser (i.e., bison) calls to get its next token
-int yylex(YYSTYPE* glslangTokenDesc, TParseContext& parseContext)
+int yylex(YYSTYPE* glslangTokenDesc, glslang::TParseContext& parseContext)
 {
     glslang::TParserToken token(*glslangTokenDesc);
 
@@ -1012,4 +1008,4 @@ int TScanContext::secondGenerationImage()
     return identifierOrType();
 }
 
-};
+} // end namespace glslang
index 81a6fb3..8d812eb 100644 (file)
@@ -112,4 +112,4 @@ bool ConsumeComment(TInputScanner& input);
 void ConsumeWhitespaceComment(TInputScanner& input, bool& foundNonSpaceTab);
 bool ScanVersion(TInputScanner& input, int& version, EProfile& profile);
 
-}; // end glslang namespace
+} // end namespace glslang
index d99df22..cf2ad2a 100644 (file)
 
 #include "ParseHelper.h"
 
-class TPpContext;
-class TPpToken;
-
 namespace glslang {
 
+class TPpContext;
+class TPpToken;
 class TParserToken;
 
 class TScanContext {
@@ -79,4 +78,4 @@ protected:
     int keyword;
 };
 
-};
+} // end namespace glslang
index 0d1c9cc..188a24c 100644 (file)
@@ -57,6 +57,8 @@
 
 namespace { // anonymous namespace for file-local functions and symbols
 
+using namespace glslang;
+
 int MapVersionToIndex(int version)
 {
         switch(version) {
@@ -105,7 +107,7 @@ bool InitializeSymbolTable(const TString& builtIns, int version, EProfile profil
        
     TParseContext parseContext(symbolTable, intermediate, true, version, profile, language, infoSink);
     TPpContext ppContext(parseContext);
-    glslang::TScanContext scanContext(parseContext);
+    TScanContext scanContext(parseContext);
     parseContext.scanContext = &scanContext;
     parseContext.ppContext = &ppContext;
     
@@ -310,7 +312,7 @@ bool DeduceProfile(TInfoSink& infoSink, int version, EProfile& profile)
     return true;
 }
 
-}; // end anonymous namespace for local functions
+} // end anonymous namespace for local functions
 
 //
 // ShInitialize() should be called exactly once per process, not per thread.
index 8fde88d..b6e4ced 100644 (file)
@@ -41,6 +41,8 @@
 
 #include "SymbolTable.h"
 
+namespace glslang {
+
 //
 // TType helper function needs a place to live.
 //
@@ -222,7 +224,7 @@ TVariable::TVariable(const TVariable& copyOf, TStructureMap& remapper) : TSymbol
        if (copyOf.unionArray) {                
                assert(!copyOf.type.getStruct());
                assert(copyOf.type.getObjectSize() == 1);
-               unionArray = new constUnion[1];
+               unionArray = new TConstUnion[1];
         unionArray[0] = copyOf.unionArray[0];
        } else
                unionArray = 0;
@@ -283,3 +285,5 @@ void TSymbolTable::copyTable(const TSymbolTable& copyOf)
        for (unsigned int i = 0; i < copyOf.table.size(); ++i)
                table.push_back(copyOf.table[i]->clone(remapper));
 }
+
+} // end namespace glslang
index d807213..b885b8e 100644 (file)
@@ -69,6 +69,8 @@
 #include "../Include/intermediate.h"
 #include "../Include/InfoSink.h"
 
+namespace glslang {
+
 //
 // Symbol base class.  (Can build functions or variables out of these...)
 //
@@ -126,16 +128,16 @@ public:
 
     virtual void dump(TInfoSink &infoSink) const;
 
-    constUnion* getConstUnionPointer() {
+    TConstUnion* getConstUnionPointer() {
         if (!unionArray)
-            unionArray = new constUnion[type.getObjectSize()];
+            unionArray = new TConstUnion[type.getObjectSize()];
 
         return unionArray;
     }
 
-    constUnion* getConstUnionPointer() const { return unionArray; }
+    TConstUnion* getConstUnionPointer() const { return unionArray; }
 
-    void shareConstPointer( constUnion *constArray)
+    void shareConstPointer( TConstUnion *constArray)
     {
         delete unionArray;
         unionArray = constArray;
@@ -150,7 +152,7 @@ protected:
     bool userType;
     // we are assuming that Pool Allocator will free the memory allocated to unionArray
     // when this object is destroyed
-    constUnion *unionArray;
+    TConstUnion *unionArray;
     TType *arrayInformationType;  // this is used for updating maxArraySize in all the references to a given symbol
 };
 
@@ -479,4 +481,6 @@ protected:
     unsigned int adoptedLevels;
 };
 
+} // end namespace glslang
+
 #endif // _SYMBOL_TABLE_INCLUDED_
index cfcc931..25e9267 100644 (file)
@@ -44,6 +44,8 @@
 
 #include "ParseHelper.h"
 
+namespace glslang {
+
 const char* StageName[EShLangCount] = {
     "vertex",
     "tessellation control",
@@ -164,3 +166,5 @@ void TParseContext::doubleCheck(TSourceLoc loc, const char* op)
     profileRequires(loc, ECoreProfile, 400, 0, op);
     profileRequires(loc, ECompatibilityProfile, 400, 0, op);
 }
+
+} // end namespace glslang
index 763f9f4..1a55023 100644 (file)
@@ -35,8 +35,8 @@
 //\r
 \r
 /**\r
- * This is bison grammar and production code for parsing the OpenGL 2.0 shading\r
- * languages.\r
+ * This is bison grammar and productions for parsing all versions of the \r
+ * GLSL shading languages.\r
  */\r
 %{\r
 \r
@@ -59,37 +59,39 @@ Jutta Degener, 1995
 #include "ParseHelper.h"\r
 #include "../Public/ShaderLang.h"\r
 \r
+using namespace glslang;\r
+\r
 %}\r
 \r
 %union {\r
     struct {\r
-        TSourceLoc loc;\r
+        glslang::TSourceLoc loc;\r
         union {\r
-            TString *string;\r
+            glslang::TString *string;\r
             int i;\r
             unsigned int u;\r
             bool b;\r
             double d;\r
         };\r
-        TSymbol* symbol;\r
+        glslang::TSymbol* symbol;\r
     } lex;\r
     struct {\r
-        TSourceLoc loc;\r
-        TOperator op;\r
+        glslang::TSourceLoc loc;\r
+        glslang::TOperator op;\r
         union {\r
             TIntermNode* intermNode;\r
-            TIntermNodePair nodePair;\r
-            TIntermTyped* intermTypedNode;\r
-            TIntermAggregate* intermAggregate;\r
+            glslang::TIntermNodePair nodePair;\r
+            glslang::TIntermTyped* intermTypedNode;\r
+            glslang::TIntermAggregate* intermAggregate;\r
         };\r
         union {\r
-            TPublicType type;\r
-            TFunction* function;\r
-            TParameter param;\r
-            TTypeLoc typeLine;\r
-            TTypeList* typeList;\r
-            TArraySizes arraySizes;\r
-            TIdentifierList* identifierList;\r
+            glslang::TPublicType type;\r
+            glslang::TFunction* function;\r
+            glslang::TParameter param;\r
+            glslang::TTypeLoc typeLine;\r
+            glslang::TTypeList* typeList;\r
+            glslang::TArraySizes arraySizes;\r
+            glslang::TIdentifierList* identifierList;\r
         };\r
     } interm;\r
 }\r
@@ -224,29 +226,29 @@ primary_expression
         $$ = $1;\r
     }\r
     | INTCONSTANT {\r
-        constUnion *unionArray = new constUnion[1];\r
+        TConstUnion *unionArray = new TConstUnion[1];\r
         unionArray->setIConst($1.i);\r
         $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtInt, EvqConst), $1.loc);\r
     }\r
     | UINTCONSTANT {        \r
         parseContext.fullIntegerCheck($1.loc, "unsigned literal");\r
-        constUnion *unionArray = new constUnion[1];\r
+        TConstUnion *unionArray = new TConstUnion[1];\r
         unionArray->setUConst($1.u);\r
         $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtUint, EvqConst), $1.loc);\r
     }\r
     | FLOATCONSTANT {\r
-        constUnion *unionArray = new constUnion[1];\r
+        TConstUnion *unionArray = new TConstUnion[1];\r
         unionArray->setDConst($1.d);\r
         $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtFloat, EvqConst), $1.loc);\r
     }\r
     | DOUBLECONSTANT {\r
         parseContext.doubleCheck($1.loc, "double literal");\r
-        constUnion *unionArray = new constUnion[1];\r
+        TConstUnion *unionArray = new TConstUnion[1];\r
         unionArray->setDConst($1.d);\r
         $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtDouble, EvqConst), $1.loc);\r
     }\r
     | BOOLCONSTANT {\r
-        constUnion *unionArray = new constUnion[1];\r
+        TConstUnion *unionArray = new TConstUnion[1];\r
         unionArray->setBConst($1.b);\r
         $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $1.loc);\r
     }\r
@@ -511,7 +513,7 @@ relational_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpLessThan, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "<", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -520,7 +522,7 @@ relational_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThan, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, ">", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -529,7 +531,7 @@ relational_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpLessThanEqual, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "<=", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -538,7 +540,7 @@ relational_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpGreaterThanEqual, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, ">=", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -551,7 +553,7 @@ equality_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpEqual, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "==", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         } else if (($1->isArray() || $3->isArray()))\r
@@ -561,7 +563,7 @@ equality_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpNotEqual, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "!=", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         } else if (($1->isArray() || $3->isArray()))\r
@@ -611,7 +613,7 @@ logical_and_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpLogicalAnd, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "&&", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -624,7 +626,7 @@ logical_xor_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpLogicalXor, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "^^", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -637,7 +639,7 @@ logical_or_expression
         $$ = parseContext.intermediate.addBinaryMath(EOpLogicalOr, $1, $3, $2.loc);\r
         if ($$ == 0) {\r
             parseContext.binaryOpError($2.loc, "||", $1->getCompleteString(), $3->getCompleteString());\r
-            constUnion *unionArray = new constUnion[1];\r
+            TConstUnion *unionArray = new TConstUnion[1];\r
             unionArray->setBConst(false);\r
             $$ = parseContext.intermediate.addConstantUnion(unionArray, TType(EbtBool, EvqConst), $2.loc);\r
         }\r
@@ -871,7 +873,7 @@ function_header
     : fully_specified_type IDENTIFIER LEFT_PAREN {\r
         if ($1.qualifier.storage != EvqGlobal && $1.qualifier.storage != EvqTemporary) {\r
             parseContext.error($2.loc, "no qualifiers allowed for function return",\r
-                               getStorageQualifierString($1.qualifier.storage), "");\r
+                               GetStorageQualifierString($1.qualifier.storage), "");\r
         }\r
 \r
         // Add the function as a prototype after parsing it (we do not support recursion)\r
index 89d6be2..b290a76 100644 (file)
@@ -36,6 +36,8 @@
 
 #include "localintermediate.h"
 
+namespace glslang {
+
 //
 // Two purposes:
 // 1.  Show an example of how to iterate tree.  Functions can
@@ -584,3 +586,5 @@ void TIntermediate::outputTree(TIntermNode* root)
 
     root->traverse(&it);
 }
+
+} // end namespace glslang
index 4538dea..9d2c096 100644 (file)
@@ -40,6 +40,8 @@
 #include "SymbolTable.h"
 #include "Versions.h"
 
+namespace glslang {
+
 struct TVectorFields {
     int offsets[4];
     int num;
@@ -48,7 +50,6 @@ struct TVectorFields {
 //
 // Set of helper functions to help parse and build the tree.
 //
-class TInfoSink;
 class TIntermediate {
 public:    
     POOL_ALLOCATOR_NEW_DELETE(GetThreadPoolAllocator())
@@ -74,9 +75,9 @@ public:
     TIntermTyped* addSelection(TIntermTyped* cond, TIntermTyped* trueBlock, TIntermTyped* falseBlock, TSourceLoc);
     TIntermTyped* addComma(TIntermTyped* left, TIntermTyped* right, TSourceLoc);
     TIntermTyped* addMethod(TIntermTyped*, const TType&, const TString*, TSourceLoc);
-    TIntermConstantUnion* addConstantUnion(constUnion*, const TType&, TSourceLoc);
+    TIntermConstantUnion* addConstantUnion(TConstUnion*, const TType&, TSourceLoc);
     TIntermTyped* promoteConstantUnion(TBasicType, TIntermConstantUnion*) ;
-    bool parseConstTree(TSourceLoc, TIntermNode*, constUnion*, TOperator, const TType&, bool singleConstantParam = false);
+    bool parseConstTree(TSourceLoc, TIntermNode*, TConstUnion*, TOperator, const TType&, bool singleConstantParam = false);
     TIntermNode* addLoop(TIntermNode*, TIntermTyped*, TIntermTyped*, bool testFirst, TSourceLoc);
     TIntermBranch* addBranch(TOperator, TSourceLoc);
     TIntermBranch* addBranch(TOperator, TIntermTyped*, TSourceLoc);
@@ -97,4 +98,6 @@ private:
     void operator=(TIntermediate&); // prevent assignments
 };
 
+} // end namespace glslang
+
 #endif // _LOCAL_INTERMEDIATE_INCLUDED_
index 84b5bb0..6f04fa3 100644 (file)
 
 #include "ParseHelper.h"
 
+namespace glslang {
+
 //
 // Use this class to carry along data from node to node in 
 // the traversal
 //
 class TConstTraverser : public TIntermTraverser {
 public:
-    TConstTraverser(constUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
+    TConstTraverser(TConstUnion* cUnion, bool singleConstParam, TOperator constructType, TInfoSink& sink, const TType& t) : unionArray(cUnion), type(t),
         constructorType(constructType), singleConstantParam(singleConstParam), infoSink(sink), error(false), isMatrix(false), 
         matrixCols(0), matrixRows(0) {  index = 0; tOp = EOpNull;}
     int index ;
-    constUnion *unionArray;
+    TConstUnion *unionArray;
     TOperator tOp;
     const TType& type;
     TOperator constructorType;
@@ -173,7 +175,7 @@ bool ParseSelection(bool /* preVisit */, TIntermSelection* node, TIntermTraverse
 void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
 {
     TConstTraverser* oit = static_cast<TConstTraverser*>(it);
-    constUnion* leftUnionArray = oit->unionArray;
+    TConstUnion* leftUnionArray = oit->unionArray;
     int instanceSize = oit->type.getObjectSize();
 
     if (oit->index >= instanceSize)
@@ -182,7 +184,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
     if (!oit->singleConstantParam) {
         int size = node->getType().getObjectSize();
     
-        constUnion *rightUnionArray = node->getUnionArrayPointer();
+        TConstUnion *rightUnionArray = node->getUnionArrayPointer();
         for (int i=0; i < size; i++) {
             if (oit->index >= instanceSize)
                 return;
@@ -198,7 +200,7 @@ void ParseConstantUnion(TIntermConstantUnion* node, TIntermTraverser* it)
         matrixRows = oit->matrixRows;
         isMatrix = oit->isMatrix;
         totalSize = oit->index + size;
-        constUnion *rightUnionArray = node->getUnionArrayPointer();
+        TConstUnion *rightUnionArray = node->getUnionArrayPointer();
         if (!isMatrix) {
             int count = 0;
             for (int i = oit->index; i < totalSize; i++) {
@@ -255,7 +257,7 @@ bool ParseBranch(bool /* previsit*/, TIntermBranch* node, TIntermTraverser* it)
 // Individual functions can be initialized to 0 to skip processing of that
 // type of node.  It's children will still be processed.
 //
-bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
+bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, TConstUnion* unionArray, TOperator constructorType, const TType& t, bool singleConstantParam)
 {
     if (root == 0)
         return false;
@@ -277,3 +279,5 @@ bool TIntermediate::parseConstTree(TSourceLoc line, TIntermNode* root, constUnio
     else
         return false;
 }
+
+} // end namespace glslang
index 3f2b689..98406c5 100644 (file)
@@ -94,6 +94,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #undef malloc
 #undef free
 
+namespace glslang {
+
 int TPpContext::InitCPP()
 {
     TPpContext::AtomTable* atable = &atomTable;
@@ -821,8 +823,8 @@ void TPpContext::FreeMacro(MacroSymbol *s) {
     DeleteTokenStream(s->body);
 }
 
-static int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
-static void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
+int eof_scan(TPpContext*, TPpContext::InputSrc* in, TPpToken* yylvalpp) { return -1; }
+void noop(TPpContext*, TPpContext::InputSrc* in, int ch, TPpToken* yylvalpp) { }
 
 void TPpContext::PushEofSrc()
 {
@@ -1074,3 +1076,5 @@ int TPpContext::ChkCorrectElseNesting()
 
     return 0;
 }
+
+} // end namespace glslang
\ No newline at end of file
index 379f25c..bb3502f 100644 (file)
@@ -94,11 +94,15 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #undef realloc
 #undef free
 
+namespace {
+
+using namespace glslang;
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 ////////////////////////////////////////// String table: //////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
-static const struct {
+const struct {
     int val;
     const char *str;
 } tokens[] = {
@@ -135,7 +139,6 @@ static const struct {
 * InitStringTable() - Initialize the string table.
 *
 */
-
 int InitStringTable(TPpContext::StringTable *stable)
 {
     stable->strings = (char *) malloc(INIT_STRING_TABLE_SIZE);
@@ -151,7 +154,6 @@ int InitStringTable(TPpContext::StringTable *stable)
 * FreeStringTable() - Free the string table.
 *
 */
-
 void FreeStringTable(TPpContext::StringTable *stable)
 {
     if (stable->strings)
@@ -165,8 +167,7 @@ void FreeStringTable(TPpContext::StringTable *stable)
 * HashString() - Hash a string with the base hash function.
 *
 */
-
-static int HashString(const char *s)
+int HashString(const char *s)
 {
     int hval = 0;
 
@@ -181,8 +182,7 @@ static int HashString(const char *s)
 * HashString2() - Hash a string with the incrimenting hash function.
 *
 */
-
-static int HashString2(const char *s)
+int HashString2(const char *s)
 {
     int hval = 0;
 
@@ -197,8 +197,7 @@ static int HashString2(const char *s)
 * AddString() - Add a string to a string table.  Return it's offset.
 *
 */
-
-static int AddString(TPpContext::StringTable *stable, const char *s)
+int AddString(TPpContext::StringTable *stable, const char *s)
 {
     int len, loc;
     char *str;
@@ -227,8 +226,7 @@ static int AddString(TPpContext::StringTable *stable, const char *s)
 * InitHashTable() - Initialize the hash table.
 *
 */
-
-static int InitHashTable(TPpContext::HashTable *htable, int fsize)
+int InitHashTable(TPpContext::HashTable *htable, int fsize)
 {
     int ii;
 
@@ -250,8 +248,7 @@ static int InitHashTable(TPpContext::HashTable *htable, int fsize)
 * FreeHashTable() - Free the hash table.
 *
 */
-
-static void FreeHashTable(TPpContext::HashTable *htable)
+void FreeHashTable(TPpContext::HashTable *htable)
 {
     if (htable->entry)
         free(htable->entry);
@@ -264,8 +261,7 @@ static void FreeHashTable(TPpContext::HashTable *htable)
 * Empty() - See if a hash table entry is empty.
 *
 */
-
-static int Empty(TPpContext::HashTable *htable, int hashloc)
+int Empty(TPpContext::HashTable *htable, int hashloc)
 {
     assert(hashloc >= 0 && hashloc < htable->size);
     if (htable->entry[hashloc].index == 0) {
@@ -279,8 +275,7 @@ static int Empty(TPpContext::HashTable *htable, int hashloc)
 * Match() - See if a hash table entry is matches a string.
 *
 */
-
-static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
+int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable, const char *s, int hashloc)
 {
     int strloc;
 
@@ -302,7 +297,6 @@ static int Match(TPpContext::HashTable *htable, TPpContext::StringTable *stable,
 * GrowAtomTable() - Grow the atom table to at least "size" if it's smaller.
 *
 */
-
 int GrowAtomTable(TPpContext::AtomTable *atable, int size)
 {
     int *newmap, *newrev;
@@ -337,8 +331,7 @@ int GrowAtomTable(TPpContext::AtomTable *atable, int size)
 * lReverse() - Reverse the bottom 20 bits of a 32 bit int.
 *
 */
-
-static int lReverse(int fval)
+int lReverse(int fval)
 {
     unsigned int in = fval;
     int result = 0, cnt = 0;
@@ -362,7 +355,6 @@ static int lReverse(int fval)
 * AllocateAtom() - Allocate a new atom.  Associated with the "undefined" value of -1.
 *
 */
-
 int AllocateAtom(TPpContext::AtomTable *atable)
 {
     if (atable->nextFree >= atable->size)
@@ -377,7 +369,6 @@ int AllocateAtom(TPpContext::AtomTable *atable)
 * SetAtomValue() - Allocate a new atom associated with "hashindex".
 *
 */
-
 void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
 {
     atable->amap[atomnumber] = atable->htable.entry[hashindex].index;
@@ -388,7 +379,6 @@ void SetAtomValue(TPpContext::AtomTable *atable, int atomnumber, int hashindex)
 * FindHashLoc() - Find the hash location for this string.  Return -1 it hash table is full.
 *
 */
-
 int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
 {
     int hashloc, hashdelta, count;
@@ -438,11 +428,14 @@ int FindHashLoc(TPpContext::AtomTable *atable, const char *s)
     return hashloc;
 } // FindHashLoc
 
+} // end anonymous namespace
+
+namespace glslang {
+
 /*
 * IncreaseHashTableSize()
 *
 */
-
 int TPpContext::IncreaseHashTableSize(AtomTable *atable)
 {
     int ii, strloc, oldhashloc, value, size;
@@ -705,7 +698,4 @@ void TPpContext::FreeAtomTable(AtomTable *atable)
     atable->size = 0;
 } // FreeAtomTable
 
-///////////////////////////////////////////////////////////////////////////////////////////////
-///////////////////////////////////////// End of atom.c ///////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
+} // end namespace glslang
index 1021d63..7a630f0 100644 (file)
@@ -81,6 +81,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "PpContext.h"
 
+namespace glslang {
+
 TPpContext::TPpContext(TParseContext& pc) : 
     parseContext(pc), preamble(0), strings(0), notAVersionToken(false),
     ScopeList(0), CurrentScope(0), GlobalScope(0)
@@ -124,3 +126,5 @@ void TPpContext::setShaderStrings(char* s[], int l[], int n)
         currentString = 0;
     }
 }
+
+} // end namespace glslang
index 5e228a1..a434fa1 100644 (file)
@@ -80,6 +80,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 #include "../ParseHelper.h"
 
+namespace glslang {
+
 class TPpToken {
 public:
     static const int maxTokenLength = 1024;
@@ -386,5 +388,6 @@ protected:
     int mem_AddCleanup(MemoryPool *p, void (*fn)(void *, void*), void *arg1, void* arg2);
 };
 
-#endif  // PPCONTEXT_H
+} // end namespace glslang
 
+#endif  // PPCONTEXT_H
index e59f242..15ef756 100644 (file)
@@ -91,6 +91,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #undef malloc
 #undef free
 
+namespace glslang {
+
 struct chunk {
     struct chunk        *next;
 };
@@ -184,3 +186,5 @@ int TPpContext::mem_AddCleanup(MemoryPool *pool, void (*fn)(void *, void*), void
     pool->cleanup = cleanup;
     return 0;
 }
+
+} // end namespace glslang
index 9da73d8..6f819eb 100644 (file)
@@ -89,13 +89,24 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "PpContext.h"
 #include "PpTokens.h"
 
-static int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
+namespace {
+
+using namespace glslang;
+
+int eof_scan(TPpContext*, TPpContext::InputSrc*, TPpToken*)
 {
     return EOF;
-} // eof_scan
+}
+
+void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
+{
+}
 
-static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {}
-static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
+TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
+
+} // end anonymous namespace
+
+namespace glslang {
 
 int TPpContext::InitScanner(TPpContext *cpp)
 {
@@ -831,7 +842,4 @@ int TPpContext::check_EOF(int token)
     return 0;
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////// End of scanner.c //////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
-
+} // end namespace glslang
index 45ea537..204825d 100644 (file)
@@ -90,7 +90,11 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 /////////////////////////////////// Symbol Table Variables: ///////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
-static void unlinkScope(void *_scope, void* scopeList)
+namespace {
+
+using namespace glslang;
+
+void unlinkScope(void *_scope, void* scopeList)
 {
     TPpContext::Scope *scope = (TPpContext::Scope*)_scope;
 
@@ -102,6 +106,10 @@ static void unlinkScope(void *_scope, void* scopeList)
         *(TPpContext::Scope**)scopeList = scope->next;
 }
 
+} // end anonymous namespace
+
+namespace glslang {
+
 /*
 * NewScope()
 *
@@ -315,3 +323,4 @@ TPpContext::Symbol* TPpContext::LookUpSymbol(Scope *fScope, int atom)
     return NULL;
 } // LookUpSymbol
 
+} // end namespace glslang
index 13a91b5..7adca67 100644 (file)
@@ -92,6 +92,8 @@ NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #include "PpContext.h"
 #include "PpTokens.h"
 
+namespace glslang {
+
 ///////////////////////////////////////////////////////////////////////////////////////////////
 //////////////////////// Preprocessor and Token Recorder and Playback: ////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////
@@ -488,6 +490,4 @@ void TPpContext::DumpTokenStream(FILE *fp, TokenStream *s, TPpToken * yylvalpp)
     }
 }
 
-///////////////////////////////////////////////////////////////////////////////////////////////
-/////////////////////////////////////// End of tokens.c ///////////////////////////////////////
-///////////////////////////////////////////////////////////////////////////////////////////////
+} // end namespace glslang
index f7888d0..6fc8fc3 100644 (file)
@@ -46,6 +46,7 @@
 
 #define _vsnprintf vsnprintf
 
+namespace glslang {
 
 void DetachThreadLinux(void *);
 
@@ -60,7 +61,7 @@ bool        OS_SetTLSValue(OS_TLSIndex nIndex, void *lpvValue);
 bool        OS_FreeTLSIndex(OS_TLSIndex nIndex); 
 
 
-inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
+inline void* OS_GetTLSValue(OS_TLSIndex nIndex)
 {
        //
        // This function should return 0 if nIndex is invalid.
@@ -69,18 +70,18 @@ inline void * OS_GetTLSValue(OS_TLSIndex nIndex)
        return pthread_getspecific(nIndex); 
 }
 
-namespace glslang {
-    void InitGlobalLock();
-    void GetGlobalLock();
-    void ReleaseGlobalLock();
+void InitGlobalLock();
+void GetGlobalLock();
+void ReleaseGlobalLock();
+
+typedef unsigned int (*TThreadEntrypoint)(void*);
+void* OS_CreateThread(TThreadEntrypoint);
+void OS_WaitForAllThreads(void* threads, int numThreads);
 
-    typedef unsigned int (*TThreadEntrypoint)(void*);
-    void* OS_CreateThread(TThreadEntrypoint);
-    void OS_WaitForAllThreads(void* threads, int numThreads);
+void OS_Sleep(int milliseconds);
 
-    void OS_Sleep(int milliseconds);
+void OS_DumpMemoryCounters();
 
-    void OS_DumpMemoryCounters();
-};
+} // end namespace glslang
 
 #endif // __OSINCLUDE_H
index 1f6cbef..f439ddd 100644 (file)
@@ -38,6 +38,8 @@
 #include "osinclude.h"
 #include "InitializeDll.h"
 
+namespace glslang {
+
 //
 // Thread cleanup
 //
@@ -135,25 +137,25 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
                return false;
 }
 
-namespace glslang {
-    // TODO: if we need these on linux, flesh them out
-    void InitGlobalLock() { }
-    void GetGlobalLock() { }
-    void ReleaseGlobalLock() { }
-
-    void* OS_CreateThread(TThreadEntrypoint entry)
-    {
-    }
-
-    void OS_WaitForAllThreads(void* threads, int numThreads)
-    {
-    }
-
-    void OS_Sleep(int milliseconds)
-    {
-    }
-
-    void OS_DumpMemoryCounters()
-    {
-    }
-};
+// TODO: if we need these on linux, flesh them out
+void InitGlobalLock() { }
+void GetGlobalLock() { }
+void ReleaseGlobalLock() { }
+
+void* OS_CreateThread(TThreadEntrypoint entry)
+{
+}
+
+void OS_WaitForAllThreads(void* threads, int numThreads)
+{
+}
+
+void OS_Sleep(int milliseconds)
+{
+}
+
+void OS_DumpMemoryCounters()
+{
+}
+
+} // end namespace glslang
index 7e4d9a3..6d6b0fd 100644 (file)
@@ -45,24 +45,24 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
        {
                case DLL_PROCESS_ATTACH:
 
-            if (!InitProcess())
+            if (! glslang::InitProcess())
                 return FALSE;
             break;
                case DLL_THREAD_ATTACH:
 
-            if (!InitThread())
+            if (! glslang::InitThread())
                 return FALSE;
             break;
 
                case DLL_THREAD_DETACH:
 
-                       if (!DetachThread())
+                       if (! glslang::DetachThread())
                                return FALSE;
                        break;
 
                case DLL_PROCESS_DETACH:
 
-                       DetachProcess();
+                       glslang::DetachProcess();
                        break;
 
                default:
index 63ed3e0..fc19a40 100644 (file)
@@ -44,6 +44,8 @@
 #error Trying to include a windows specific file in a non windows build.
 #endif
 
+namespace glslang {
+
 //
 // Thread Local Storage Operations
 //
@@ -56,18 +58,18 @@ bool        OS_FreeTLSIndex(OS_TLSIndex nIndex);
 
 void* OS_GetTLSValue(OS_TLSIndex nIndex);
 
-namespace glslang {
-    void InitGlobalLock();
-    void GetGlobalLock();
-    void ReleaseGlobalLock();
+void InitGlobalLock();
+void GetGlobalLock();
+void ReleaseGlobalLock();
+
+typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
+void* OS_CreateThread(TThreadEntrypoint);
+void OS_WaitForAllThreads(void* threads, int numThreads);
 
-    typedef unsigned int (__stdcall *TThreadEntrypoint)(void*);
-    void* OS_CreateThread(TThreadEntrypoint);
-    void OS_WaitForAllThreads(void* threads, int numThreads);
+void OS_Sleep(int milliseconds);
 
-    void OS_Sleep(int milliseconds);
+void OS_DumpMemoryCounters();
 
-    void OS_DumpMemoryCounters();
-};
+} // end namespace glslang
 
 #endif // __OSINCLUDE_H
index 5bc3102..4c6caf0 100644 (file)
@@ -50,6 +50,8 @@
 #error Trying to build a windows specific file in a non windows build.
 #endif
 
+namespace glslang {
+
 //
 // Thread Local Storage Operations
 //
@@ -97,44 +99,44 @@ bool OS_FreeTLSIndex(OS_TLSIndex nIndex)
                return false;
 }
 
-namespace glslang {
-    HANDLE GlobalLock;
-
-    void InitGlobalLock()
-    {
-        GlobalLock = CreateMutex(0, false, 0);
-    }
-
-    void GetGlobalLock()
-    {
-        WaitForSingleObject(GlobalLock, INFINITE);
-    }
-
-    void ReleaseGlobalLock()
-    {
-        ReleaseMutex(GlobalLock);
-    }
-
-    void* OS_CreateThread(TThreadEntrypoint entry)
-    {
-        return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
-        //return CreateThread(0, 0, entry, 0, 0, 0);
-    }
-
-    void OS_WaitForAllThreads(void* threads, int numThreads)
-    {
-        WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
-    }
-
-    void OS_Sleep(int milliseconds)
-    {
-        Sleep(milliseconds);
-    }
-
-    void OS_DumpMemoryCounters()
-    {
-        PROCESS_MEMORY_COUNTERS counters;
-        GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
-        printf("Working set size: %d\n", counters.WorkingSetSize);
-    }
-};
+HANDLE GlobalLock;
+
+void InitGlobalLock()
+{
+    GlobalLock = CreateMutex(0, false, 0);
+}
+
+void GetGlobalLock()
+{
+    WaitForSingleObject(GlobalLock, INFINITE);
+}
+
+void ReleaseGlobalLock()
+{
+    ReleaseMutex(GlobalLock);
+}
+
+void* OS_CreateThread(TThreadEntrypoint entry)
+{
+    return (void*)_beginthreadex(0, 0, entry, 0, 0, 0);
+    //return CreateThread(0, 0, entry, 0, 0, 0);
+}
+
+void OS_WaitForAllThreads(void* threads, int numThreads)
+{
+    WaitForMultipleObjects(numThreads, (HANDLE*)threads, true, INFINITE);
+}
+
+void OS_Sleep(int milliseconds)
+{
+    Sleep(milliseconds);
+}
+
+void OS_DumpMemoryCounters()
+{
+    PROCESS_MEMORY_COUNTERS counters;
+    GetProcessMemoryInfo(GetCurrentProcess(), &counters, sizeof(counters));
+    printf("Working set size: %d\n", counters.WorkingSetSize);
+}
+
+} // namespace glslang