Put all glslang internals (but not the external interface) into the glslang namespace.
git-svn-id: https://cvs.khronos.org/svn/repos/ogl/trunk/ecosystem/public/sdk/tools/glslang@22882 e7fa87d3-cd2b-0410-9028-fcbf551c1848
This commit is contained in:
parent
23bdb29eac
commit
b603f918a4
55 changed files with 511 additions and 463 deletions
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
||||
static void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp) {}
|
||||
static TPpContext::InputSrc eof_inputsrc = { 0, &eof_scan, &eof_scan, &noop };
|
||||
void noop(TPpContext*, TPpContext::InputSrc *in, int ch, TPpToken * yylvalpp)
|
||||
{
|
||||
}
|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue