diff options
author | Kim Kibum <kb0929.kim@samsung.com> | 2012-04-29 17:05:54 +0900 |
---|---|---|
committer | Kim Kibum <kb0929.kim@samsung.com> | 2012-04-29 17:05:54 +0900 |
commit | af0ee32ff16f50fd25229151af7b4a9a6753ebe5 (patch) | |
tree | 23879e4123b40df9f773d4775dd64eefd914f4fe /es_2_0 | |
parent | 90dff65a3ccb36853763486671163ca81274b677 (diff) | |
download | simulator-opengl-af0ee32ff16f50fd25229151af7b4a9a6753ebe5.tar.gz simulator-opengl-af0ee32ff16f50fd25229151af7b4a9a6753ebe5.tar.bz2 simulator-opengl-af0ee32ff16f50fd25229151af7b4a9a6753ebe5.zip |
upload tizen1.0 source
Diffstat (limited to 'es_2_0')
37 files changed, 17444 insertions, 0 deletions
diff --git a/es_2_0/Buffer.c b/es_2_0/Buffer.c new file mode 100755 index 0000000..25d1fad --- /dev/null +++ b/es_2_0/Buffer.c @@ -0,0 +1,334 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +#include "es2front.h" +#include "./GLES2/gl2ext.h" + + +void GL_APIENTRY ES2INTER(BufferObjectInit)(struct BufferObjectUnit* pUnit) { + pUnit->bGenerated = GL_FALSE; + pUnit->uSize = 0; + pUnit->eUsage = GL_STATIC_DRAW; + pUnit->pData = NULL; + pUnit->pConverted = NULL; + pUnit->uOffset = 0; +} + +void GL_APIENTRY ES2INTER(BufferObjectRelease)(struct BufferObjectUnit* pUnit) { + if (pUnit->pData != NULL) { + free(pUnit->pData); + } + if (pUnit->pConverted != NULL) { + free(pUnit->pConverted); + } + pUnit->bGenerated = GL_FALSE; + pUnit->uSize = 0; + pUnit->eUsage = GL_STATIC_DRAW; + pUnit->pData = NULL; + pUnit->pConverted = NULL; + pUnit->uOffset = 0; +} + +GLboolean GL_APIENTRY ES2INTER(BufferObjectAssure)(const char* funcname, GLint iMaxIndex) { + register struct BufferObjectUnit* ptr; + register GLint nAllocated; + register int i; + nAllocated = CCV(nBufferObjectAllocated); + if (iMaxIndex < nAllocated) return GL_TRUE; + while (iMaxIndex >= nAllocated) { + nAllocated *= 2; + } + ptr = realloc(CCV(pBufferObject), nAllocated * sizeof(struct BufferObjectUnit)); + if (ptr == NULL) { + SET_ERROR(GL_OUT_OF_MEMORY, "%s: cannot allocate %d bytes\n", + funcname, nAllocated * sizeof(struct BufferObjectUnit)); + return GL_FALSE; + } + for (i = CCV(nBufferObjectAllocated); i < nAllocated; i++) { + ES2INTER(BufferObjectInit)(&(ptr[i])); + } + CCV(pBufferObject) = ptr; + CCV(nBufferObjectAllocated) = nAllocated; + return GL_TRUE; +} + +void GL_APIENTRY ES2ENTRY(GenBuffers)(GLsizei n, GLuint* buffers) { +#define FUNC_NAME "GenBuffers" + register GLint iMaxIndex; + register int i; + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (n == 0) { + return; + } + FNPTR(GenBuffers)(n, buffers); + iMaxIndex = buffers[0]; + for (i = 1; i < n; i++) { + if (iMaxIndex < buffers[i]) iMaxIndex = buffers[i]; + } + if (ES2INTER(BufferObjectAssure)(FUNC_NAME, iMaxIndex) == GL_FALSE) { + return; + } + for (i = 0; i < n; i++) { + int ind = buffers[i]; + CCV(pBufferObject)[ind].bGenerated = GL_TRUE; + } +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(DeleteBuffers)(GLsizei n, const GLuint* buffers) { + register int i, j; + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + for (i = 0; i < n; i++) { + register GLuint iBuffer = buffers[i]; + if (iBuffer != 0 + && iBuffer < CCV(nBufferObjectAllocated) + && CCV(pBufferObject)[iBuffer].bGenerated == GL_TRUE) { + for (j = 0; j < CCV(nMaxVertexAttribs); j++) { + if (CCV(pVertexAttrib[j].uBufferBinding) == iBuffer) { + CCV(pVertexAttrib[j].uBufferBinding) = 0; + } + } + if (CCV(uArrayBufferBinding) == iBuffer) { + CCV(uArrayBufferBinding) = 0; + } + if (CCV(uElementArrayBufferBinding) == iBuffer) { + CCV(uElementArrayBufferBinding) = 0; + } + ES2INTER(BufferObjectRelease)(&(CCV(pBufferObject)[iBuffer])); + } + } + FNPTR(DeleteBuffers)(n, buffers); +} + +GLboolean GL_APIENTRY ES2ENTRY(IsBuffer)(GLuint buffer) { + GLboolean bAnswer, bCheck; + bAnswer = FNPTR(IsBuffer)(buffer); + bCheck = (0 < buffer) && (buffer < CCV(nBufferObjectAllocated) + && CCV(pBufferObject)[buffer].bGenerated == GL_TRUE); + return bAnswer; +} + +void GL_APIENTRY ES2ENTRY(BindBuffer)(GLenum target, GLuint buffer) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ARRAY_BUFFER: + CCV(uArrayBufferBinding) = buffer; + FNPTR(BindBuffer)(target, buffer); + break; + case GL_ELEMENT_ARRAY_BUFFER: + CCV(uElementArrayBufferBinding) = buffer; + FNPTR(BindBuffer)(target, buffer); + break; + } +} + +void GL_APIENTRY ES2ENTRY(GetBufferParameteriv)(GLenum target, GLenum pname, GLint* params) { + register int iBuffer; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ARRAY_BUFFER: + iBuffer = CCV(uArrayBufferBinding); + break; + case GL_ELEMENT_ARRAY_BUFFER: + iBuffer = CCV(uElementArrayBufferBinding); + break; + } + if (iBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_BUFFER_SIZE: + if (iBuffer < CCV(nBufferObjectAllocated) + && CCV(pBufferObject)[iBuffer].bGenerated == GL_TRUE) { + params[0] = (GLint)(CCV(pBufferObject)[iBuffer].uSize); + } else { + params[0] = 0; + } + break; + case GL_BUFFER_USAGE: + if (iBuffer < CCV(nBufferObjectAllocated) + && CCV(pBufferObject)[iBuffer].bGenerated == GL_TRUE) { + params[0] = (GLint)(CCV(pBufferObject)[iBuffer].eUsage); + } else { + params[0] = (GLint)(GL_STATIC_DRAW); + } + break; + case GL_BUFFER_ACCESS_OES: + params[0] = GL_WRITE_ONLY_OES; + break; + case GL_BUFFER_MAPPED_OES: + params[0] = GL_FALSE; + break; + } +} + +void GL_APIENTRY ES2ENTRY(BufferData)(GLenum target, + GLsizeiptr size, const GLvoid* data, GLenum usage) { +#define FUNC_NAME "BufferData" + register struct BufferObjectUnit* pUnit; + int iBuffer; + GLvoid* pData; + GLintptr uOffset; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ARRAY_BUFFER: + iBuffer = CCV(uArrayBufferBinding); + break; + case GL_ELEMENT_ARRAY_BUFFER: + iBuffer = CCV(uElementArrayBufferBinding); + break; + } + if (iBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (size < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + switch (usage) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_STREAM_DRAW: + case GL_STATIC_DRAW: + case GL_DYNAMIC_DRAW: + break; + } + if (ES2INTER(BufferObjectAssure)(FUNC_NAME, iBuffer) == GL_FALSE) { + return; + } + if (CCV(pBufferObject[iBuffer].bGenerated) == GL_FALSE) { + CCV(pBufferObject)[iBuffer].bGenerated = GL_TRUE; + } + pUnit = &(CCV(pBufferObject[iBuffer])); + uOffset = ((size + 3) / 4) * 4; + pData = realloc(pUnit->pData, 2 * uOffset); + if (pData == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return; + } + pUnit->uSize = size; + pUnit->eUsage = usage; + pUnit->pData = pData; + if ((pUnit->pConverted = realloc(pUnit->pConverted, uOffset)) == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return; + } + pUnit->uOffset = uOffset; + if (data != NULL) { + GLfixed* pFixed = (GLfixed*)data; + GLfloat* pFloat = (GLfloat*)((GLubyte*)pData + uOffset); + int nCount = uOffset / sizeof(GLfixed); + while (nCount--) { + register GLfixed xValue = *pFixed++; + register GLfloat fValue = fixed_to_float(xValue); + *pFloat++ = fValue; + } + memcpy(pData, data, size); + FNPTR(BufferData)(target, pUnit->uOffset * 2, pUnit->pData, usage); + pFixed = (GLfixed*)data; + pFloat = (GLfloat*)(pUnit->pConverted); + nCount = uOffset / sizeof(GLfixed); + while (nCount--) { + register GLfixed xValue = *pFixed++; + register GLfloat fValue = fixed_to_float(xValue); + *pFloat++ = fValue; + } + } else { + memset(pData, 0, 2 * pUnit->uOffset); + memset(pUnit->pConverted, 0, pUnit->uOffset); + FNPTR(BufferData)(target, pUnit->uOffset * 2, NULL, usage); + } +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(BufferSubData)(GLenum target, + GLintptr offset, GLsizeiptr size, const GLvoid* data) { +#define FUNC_NAME "BufferSubData" + register struct BufferObjectUnit* pUnit; + int iBuffer; + GLfixed* pFixed; + GLfloat* pFloat; + int nCount; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ARRAY_BUFFER: + iBuffer = CCV(uArrayBufferBinding); + break; + case GL_ELEMENT_ARRAY_BUFFER: + iBuffer = CCV(uElementArrayBufferBinding); + break; + } + if (iBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (offset < 0 || size < 0 || offset + size > CCV(pBufferObject[iBuffer].uSize)) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + if (ES2INTER(BufferObjectAssure)(FUNC_NAME, iBuffer) == GL_FALSE) { + return; + } + if (CCV(pBufferObject[iBuffer].bGenerated) == GL_FALSE) { + CCV(pBufferObject)[iBuffer].bGenerated = GL_TRUE; + } + pUnit = &(CCV(pBufferObject[iBuffer])); + pFixed = (GLfixed*)((GLubyte*)(pUnit->pData) + offset); + memcpy(pFixed, data, size); + pFloat = (GLfloat*)((GLubyte*)(pFixed) + pUnit->uOffset); + nCount = size / sizeof(GLfixed); + while (nCount--) { + register GLfixed xValue = *pFixed++; + register GLfloat fValue = fixed_to_float(xValue); + *pFloat++ = fValue; + } + FNPTR(BufferSubData)(target, offset, size, data); + FNPTR(BufferSubData)(target, offset + pUnit->uOffset, size, + ((GLchar*)(pUnit->pData) + pUnit->uOffset + offset)); + pFixed = (GLfixed*)(data); + pFloat = (GLfloat*)((GLubyte*)(pUnit->pConverted) + offset); + nCount = size / sizeof(GLfixed); + while (nCount--) { + register GLfixed xValue = *pFixed++; + register GLfloat fValue = fixed_to_float(xValue); + *pFloat++ = fValue; + } +#undef FUNC_NAME +} diff --git a/es_2_0/Clear.c b/es_2_0/Clear.c new file mode 100755 index 0000000..affc18e --- /dev/null +++ b/es_2_0/Clear.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(Clear)(GLbitfield mask) { + if ((mask & ~(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT)) != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(Clear)(mask); +} + +void GL_APIENTRY ES2ENTRY(ClearColor)(GLclampf red, + GLclampf green, GLclampf blue, GLclampf alpha) { + FNPTR(ClearColor)(red, green, blue, alpha); +} + +void GL_APIENTRY ES2ENTRY(ClearDepthf)(GLclampf depth) { + FNPTR(ClearDepth)((GLclampd)(depth)); +} + +void GL_APIENTRY ES2ENTRY(ClearStencil)(GLint s) { + FNPTR(ClearStencil)(s); +} + +void GL_APIENTRY ES2ENTRY(ColorMask)(GLboolean red, + GLboolean green, GLboolean blue, GLboolean alpha) { + FNPTR(ColorMask)(red, green, blue, alpha); +} + +void GL_APIENTRY ES2ENTRY(DepthMask)(GLboolean flag) { + FNPTR(DepthMask)(flag); +} + +void GL_APIENTRY ES2ENTRY(StencilMask)(GLuint mask) { + FNPTR(StencilMask)(mask); +} + +void GL_APIENTRY ES2ENTRY(StencilMaskSeparate)(GLenum face, GLuint mask) { + switch (face) { + default: + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + } + FNPTR(StencilMaskSeparate)(face, mask); +} + + diff --git a/es_2_0/Compressed.c b/es_2_0/Compressed.c new file mode 100755 index 0000000..f2002eb --- /dev/null +++ b/es_2_0/Compressed.c @@ -0,0 +1,156 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +#ifndef GL_TEXTURE_WIDTH +#define GL_TEXTURE_WIDTH 0x1000 +#endif + +#ifndef GL_TEXTURE_HEIGHT +#define GL_TEXTURE_HEIGHT 0x1001 +#endif + + +void GL_APIENTRY ES2ENTRY(CompressedTexImage2D)(GLenum target, + GLint level, GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const void* data) { + GLint iCompressedTexFormats[64]; + GLint nCompressedTexFormats; + int iMaxSize; + int i; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &iMaxSize); + break; + } + FNPTR(GetIntegerv)(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nCompressedTexFormats); + FNPTR(GetIntegerv)(GL_COMPRESSED_TEXTURE_FORMATS, iCompressedTexFormats); + for (i = 0; i < nCompressedTexFormats; i++) { + if (iCompressedTexFormats[i] == internalformat) break; + } + if (i == nCompressedTexFormats) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || iMaxSize < width || height < 0 || iMaxSize < height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (border != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + + FNPTR(CompressedTexImage2D)(target, level, internalformat, width, height, border, + imageSize, data); +} + +void GL_APIENTRY ES2ENTRY(CompressedTexSubImage2D)(GLenum target, + GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLsizei imageSize, const GLvoid* data) { + GLint iCompressedTexFormats[64]; + GLint nCompressedTexFormats; + int iMaxSize; + int iWidth, iHeight; + int iInternalFormat; + int i; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &iMaxSize); + break; + } + FNPTR(GetIntegerv)(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nCompressedTexFormats); + FNPTR(GetIntegerv)(GL_COMPRESSED_TEXTURE_FORMATS, iCompressedTexFormats); + for (i = 0; i < nCompressedTexFormats; i++) { + if (iCompressedTexFormats[i] == format) break; + } + if (i == nCompressedTexFormats) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_WIDTH, &iWidth); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_HEIGHT, &iHeight); + if (xoffset < 0 || iWidth < (xoffset + width) || yoffset < 0 || iHeight < (yoffset + height)) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + FNPTR(CompressedTexSubImage2D)(target, level, xoffset, yoffset, width, height, format, + imageSize, data); +} diff --git a/es_2_0/DrawArray.c b/es_2_0/DrawArray.c new file mode 100755 index 0000000..171c573 --- /dev/null +++ b/es_2_0/DrawArray.c @@ -0,0 +1,132 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(DrawArrays)(GLenum mode, GLint first, GLsizei count) { + GLint iArrayBufferBinding; + GLvoid* pNewArea; + GLchar* pFixedBase; + GLfloat* pFloat; + int i, j; + GLboolean bSpecial = (CCV(pVertexAttrib[0].bEnabled) == GL_FALSE) + && (CCV(pVertexAttrib[1].bEnabled) == GL_TRUE); + if (mode < 0 || GL_TRIANGLE_FAN < mode) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (count < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (count == 0) { + return; + } + + FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &iArrayBufferBinding); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); + for (i = 0; i < CCV(nMaxVertexAttribs); i++) { + register struct VertexAttribUnit* pVertexAttrib = &(CCV(pVertexAttrib[i])); + if (pVertexAttrib->bEnabled == GL_FALSE) continue; + if (i == 1 && bSpecial == GL_TRUE && pVertexAttrib->eType != GL_FIXED) { + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, pVertexAttrib->uBufferBinding); + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, + pVertexAttrib->eType, pVertexAttrib->bNormalized, pVertexAttrib->uStride, + pVertexAttrib->pData); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); + } + if (pVertexAttrib->eType != GL_FIXED) continue; + if (pVertexAttrib->uBufferBinding != 0) { + register GLuint uBuffer = pVertexAttrib->uBufferBinding; + register struct BufferObjectUnit* pBufferObject = &CCV(pBufferObject[uBuffer]); +#if defined(USE_CONVERTED) + register GLubyte* pConverted = (GLubyte*)(pBufferObject->pConverted) + + (GLsizei)(pVertexAttrib->pData); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); + FNPTR(VertexAttribPointer)(i, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + if (i == 1 && bSpecial == GL_TRUE) { + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + } +#else + register GLubyte* pConverted = (GLubyte*)pVertexAttrib->pData + pBufferObject->uOffset; + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, uBuffer); + FNPTR(VertexAttribPointer)(i, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + if (i == 1 && bSpecial == GL_TRUE) { + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + } + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); +#endif + } else { + pNewArea = realloc(pVertexAttrib->pConverted, + pVertexAttrib->iSize * count * sizeof(GLfixed)); + if (pNewArea == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, iArrayBufferBinding); + return; + } + pVertexAttrib->pConverted = pNewArea; + pFixedBase = (GLchar*)(pVertexAttrib->pData) + first * pVertexAttrib->uStride; + pFloat = (GLfloat*)(pNewArea); + for (j = first; j < first + count; j++) { + int k = pVertexAttrib->iSize; + GLfixed* pFixed = (GLfixed*)(pFixedBase); + while (k--) { + register GLfixed xValue = *pFixed++; + register GLfloat fValue = fixed_to_float(xValue); + *pFloat++ = fValue; + } + pFixedBase += pVertexAttrib->uStride; + } + FNPTR(VertexAttribPointer)(i, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->iSize * sizeof(GLfixed), + (GLvoid*)((GLubyte*)(pVertexAttrib->pConverted) + - first * pVertexAttrib->uStride)); + if (i == 1 && bSpecial == GL_TRUE) { + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->iSize * sizeof(GLfixed), + (GLvoid*)((GLubyte*)(pVertexAttrib->pConverted) + - first * pVertexAttrib->uStride)); + } + } + } + if (bSpecial == GL_TRUE) { + FNPTR(EnableVertexAttribArray)(0); + } + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, iArrayBufferBinding); + FNPTR(DrawArrays)(mode, first, count); + if (bSpecial == GL_TRUE) { + FNPTR(DisableVertexAttribArray)(0); + } +} diff --git a/es_2_0/DrawElement.c b/es_2_0/DrawElement.c new file mode 100755 index 0000000..13b7ade --- /dev/null +++ b/es_2_0/DrawElement.c @@ -0,0 +1,208 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(DrawElements)(GLenum mode, GLsizei count, GLenum type, + const void* indices) { + GLvoid* pNewArea; + GLchar* pFixedBase; + GLfloat* pFloat; + GLint iArrayBufferBinding; + GLint iElementArrayBufferBinding; + int iFirst, iLast; + int i, j; + GLboolean bSpecial = (CCV(pVertexAttrib[0].bEnabled) == GL_FALSE) + && (CCV(pVertexAttrib[1].bEnabled) == GL_TRUE); + if (mode < 0 || GL_TRIANGLE_FAN < mode) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (count < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (count == 0) { + return; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_UNSIGNED_BYTE: + case GL_UNSIGNED_SHORT: +#if defined(PROVIDING_OES_element_index_uint) + case GL_UNSIGNED_INT: +#endif + break; + } + + FNPTR(GetIntegerv)(GL_ELEMENT_ARRAY_BUFFER_BINDING, &iElementArrayBufferBinding); + switch (type) { + case GL_UNSIGNED_BYTE: { + GLubyte* pSrc; + static GLubyte* pBufferArea = NULL; + if (iElementArrayBufferBinding != 0) { + pSrc = (GLubyte*)realloc(pBufferArea, count * sizeof(GLubyte)); + assert(pSrc != NULL); + pBufferArea = pSrc; + FNPTR(GetBufferSubData)(GL_ELEMENT_ARRAY_BUFFER, (GLintptr)indices, + count * sizeof(GLubyte), pSrc); + } else { + pSrc = (GLubyte*)(indices); + } + iFirst = iLast = pSrc[0]; + for (i = 1; i < count; i++) { + if (pSrc[i] > iLast) iLast = pSrc[i]; + else if (pSrc[i] < iFirst) iFirst = pSrc[i]; + } + } + break; + case GL_UNSIGNED_SHORT: { + GLushort* pSrc; + static GLushort* pBufferArea = NULL; + if (iElementArrayBufferBinding != 0) { + pSrc = (GLushort*)realloc(pBufferArea, count * sizeof(GLushort)); + assert(pSrc != NULL); + pBufferArea = pSrc; + FNPTR(GetBufferSubData)(GL_ELEMENT_ARRAY_BUFFER, (GLintptr)indices, + count * sizeof(GLushort), pSrc); + } else { + pSrc = (GLushort*)(indices); + } + iFirst = iLast = pSrc[0]; + for (i = 1; i < count; i++) { + if (pSrc[i] > iLast) iLast = pSrc[i]; + else if (pSrc[i] < iFirst) iFirst = pSrc[i]; + } + } + break; +#if defined(PROVIDING_OES_element_index_uint) + case GL_UNSIGNED_INT: { + GLuint* pSrc; + static GLuint* pBufferArea = NULL; + if (iElementArrayBufferBinding != 0) { + pSrc = (GLuint*)realloc(pBufferArea, count * sizeof(GLuint)); + assert(pSrc != NULL); + pBufferArea = pSrc; + FNPTR(GetBufferSubData)(GL_ELEMENT_ARRAY_BUFFER, (GLintptr)indices, + count * sizeof(GLuint), pSrc); + } else { + pSrc = (GLuint*)(indices); + } + iFirst = iLast = pSrc[0]; + for (i = 1; i < count; i++) { + if (pSrc[i] > iLast) iLast = pSrc[i]; + else if (pSrc[i] < iFirst) iFirst = pSrc[i]; + } + } + break; +#endif + } + FNPTR(GetIntegerv)(GL_ARRAY_BUFFER_BINDING, &iArrayBufferBinding); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); + for (i = 0; i < CCV(nMaxVertexAttribs); i++) { + register struct VertexAttribUnit* pVertexAttrib = &(CCV(pVertexAttrib[i])); + if (pVertexAttrib->bEnabled == GL_FALSE) continue; + if (i == 1 && bSpecial == GL_TRUE && pVertexAttrib->eType != GL_FIXED) { + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, pVertexAttrib->uBufferBinding); + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, + pVertexAttrib->eType, pVertexAttrib->bNormalized, pVertexAttrib->uStride, + pVertexAttrib->pData); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); + } + if (pVertexAttrib->eType != GL_FIXED) continue; + if (pVertexAttrib->uBufferBinding != 0) { + register GLuint uBuffer = pVertexAttrib->uBufferBinding; + register struct BufferObjectUnit* pBufferObject = &CCV(pBufferObject[uBuffer]); +#if defined(USE_CONVERTED) + register GLubyte* pConverted = (GLubyte*)(pBufferObject->pConverted) + + (GLsizei)(pVertexAttrib->pData); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); + FNPTR(VertexAttribPointer)(i, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + if (i == 1 && bSpecial == GL_TRUE) { + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + } +#else + register GLubyte* pConverted = (GLubyte*)pVertexAttrib->pData + pBufferObject->uOffset; + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, uBuffer); + FNPTR(VertexAttribPointer)(i, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + if (i == 1 && bSpecial == GL_TRUE) { + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->uStride, pConverted); + } + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, 0); +#endif + } else { + pNewArea = realloc(pVertexAttrib->pConverted, + pVertexAttrib->iSize * (iLast - iFirst + 1) * sizeof(GLfixed)); + if (pNewArea == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, iArrayBufferBinding); + return; + } + pVertexAttrib->pConverted = pNewArea; + pFixedBase = (GLchar*)(pVertexAttrib->pData) + iFirst * pVertexAttrib->uStride; + pFloat = (GLfloat*)(pNewArea); + for (j = iFirst; j < iLast + 1; j++) { + int k = pVertexAttrib->iSize; + GLfixed* pFixed = (GLfixed*)(pFixedBase); + while (k--) { + register GLfixed xValue = *pFixed++; + register GLfloat fValue = fixed_to_float(xValue); + *pFloat++ = fValue; + } + pFixedBase += pVertexAttrib->uStride; + } + FNPTR(VertexAttribPointer)(i, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->iSize * sizeof(GLfixed), + (GLvoid*)((GLubyte*)(pVertexAttrib->pConverted) + - iFirst * pVertexAttrib->uStride)); + if (i == 1 && bSpecial == GL_TRUE) { + FNPTR(VertexAttribPointer)(0, pVertexAttrib->iSize, GL_FLOAT, + pVertexAttrib->bNormalized, pVertexAttrib->iSize * sizeof(GLfixed), + (GLvoid*)((GLubyte*)(pVertexAttrib->pConverted) + - iFirst * pVertexAttrib->uStride)); + } + } + } + if (bSpecial == GL_TRUE) { + FNPTR(EnableVertexAttribArray)(0); + } + FNPTR(BindBuffer)(GL_ARRAY_BUFFER, iArrayBufferBinding); + FNPTR(DrawElements)(mode, count, type, indices); + if (bSpecial == GL_TRUE) { + FNPTR(DisableVertexAttribArray)(0); + } +} diff --git a/es_2_0/EGLImage.c b/es_2_0/EGLImage.c new file mode 100644 index 0000000..b6d64de --- /dev/null +++ b/es_2_0/EGLImage.c @@ -0,0 +1,58 @@ +/* + * EGLImage.c + * + */ +#include "es2front.h" +#include <EGL/egl.h> +#include <GLES2/gl2ext.h> +#include <X11/Xlib.h> +#include <X11/Xutil.h> +#include <dlfcn.h> + +#define EGL_SO_FILENAME "libEGL.so" +#define EGLCROSS_PREFIX "__hazel_cross__" + +void* g_dlhandle_egl = NULL; + +void GL_APIENTRY ES2ENTRY(EGLImageTargetTexture2DOES) (GLenum target, + GLeglImageOES image) { + + int width, height, depth; + EGLNativeDisplayType dpy; + Pixmap pixmap; + XImage *img; + + int (*fpGetEGLImagePixmapInfo)(void *eglimg, + EGLNativeDisplayType *dpy, + Pixmap *pixmap, + int *width, int *height, int *depth) = NULL; + + if (g_dlhandle_egl == NULL) { + if ((g_dlhandle_egl = dlopen(EGL_SO_FILENAME, RTLD_NOW | RTLD_GLOBAL)) == NULL) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + } + + fpGetEGLImagePixmapInfo = dlsym(g_dlhandle_egl, EGLCROSS_PREFIX "GetEGLImagePixmapInfo"); + if (fpGetEGLImagePixmapInfo != NULL) { + (*fpGetEGLImagePixmapInfo)(image, &dpy, &pixmap, &width, &height, &depth); + } + + fprintf (stderr, "EGLImage: glEGLImageTargetTexture2DOES () was called!\n"); + fprintf (stderr, "======== target = 0x%x\n", (unsigned int)target); + fprintf (stderr, "======== image = 0x%x\n", (unsigned int)image); + fprintf (stderr, "======== width = 0x%x\n", (unsigned int)width); + fprintf (stderr, "======== height = 0x%x\n", (unsigned int)height); + fprintf (stderr, "======== depth = 0x%x\n", (unsigned int)depth); + + img = XGetImage ((Display*)dpy, pixmap, 0, 0, width, height, AllPlanes, ZPixmap); + if (img == NULL) { + fprintf (stderr, "EGLImage: Failed to get pixmap image!\n"); + } + + FNPTR(TexImage2D)(target, 0, GL_RGB, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, img->data); + + XDestroyImage (img); + +} diff --git a/es_2_0/Enable.c b/es_2_0/Enable.c new file mode 100755 index 0000000..8a7e2af --- /dev/null +++ b/es_2_0/Enable.c @@ -0,0 +1,98 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(Enable)(GLenum cap) { + switch (cap) { + case GL_BLEND: + case GL_CULL_FACE: + case GL_DEPTH_TEST: + case GL_DITHER: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_SCISSOR_TEST: + case GL_STENCIL_TEST: + FNPTR(Enable)(cap); + break; + /* + case GL_DEPTH_TEST: + // disabled for poor supporting in WebGL. + break; + */ + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + break; + } +} + + +void GL_APIENTRY ES2ENTRY(Disable)(GLenum cap) { + switch (cap) { + case GL_BLEND: + case GL_CULL_FACE: + case GL_DEPTH_TEST: + case GL_DITHER: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_SCISSOR_TEST: + case GL_STENCIL_TEST: + FNPTR(Disable)(cap); + break; + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + break; + } +} + + +GLboolean GL_APIENTRY ES2ENTRY(IsEnabled)(GLenum cap) { + switch (cap) { + case GL_BLEND: + case GL_CULL_FACE: + case GL_DEPTH_TEST: + case GL_DITHER: + case GL_POLYGON_OFFSET_FILL: + case GL_SAMPLE_ALPHA_TO_COVERAGE: + case GL_SAMPLE_COVERAGE: + case GL_SCISSOR_TEST: + case GL_STENCIL_TEST: + return FNPTR(IsEnabled)(cap); + break; + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return 0; + break; + } +} diff --git a/es_2_0/Error.c b/es_2_0/Error.c new file mode 100755 index 0000000..3ac3874 --- /dev/null +++ b/es_2_0/Error.c @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <stdarg.h> + + +GLenum GL_APIENTRY ES2ENTRY(GetError)(void) { + register GLenum eResult = FNPTR(GetError)(); + if (CCV(eError) != GL_NO_ERROR) { + eResult = CCV(eError); + CCV(eError) = GL_NO_ERROR; + } + return eResult; +} + + + +void GL_APIENTRY ES2INTER(SetError)(GLenum eError) { + if (CCV(eError) == GL_NO_ERROR) { + CCV(eError) = eError; + } +} + diff --git a/es_2_0/EvalLex.inl b/es_2_0/EvalLex.inl new file mode 100755 index 0000000..5bf0a74 --- /dev/null +++ b/es_2_0/EvalLex.inl @@ -0,0 +1,1830 @@ + +#line 3 "EvalLex.inl" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer hazelEval_create_buffer +#define yy_delete_buffer hazelEval_delete_buffer +#define yy_flex_debug hazelEval_flex_debug +#define yy_init_buffer hazelEval_init_buffer +#define yy_flush_buffer hazelEval_flush_buffer +#define yy_load_buffer_state hazelEval_load_buffer_state +#define yy_switch_to_buffer hazelEval_switch_to_buffer +#define yyin hazelEvalin +#define yyleng hazelEvalleng +#define yylex hazelEvallex +#define yylineno hazelEvallineno +#define yyout hazelEvalout +#define yyrestart hazelEvalrestart +#define yytext hazelEvaltext +#define yywrap hazelEvalwrap +#define yyalloc hazelEvalalloc +#define yyrealloc hazelEvalrealloc +#define yyfree hazelEvalfree + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE hazelEvalrestart(hazelEvalin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int hazelEvalleng; + +extern FILE *hazelEvalin, *hazelEvalout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up hazelEvaltext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up hazelEvaltext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via hazelEvalrestart()), so that the user can continue scanning by + * just pointing hazelEvalin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when hazelEvaltext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int hazelEvalleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow hazelEvalwrap()'s to do buffer switches + * instead of setting up a fresh hazelEvalin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void hazelEvalrestart (FILE *input_file ); +void hazelEval_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE hazelEval_create_buffer (FILE *file,int size ); +void hazelEval_delete_buffer (YY_BUFFER_STATE b ); +void hazelEval_flush_buffer (YY_BUFFER_STATE b ); +void hazelEvalpush_buffer_state (YY_BUFFER_STATE new_buffer ); +void hazelEvalpop_buffer_state (void ); + +static void hazelEvalensure_buffer_stack (void ); +static void hazelEval_load_buffer_state (void ); +static void hazelEval_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER hazelEval_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE hazelEval_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE hazelEval_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE hazelEval_scan_bytes (yyconst char *bytes,int len ); + +void *hazelEvalalloc (yy_size_t ); +void *hazelEvalrealloc (void *,yy_size_t ); +void hazelEvalfree (void * ); + +#define yy_new_buffer hazelEval_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + hazelEvalensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + hazelEval_create_buffer(hazelEvalin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + hazelEvalensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + hazelEval_create_buffer(hazelEvalin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +typedef unsigned char YY_CHAR; + +FILE *hazelEvalin = (FILE *) 0, *hazelEvalout = (FILE *) 0; + +typedef int yy_state_type; + +extern int hazelEvallineno; + +int hazelEvallineno = 1; + +extern char *hazelEvaltext; +#define yytext_ptr hazelEvaltext + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up hazelEvaltext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + hazelEvalleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 15 +#define YY_END_OF_BUFFER 16 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[32] = + { 0, + 0, 0, 16, 14, 13, 15, 14, 14, 3, 2, + 2, 14, 14, 14, 1, 14, 10, 11, 3, 0, + 2, 2, 5, 7, 9, 8, 6, 1, 12, 4, + 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 1, 1, 1, 1, 5, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 6, 7, 7, + 7, 7, 7, 7, 7, 8, 8, 1, 1, 9, + 10, 11, 1, 1, 12, 12, 12, 12, 12, 12, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 14, 13, 13, + 1, 1, 1, 1, 13, 1, 12, 12, 12, 12, + + 12, 12, 13, 13, 13, 13, 13, 13, 13, 13, + 13, 13, 13, 13, 13, 13, 13, 13, 13, 15, + 13, 13, 1, 16, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[17] = + { 0, + 1, 1, 1, 1, 1, 2, 2, 2, 1, 1, + 1, 3, 4, 4, 4, 1 + } ; + +static yyconst flex_int16_t yy_base[36] = + { 0, + 0, 0, 40, 41, 41, 41, 29, 33, 11, 29, + 0, 10, 26, 11, 0, 19, 41, 41, 17, 0, + 26, 0, 41, 41, 41, 41, 41, 0, 41, 0, + 41, 31, 30, 25, 28 + } ; + +static yyconst flex_int16_t yy_def[36] = + { 0, + 31, 1, 31, 31, 31, 31, 31, 31, 31, 32, + 33, 31, 31, 31, 34, 31, 31, 31, 31, 35, + 32, 33, 31, 31, 31, 31, 31, 34, 31, 35, + 0, 31, 31, 31, 31 + } ; + +static yyconst flex_int16_t yy_nxt[58] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 15, 15, 15, 16, 19, 19, 23, 24, + 26, 27, 19, 19, 20, 20, 28, 28, 28, 30, + 30, 22, 21, 22, 29, 25, 22, 18, 17, 31, + 3, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31 + } ; + +static yyconst flex_int16_t yy_chk[58] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 9, 9, 12, 12, + 14, 14, 19, 19, 9, 9, 34, 34, 34, 35, + 35, 33, 32, 21, 16, 13, 10, 8, 7, 3, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 31, 31, 31, 31, 31, 31, 31 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int hazelEval_flex_debug; +int hazelEval_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *hazelEvaltext; + +/* The generated EvalLex.c file must be included at the end of EvalYacc.c */ + +static char* pSrcPtr; + +void hazelEvalPrepare(char* ptr) { + pSrcPtr = ptr; +} + +static int hazelEvalwrap(void) { + return 1; +} + +/* +Gets input and stuffs it into "buf". +number of characters read, or YY_NULL, is returned in "result". +*/ +#undef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + { \ + if (*pSrcPtr == '\0') { \ + result = YY_NULL; \ + } else { \ + result = strlen(pSrcPtr); \ + strcpy(buf, pSrcPtr); \ + pSrcPtr += result; \ + } \ + } + +#define INITIAL 0 + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int hazelEvallex_destroy (void ); + +int hazelEvalget_debug (void ); + +void hazelEvalset_debug (int debug_flag ); + +YY_EXTRA_TYPE hazelEvalget_extra (void ); + +void hazelEvalset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *hazelEvalget_in (void ); + +void hazelEvalset_in (FILE * in_str ); + +FILE *hazelEvalget_out (void ); + +void hazelEvalset_out (FILE * out_str ); + +int hazelEvalget_leng (void ); + +char *hazelEvalget_text (void ); + +int hazelEvalget_lineno (void ); + +void hazelEvalset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int hazelEvalwrap (void ); +#else +extern int hazelEvalwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( hazelEvaltext, hazelEvalleng, 1, hazelEvalout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + unsigned n; \ + for ( n = 0; n < max_size && \ + (c = getc( hazelEvalin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( hazelEvalin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, hazelEvalin))==0 && ferror(hazelEvalin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(hazelEvalin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int hazelEvallex (void); + +#define YY_DECL int hazelEvallex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after hazelEvaltext and hazelEvalleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! hazelEvalin ) + hazelEvalin = stdin; + + if ( ! hazelEvalout ) + hazelEvalout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + hazelEvalensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + hazelEval_create_buffer(hazelEvalin,YY_BUF_SIZE ); + } + + hazelEval_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of hazelEvaltext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 32 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 41 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +YY_RULE_SETUP +{ + if (strcmp(hazelEvaltext, "defined") == 0) { + return DEFINED; + } else { + struct SymbolEntry* ptr = ES2INTER(MacroSearchMacro)(hazelEvaltext); + yylval = (int)(ptr); + return IDENTIFIER; + } +} + YY_BREAK +case 2: +YY_RULE_SETUP +{ yylval = (int)strtol(hazelEvaltext, NULL, 10); return NUMBER; } + YY_BREAK +case 3: +YY_RULE_SETUP +{ yylval = (int)strtol(hazelEvaltext, NULL, 8); return NUMBER; } + YY_BREAK +case 4: +YY_RULE_SETUP +{ yylval = (int)strtol(hazelEvaltext, NULL, 16); return NUMBER; } + YY_BREAK +case 5: +YY_RULE_SETUP +{ return LEFT_OP; } + YY_BREAK +case 6: +YY_RULE_SETUP +{ return RIGHT_OP; } + YY_BREAK +case 7: +YY_RULE_SETUP +{ return LE_OP; } + YY_BREAK +case 8: +YY_RULE_SETUP +{ return GE_OP; } + YY_BREAK +case 9: +YY_RULE_SETUP +{ return EQ_OP; } + YY_BREAK +case 10: +YY_RULE_SETUP +{ return NE_OP; } + YY_BREAK +case 11: +YY_RULE_SETUP +{ return AND_OP; } + YY_BREAK +case 12: +YY_RULE_SETUP +{ return OR_OP; } + YY_BREAK +case 13: +YY_RULE_SETUP +{ /* ignore it */ } + YY_BREAK +case 14: +YY_RULE_SETUP +{ return hazelEvaltext[0]; } + YY_BREAK +case 15: +YY_RULE_SETUP +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed hazelEvalin at a new source and called + * hazelEvallex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = hazelEvalin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( hazelEvalwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * hazelEvaltext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of hazelEvallex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + hazelEvalrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + hazelEvalrestart(hazelEvalin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) hazelEvalrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 32 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 32 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 31); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up hazelEvaltext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + hazelEvalrestart(hazelEvalin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( hazelEvalwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve hazelEvaltext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void hazelEvalrestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + hazelEvalensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + hazelEval_create_buffer(hazelEvalin,YY_BUF_SIZE ); + } + + hazelEval_init_buffer(YY_CURRENT_BUFFER,input_file ); + hazelEval_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void hazelEval_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * hazelEvalpop_buffer_state(); + * hazelEvalpush_buffer_state(new_buffer); + */ + hazelEvalensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + hazelEval_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (hazelEvalwrap()) processing, but the only time this flag + * is looked at is after hazelEvalwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void hazelEval_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + hazelEvalin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE hazelEval_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) hazelEvalalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in hazelEval_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) hazelEvalalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in hazelEval_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + hazelEval_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with hazelEval_create_buffer() + * + */ + void hazelEval_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + hazelEvalfree((void *) b->yy_ch_buf ); + + hazelEvalfree((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a hazelEvalrestart() or at EOF. + */ + static void hazelEval_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + hazelEval_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then hazelEval_init_buffer was _probably_ + * called from hazelEvalrestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void hazelEval_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + hazelEval_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void hazelEvalpush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + hazelEvalensure_buffer_stack(); + + /* This block is copied from hazelEval_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from hazelEval_switch_to_buffer. */ + hazelEval_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void hazelEvalpop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + hazelEval_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + hazelEval_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void hazelEvalensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)hazelEvalalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in hazelEvalensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)hazelEvalrealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in hazelEvalensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE hazelEval_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) hazelEvalalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in hazelEval_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + hazelEval_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to hazelEvallex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * hazelEval_scan_bytes() instead. + */ +YY_BUFFER_STATE hazelEval_scan_string (yyconst char * yystr ) +{ + + return hazelEval_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to hazelEvallex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE hazelEval_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) hazelEvalalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in hazelEval_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = hazelEval_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in hazelEval_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up hazelEvaltext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + hazelEvaltext[hazelEvalleng] = (yy_hold_char); \ + (yy_c_buf_p) = hazelEvaltext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + hazelEvalleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int hazelEvalget_lineno (void) +{ + + return hazelEvallineno; +} + +/** Get the input stream. + * + */ +FILE *hazelEvalget_in (void) +{ + return hazelEvalin; +} + +/** Get the output stream. + * + */ +FILE *hazelEvalget_out (void) +{ + return hazelEvalout; +} + +/** Get the length of the current token. + * + */ +int hazelEvalget_leng (void) +{ + return hazelEvalleng; +} + +/** Get the current token. + * + */ + +char *hazelEvalget_text (void) +{ + return hazelEvaltext; +} + +/** Set the current line number. + * @param line_number + * + */ +void hazelEvalset_lineno (int line_number ) +{ + + hazelEvallineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see hazelEval_switch_to_buffer + */ +void hazelEvalset_in (FILE * in_str ) +{ + hazelEvalin = in_str ; +} + +void hazelEvalset_out (FILE * out_str ) +{ + hazelEvalout = out_str ; +} + +int hazelEvalget_debug (void) +{ + return hazelEval_flex_debug; +} + +void hazelEvalset_debug (int bdebug ) +{ + hazelEval_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from hazelEvallex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + hazelEvalin = stdin; + hazelEvalout = stdout; +#else + hazelEvalin = (FILE *) 0; + hazelEvalout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * hazelEvallex_init() + */ + return 0; +} + +/* hazelEvallex_destroy is for both reentrant and non-reentrant scanners. */ +int hazelEvallex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + hazelEval_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + hazelEvalpop_buffer_state(); + } + + /* Destroy the stack itself. */ + hazelEvalfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * hazelEvallex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *hazelEvalalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *hazelEvalrealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void hazelEvalfree (void * ptr ) +{ + free( (char *) ptr ); /* see hazelEvalrealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + diff --git a/es_2_0/EvalParse.c b/es_2_0/EvalParse.c new file mode 100755 index 0000000..a80c304 --- /dev/null +++ b/es_2_0/EvalParse.c @@ -0,0 +1,760 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef lint +static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +#endif + +#include <stdlib.h> +#include <string.h> + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYPATCH 20070509 + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING (yyerrflag != 0) + +extern int yyparse(void); + +static int yygrowstack(void); +#define yyparse hazelEvalparse +#define yylex hazelEvallex +#define yyerror hazelEvalerror +#define yychar hazelEvalchar +#define yyval hazelEvalval +#define yylval hazelEvallval +#define yydebug hazelEvaldebug +#define yynerrs hazelEvalnerrs +#define yyerrflag hazelEvalerrflag +#define yyss hazelEvalss +#define yyssp hazelEvalssp +#define yyvs hazelEvalvs +#define yyvsp hazelEvalvsp +#define yylhs hazelEvallhs +#define yylen hazelEvallen +#define yydefred hazelEvaldefred +#define yydgoto hazelEvaldgoto +#define yysindex hazelEvalsindex +#define yyrindex hazelEvalrindex +#define yygindex hazelEvalgindex +#define yytable hazelEvaltable +#define yycheck hazelEvalcheck +#define yyname hazelEvalname +#define yyrule hazelEvalrule +#define YYPREFIX "hazelEval" + +#include "es2front.h" + +extern int hazelEvallex(void); +extern int hazelEvallex_destroy(void); + +static int hazelNumEval = 0; +static int hazelEvalValueA = 0; +static int hazelEvalValueB = 0; + +int hazelEvalGetResult(int* pEvalA, int* pEvalB) { + if (hazelNumEval >= 1) *pEvalA = hazelEvalValueA; + if (hazelNumEval >= 2) *pEvalB = hazelEvalValueB; + return hazelNumEval; +} + +void hazelEvalTerminate(void) { + hazelEvallex_destroy(); +} + +int yyerror(char* s) { + /* just ignore the YACC error message */ + return 1; +} + +#define IDENTIFIER 257 +#define NUMBER 258 +#define DEFINED 259 +#define LEFT_OP 260 +#define RIGHT_OP 261 +#define LE_OP 262 +#define GE_OP 263 +#define EQ_OP 264 +#define NE_OP 265 +#define AND_OP 266 +#define OR_OP 267 +#define UPLUS 268 +#define UMINUS 269 +#define YYERRCODE 256 +short hazelEvallhs[] = { -1, + 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, +}; +short hazelEvallen[] = { 2, + 1, 2, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 2, 4, 2, 2, 2, 2, 1, +}; +short hazelEvaldefred[] = { 0, + 28, 0, 0, 0, 0, 0, 0, 0, 0, 22, + 0, 24, 25, 26, 27, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 19, 20, 21, 23, 0, 0, +}; +short hazelEvaldgoto[] = { 8, + 9, +}; +short hazelEvalsindex[] = { -26, + 0, -27, -26, -26, -26, -26, -26, 0, 436, 0, + -255, 0, 0, 0, 0, 447, -26, -26, -26, -26, + -26, -26, -26, -26, -26, -26, -26, -26, -26, -26, + -26, -26, -26, -26, 473, -38, -26, -26, 0, -22, + -22, -37, -37, 681, 681, 582, 541, 527, 630, 497, + -37, -37, 0, 0, 0, 0, 0, 0, -11, -11, +}; +short hazelEvalrindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 9, 0, 0, 0, 0, 79, + 102, 114, 157, 27, 393, 194, 204, 181, 403, 397, + 288, 351, 1, 12, 0, 0, 0, 0, 37, 51, +}; +short hazelEvalgindex[] = { 0, + 746, +}; +#define YYTABLESIZE 944 +short hazelEvaltable[] = { 34, + 17, 36, 58, 1, 32, 37, 6, 38, 2, 33, + 0, 18, 11, 7, 34, 0, 3, 0, 4, 32, + 37, 0, 38, 0, 33, 34, 9, 0, 0, 0, + 32, 0, 0, 17, 0, 33, 17, 24, 17, 0, + 17, 0, 24, 17, 18, 17, 0, 24, 25, 18, + 18, 18, 0, 25, 18, 0, 18, 0, 25, 9, + 17, 0, 17, 0, 9, 0, 9, 9, 0, 17, + 0, 18, 0, 18, 17, 0, 17, 17, 15, 17, + 0, 17, 0, 18, 0, 0, 0, 0, 18, 0, + 18, 18, 0, 18, 17, 18, 17, 0, 17, 5, + 0, 16, 0, 0, 0, 18, 0, 0, 0, 0, + 18, 15, 18, 13, 0, 0, 15, 0, 15, 15, + 9, 0, 0, 0, 17, 0, 17, 0, 0, 0, + 17, 0, 0, 0, 16, 18, 0, 18, 15, 16, + 15, 16, 16, 0, 18, 0, 13, 0, 0, 0, + 9, 13, 9, 13, 13, 0, 14, 0, 0, 0, + 17, 16, 17, 16, 0, 0, 0, 0, 0, 0, + 0, 0, 15, 13, 18, 13, 18, 0, 0, 0, + 6, 0, 0, 0, 0, 0, 0, 0, 0, 14, + 0, 0, 0, 5, 14, 16, 14, 14, 0, 0, + 0, 0, 15, 4, 15, 0, 0, 13, 0, 0, + 0, 0, 0, 6, 0, 0, 14, 0, 14, 0, + 6, 6, 17, 18, 0, 16, 5, 16, 0, 10, + 0, 1, 2, 5, 5, 0, 4, 13, 0, 13, + 0, 0, 0, 4, 4, 0, 0, 0, 0, 0, + 14, 0, 0, 0, 0, 0, 0, 0, 17, 17, + 17, 17, 17, 17, 17, 17, 17, 17, 0, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 18, 0, + 14, 0, 14, 0, 9, 9, 0, 11, 0, 0, + 9, 9, 9, 9, 17, 17, 17, 17, 17, 17, + 17, 17, 17, 17, 6, 0, 6, 0, 18, 18, + 18, 18, 18, 18, 18, 18, 18, 18, 0, 5, + 11, 0, 0, 0, 0, 11, 0, 11, 11, 4, + 0, 0, 0, 0, 0, 0, 15, 15, 15, 15, + 15, 15, 15, 15, 15, 15, 0, 11, 0, 11, + 12, 0, 0, 0, 0, 0, 0, 0, 0, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 0, + 0, 13, 13, 0, 0, 13, 13, 13, 13, 13, + 13, 11, 0, 12, 0, 0, 0, 0, 12, 0, + 12, 12, 10, 0, 0, 0, 8, 0, 0, 0, + 0, 0, 7, 0, 0, 0, 0, 0, 0, 0, + 12, 11, 12, 11, 14, 14, 0, 0, 14, 14, + 14, 14, 14, 14, 0, 10, 0, 0, 0, 8, + 10, 0, 10, 10, 8, 7, 8, 8, 6, 6, + 0, 0, 7, 7, 12, 0, 6, 6, 0, 0, + 0, 5, 5, 0, 0, 0, 0, 0, 0, 5, + 5, 4, 4, 0, 0, 0, 0, 0, 6, 0, + 4, 0, 34, 27, 12, 7, 12, 32, 30, 0, + 31, 0, 33, 34, 27, 0, 10, 39, 32, 37, + 8, 38, 0, 33, 0, 28, 7, 29, 0, 0, + 0, 0, 0, 0, 0, 0, 28, 0, 29, 34, + 27, 0, 0, 0, 32, 37, 10, 38, 10, 33, + 8, 0, 8, 0, 0, 0, 7, 0, 7, 26, + 0, 0, 28, 34, 29, 0, 0, 0, 32, 37, + 26, 38, 0, 33, 0, 11, 11, 0, 0, 11, + 11, 11, 11, 11, 11, 0, 28, 0, 29, 25, + 0, 5, 0, 34, 27, 0, 26, 0, 32, 37, + 25, 38, 0, 33, 0, 0, 0, 34, 27, 0, + 0, 0, 32, 37, 0, 38, 28, 33, 29, 0, + 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, + 28, 0, 29, 0, 0, 0, 0, 0, 12, 12, + 0, 0, 12, 12, 12, 12, 12, 12, 34, 27, + 26, 0, 0, 32, 37, 0, 38, 0, 33, 0, + 0, 0, 0, 0, 26, 0, 0, 0, 0, 0, + 0, 28, 0, 29, 0, 0, 0, 0, 0, 0, + 10, 10, 0, 0, 8, 8, 10, 10, 10, 10, + 7, 7, 8, 8, 25, 0, 34, 27, 7, 7, + 0, 32, 37, 0, 38, 26, 33, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 28, + 0, 29, 0, 1, 2, 17, 18, 19, 20, 21, + 22, 23, 24, 0, 0, 25, 17, 18, 19, 20, + 21, 22, 23, 24, 0, 0, 0, 34, 0, 0, + 0, 0, 32, 37, 0, 38, 0, 33, 0, 0, + 0, 0, 17, 18, 19, 20, 21, 22, 23, 24, + 28, 0, 29, 0, 0, 0, 0, 0, 12, 13, + 14, 15, 16, 0, 35, 0, 17, 18, 19, 20, + 21, 22, 40, 41, 42, 43, 44, 45, 46, 47, + 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, + 0, 0, 59, 60, 0, 0, 17, 18, 19, 20, + 21, 22, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, 21, 22, 23, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 17, 18, 19, 20, 21, 22, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 17, + 18, 19, 20, 21, 22, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 18, 19, 20, +}; +short hazelEvalcheck[] = { 37, + 0, 257, 41, 0, 42, 43, 33, 45, 0, 47, + -1, 0, 40, 40, 37, -1, 43, -1, 45, 42, + 43, -1, 45, -1, 47, 37, 0, -1, -1, -1, + 42, -1, -1, 33, -1, 47, 0, 37, 38, -1, + 40, -1, 42, 43, 33, 45, -1, 47, 37, 38, + 0, 40, -1, 42, 43, -1, 45, -1, 47, 33, + 60, -1, 62, -1, 38, -1, 40, 41, -1, 33, + -1, 60, -1, 62, 38, -1, 40, 41, 0, 43, + -1, 45, -1, 33, -1, -1, -1, -1, 38, -1, + 40, 41, -1, 43, 94, 45, 60, -1, 62, 126, + -1, 0, -1, -1, -1, 94, -1, -1, -1, -1, + 60, 33, 62, 0, -1, -1, 38, -1, 40, 41, + 94, -1, -1, -1, 124, -1, 126, -1, -1, -1, + 94, -1, -1, -1, 33, 124, -1, 126, 60, 38, + 62, 40, 41, -1, 94, -1, 33, -1, -1, -1, + 124, 38, 126, 40, 41, -1, 0, -1, -1, -1, + 124, 60, 126, 62, -1, -1, -1, -1, -1, -1, + -1, -1, 94, 60, 124, 62, 126, -1, -1, -1, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 33, + -1, -1, -1, 0, 38, 94, 40, 41, -1, -1, + -1, -1, 124, 0, 126, -1, -1, 94, -1, -1, + -1, -1, -1, 33, -1, -1, 60, -1, 62, -1, + 40, 41, 260, 261, -1, 124, 33, 126, -1, 257, + -1, 258, 259, 40, 41, -1, 33, 124, -1, 126, + -1, -1, -1, 40, 41, -1, -1, -1, -1, -1, + 94, -1, -1, -1, -1, -1, -1, -1, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, -1, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, -1, + 124, -1, 126, -1, 258, 259, -1, 0, -1, -1, + 264, 265, 266, 267, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 124, -1, 126, -1, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, -1, 126, + 33, -1, -1, -1, -1, 38, -1, 40, 41, 126, + -1, -1, -1, -1, -1, -1, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, -1, 60, -1, 62, + 0, -1, -1, -1, -1, -1, -1, -1, -1, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, -1, + -1, 258, 259, -1, -1, 262, 263, 264, 265, 266, + 267, 94, -1, 33, -1, -1, -1, -1, 38, -1, + 40, 41, 0, -1, -1, -1, 0, -1, -1, -1, + -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, + 60, 124, 62, 126, 258, 259, -1, -1, 262, 263, + 264, 265, 266, 267, -1, 33, -1, -1, -1, 33, + 38, -1, 40, 41, 38, 33, 40, 41, 258, 259, + -1, -1, 40, 41, 94, -1, 266, 267, -1, -1, + -1, 258, 259, -1, -1, -1, -1, -1, -1, 266, + 267, 258, 259, -1, -1, -1, -1, -1, 33, -1, + 267, -1, 37, 38, 124, 40, 126, 42, 43, -1, + 45, -1, 47, 37, 38, -1, 94, 41, 42, 43, + 94, 45, -1, 47, -1, 60, 94, 62, -1, -1, + -1, -1, -1, -1, -1, -1, 60, -1, 62, 37, + 38, -1, -1, -1, 42, 43, 124, 45, 126, 47, + 124, -1, 126, -1, -1, -1, 124, -1, 126, 94, + -1, -1, 60, 37, 62, -1, -1, -1, 42, 43, + 94, 45, -1, 47, -1, 258, 259, -1, -1, 262, + 263, 264, 265, 266, 267, -1, 60, -1, 62, 124, + -1, 126, -1, 37, 38, -1, 94, -1, 42, 43, + 124, 45, -1, 47, -1, -1, -1, 37, 38, -1, + -1, -1, 42, 43, -1, 45, 60, 47, 62, -1, + -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, + 60, -1, 62, -1, -1, -1, -1, -1, 258, 259, + -1, -1, 262, 263, 264, 265, 266, 267, 37, 38, + 94, -1, -1, 42, 43, -1, 45, -1, 47, -1, + -1, -1, -1, -1, 94, -1, -1, -1, -1, -1, + -1, 60, -1, 62, -1, -1, -1, -1, -1, -1, + 258, 259, -1, -1, 258, 259, 264, 265, 266, 267, + 258, 259, 266, 267, 124, -1, 37, 38, 266, 267, + -1, 42, 43, -1, 45, 94, 47, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 60, + -1, 62, -1, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, -1, -1, 124, 260, 261, 262, 263, + 264, 265, 266, 267, -1, -1, -1, 37, -1, -1, + -1, -1, 42, 43, -1, 45, -1, 47, -1, -1, + -1, -1, 260, 261, 262, 263, 264, 265, 266, 267, + 60, -1, 62, -1, -1, -1, -1, -1, 3, 4, + 5, 6, 7, -1, 9, -1, 260, 261, 262, 263, + 264, 265, 17, 18, 19, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + -1, -1, 37, 38, -1, -1, 260, 261, 262, 263, + 264, 265, -1, -1, -1, -1, -1, -1, -1, -1, + 260, 261, 262, 263, 264, 265, 266, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 260, 261, 262, 263, 264, 265, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 260, + 261, 262, 263, 264, 265, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 260, 261, 262, 263, +}; +#define YYFINAL 8 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 269 +#if YYDEBUG +char *hazelEvalname[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'",0,"'-'",0,"'/'",0,0,0,0,0,0,0, +0,0,0,0,0,"'<'",0,"'>'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,"'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"'|'",0, +"'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,"IDENTIFIER","NUMBER","DEFINED","LEFT_OP","RIGHT_OP", +"LE_OP","GE_OP","EQ_OP","NE_OP","AND_OP","OR_OP","UPLUS","UMINUS", +}; +char *hazelEvalrule[] = { +"$accept : goal", +"goal : expr", +"goal : expr expr", +"expr : '(' expr ')'", +"expr : expr OR_OP expr", +"expr : expr AND_OP expr", +"expr : expr '|' expr", +"expr : expr '^' expr", +"expr : expr '&' expr", +"expr : expr EQ_OP expr", +"expr : expr NE_OP expr", +"expr : expr '<' expr", +"expr : expr '>' expr", +"expr : expr LE_OP expr", +"expr : expr GE_OP expr", +"expr : expr LEFT_OP expr", +"expr : expr RIGHT_OP expr", +"expr : expr '+' expr", +"expr : expr '-' expr", +"expr : expr '*' expr", +"expr : expr '/' expr", +"expr : expr '%' expr", +"expr : DEFINED IDENTIFIER", +"expr : DEFINED '(' IDENTIFIER ')'", +"expr : '+' expr", +"expr : '-' expr", +"expr : '~' expr", +"expr : '!' expr", +"expr : NUMBER", +}; +#endif +#ifndef YYSTYPE +typedef int YYSTYPE; +#endif +#if YYDEBUG +#include <stdio.h> +#endif + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif + +#define YYINITSTACKSIZE 500 + +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; + +/* variables for the parser stack */ +static short *yyss; +static short *yysslim; +static YYSTYPE *yyvs; +static int yystacksize; + +#include "EvalLex.inl" +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack(void) +{ + int newsize, i; + short *newss; + YYSTYPE *newvs; + + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = yyssp - yyss; + newss = (yyss != 0) + ? (short *)realloc(yyss, newsize * sizeof(*newss)) + : (short *)malloc(newsize * sizeof(*newss)); + if (newss == 0) + return -1; + + yyss = newss; + yyssp = newss + i; + newvs = (yyvs != 0) + ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs)) + : (YYSTYPE *)malloc(newsize * sizeof(*newvs)); + if (newvs == 0) + return -1; + + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; + return 0; +} + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse(void) +{ + register int yym, yyn, yystate; +#if YYDEBUG + register const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + + if (yyss == NULL && yygrowstack()) goto yyoverflow; + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + yyerror("syntax error"); + +#ifdef lint + goto yyerrlab; +#endif + +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym) + yyval = yyvsp[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + switch (yyn) + { +case 1: +{ hazelNumEval = 1; hazelEvalValueA = yyvsp[0]; } +break; +case 2: +{ hazelNumEval = 2; hazelEvalValueA = yyvsp[-1]; hazelEvalValueB = yyvsp[0]; } +break; +case 3: +{ yyval = yyvsp[-1]; } +break; +case 4: +{ yyval = (yyvsp[-2] || yyvsp[0]); } +break; +case 5: +{ yyval = (yyvsp[-2] && yyvsp[0]); } +break; +case 6: +{ yyval = (yyvsp[-2] | yyvsp[0]); } +break; +case 7: +{ yyval = (yyvsp[-2] ^ yyvsp[0]); } +break; +case 8: +{ yyval = (yyvsp[-2] & yyvsp[0]); } +break; +case 9: +{ yyval = (yyvsp[-2] == yyvsp[0]); } +break; +case 10: +{ yyval = (yyvsp[-2] != yyvsp[0]); } +break; +case 11: +{ yyval = (yyvsp[-2] < yyvsp[0]); } +break; +case 12: +{ yyval = (yyvsp[-2] > yyvsp[0]); } +break; +case 13: +{ yyval = (yyvsp[-2] <= yyvsp[0]); } +break; +case 14: +{ yyval = (yyvsp[-2] >= yyvsp[0]); } +break; +case 15: +{ yyval = (yyvsp[-2] << yyvsp[0]); } +break; +case 16: +{ yyval = (yyvsp[-2] >> yyvsp[0]); } +break; +case 17: +{ yyval = (yyvsp[-2] + yyvsp[0]); } +break; +case 18: +{ yyval = (yyvsp[-2] - yyvsp[0]); } +break; +case 19: +{ yyval = (yyvsp[-2] * yyvsp[0]); } +break; +case 20: +{ yyval = (yyvsp[-2] / yyvsp[0]); } +break; +case 21: +{ yyval = (yyvsp[-2] % yyvsp[0]); } +break; +case 22: +{ yyval = (yyvsp[0] != (int)(NULL)); } +break; +case 23: +{ yyval = (yyvsp[-1] != (int)(NULL)); } +break; +case 24: +{ yyval = (yyvsp[0]); } +break; +case 25: +{ yyval = (- yyvsp[0]); } +break; +case 26: +{ yyval = (~ yyvsp[0]); } +break; +case 27: +{ yyval = (! yyvsp[0]); } +break; +case 28: +{ yyval = yyvsp[0]; } +break; + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; + +yyoverflow: + yyerror("yacc stack overflow"); + +yyabort: + return (1); + +yyaccept: + return (0); +} diff --git a/es_2_0/Extend.c b/es_2_0/Extend.c new file mode 100755 index 0000000..56d119b --- /dev/null +++ b/es_2_0/Extend.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +#if defined(PROVIDING_OES_blend_func_separate) +void GL_APIENTRY ES2ENTRY(BlendFuncSeparateOES)(GLenum srcRGB, GLenum dstRGB, + GLenum srcAlpha, GLenum dstAlpha) { + ES2ENTRY(BlendFuncSeparateOES)(srcRGB, dstRGB, srcAlpha, dstAlpha); +} +#endif + +#if defined(PROVIDING_OES_blend_subtract) +void GL_APIENTRY ES2ENTRY(BlendEquationOES)(GLenum mode) { + ES2ENTRY(BlendEquation)(mode); +} +#endif + + +#if defined(PROVIDING_OES_single_precision) + +void GL_APIENTRY ES2ENTRY(DepthRangefOES)(GLclampf zNear, GLclampf zFar) { + ES2ENTRY(DepthRangef)(zNear, zFar); +} + +void GL_APIENTRY ES2ENTRY(ClearDepthfOES)(GLclampf depth) { + ES2ENTRY(ClearDepthf)(depth); +} + +#endif + + diff --git a/es_2_0/Flush.c b/es_2_0/Flush.c new file mode 100755 index 0000000..db98fcf --- /dev/null +++ b/es_2_0/Flush.c @@ -0,0 +1,61 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(Flush)(void) { + FNPTR(Flush)(); +} + +void GL_APIENTRY ES2ENTRY(Finish)(void) { + FNPTR(Finish)(); +} + +void GL_APIENTRY ES2ENTRY(Hint)(GLenum target, GLenum mode) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_GENERATE_MIPMAP_HINT: + switch (mode) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_FASTEST: + case GL_NICEST: + case GL_DONT_CARE: + break; + } + break; + } + FNPTR(Hint)(target, mode); +} diff --git a/es_2_0/Fragment.c b/es_2_0/Fragment.c new file mode 100755 index 0000000..37650d1 --- /dev/null +++ b/es_2_0/Fragment.c @@ -0,0 +1,419 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(Scissor)(GLint x, GLint y, GLsizei width, GLsizei height) { + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(Scissor)(x, y, width, height); +} + +void GL_APIENTRY ES2ENTRY(StencilFunc)(GLenum func, GLint ref, GLuint mask) { + switch (func) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + break; + } + FNPTR(StencilFunc)(func, ref, mask); +} + +void GL_APIENTRY ES2ENTRY(StencilFuncSeparate)(GLenum face, GLenum func, GLint ref, GLuint mask) { + switch (face) { + default: + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + } + switch (func) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_NEVER: + case GL_LESS: + case GL_LEQUAL: + case GL_GREATER: + case GL_GEQUAL: + case GL_EQUAL: + case GL_NOTEQUAL: + case GL_ALWAYS: + break; + } + FNPTR(StencilFuncSeparate)(face, func, ref, mask); +} + +void GL_APIENTRY ES2ENTRY(StencilOp)(GLenum fail, GLenum zfail, GLenum zpass) { + switch (fail) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_KEEP: + case GL_REPLACE: + case GL_INCR: + case GL_INCR_WRAP: + case GL_DECR: + case GL_DECR_WRAP: + case GL_INVERT: + break; + } + switch (zfail) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_KEEP: + case GL_REPLACE: + case GL_INCR: + case GL_INCR_WRAP: + case GL_DECR: + case GL_DECR_WRAP: + case GL_INVERT: + break; + } + switch (zpass) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_KEEP: + case GL_REPLACE: + case GL_INCR: + case GL_INCR_WRAP: + case GL_DECR: + case GL_DECR_WRAP: + case GL_INVERT: + break; + } + FNPTR(StencilOp)(fail, zfail, zpass); +} + +void GL_APIENTRY ES2ENTRY(StencilOpSeparate)(GLenum face, GLenum fail, GLenum zfail, GLenum zpass) { + switch (face) { + default: + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + } + switch (fail) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_KEEP: + case GL_REPLACE: + case GL_INCR: + case GL_INCR_WRAP: + case GL_DECR: + case GL_DECR_WRAP: + case GL_INVERT: + break; + } + switch (zfail) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_KEEP: + case GL_REPLACE: + case GL_INCR: + case GL_INCR_WRAP: + case GL_DECR: + case GL_DECR_WRAP: + case GL_INVERT: + break; + } + switch (zpass) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_KEEP: + case GL_REPLACE: + case GL_INCR: + case GL_INCR_WRAP: + case GL_DECR: + case GL_DECR_WRAP: + case GL_INVERT: + break; + } + FNPTR(StencilOpSeparate)(face, fail, zfail, zpass); +} + +void GL_APIENTRY ES2ENTRY(DepthFunc)(GLenum func) { + switch (func) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_NEVER: + case GL_LESS: + case GL_EQUAL: + case GL_LEQUAL: + case GL_GREATER: + case GL_NOTEQUAL: + case GL_GEQUAL: + case GL_ALWAYS: + break; + } + FNPTR(DepthFunc)(func); +} + +void GL_APIENTRY ES2ENTRY(BlendFunc)(GLenum sfactor, GLenum dfactor) { + switch (sfactor) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; + } + switch (dfactor) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + } + FNPTR(BlendFunc)(sfactor, dfactor); +} + +void GL_APIENTRY ES2ENTRY(BlendFuncSeparate)(GLenum srcRGB, GLenum dstRGB, + GLenum srcAlpha, GLenum dstAlpha) { + switch (srcRGB) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; + } + switch (dstRGB) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + } + switch (srcAlpha) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + case GL_SRC_ALPHA_SATURATE: + break; + } + switch (dstAlpha) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ZERO: + case GL_ONE: + case GL_SRC_COLOR: + case GL_ONE_MINUS_SRC_COLOR: + case GL_DST_COLOR: + case GL_ONE_MINUS_DST_COLOR: + case GL_SRC_ALPHA: + case GL_ONE_MINUS_SRC_ALPHA: + case GL_DST_ALPHA: + case GL_ONE_MINUS_DST_ALPHA: + case GL_CONSTANT_COLOR: + case GL_ONE_MINUS_CONSTANT_COLOR: + case GL_CONSTANT_ALPHA: + case GL_ONE_MINUS_CONSTANT_ALPHA: + break; + } + FNPTR(BlendFuncSeparate)(srcRGB, dstRGB, srcAlpha, dstAlpha); +} + +void GL_APIENTRY ES2ENTRY(BlendColor)(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) { + FNPTR(BlendColor)(red, green, blue, alpha); +} + +void GL_APIENTRY ES2ENTRY(BlendEquation)(GLenum mode) { + switch (mode) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + break; + } + FNPTR(BlendEquation)(mode); +} + +void GL_APIENTRY ES2ENTRY(BlendEquationSeparate)(GLenum modeRGB, GLenum modeAlpha) { + switch (modeRGB) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + break; + } + switch (modeAlpha) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_FUNC_ADD: + case GL_FUNC_SUBTRACT: + case GL_FUNC_REVERSE_SUBTRACT: + break; + } + FNPTR(BlendEquationSeparate)(modeRGB, modeAlpha); +} + +void GL_APIENTRY ES2ENTRY(SampleCoverage)(GLclampf value, GLboolean invert) { + FNPTR(SampleCoverage)(value, invert); +} + +void GL_APIENTRY ES2ENTRY(ReadPixels)(GLint x, GLint y, + GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid* pixels) { + switch (format) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (format != GL_RGB) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (format != GL_RGBA) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + } + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + + FNPTR(ReadPixels)(x, y, width, height, format, type, pixels); +} diff --git a/es_2_0/Framebuffer.c b/es_2_0/Framebuffer.c new file mode 100755 index 0000000..b18c41f --- /dev/null +++ b/es_2_0/Framebuffer.c @@ -0,0 +1,339 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <GLES2/gl2ext.h> + + +void GL_APIENTRY ES2ENTRY(GenFramebuffers)(GLsizei n, GLuint* framebuffers) { + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (n == 0) { + return; + } + FNPTR(GenFramebuffers)(n, framebuffers); +} + +void GL_APIENTRY ES2ENTRY(GenRenderbuffers)(GLsizei n, GLuint* renderbuffers) { + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (n == 0) { + return; + } + FNPTR(GenRenderbuffers)(n, renderbuffers); +} + +void GL_APIENTRY ES2ENTRY(DeleteFramebuffers)(GLsizei n, const GLuint* framebuffers) { + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(DeleteFramebuffers)(n, framebuffers); +} + +void GL_APIENTRY ES2ENTRY(DeleteRenderbuffers)(GLsizei n, const GLuint* renderbuffers) { + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(DeleteRenderbuffers)(n, renderbuffers); +} + +GLboolean GL_APIENTRY ES2ENTRY(IsFramebuffer)(GLuint framebuffer) { + register GLboolean bAnswer; + bAnswer = FNPTR(IsFramebuffer)(framebuffer); + return bAnswer; +} + +GLboolean GL_APIENTRY ES2ENTRY(IsRenderbuffer)(GLuint renderbuffer) { + register GLboolean bAnswer; + bAnswer = FNPTR(IsRenderbuffer)(renderbuffer); + return bAnswer; +} + +void GL_APIENTRY ES2ENTRY(BindFramebuffer)(GLenum target, GLuint framebuffer) { + if (target != GL_FRAMEBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(BindFramebuffer)(target, framebuffer); +} + +void GL_APIENTRY ES2ENTRY(BindRenderbuffer)(GLenum target, GLuint renderbuffer) { + if (target != GL_RENDERBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(BindRenderbuffer)(target, renderbuffer); +} + +void GL_APIENTRY ES2ENTRY(RenderbufferStorage)(GLenum target, + GLenum internalformat, GLsizei width, GLsizei height) { + int iMaxSize; + GLuint uRenderBuffer; + if (target != GL_RENDERBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + switch (internalformat) { + default: + case GL_DEPTH_COMPONENT24_OES: + case GL_DEPTH_COMPONENT32_OES: + case GL_STENCIL_INDEX: + case GL_DEPTH_STENCIL_OES: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; +#if defined(PROVIDING_OES_rgb8_rgba8) + case GL_RGB8_OES: + case GL_RGBA8_OES: +#endif +#if defined(PROVIDING_OES_packed_depth_stencil) + case GL_DEPTH24_STENCIL8_OES: +#endif + case GL_RGBA4: + case GL_RGB5_A1: + case GL_DEPTH_COMPONENT16: + case GL_STENCIL_INDEX8: + break; + case GL_RGB565: + internalformat = GL_RGB5_A1; + break; + } + FNPTR(GetIntegerv)(GL_MAX_RENDERBUFFER_SIZE, &iMaxSize); + if (width < 0 || iMaxSize < width || height < 0 || iMaxSize < height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_RENDERBUFFER_BINDING, &uRenderBuffer); + if (uRenderBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(RenderbufferStorage)(target, internalformat, width, height); +} + +void GL_APIENTRY ES2ENTRY(GetRenderbufferParameteriv)(GLenum target, GLenum pname, GLint* params) { + GLuint uRenderBuffer; + if (target != GL_RENDERBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_RENDERBUFFER_WIDTH: + case GL_RENDERBUFFER_HEIGHT: + case GL_RENDERBUFFER_INTERNAL_FORMAT: + case GL_RENDERBUFFER_RED_SIZE: + case GL_RENDERBUFFER_GREEN_SIZE: + case GL_RENDERBUFFER_BLUE_SIZE: + case GL_RENDERBUFFER_ALPHA_SIZE: + case GL_RENDERBUFFER_DEPTH_SIZE: + case GL_RENDERBUFFER_STENCIL_SIZE: + break; + } + FNPTR(GetIntegerv)(GL_RENDERBUFFER_BINDING, &uRenderBuffer); + if (uRenderBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetRenderbufferParameteriv)(target, pname, params); +} + +void GL_APIENTRY ES2ENTRY(FramebufferRenderbuffer)(GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer) { + GLuint uBuffer; + if (target != GL_FRAMEBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(GetIntegerv)(GL_FRAMEBUFFER_BINDING, &uBuffer); + if (uBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (renderbuffertarget != GL_RENDERBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (renderbuffer != 0 && FNPTR(IsRenderbuffer)(renderbuffer) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (attachment) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + } + FNPTR(FramebufferRenderbuffer)(target, attachment, renderbuffertarget, renderbuffer); +} + +void GL_APIENTRY ES2ENTRY(FramebufferTexture2D)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) { + GLuint uBuffer; + if (target != GL_FRAMEBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(GetIntegerv)(GL_FRAMEBUFFER_BINDING, &uBuffer); + if (uBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (attachment) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + } + if (texture == 0) { + FNPTR(FramebufferTexture2D)(target, attachment, textarget, texture, level); + return; + } + if (FNPTR(IsTexture)(texture) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (level != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } +// disable GenMipmap which caused driver crash on Ubuntu with Intel graphic card. +#if 0 + switch (textarget) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GenerateMipmap)(GL_TEXTURE_2D); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + FNPTR(GenerateMipmap)(GL_TEXTURE_CUBE_MAP); + break; + } +#endif + FNPTR(FramebufferTexture2D)(target, attachment, textarget, texture, level); +} + +void GL_APIENTRY ES2ENTRY(GetFramebufferAttachmentParameteriv)(GLenum target, + GLenum attachment, GLenum pname, GLint* params) { + GLuint uBuffer; + if (target != GL_FRAMEBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(GetIntegerv)(GL_FRAMEBUFFER_BINDING, &uBuffer); + if (uBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (attachment) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE: + case GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL: + case GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE: + break; + } + FNPTR(GetFramebufferAttachmentParameteriv)(target, attachment, pname, params); +} + +#if ! defined(GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT) +#define GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT 0x8CD8 +#endif +#if ! defined(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER) +#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER 0x8CDB +#endif +#if ! defined(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER) +#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER 0x8CDC +#endif +#if ! defined(GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT) +#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA +#endif +#if ! defined(GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE) +#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE 0x8D56 +#endif + +GLenum GL_APIENTRY ES2ENTRY(CheckFramebufferStatus)(GLenum target) { + register GLenum eValue; + if (target != GL_FRAMEBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + } + eValue = FNPTR(CheckFramebufferStatus)(target); + switch (eValue) { + default: + case GL_FRAMEBUFFER_COMPLETE: + case GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT: + case GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT: + case GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS: + case GL_FRAMEBUFFER_UNSUPPORTED: + break; + case GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER: + case GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER: + eValue = GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + break; + case GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT: + case GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE: + eValue = GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS; + break; + case 0: + eValue = GL_FRAMEBUFFER_UNSUPPORTED; + break; + } + return (eValue == 0) ? GL_FRAMEBUFFER_UNSUPPORTED : eValue; +} diff --git a/es_2_0/Get.c b/es_2_0/Get.c new file mode 100755 index 0000000..bd2f2e8 --- /dev/null +++ b/es_2_0/Get.c @@ -0,0 +1,455 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <GLES2/gl2ext.h> + +#ifndef GL_MAX_FRAGMENT_UNIFORM_COMPONENTS +#define GL_MAX_FRAGMENT_UNIFORM_COMPONENTS 0x8B49 +#endif +#ifndef GL_MAX_VARYING_FLOATS +#define GL_MAX_VARYING_FLOATS 0x8B4B +#endif +#ifndef GL_MAX_VERTEX_UNIFORM_COMPONENTS +#define GL_MAX_VERTEX_UNIFORM_COMPONENTS 0x8B4A +#endif + +const GLubyte* GL_APIENTRY ES2ENTRY(GetString)(GLenum name) { + static char buf[128]; + switch (name) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return NULL; + break; + case GL_VENDOR: + return (GLubyte*)"Huone Inc."; + break; + case GL_RENDERER: +#if defined(__pic__) + return (GLubyte*)"AlexGL ES 2.0 dynamic on OpenGL(" __DATE__ " " __TIME__ ")"; +#else + return (GLubyte*)"AlexGL ES 2.0 on OpenGL(" __DATE__ " " __TIME__ ")"; +#endif + break; + case GL_VERSION: + sprintf(buf, "OpenGL ES 2.0 (on %s)", FNPTR(GetString)(GL_VERSION)); + return (GLubyte*)buf; + break; + case GL_SHADING_LANGUAGE_VERSION: + return (GLubyte*)FNPTR(GetString)(name); + break; + case GL_EXTENSIONS: + return (GLubyte*) +#if defined(PROVIDING_OES_blend_func_separate) + "GL_OES_blend_func_separate " +#endif +#if defined(PROVIDING_OES_blend_subtract) + "GL_OES_blend_subtract " +#endif +#if defined(PROVIDING_OES_fixed_point) + "GL_OES_fixed_point " +#endif +#if defined(PROVIDING_OES_single_precision) + "GL_OES_single_precision " +#endif +#if defined(PROVIDING_OES_stencil_wrap) + "GL_OES_stencil_wrap " +#endif +#if defined(PROVIDING_OES_texture_mirrored_repeat) + "GL_OES_texture_mirrored_repeat " +#endif +#if defined(PROVIDING_OES_element_index_uint) + "GL_OES_element_index_uint " +#endif +#if defined(PROVIDING_OES_texture_3D) + "GL_OES_texture_3D " +#endif +#if defined(PROVIDING_OES_texture_npot) + "GL_OES_texture_npot " +#endif +#if defined(PROVIDING_OES_rgb8_rgba8) + "GL_OES_rgb8_rgba8 " +#endif +#if defined(PROVIDING_OES_packed_depth_stencil) + "GL_OES_packed_depth_stencil " +#endif + ""; + break; + } +} + +void GL_APIENTRY ES2ENTRY(GetFloatv)(GLenum pname, GLfloat* params) { + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ACTIVE_TEXTURE: + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_ALPHA_BITS: + case GL_ARRAY_BUFFER_BINDING: + case GL_BLEND: + case GL_BLEND_COLOR: + case GL_BLEND_DST_ALPHA: + case GL_BLEND_DST_RGB: + case GL_BLEND_EQUATION_ALPHA: + case GL_BLEND_EQUATION_RGB: + case GL_BLEND_SRC_ALPHA: + case GL_BLEND_SRC_RGB: + case GL_BLUE_BITS: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_COMPRESSED_TEXTURE_FORMATS: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_CURRENT_PROGRAM: + case GL_DEPTH_BITS: + case GL_DEPTH_CLEAR_VALUE: + case GL_DEPTH_FUNC: + case GL_DEPTH_RANGE: + case GL_DEPTH_TEST: + case GL_DEPTH_WRITEMASK: + case GL_DITHER: + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + case GL_FRAMEBUFFER_BINDING: + case GL_FRONT_FACE: + case GL_GENERATE_MIPMAP_HINT: + case GL_GREEN_BITS: + case GL_LINE_WIDTH: + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + case GL_MAX_RENDERBUFFER_SIZE: + case GL_MAX_TEXTURE_IMAGE_UNITS: + case GL_MAX_TEXTURE_SIZE: + case GL_MAX_VERTEX_ATTRIBS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_VIEWPORT_DIMS: + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + case GL_PACK_ALIGNMENT: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_RENDERBUFFER_BINDING: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_SCISSOR_BOX: + case GL_SCISSOR_TEST: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_WRITEMASK: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_FUNC: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_WRITEMASK: + case GL_SUBPIXEL_BITS: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_UNPACK_ALIGNMENT: + case GL_VIEWPORT: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_BINDING_3D_OES: + case GL_MAX_3D_TEXTURE_SIZE_OES: +#endif + break; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + FNPTR(GetFloatv)(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, params); + *params /= 4; + return; + case GL_MAX_VARYING_VECTORS: + FNPTR(GetFloatv)(GL_MAX_VARYING_FLOATS, params); + *params /= 4; + return; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + FNPTR(GetFloatv)(GL_MAX_VERTEX_UNIFORM_COMPONENTS, params); + *params /= 4; + return; + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + *params = (GLfloat)GL_RGBA; + return; + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + *params = (GLfloat)GL_UNSIGNED_BYTE; + return; + case GL_NUM_SHADER_BINARY_FORMATS: + *params = 0; + return; + case GL_SHADER_BINARY_FORMATS: + *params = 0; + return; + case GL_SHADER_COMPILER: + *params = (GLfloat)GL_TRUE; + return; + } + FNPTR(GetFloatv)(pname, params); +} + +void GL_APIENTRY ES2ENTRY(GetBooleanv)(GLenum pname, GLboolean* params) { + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ACTIVE_TEXTURE: + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_ALPHA_BITS: + case GL_ARRAY_BUFFER_BINDING: + case GL_BLEND: + case GL_BLEND_COLOR: + case GL_BLEND_DST_ALPHA: + case GL_BLEND_DST_RGB: + case GL_BLEND_EQUATION_ALPHA: + case GL_BLEND_EQUATION_RGB: + case GL_BLEND_SRC_ALPHA: + case GL_BLEND_SRC_RGB: + case GL_BLUE_BITS: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_COMPRESSED_TEXTURE_FORMATS: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_CURRENT_PROGRAM: + case GL_DEPTH_BITS: + case GL_DEPTH_CLEAR_VALUE: + case GL_DEPTH_FUNC: + case GL_DEPTH_RANGE: + case GL_DEPTH_TEST: + case GL_DEPTH_WRITEMASK: + case GL_DITHER: + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + case GL_FRAMEBUFFER_BINDING: + case GL_FRONT_FACE: + case GL_GENERATE_MIPMAP_HINT: + case GL_GREEN_BITS: + case GL_LINE_WIDTH: + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + case GL_MAX_RENDERBUFFER_SIZE: + case GL_MAX_TEXTURE_IMAGE_UNITS: + case GL_MAX_TEXTURE_SIZE: + case GL_MAX_VERTEX_ATTRIBS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_VIEWPORT_DIMS: + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + case GL_PACK_ALIGNMENT: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_RENDERBUFFER_BINDING: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_SCISSOR_BOX: + case GL_SCISSOR_TEST: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_WRITEMASK: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_FUNC: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_WRITEMASK: + case GL_SUBPIXEL_BITS: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_UNPACK_ALIGNMENT: + case GL_VIEWPORT: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_BINDING_3D_OES: + case GL_MAX_3D_TEXTURE_SIZE_OES: +#endif + break; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + FNPTR(GetBooleanv)(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, params); + return; + case GL_MAX_VARYING_VECTORS: + FNPTR(GetBooleanv)(GL_MAX_VARYING_FLOATS, params); + return; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + FNPTR(GetBooleanv)(GL_MAX_VERTEX_UNIFORM_COMPONENTS, params); + return; + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + *params = (GLboolean)GL_TRUE; + return; + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + *params = (GLboolean)GL_TRUE; + return; + case GL_NUM_SHADER_BINARY_FORMATS: + *params = (GLboolean)0; + return; + case GL_SHADER_BINARY_FORMATS: + *params = (GLboolean)0; + return; + case GL_SHADER_COMPILER: + *params = (GLboolean)GL_TRUE; + return; + } + FNPTR(GetBooleanv)(pname, params); +} + +void GL_APIENTRY ES2ENTRY(GetIntegerv)(GLenum pname, GLint* params) { + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ACTIVE_TEXTURE: + case GL_ALIASED_LINE_WIDTH_RANGE: + case GL_ALIASED_POINT_SIZE_RANGE: + case GL_ALPHA_BITS: + case GL_ARRAY_BUFFER_BINDING: + case GL_BLEND: + case GL_BLEND_COLOR: + case GL_BLEND_DST_ALPHA: + case GL_BLEND_DST_RGB: + case GL_BLEND_EQUATION_ALPHA: + case GL_BLEND_EQUATION_RGB: + case GL_BLEND_SRC_ALPHA: + case GL_BLEND_SRC_RGB: + case GL_BLUE_BITS: + case GL_COLOR_CLEAR_VALUE: + case GL_COLOR_WRITEMASK: + case GL_COMPRESSED_TEXTURE_FORMATS: + case GL_CULL_FACE: + case GL_CULL_FACE_MODE: + case GL_CURRENT_PROGRAM: + case GL_DEPTH_BITS: + case GL_DEPTH_CLEAR_VALUE: + case GL_DEPTH_FUNC: + case GL_DEPTH_RANGE: + case GL_DEPTH_TEST: + case GL_DEPTH_WRITEMASK: + case GL_DITHER: + case GL_ELEMENT_ARRAY_BUFFER_BINDING: + case GL_FRAMEBUFFER_BINDING: + case GL_FRONT_FACE: + case GL_GENERATE_MIPMAP_HINT: + case GL_GREEN_BITS: + case GL_LINE_WIDTH: + case GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS: + case GL_MAX_CUBE_MAP_TEXTURE_SIZE: + case GL_MAX_RENDERBUFFER_SIZE: + case GL_MAX_TEXTURE_IMAGE_UNITS: + case GL_MAX_TEXTURE_SIZE: + case GL_MAX_VERTEX_ATTRIBS: + case GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS: + case GL_MAX_VIEWPORT_DIMS: + case GL_NUM_COMPRESSED_TEXTURE_FORMATS: + case GL_PACK_ALIGNMENT: + case GL_POLYGON_OFFSET_FACTOR: + case GL_POLYGON_OFFSET_FILL: + case GL_POLYGON_OFFSET_UNITS: + case GL_RED_BITS: + case GL_RENDERBUFFER_BINDING: + case GL_SAMPLE_BUFFERS: + case GL_SAMPLE_COVERAGE_INVERT: + case GL_SAMPLE_COVERAGE_VALUE: + case GL_SAMPLES: + case GL_SCISSOR_BOX: + case GL_SCISSOR_TEST: + case GL_STENCIL_BACK_FAIL: + case GL_STENCIL_BACK_FUNC: + case GL_STENCIL_BACK_PASS_DEPTH_FAIL: + case GL_STENCIL_BACK_PASS_DEPTH_PASS: + case GL_STENCIL_BACK_REF: + case GL_STENCIL_BACK_VALUE_MASK: + case GL_STENCIL_BACK_WRITEMASK: + case GL_STENCIL_BITS: + case GL_STENCIL_CLEAR_VALUE: + case GL_STENCIL_FAIL: + case GL_STENCIL_FUNC: + case GL_STENCIL_PASS_DEPTH_FAIL: + case GL_STENCIL_PASS_DEPTH_PASS: + case GL_STENCIL_REF: + case GL_STENCIL_TEST: + case GL_STENCIL_VALUE_MASK: + case GL_STENCIL_WRITEMASK: + case GL_SUBPIXEL_BITS: + case GL_TEXTURE_BINDING_2D: + case GL_TEXTURE_BINDING_CUBE_MAP: + case GL_UNPACK_ALIGNMENT: + case GL_VIEWPORT: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_BINDING_3D_OES: + case GL_MAX_3D_TEXTURE_SIZE_OES: +#endif + break; + case GL_MAX_FRAGMENT_UNIFORM_VECTORS: + FNPTR(GetIntegerv)(GL_MAX_FRAGMENT_UNIFORM_COMPONENTS, params); + *params /= 4; + return; + case GL_MAX_VARYING_VECTORS: + FNPTR(GetIntegerv)(GL_MAX_VARYING_FLOATS, params); + *params /= 4; + return; + case GL_MAX_VERTEX_UNIFORM_VECTORS: + FNPTR(GetIntegerv)(GL_MAX_VERTEX_UNIFORM_COMPONENTS, params); + *params /= 4; + return; + case GL_IMPLEMENTATION_COLOR_READ_FORMAT: + *params = GL_RGBA; + return; + case GL_IMPLEMENTATION_COLOR_READ_TYPE: + *params = GL_UNSIGNED_BYTE; + return; + case GL_NUM_SHADER_BINARY_FORMATS: + *params = 0; + return; + case GL_SHADER_BINARY_FORMATS: + *params = 0; + return; + case GL_SHADER_COMPILER: + *params = (GLint)GL_TRUE; + return; + } + FNPTR(GetIntegerv)(pname, params); +} diff --git a/es_2_0/Link.c b/es_2_0/Link.c new file mode 100755 index 0000000..e77b376 --- /dev/null +++ b/es_2_0/Link.c @@ -0,0 +1,163 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(GetActiveUniform)(GLuint program, + GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { + GLint nActiveUniforms; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetProgramiv)(program, GL_ACTIVE_UNIFORMS, &nActiveUniforms); + if (index >= nActiveUniforms) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (bufsize < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetActiveUniform)(program, index, bufsize, length, size, type, name); + assert(*type == GL_FLOAT + || *type == GL_FLOAT_VEC2 + || *type == GL_FLOAT_VEC3 + || *type == GL_FLOAT_VEC4 + || *type == GL_INT + || *type == GL_INT_VEC2 + || *type == GL_INT_VEC3 + || *type == GL_INT_VEC4 + || *type == GL_BOOL + || *type == GL_BOOL_VEC2 + || *type == GL_BOOL_VEC3 + || *type == GL_BOOL_VEC4 + || *type == GL_FLOAT_MAT2 + || *type == GL_FLOAT_MAT3 + || *type == GL_FLOAT_MAT4 + || *type == GL_SAMPLER_2D + || *type == GL_SAMPLER_CUBE); +} + +GLint GL_APIENTRY ES2ENTRY(GetUniformLocation)(GLuint program, const char* name) { + GLint iAnswer; + GLint iLinkStatus; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return -1; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return -1; + } + FNPTR(GetProgramiv)(program, GL_LINK_STATUS, &iLinkStatus); + if (iLinkStatus == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return -1; + } + iAnswer = FNPTR(GetUniformLocation)(program, name); + return iAnswer; +} + +void GL_APIENTRY ES2ENTRY(GetActiveAttrib)(GLuint program, + GLuint index, GLsizei bufsize, GLsizei* length, GLint* size, GLenum* type, char* name) { + GLint nActiveAttribs; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } +/* + FNPTR(GetProgramiv)(program, GL_ACTIVE_ATTRIBUTES, &nActiveAttribs); + if (index >= nActiveAttribs) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } +*/ + if (bufsize < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetActiveAttrib)(program, index, bufsize, length, size, type, name); +/* + assert(*type == GL_FLOAT + || *type == GL_FLOAT_VEC2 + || *type == GL_FLOAT_VEC3 + || *type == GL_FLOAT_VEC4 + || *type == GL_FLOAT_MAT2 + || *type == GL_FLOAT_MAT3 + || *type == GL_FLOAT_MAT4); +*/ +} + +int GL_APIENTRY ES2ENTRY(GetAttribLocation)(GLuint program, const char* name) { + GLint iAnswer; + GLint iLinkStatus; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return -1; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return -1; + } + FNPTR(GetProgramiv)(program, GL_LINK_STATUS, &iLinkStatus); + if (iLinkStatus == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return -1; + } + iAnswer = FNPTR(GetAttribLocation)(program, name); + return iAnswer; +} + +void GL_APIENTRY ES2ENTRY(BindAttribLocation)(GLuint program, GLuint index, const char* name) { + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (CCV(nMaxVertexAttribs) <= index) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + + } + if (name[0] == 'g' && name[1] == 'l' && name[2] == '_') { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(BindAttribLocation)(program, index, name); +} diff --git a/es_2_0/ParseLex.inl b/es_2_0/ParseLex.inl new file mode 100755 index 0000000..9099b91 --- /dev/null +++ b/es_2_0/ParseLex.inl @@ -0,0 +1,2453 @@ + +#line 3 "ParseLex.inl" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer hazelParse_create_buffer +#define yy_delete_buffer hazelParse_delete_buffer +#define yy_flex_debug hazelParse_flex_debug +#define yy_init_buffer hazelParse_init_buffer +#define yy_flush_buffer hazelParse_flush_buffer +#define yy_load_buffer_state hazelParse_load_buffer_state +#define yy_switch_to_buffer hazelParse_switch_to_buffer +#define yyin hazelParsein +#define yyleng hazelParseleng +#define yylex hazelParselex +#define yylineno hazelParselineno +#define yyout hazelParseout +#define yyrestart hazelParserestart +#define yytext hazelParsetext +#define yywrap hazelParsewrap +#define yyalloc hazelParsealloc +#define yyrealloc hazelParserealloc +#define yyfree hazelParsefree + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE hazelParserestart(hazelParsein ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int hazelParseleng; + +extern FILE *hazelParsein, *hazelParseout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up hazelParsetext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up hazelParsetext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via hazelParserestart()), so that the user can continue scanning by + * just pointing hazelParsein at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when hazelParsetext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int hazelParseleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow hazelParsewrap()'s to do buffer switches + * instead of setting up a fresh hazelParsein. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void hazelParserestart (FILE *input_file ); +void hazelParse_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE hazelParse_create_buffer (FILE *file,int size ); +void hazelParse_delete_buffer (YY_BUFFER_STATE b ); +void hazelParse_flush_buffer (YY_BUFFER_STATE b ); +void hazelParsepush_buffer_state (YY_BUFFER_STATE new_buffer ); +void hazelParsepop_buffer_state (void ); + +static void hazelParseensure_buffer_stack (void ); +static void hazelParse_load_buffer_state (void ); +static void hazelParse_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER hazelParse_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE hazelParse_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE hazelParse_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE hazelParse_scan_bytes (yyconst char *bytes,int len ); + +void *hazelParsealloc (yy_size_t ); +void *hazelParserealloc (void *,yy_size_t ); +void hazelParsefree (void * ); + +#define yy_new_buffer hazelParse_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + hazelParseensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + hazelParse_create_buffer(hazelParsein,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + hazelParseensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + hazelParse_create_buffer(hazelParsein,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +typedef unsigned char YY_CHAR; + +FILE *hazelParsein = (FILE *) 0, *hazelParseout = (FILE *) 0; + +typedef int yy_state_type; + +extern int hazelParselineno; + +int hazelParselineno = 1; + +extern char *hazelParsetext; +#define yytext_ptr hazelParsetext + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up hazelParsetext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + hazelParseleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 133 +#define YY_END_OF_BUFFER 134 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[428] = + { 0, + 0, 0, 134, 132, 127, 128, 126, 132, 122, 123, + 132, 132, 132, 132, 132, 94, 93, 93, 129, 132, + 132, 132, 92, 124, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 130, 125, 131, 121, 113, 111, + 102, 101, 112, 107, 100, 103, 118, 98, 104, 97, + 94, 0, 0, 0, 93, 93, 109, 110, 105, 106, + 117, 92, 119, 120, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 81, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 84, 73, + + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 114, 115, 0, + 96, 0, 0, 99, 95, 108, 116, 1, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 82, 92, 92, 92, + 92, 92, 92, 92, 92, 52, 92, 92, 92, 92, + 92, 92, 92, 92, 74, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 0, 98, + + 0, 0, 97, 92, 51, 92, 92, 46, 92, 92, + 92, 92, 92, 92, 92, 85, 4, 92, 92, 92, + 20, 92, 92, 9, 24, 92, 92, 92, 92, 92, + 92, 92, 92, 21, 76, 63, 64, 65, 92, 92, + 92, 92, 92, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 92, 92, 7, 90, 92, 92, 92, 92, + 92, 92, 54, 55, 56, 50, 92, 92, 0, 96, + 92, 79, 57, 58, 59, 2, 70, 92, 92, 92, + 92, 33, 34, 35, 92, 91, 25, 53, 36, 37, + 38, 78, 30, 31, 32, 92, 75, 28, 92, 92, + + 60, 61, 62, 92, 92, 92, 92, 92, 92, 92, + 92, 92, 22, 92, 92, 92, 92, 92, 92, 92, + 92, 3, 92, 48, 92, 92, 83, 92, 92, 92, + 92, 23, 17, 12, 92, 92, 92, 92, 92, 29, + 8, 92, 15, 88, 92, 45, 16, 89, 27, 10, + 92, 92, 92, 92, 92, 92, 92, 92, 11, 87, + 92, 92, 92, 77, 92, 92, 92, 92, 92, 5, + 71, 92, 72, 92, 92, 80, 18, 92, 92, 92, + 13, 92, 92, 92, 92, 92, 6, 26, 14, 69, + 19, 68, 47, 86, 39, 66, 49, 92, 92, 92, + + 92, 92, 92, 92, 92, 92, 92, 67, 92, 92, + 92, 92, 92, 42, 92, 43, 92, 92, 92, 40, + 92, 41, 92, 92, 92, 44, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 4, 5, 1, 1, 1, 6, 7, 1, 1, + 1, 8, 9, 1, 10, 11, 12, 13, 14, 15, + 16, 17, 18, 18, 18, 19, 19, 1, 20, 21, + 22, 23, 1, 1, 24, 24, 25, 26, 27, 24, + 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, + 28, 29, 30, 28, 28, 28, 28, 31, 28, 28, + 1, 1, 1, 32, 28, 1, 33, 34, 35, 36, + + 37, 38, 39, 40, 41, 28, 42, 43, 44, 45, + 46, 47, 28, 48, 49, 50, 51, 52, 53, 54, + 55, 56, 57, 58, 59, 60, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[61] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, + 3, 1, 4, 4, 4, 4, 4, 4, 4, 1, + 1, 1, 1, 5, 5, 5, 6, 7, 7, 7, + 7, 1, 5, 5, 5, 5, 6, 5, 7, 7, + 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, + 7, 7, 7, 7, 7, 7, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[439] = + { 0, + 0, 0, 553, 554, 554, 554, 554, 530, 529, 54, + 528, 53, 55, 53, 527, 67, 68, 62, 554, 42, + 526, 68, 0, 70, 47, 55, 67, 71, 66, 73, + 501, 85, 77, 500, 91, 94, 494, 97, 507, 101, + 95, 104, 122, 503, 554, 109, 554, 554, 554, 554, + 554, 554, 554, 554, 554, 554, 554, 109, 554, 120, + 102, 133, 129, 0, 147, 150, 520, 554, 554, 554, + 519, 0, 554, 554, 496, 489, 492, 500, 499, 486, + 501, 488, 494, 482, 479, 492, 479, 476, 476, 482, + 470, 129, 475, 485, 471, 477, 480, 481, 0, 126, + + 480, 118, 466, 479, 470, 472, 462, 476, 473, 475, + 458, 463, 460, 449, 131, 457, 462, 458, 460, 449, + 452, 139, 457, 449, 461, 140, 454, 554, 554, 176, + 155, 180, 180, 187, 0, 554, 554, 0, 446, 450, + 459, 456, 440, 440, 158, 455, 452, 452, 450, 447, + 439, 445, 432, 443, 429, 445, 0, 442, 430, 437, + 434, 438, 431, 420, 419, 432, 435, 432, 427, 418, + 194, 423, 426, 417, 414, 418, 424, 415, 406, 409, + 407, 417, 403, 401, 414, 400, 402, 399, 410, 409, + 174, 404, 399, 388, 198, 406, 408, 397, 208, 215, + + 207, 222, 229, 398, 0, 396, 234, 0, 388, 386, + 394, 383, 400, 389, 237, 0, 0, 383, 393, 393, + 0, 378, 240, 0, 0, 380, 243, 381, 375, 374, + 375, 374, 246, 0, 0, 0, 0, 0, 370, 371, + 376, 367, 380, 375, 374, 366, 370, 362, 365, 369, + 374, 360, 372, 363, 0, 0, 369, 358, 358, 363, + 362, 359, 0, 0, 0, 0, 349, 361, 251, 258, + 363, 0, 0, 0, 0, 0, 0, 351, 352, 346, + 356, 0, 0, 0, 347, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 354, 0, 0, 352, 348, + + 0, 0, 0, 344, 340, 345, 335, 348, 334, 347, + 336, 343, 0, 341, 343, 327, 329, 335, 341, 336, + 324, 0, 326, 0, 325, 328, 0, 317, 316, 316, + 329, 0, 331, 0, 330, 329, 314, 327, 314, 0, + 0, 317, 0, 0, 309, 0, 0, 0, 0, 0, + 306, 317, 310, 316, 313, 308, 300, 312, 0, 0, + 305, 312, 301, 0, 310, 307, 297, 264, 305, 0, + 0, 305, 0, 303, 302, 0, 0, 301, 287, 299, + 0, 290, 308, 307, 306, 280, 0, 0, 0, 0, + 0, 0, 0, 0, 300, 189, 300, 294, 287, 288, + + 282, 282, 276, 277, 271, 270, 261, 0, 256, 238, + 251, 236, 239, 254, 237, 0, 229, 241, 138, 0, + 132, 0, 57, 42, 21, 0, 554, 287, 291, 294, + 298, 301, 305, 310, 311, 316, 319, 322 + } ; + +static yyconst flex_int16_t yy_def[439] = + { 0, + 427, 1, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 428, 429, 427, 427, + 427, 427, 430, 427, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 431, 427, 432, + 16, 433, 434, 435, 428, 429, 427, 427, 427, 427, + 427, 430, 427, 427, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 427, 427, 436, + 432, 437, 427, 427, 435, 427, 427, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 427, 427, + + 438, 427, 427, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 427, 427, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 430, 430, 430, 430, + 430, 430, 430, 430, 430, 430, 0, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427 + } ; + +static yyconst flex_int16_t yy_nxt[615] = + { 0, + 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, + 14, 15, 16, 17, 17, 17, 17, 17, 18, 19, + 20, 21, 22, 23, 23, 23, 23, 23, 23, 23, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 23, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 43, 44, 23, 23, 23, 45, 46, 47, 48, + 51, 54, 67, 68, 56, 58, 58, 58, 58, 58, + 58, 58, 60, 426, 55, 52, 57, 60, 60, 61, + 61, 61, 61, 61, 61, 62, 66, 425, 63, 70, + 71, 73, 424, 63, 63, 75, 76, 64, 63, 80, + + 77, 74, 78, 63, 63, 90, 79, 83, 87, 81, + 88, 84, 82, 91, 99, 92, 85, 96, 93, 89, + 64, 100, 86, 103, 94, 97, 105, 104, 101, 108, + 128, 118, 427, 112, 119, 130, 98, 133, 133, 106, + 113, 114, 120, 60, 109, 130, 132, 110, 122, 121, + 115, 116, 123, 117, 124, 427, 132, 60, 125, 63, + 60, 155, 169, 183, 423, 66, 129, 126, 163, 63, + 170, 164, 165, 63, 156, 166, 63, 167, 184, 191, + 196, 201, 197, 63, 199, 199, 63, 192, 202, 202, + 422, 201, 134, 134, 134, 134, 134, 134, 134, 134, + + 134, 134, 134, 134, 134, 134, 210, 211, 236, 237, + 238, 258, 263, 264, 265, 269, 269, 400, 401, 259, + 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, + 200, 200, 200, 200, 203, 203, 203, 203, 203, 203, + 203, 203, 203, 203, 203, 203, 203, 203, 273, 274, + 275, 282, 283, 284, 289, 290, 291, 293, 294, 295, + 301, 302, 303, 270, 270, 270, 270, 270, 270, 270, + 270, 270, 270, 270, 270, 270, 270, 383, 384, 385, + 421, 420, 419, 418, 417, 416, 415, 414, 386, 65, + 65, 413, 65, 66, 66, 412, 66, 72, 72, 72, + + 72, 58, 411, 58, 131, 410, 131, 62, 62, 409, + 62, 134, 408, 134, 135, 135, 135, 200, 407, 200, + 203, 406, 203, 270, 405, 270, 404, 403, 402, 399, + 398, 397, 396, 395, 394, 393, 392, 391, 390, 389, + 388, 387, 382, 381, 380, 379, 378, 377, 376, 375, + 374, 373, 372, 371, 370, 369, 368, 367, 366, 365, + 364, 363, 362, 361, 360, 359, 358, 357, 356, 355, + 354, 353, 352, 351, 350, 349, 348, 347, 346, 345, + 344, 343, 342, 341, 340, 339, 338, 337, 336, 335, + 334, 333, 332, 331, 330, 329, 328, 327, 326, 325, + + 324, 323, 322, 321, 320, 319, 318, 317, 316, 315, + 314, 313, 312, 311, 310, 309, 308, 307, 306, 305, + 304, 300, 299, 298, 297, 296, 292, 288, 287, 286, + 285, 281, 280, 279, 278, 277, 276, 272, 271, 268, + 267, 266, 262, 261, 260, 257, 256, 255, 254, 253, + 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, + 242, 241, 240, 239, 235, 234, 233, 232, 231, 230, + 229, 228, 227, 226, 225, 224, 223, 222, 221, 220, + 219, 218, 217, 216, 215, 214, 213, 212, 209, 208, + 207, 206, 205, 204, 198, 195, 194, 193, 190, 189, + + 188, 187, 186, 185, 182, 181, 180, 179, 178, 177, + 176, 175, 174, 173, 172, 171, 168, 162, 161, 160, + 159, 158, 157, 154, 153, 152, 151, 150, 149, 148, + 147, 146, 145, 144, 143, 142, 141, 140, 139, 138, + 137, 136, 127, 111, 107, 102, 95, 69, 59, 53, + 50, 49, 427, 3, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427 + } ; + +static yyconst flex_int16_t yy_chk[615] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 10, 12, 20, 20, 13, 14, 14, 14, 14, 14, + 14, 14, 18, 425, 12, 10, 13, 16, 17, 16, + 16, 16, 16, 16, 16, 16, 17, 424, 18, 22, + 22, 24, 423, 16, 17, 25, 25, 16, 18, 27, + + 26, 24, 26, 16, 17, 30, 26, 28, 29, 27, + 29, 28, 27, 30, 33, 30, 28, 32, 30, 29, + 16, 33, 28, 35, 30, 32, 36, 35, 33, 38, + 46, 41, 61, 40, 41, 58, 32, 63, 63, 36, + 40, 40, 41, 62, 38, 58, 60, 38, 42, 41, + 40, 40, 42, 40, 43, 61, 60, 65, 43, 62, + 66, 92, 102, 115, 421, 65, 46, 43, 100, 62, + 102, 100, 100, 65, 92, 100, 66, 100, 115, 122, + 126, 131, 126, 65, 130, 130, 66, 122, 132, 132, + 419, 131, 133, 133, 133, 133, 133, 133, 133, 134, + + 134, 134, 134, 134, 134, 134, 145, 145, 171, 171, + 171, 191, 195, 195, 195, 201, 201, 396, 396, 191, + 199, 199, 199, 199, 199, 199, 199, 200, 200, 200, + 200, 200, 200, 200, 202, 202, 202, 202, 202, 202, + 202, 203, 203, 203, 203, 203, 203, 203, 207, 207, + 207, 215, 215, 215, 223, 223, 223, 227, 227, 227, + 233, 233, 233, 269, 269, 269, 269, 269, 269, 269, + 270, 270, 270, 270, 270, 270, 270, 368, 368, 368, + 418, 417, 415, 414, 413, 412, 411, 410, 368, 428, + 428, 409, 428, 429, 429, 407, 429, 430, 430, 430, + + 430, 431, 406, 431, 432, 405, 432, 433, 433, 404, + 433, 434, 403, 434, 435, 435, 435, 436, 402, 436, + 437, 401, 437, 438, 400, 438, 399, 398, 397, 395, + 386, 385, 384, 383, 382, 380, 379, 378, 375, 374, + 372, 369, 367, 366, 365, 363, 362, 361, 358, 357, + 356, 355, 354, 353, 352, 351, 345, 342, 339, 338, + 337, 336, 335, 333, 331, 330, 329, 328, 326, 325, + 323, 321, 320, 319, 318, 317, 316, 315, 314, 312, + 311, 310, 309, 308, 307, 306, 305, 304, 300, 299, + 296, 285, 281, 280, 279, 278, 271, 268, 267, 262, + + 261, 260, 259, 258, 257, 254, 253, 252, 251, 250, + 249, 248, 247, 246, 245, 244, 243, 242, 241, 240, + 239, 232, 231, 230, 229, 228, 226, 222, 220, 219, + 218, 214, 213, 212, 211, 210, 209, 206, 204, 198, + 197, 196, 194, 193, 192, 190, 189, 188, 187, 186, + 185, 184, 183, 182, 181, 180, 179, 178, 177, 176, + 175, 174, 173, 172, 170, 169, 168, 167, 166, 165, + 164, 163, 162, 161, 160, 159, 158, 156, 155, 154, + 153, 152, 151, 150, 149, 148, 147, 146, 144, 143, + 142, 141, 140, 139, 127, 125, 124, 123, 121, 120, + + 119, 118, 117, 116, 114, 113, 112, 111, 110, 109, + 108, 107, 106, 105, 104, 103, 101, 98, 97, 96, + 95, 94, 93, 91, 90, 89, 88, 87, 86, 85, + 84, 83, 82, 81, 80, 79, 78, 77, 76, 75, + 71, 67, 44, 39, 37, 34, 31, 21, 15, 11, + 9, 8, 3, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + + 427, 427, 427, 427, 427, 427, 427, 427, 427, 427, + 427, 427, 427, 427 + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int hazelParse_flex_debug; +int hazelParse_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *hazelParsetext; + +/* The generated ParseLex.c file must be included at the end of ParseYacc.c */ + +extern int hazelEnableTexture3D; + +extern int iLine; + +static int hazelParsewrap(void) { + return 1; +} + +/* +Gets input and stuffs it into "buf". +number of characters read, or YY_NULL, is returned in "result". +*/ +#undef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + { \ + if (*pSrcPtr == '\0') { \ + result = YY_NULL; \ + } else { \ + result = strlen(pSrcPtr); \ + strcpy(buf, pSrcPtr); \ + pSrcPtr += result; \ + } \ + } + +#define SET_TOKEN(_str_) \ + do { \ + memset(&(yylval), 0, sizeof(yylval)); \ + yylval.token.name = malloc(strlen(_str_) + 1); \ + strcpy(yylval.token.name, _str_); \ + } while (0) + +#define INITIAL 0 + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int hazelParselex_destroy (void ); + +int hazelParseget_debug (void ); + +void hazelParseset_debug (int debug_flag ); + +YY_EXTRA_TYPE hazelParseget_extra (void ); + +void hazelParseset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *hazelParseget_in (void ); + +void hazelParseset_in (FILE * in_str ); + +FILE *hazelParseget_out (void ); + +void hazelParseset_out (FILE * out_str ); + +int hazelParseget_leng (void ); + +char *hazelParseget_text (void ); + +int hazelParseget_lineno (void ); + +void hazelParseset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int hazelParsewrap (void ); +#else +extern int hazelParsewrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( hazelParsetext, hazelParseleng, 1, hazelParseout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + unsigned n; \ + for ( n = 0; n < max_size && \ + (c = getc( hazelParsein )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( hazelParsein ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, hazelParsein))==0 && ferror(hazelParsein)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(hazelParsein); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int hazelParselex (void); + +#define YY_DECL int hazelParselex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after hazelParsetext and hazelParseleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + /* 3.7 reserved */ + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! hazelParsein ) + hazelParsein = stdin; + + if ( ! hazelParseout ) + hazelParseout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + hazelParseensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + hazelParse_create_buffer(hazelParsein,YY_BUF_SIZE ); + } + + hazelParse_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of hazelParsetext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 428 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 554 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +case 2: +case 3: +case 4: +case 5: +case 6: +case 7: +case 8: +case 9: +case 10: +case 11: +case 12: +case 13: +case 14: +case 15: +case 16: +case 17: +case 18: +case 19: +case 20: +case 21: +case 22: +case 23: +case 24: +case 25: +case 26: +case 27: +case 28: +case 29: +case 30: +case 31: +case 32: +case 33: +case 34: +case 35: +case 36: +case 37: +case 38: +case 39: +case 40: +case 41: +case 42: +case 43: +case 44: +case 45: +case 46: +case 47: +case 48: +YY_RULE_SETUP +{ + FOUND_RESERVED(hazelParsetext); + SET_TOKEN(hazelParsetext); + return '$'; +} + YY_BREAK +case 49: +YY_RULE_SETUP +{ + if (hazelEnableTexture3D == GL_TRUE) { + SET_TOKEN(hazelParsetext); yylval.token.type = T_SAMPLER3D; return SAMPLER3D; + } else { + FOUND_RESERVED(hazelParsetext); + SET_TOKEN(hazelParsetext); + return '$'; + } +} + YY_BREAK +/* 4.1 basic types */ +case 50: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_VOID; return VOID; } + YY_BREAK +case 51: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_BOOL; return BOOL; } + YY_BREAK +case 52: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_INT; return INT; } + YY_BREAK +case 53: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_FLOAT; return FLOAT; } + YY_BREAK +case 54: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_VEC2; return VEC2; } + YY_BREAK +case 55: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_VEC3; return VEC3; } + YY_BREAK +case 56: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_VEC4; return VEC4; } + YY_BREAK +case 57: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_BVEC2; return BVEC2; } + YY_BREAK +case 58: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_BVEC3; return BVEC3; } + YY_BREAK +case 59: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_BVEC4; return BVEC4; } + YY_BREAK +case 60: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_IVEC2; return IVEC2; } + YY_BREAK +case 61: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_IVEC3; return IVEC3; } + YY_BREAK +case 62: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_IVEC4; return IVEC4; } + YY_BREAK +case 63: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_MAT2; return MAT2; } + YY_BREAK +case 64: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_MAT3; return MAT3; } + YY_BREAK +case 65: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_MAT4; return MAT4; } + YY_BREAK +case 66: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_SAMPLER2D; return SAMPLER2D; } + YY_BREAK +case 67: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = T_SAMPLERCUBE; return SAMPLERCUBE; } + YY_BREAK +/* 3.7 keywords */ +case 68: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_INVARIANT; return INVARIANT; } + YY_BREAK +case 69: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_ATTRIBUTE; return ATTRIBUTE; } + YY_BREAK +case 70: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_CONST; return CONST; } + YY_BREAK +case 71: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_UNIFORM; return UNIFORM; } + YY_BREAK +case 72: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_VARYING; return VARYING; } + YY_BREAK +case 73: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_IN; return IN; } + YY_BREAK +case 74: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_OUT; return OUT; } + YY_BREAK +case 75: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_INOUT; return INOUT; } + YY_BREAK +case 76: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_LOWP; return LOW_PRECISION; } + YY_BREAK +case 77: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_MEDIUMP; return MEDIUM_PRECISION; } + YY_BREAK +case 78: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); yylval.token.type = S_HIGHP; return HIGH_PRECISION; } + YY_BREAK +case 79: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return BREAK; } + YY_BREAK +case 80: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return CONTINUE; } + YY_BREAK +case 81: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return DO; } + YY_BREAK +case 82: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return FOR; } + YY_BREAK +case 83: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return WHILE; } + YY_BREAK +case 84: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return IF; } + YY_BREAK +case 85: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return ELSE; } + YY_BREAK +case 86: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return PRECISION; } + YY_BREAK +case 87: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return DISCARD; } + YY_BREAK +case 88: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return RETURN; } + YY_BREAK +case 89: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return STRUCT; } + YY_BREAK +/* 4.1.2 booleans */ +case 90: +YY_RULE_SETUP +{ + SET_TOKEN(hazelParsetext); + yylval.token.type = (T_BOOL | S_CONST); + yylval.token.ival = 1; + return BOOLCONSTANT; +} + YY_BREAK +case 91: +YY_RULE_SETUP +{ + SET_TOKEN(hazelParsetext); + yylval.token.type = (T_BOOL | S_CONST); + yylval.token.ival = 0; + return BOOLCONSTANT; +} + YY_BREAK +/* 3.8 identifiers */ +case 92: +YY_RULE_SETUP +{ + if (strstr(hazelParsetext, "__") != NULL) { + yyerror("identifiers containing two consecutive underscores(__) are reserved\n"); + SET_TOKEN(hazelParsetext); + return '$'; + } + SET_TOKEN(hazelParsetext); + return IDENTIFIER; +} + YY_BREAK +/* 4.1.3 integers */ +case 93: +case 94: +case 95: +YY_RULE_SETUP +{ + SET_TOKEN(hazelParsetext); + yylval.token.type = (T_INT | S_CONST); + yylval.token.ival = (int)strtol(hazelParsetext, NULL, 0); + return INTCONSTANT; +} + YY_BREAK +/* 4.1.4 floats */ +case 96: +case 97: +case 98: +case 99: +YY_RULE_SETUP +{ + SET_TOKEN(hazelParsetext); + yylval.token.type = (T_FLOAT | S_CONST); + yylval.token.fval = (float)strtod(hazelParsetext, NULL); + return FLOATCONSTANT; +} + YY_BREAK +/* operators */ +case 100: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return ADD_ASSIGN; } + YY_BREAK +case 101: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return AND_ASSIGN; /* reserved */ } + YY_BREAK +case 102: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return AND_OP; } + YY_BREAK +case 103: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return DEC_OP; } + YY_BREAK +case 104: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return DIV_ASSIGN; } + YY_BREAK +case 105: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return EQ_OP; } + YY_BREAK +case 106: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return GE_OP; } + YY_BREAK +case 107: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return INC_OP; } + YY_BREAK +case 108: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return LEFT_ASSIGN; /* reserved */ } + YY_BREAK +case 109: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return LEFT_OP; /* reserved */ } + YY_BREAK +case 110: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return LE_OP; } + YY_BREAK +case 111: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return MOD_ASSIGN; /* reserved */ } + YY_BREAK +case 112: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return MUL_ASSIGN; } + YY_BREAK +case 113: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return NE_OP; } + YY_BREAK +case 114: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return OR_ASSIGN; /* reserved */ } + YY_BREAK +case 115: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return OR_OP; } + YY_BREAK +case 116: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return RIGHT_ASSIGN; /* reserved */ } + YY_BREAK +case 117: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return RIGHT_OP; /* reserved */ } + YY_BREAK +case 118: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return SUB_ASSIGN; } + YY_BREAK +case 119: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return XOR_ASSIGN; /* reserved */ } + YY_BREAK +case 120: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return XOR_OP; } + YY_BREAK +case 121: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return hazelParsetext[0]; /* reserved */ } + YY_BREAK +case 122: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return hazelParsetext[0]; /* reserved */ } + YY_BREAK +case 123: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return hazelParsetext[0]; /* reserved */ } + YY_BREAK +case 124: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return hazelParsetext[0]; /* reserved */ } + YY_BREAK +case 125: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return hazelParsetext[0]; /* reserved */ } + YY_BREAK +/* extras */ +case 126: +YY_RULE_SETUP +{ /* ignore it */ } + YY_BREAK +case 127: +YY_RULE_SETUP +{ /* ignore it */ } + YY_BREAK +case 128: +/* rule 128 can match eol */ +YY_RULE_SETUP +{ iLine++; /* count new line */ } + YY_BREAK +case 129: +YY_RULE_SETUP +{ SET_TOKEN(";\n"); return hazelParsetext[0]; /* newline */ } + YY_BREAK +case 130: +YY_RULE_SETUP +{ SET_TOKEN("{\n"); return hazelParsetext[0]; /* newline */ } + YY_BREAK +case 131: +YY_RULE_SETUP +{ SET_TOKEN("}\n"); return hazelParsetext[0]; /* newline */ } + YY_BREAK +case 132: +YY_RULE_SETUP +{ SET_TOKEN(hazelParsetext); return hazelParsetext[0]; } + YY_BREAK +case 133: +YY_RULE_SETUP +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed hazelParsein at a new source and called + * hazelParselex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = hazelParsein; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( hazelParsewrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * hazelParsetext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of hazelParselex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + hazelParserealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + hazelParserestart(hazelParsein ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) hazelParserealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 428 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 428 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 427); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up hazelParsetext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + hazelParserestart(hazelParsein ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( hazelParsewrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve hazelParsetext */ + (yy_hold_char) = *++(yy_c_buf_p); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void hazelParserestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + hazelParseensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + hazelParse_create_buffer(hazelParsein,YY_BUF_SIZE ); + } + + hazelParse_init_buffer(YY_CURRENT_BUFFER,input_file ); + hazelParse_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void hazelParse_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * hazelParsepop_buffer_state(); + * hazelParsepush_buffer_state(new_buffer); + */ + hazelParseensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + hazelParse_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (hazelParsewrap()) processing, but the only time this flag + * is looked at is after hazelParsewrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void hazelParse_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + hazelParsein = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE hazelParse_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) hazelParsealloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in hazelParse_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) hazelParsealloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in hazelParse_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + hazelParse_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with hazelParse_create_buffer() + * + */ + void hazelParse_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + hazelParsefree((void *) b->yy_ch_buf ); + + hazelParsefree((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a hazelParserestart() or at EOF. + */ + static void hazelParse_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + hazelParse_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then hazelParse_init_buffer was _probably_ + * called from hazelParserestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void hazelParse_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + hazelParse_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void hazelParsepush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + hazelParseensure_buffer_stack(); + + /* This block is copied from hazelParse_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from hazelParse_switch_to_buffer. */ + hazelParse_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void hazelParsepop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + hazelParse_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + hazelParse_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void hazelParseensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)hazelParsealloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in hazelParseensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)hazelParserealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in hazelParseensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE hazelParse_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) hazelParsealloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in hazelParse_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + hazelParse_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to hazelParselex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * hazelParse_scan_bytes() instead. + */ +YY_BUFFER_STATE hazelParse_scan_string (yyconst char * yystr ) +{ + + return hazelParse_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to hazelParselex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE hazelParse_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) hazelParsealloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in hazelParse_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = hazelParse_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in hazelParse_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up hazelParsetext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + hazelParsetext[hazelParseleng] = (yy_hold_char); \ + (yy_c_buf_p) = hazelParsetext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + hazelParseleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int hazelParseget_lineno (void) +{ + + return hazelParselineno; +} + +/** Get the input stream. + * + */ +FILE *hazelParseget_in (void) +{ + return hazelParsein; +} + +/** Get the output stream. + * + */ +FILE *hazelParseget_out (void) +{ + return hazelParseout; +} + +/** Get the length of the current token. + * + */ +int hazelParseget_leng (void) +{ + return hazelParseleng; +} + +/** Get the current token. + * + */ + +char *hazelParseget_text (void) +{ + return hazelParsetext; +} + +/** Set the current line number. + * @param line_number + * + */ +void hazelParseset_lineno (int line_number ) +{ + + hazelParselineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see hazelParse_switch_to_buffer + */ +void hazelParseset_in (FILE * in_str ) +{ + hazelParsein = in_str ; +} + +void hazelParseset_out (FILE * out_str ) +{ + hazelParseout = out_str ; +} + +int hazelParseget_debug (void) +{ + return hazelParse_flex_debug; +} + +void hazelParseset_debug (int bdebug ) +{ + hazelParse_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from hazelParselex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + hazelParsein = stdin; + hazelParseout = stdout; +#else + hazelParsein = (FILE *) 0; + hazelParseout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * hazelParselex_init() + */ + return 0; +} + +/* hazelParselex_destroy is for both reentrant and non-reentrant scanners. */ +int hazelParselex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + hazelParse_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + hazelParsepop_buffer_state(); + } + + /* Destroy the stack itself. */ + hazelParsefree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * hazelParselex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *hazelParsealloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *hazelParserealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void hazelParsefree (void * ptr ) +{ + free( (char *) ptr ); /* see hazelParserealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + diff --git a/es_2_0/ParseParse.c b/es_2_0/ParseParse.c new file mode 100755 index 0000000..3178cb3 --- /dev/null +++ b/es_2_0/ParseParse.c @@ -0,0 +1,2008 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef lint +static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93"; +#endif + +#include <stdlib.h> +#include <string.h> + +#define YYBYACC 1 +#define YYMAJOR 1 +#define YYMINOR 9 +#define YYPATCH 20070509 + +#define YYEMPTY (-1) +#define yyclearin (yychar = YYEMPTY) +#define yyerrok (yyerrflag = 0) +#define YYRECOVERING (yyerrflag != 0) + +extern int yyparse(void); + +static int yygrowstack(void); +#define yyparse hazelParseparse +#define yylex hazelParselex +#define yyerror hazelParseerror +#define yychar hazelParsechar +#define yyval hazelParseval +#define yylval hazelParselval +#define yydebug hazelParsedebug +#define yynerrs hazelParsenerrs +#define yyerrflag hazelParseerrflag +#define yyss hazelParsess +#define yyssp hazelParsessp +#define yyvs hazelParsevs +#define yyvsp hazelParsevsp +#define yylhs hazelParselhs +#define yylen hazelParselen +#define yydefred hazelParsedefred +#define yydgoto hazelParsedgoto +#define yysindex hazelParsesindex +#define yyrindex hazelParserindex +#define yygindex hazelParsegindex +#define yytable hazelParsetable +#define yycheck hazelParsecheck +#define yyname hazelParsename +#define yyrule hazelParserule +#define YYPREFIX "hazelParse" + +#include "es2front.h" + +/* #define PROVIDING_FULLDEBUG*/ + +static struct ShaderObjectUnit* pUnit; +static GLenum eShaderType; +static char* pSrcPtr; +static char* pDstPtr; +static int iSemError; /* semantic error flag*/ +static int iLine; /* current line number: controlled by LEX*/ + +static struct TableEntry* ptrMainStack[100]; /* pointing to struct/func name*/ +static struct TableEntry* ptrFirstStack[100]; /* pointing 1st member/param*/ +static struct TableEntry* ptrLastStack[100]; /* pointing 1st member/param*/ +static int iStackTop = -1; + +void pushMain(struct TableEntry* ptr) { + assert(ptr != NULL); + assert(iStackTop < sizeof(ptrMainStack) / sizeof(ptrMainStack[0])); + iStackTop++; + ptrMainStack[iStackTop] = ptr; + ptrFirstStack[iStackTop] = NULL; + ptrLastStack[iStackTop] = NULL; +} + +void setFirst(struct TableEntry* ptr) { ptrFirstStack[iStackTop] = ptr; } +void setLast(struct TableEntry* ptr) { ptrLastStack[iStackTop] = ptr; } + +void popMain(void) { + ptrMainStack[iStackTop] = NULL; + ptrFirstStack[iStackTop] = NULL; + ptrLastStack[iStackTop] = NULL; + iStackTop--; + assert(iStackTop >= -1); +} + +struct TableEntry* getMain(void) { return ptrMainStack[iStackTop]; } +struct TableEntry* getFirst(void) { return ptrFirstStack[iStackTop]; } +struct TableEntry* getLast(void) { return ptrLastStack[iStackTop]; } + +extern int hazelParselex(void); +extern int hazelParselex_destroy(void); + +void hazelParseTerminate(void) { + hazelParselex_destroy(); +} + +int hazelParseGetError(void) { + return iSemError; +} + +void hazelERROR(char* kind, char* s) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d): %s around '%s'\n", iLine, kind, s); + iSemError = 1; +} + +#define ERROR(k,s) \ + do { \ + hazelERROR(k, s); \ + iSemError = 1; \ + YYERROR; \ + } while (0) + +void UNSUPPORTED(char* s) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d): '%s' is not supported\n", iLine, s); + iSemError = 1; +} + +void FOUND_RESERVED(char* s) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d): cannot use reserved keyword '%s'\n", iLine, s); + iSemError = 1; +} + +void UNDEFINED(char* s) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d): '%s' undefined\n", iLine, s); + iSemError = 1; +} + +void ALREADY_DEFINED(char* s) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d): '%s' is already defined\n", iLine, s); + iSemError = 1; +} + +typedef union { + struct TableEntry token; +} YYSTYPE; + +#define FREE() \ + do { \ + int i; \ + for (i = -yym + 1; i <= 0; i++) { \ + assert(yyvsp[i].token.name != NULL); \ + free(yyvsp[i].token.name); \ + yyvsp[i].token.name == NULL; \ + } \ + } while (0) + +#define MERGE() \ + do { \ + int i; \ + int len = 0; \ + if (yym == 1) { \ + memcpy(&(yyval), &(yyvsp[0]), sizeof(yyval)); \ + } else if (yym > 1) { \ + memset(&(yyval), 0, sizeof(yyval)); \ + for (i = -yym + 1; i <= 0; i++) { \ + assert(yyvsp[i].token.name != NULL); \ + len += strlen(yyvsp[i].token.name) + 1; \ + } \ + yyval.token.name = malloc(len); \ + strcpy(yyval.token.name, yyvsp[-yym + 1].token.name); \ + for (i = -yym + 2; i <= 0; i++) { \ + strcat(yyval.token.name, " "); \ + strcat(yyval.token.name, yyvsp[i].token.name); \ + free(yyvsp[i].token.name); \ + yyvsp[i].token.name = NULL; \ + } \ + } \ + } while (0) + +#define VOID 257 +#define BOOL 258 +#define INT 259 +#define FLOAT 260 +#define VEC2 261 +#define VEC3 262 +#define VEC4 263 +#define BVEC2 264 +#define BVEC3 265 +#define BVEC4 266 +#define IVEC2 267 +#define IVEC3 268 +#define IVEC4 269 +#define MAT2 270 +#define MAT3 271 +#define MAT4 272 +#define SAMPLER2D 273 +#define SAMPLER3D 274 +#define SAMPLERCUBE 275 +#define ATTRIBUTE 276 +#define CONST 277 +#define UNIFORM 278 +#define VARYING 279 +#define BREAK 280 +#define CONTINUE 281 +#define DO 282 +#define FOR 283 +#define WHILE 284 +#define IF 285 +#define ELSE 286 +#define IN 287 +#define OUT 288 +#define INOUT 289 +#define LOW_PRECISION 290 +#define MEDIUM_PRECISION 291 +#define HIGH_PRECISION 292 +#define PRECISION 293 +#define INVARIANT 294 +#define DISCARD 295 +#define RETURN 296 +#define STRUCT 297 +#define BOOLCONSTANT 298 +#define IDENTIFIER 299 +#define INTCONSTANT 300 +#define FLOATCONSTANT 301 +#define ADD_ASSIGN 302 +#define SUB_ASSIGN 303 +#define MUL_ASSIGN 304 +#define DIV_ASSIGN 305 +#define MOD_ASSIGN 306 +#define LEFT_ASSIGN 307 +#define RIGHT_ASSIGN 308 +#define AND_ASSIGN 309 +#define XOR_ASSIGN 310 +#define OR_ASSIGN 311 +#define OR_OP 312 +#define XOR_OP 313 +#define AND_OP 314 +#define EQ_OP 315 +#define NE_OP 316 +#define LE_OP 317 +#define GE_OP 318 +#define LEFT_OP 319 +#define RIGHT_OP 320 +#define INC_OP 321 +#define DEC_OP 322 +#define UPLUS 323 +#define UMINUS 324 +#define YYERRCODE 256 +short hazelParselhs[] = { -1, + 0, 1, 1, 2, 2, 3, 7, 7, 7, 7, + 7, 9, 9, 9, 9, 9, 9, 11, 10, 12, + 12, 13, 13, 14, 16, 16, 16, 16, 16, 16, + 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, + 5, 17, 17, 18, 18, 19, 20, 20, 20, 20, + 24, 24, 23, 23, 23, 23, 25, 25, 28, 28, + 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, + 29, 29, 29, 29, 29, 30, 30, 15, 15, 31, + 31, 31, 31, 31, 31, 31, 31, 31, 31, 31, + 8, 8, 27, 4, 4, 4, 32, 32, 32, 32, + 35, 35, 35, 35, 35, 37, 22, 22, 22, 22, + 22, 33, 33, 33, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, + 38, 38, 38, 38, 21, 21, 26, 26, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 34, + 34, 34, 34, 34, 34, 34, 34, 34, 34, 39, + 40, 40, 41, 41, 42, 42, 42, 43, 43, 36, + 44, 45, 45, 47, 47, 47, 47, 47, 46, 46, + 53, 53, 6, 6, 52, 52, 48, 48, 49, 54, + 54, 55, 55, 50, 50, 50, 56, 56, 58, 58, + 57, 57, 51, 51, 51, 51, 51, +}; +short hazelParselen[] = { 2, + 1, 1, 2, 1, 1, 2, 1, 1, 1, 3, + 1, 1, 1, 2, 2, 4, 3, 1, 2, 1, + 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 2, 1, 1, 2, 3, 3, 3, 2, 3, 2, + 2, 5, 1, 1, 1, 0, 1, 4, 1, 2, + 2, 2, 2, 2, 2, 1, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, + 3, 3, 3, 3, 3, 1, 5, 1, 3, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 3, 1, 2, 2, 4, 1, 3, 6, 5, + 1, 2, 4, 5, 2, 1, 1, 1, 1, 1, + 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 2, 1, 2, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, + 3, 2, 2, 3, 1, 3, 6, 2, 5, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 2, 3, 1, 2, 1, 2, 5, 3, + 1, 1, 4, 5, 7, 6, 1, 1, 1, 0, + 2, 3, 2, 2, 2, 3, 2, +}; +short hazelParsedefred[] = { 0, + 149, 152, 151, 150, 153, 154, 155, 156, 157, 158, + 159, 160, 161, 162, 163, 164, 165, 166, 167, 120, + 117, 119, 118, 124, 123, 122, 0, 0, 0, 169, + 0, 0, 2, 4, 5, 0, 0, 0, 0, 0, + 0, 145, 0, 0, 147, 107, 168, 0, 0, 121, + 115, 0, 172, 3, 104, 0, 6, 41, 0, 53, + 54, 55, 0, 44, 0, 0, 0, 146, 0, 105, + 148, 0, 0, 0, 175, 0, 171, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 9, 0, 7, 8, 0, 0, 0, 0, 0, 0, + 0, 197, 193, 0, 181, 0, 12, 0, 0, 13, + 0, 0, 0, 101, 0, 0, 0, 88, 184, 195, + 182, 183, 185, 186, 187, 188, 0, 45, 0, 48, + 50, 0, 0, 46, 0, 0, 0, 170, 0, 0, + 173, 106, 214, 213, 191, 192, 0, 0, 0, 0, + 217, 27, 26, 25, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 0, 215, 0, 0, + 0, 0, 0, 0, 0, 0, 189, 0, 0, 198, + 14, 15, 0, 0, 19, 0, 22, 24, 90, 93, + 94, 91, 92, 95, 96, 97, 98, 99, 100, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 194, 196, 47, 49, 0, 0, 180, 113, 0, 66, + 103, 0, 0, 0, 174, 0, 0, 208, 207, 0, + 0, 0, 0, 0, 216, 10, 190, 102, 0, 0, + 17, 23, 89, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, + 68, 69, 0, 0, 0, 114, 110, 0, 0, 0, + 0, 209, 0, 0, 0, 0, 0, 16, 0, 0, + 58, 109, 179, 0, 0, 0, 0, 0, 204, 0, + 199, 87, 52, 177, 0, 206, 0, 203, 0, 205, + 200, +}; +short hazelParsedgoto[] = { 31, + 32, 33, 34, 115, 116, 155, 117, 118, 119, 120, + 260, 121, 122, 123, 124, 125, 37, 38, 39, 64, + 40, 41, 66, 140, 141, 42, 239, 126, 127, 128, + 210, 43, 44, 45, 46, 238, 0, 0, 47, 48, + 73, 74, 75, 129, 130, 131, 132, 133, 134, 135, + 136, 137, 157, 311, 253, 250, 293, 294, +}; +short hazelParsesindex[] = { 2130, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, -73, -239, -121, 0, + 0, 2130, 0, 0, 0, -26, -27, -5, 206, -251, + 2045, 0, -17, 2216, 0, 0, 0, 2045, 2216, 0, + 0, -60, 0, 0, 0, -33, 0, 0, 206, 0, + 0, 0, -214, 0, 159, 2045, -6, 0, -228, 0, + 0, -185, 1960, 65, 0, 77, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 86, 87, 472, 126, 127, 132, 96, 848, + 0, 0, 0, 0, 1249, 1249, 1249, 1249, 1249, 1249, + 863, 0, 0, 35, 0, 129, 0, 90, -41, 0, + 151, 167, 863, 0, 164, 770, 160, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 130, 0, 2045, 0, + 0, -85, 863, 0, 863, -46, 122, 0, 95, -29, + 0, 0, 0, 0, 0, 0, -13, 741, 670, 863, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 98, -41, + -41, -41, -41, -41, -41, 71, 0, 309, 863, 0, + 0, 0, 863, -21, 0, 863, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 863, + 863, 863, 863, 863, 863, 863, 863, 863, 863, 863, + 863, 863, 863, 863, 863, 863, 863, 863, 863, 863, + 0, 0, 0, 0, 188, 863, 0, 0, 197, 0, + 0, 863, 863, 863, 0, 246, 299, 0, 0, 670, + 297, 52, 312, 112, 0, 0, 0, 0, 297, 274, + 0, 0, 0, 502, 44, 935, 1009, 148, 490, 4, + 4, -34, -34, -34, -34, 511, 511, 240, 240, 0, + 0, 0, 14, 863, 276, 0, 0, 286, 287, 863, + 863, 0, 344, 327, 355, 579, 472, 0, 863, 324, + 0, 0, 0, 345, 135, 579, 863, 863, 0, 155, + 0, 0, 0, 0, 378, 0, 297, 0, 472, 0, + 0, +}; +short hazelParserindex[] = { 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 442, 0, 0, 0, 0, 0, 403, 1916, 115, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 2173, 0, + 0, 0, 0, 0, 2173, 0, 157, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, -24, -23, -16, + 39, 67, 85, 156, 459, 484, 498, 583, 585, 588, + 593, 595, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 1149, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 1186, 0, + 0, 408, 409, 0, 0, 58, 15, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 139, 0, 0, 0, 162, 296, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1113, 0, 0, 1223, + 1260, 1314, 1351, 1548, 1636, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 168, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 306, 0, 0, 0, 397, + 78, 0, 0, 0, 0, 0, 0, 0, 364, 0, + 0, 0, 0, 448, 106, 69, 395, -40, 2072, 2009, + 2046, 1746, 1783, 1843, 1983, 1683, 1720, 1646, 1673, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 419, 0, 0, 400, + 0, 0, 0, 0, 0, 0, 420, 0, 0, 0, + 0, +}; +short hazelParsegindex[] = { 0, + 0, 430, 0, 29, 38, 433, 0, 984, 238, 0, + 0, 0, 0, 0, 1098, 0, 0, 0, 0, 411, + -128, 18, 406, 342, 347, -4, -103, 2049, 1697, -113, + 0, 0, 460, 99, 0, -220, 0, 0, 0, 0, + 0, 417, 0, 333, -112, 0, -28, 338, 0, 0, + 0, 383, -267, 0, 248, 0, 0, 0, +}; +#define YYTABLESIZE 2515 +short hazelParsetable[] = { 110, + 81, 53, 229, 81, 194, 236, 111, 227, 225, 105, + 226, 106, 228, 58, 242, 27, 26, 81, 81, 152, + 151, 287, 81, 25, 232, 112, 69, 150, 35, 310, + 252, 241, 55, 144, 152, 151, 68, 36, 59, 50, + 229, 70, 150, 72, 243, 227, 225, 67, 226, 193, + 228, 321, 81, 81, 143, 86, 65, 189, 86, 51, + 35, 142, 77, 219, 50, 220, 156, 110, 72, 36, + 146, 299, 86, 86, 111, 232, 65, 105, 28, 106, + 229, 216, 153, 81, 145, 227, 225, 318, 226, 114, + 228, 113, 109, 112, 66, 66, 56, 153, 66, 66, + 66, 66, 66, 219, 66, 220, 29, 86, 150, 83, + 154, 256, 83, 147, 189, 66, 66, 66, 202, 66, + 66, 252, 241, 151, 30, 154, 83, 83, 155, 241, + 241, 83, 285, 189, 142, 152, 202, 215, 150, 288, + 289, 189, 71, 155, 153, 154, 84, 76, 190, 84, + 66, 66, 297, 245, 161, 189, 255, 114, 111, 187, + 109, 83, 110, 84, 84, 158, 159, 214, 84, 111, + 241, 160, 105, 111, 106, 315, 241, 52, 189, 57, + 300, 66, 57, 309, 229, 216, 304, 55, 112, 227, + 225, 195, 226, 316, 228, 31, 229, 216, 84, 156, + 112, 227, 225, 198, 226, 108, 228, 219, 51, 220, + 196, 51, 244, 235, 156, 112, 24, 25, 26, 219, + 108, 220, 230, 1, 78, 79, 80, 81, 82, 83, + 84, 85, 86, 87, 88, 89, 90, 91, 92, 17, + 18, 19, 20, 21, 22, 23, 93, 94, 95, 96, + 97, 98, 114, 215, 231, 109, 24, 25, 26, 27, + 28, 99, 100, 29, 101, 102, 103, 104, 156, 246, + 247, 81, 81, 81, 152, 151, 229, 261, 284, 191, + 192, 227, 150, 214, 223, 224, 228, 107, 108, 286, + 156, 1, 78, 79, 80, 81, 82, 83, 84, 85, + 86, 87, 88, 89, 90, 91, 92, 17, 18, 19, + 20, 21, 22, 23, 93, 94, 95, 96, 97, 98, + 221, 222, 223, 224, 24, 25, 26, 27, 28, 99, + 100, 29, 101, 102, 103, 104, 290, 153, 291, 178, + 189, 110, 180, 181, 182, 183, 184, 185, 111, 176, + 295, 105, 296, 106, 178, 107, 108, 213, 217, 218, + 221, 222, 223, 224, 176, 154, 298, 112, 301, 66, + 66, 66, 66, 66, 66, 66, 66, 66, 302, 303, + 83, 83, 83, 155, 306, 307, 1, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 17, 18, 19, 20, 21, 22, 23, 93, + 94, 95, 96, 97, 98, 308, 313, 84, 84, 24, + 25, 26, 27, 28, 99, 100, 29, 101, 102, 103, + 104, 114, 201, 257, 109, 82, 320, 314, 82, 201, + 319, 1, 201, 42, 201, 60, 61, 62, 20, 21, + 107, 108, 82, 82, 156, 210, 18, 82, 201, 211, + 212, 54, 217, 218, 221, 222, 223, 224, 57, 138, + 139, 211, 212, 213, 217, 218, 221, 222, 223, 224, + 233, 20, 21, 22, 23, 234, 49, 82, 85, 149, + 248, 85, 60, 61, 62, 249, 188, 292, 32, 63, + 0, 0, 157, 0, 110, 85, 85, 0, 0, 0, + 85, 111, 0, 0, 105, 0, 106, 157, 82, 0, + 0, 0, 201, 33, 201, 201, 229, 158, 0, 0, + 112, 227, 225, 0, 226, 0, 228, 34, 229, 216, + 85, 159, 158, 227, 225, 0, 226, 229, 228, 219, + 0, 220, 227, 225, 0, 226, 159, 228, 0, 0, + 0, 219, 0, 220, 0, 1, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, 17, 18, 19, 20, 21, 22, 23, 93, 94, + 95, 96, 97, 98, 56, 215, 0, 109, 24, 25, + 26, 27, 28, 99, 100, 29, 101, 102, 103, 104, + 0, 110, 0, 0, 0, 0, 0, 0, 111, 0, + 0, 105, 35, 106, 36, 214, 160, 37, 161, 107, + 108, 162, 38, 0, 39, 0, 163, 112, 164, 0, + 0, 160, 0, 161, 0, 0, 162, 0, 0, 0, + 0, 163, 0, 164, 0, 0, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 201, 201, 201, 201, 0, 0, 0, 0, 201, + 201, 201, 201, 201, 201, 201, 201, 201, 201, 201, + 201, 114, 110, 0, 109, 0, 82, 82, 82, 111, + 0, 0, 105, 0, 106, 0, 0, 0, 0, 0, + 201, 201, 0, 0, 0, 0, 0, 0, 1, 78, + 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, + 89, 90, 91, 92, 17, 18, 19, 20, 21, 22, + 23, 93, 94, 95, 96, 97, 98, 157, 0, 85, + 0, 24, 25, 26, 27, 28, 99, 100, 29, 101, + 102, 103, 104, 110, 0, 0, 0, 0, 0, 0, + 111, 0, 158, 105, 0, 106, 0, 0, 0, 0, + 0, 0, 107, 108, 0, 109, 159, 0, 0, 112, + 0, 0, 0, 0, 217, 218, 221, 222, 223, 224, + 0, 0, 0, 0, 212, 213, 217, 218, 221, 222, + 223, 224, 0, 0, 0, 0, 0, 0, 0, 0, + 199, 0, 0, 0, 0, 1, 78, 79, 80, 81, + 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, + 92, 17, 18, 19, 20, 21, 22, 23, 93, 94, + 95, 96, 97, 98, 0, 0, 109, 0, 24, 25, + 26, 27, 28, 99, 100, 29, 101, 102, 103, 104, + 110, 160, 0, 161, 0, 0, 162, 111, 0, 0, + 105, 163, 106, 164, 0, 110, 0, 0, 0, 107, + 108, 0, 111, 0, 0, 105, 178, 106, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 1, 78, 79, 80, + 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, + 91, 92, 17, 18, 19, 20, 21, 22, 23, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 25, 26, 0, 63, 0, 0, 29, 101, 102, 103, + 104, 229, 216, 109, 0, 0, 227, 225, 0, 226, + 0, 228, 0, 0, 0, 0, 0, 0, 109, 0, + 107, 108, 0, 0, 219, 0, 220, 1, 78, 79, + 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, + 90, 91, 92, 17, 18, 19, 20, 21, 22, 23, + 0, 0, 0, 0, 0, 0, 0, 0, 215, 0, + 24, 25, 26, 27, 28, 0, 0, 29, 101, 102, + 103, 104, 0, 0, 0, 229, 216, 0, 0, 0, + 227, 225, 0, 226, 0, 228, 0, 0, 214, 0, + 0, 107, 108, 0, 0, 0, 0, 0, 219, 0, + 220, 200, 201, 202, 203, 204, 205, 206, 207, 208, + 209, 0, 0, 179, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 186, 0, 0, 0, 0, 0, + 0, 0, 215, 0, 0, 162, 163, 164, 165, 166, + 167, 168, 169, 170, 171, 172, 173, 174, 175, 176, + 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, + 172, 173, 174, 175, 176, 0, 0, 0, 0, 0, + 0, 0, 251, 254, 0, 101, 177, 103, 104, 11, + 11, 0, 40, 11, 11, 11, 11, 11, 11, 11, + 101, 177, 103, 104, 0, 0, 0, 0, 107, 108, + 11, 11, 11, 11, 11, 11, 259, 0, 0, 0, + 0, 0, 0, 107, 108, 11, 11, 0, 40, 11, + 11, 11, 11, 11, 11, 11, 0, 0, 0, 0, + 0, 0, 0, 11, 0, 11, 11, 11, 11, 11, + 11, 11, 0, 283, 0, 0, 0, 0, 0, 0, + 197, 0, 59, 59, 0, 0, 59, 59, 59, 59, + 59, 0, 59, 251, 0, 0, 11, 0, 0, 11, + 237, 0, 11, 59, 59, 59, 59, 59, 59, 217, + 218, 221, 222, 223, 224, 0, 0, 0, 0, 62, + 62, 0, 0, 62, 62, 62, 62, 62, 0, 62, + 0, 0, 11, 0, 305, 0, 0, 0, 59, 59, + 62, 62, 62, 62, 62, 62, 258, 0, 111, 0, + 317, 0, 0, 262, 0, 0, 63, 63, 0, 0, + 63, 63, 63, 63, 63, 0, 63, 263, 0, 59, + 0, 0, 0, 0, 0, 62, 62, 63, 63, 63, + 63, 63, 63, 217, 218, 221, 222, 223, 224, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 237, + 0, 0, 0, 0, 0, 0, 62, 0, 0, 0, + 60, 60, 63, 63, 60, 60, 60, 60, 60, 0, + 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 60, 60, 60, 60, 60, 60, 0, 0, 0, + 0, 0, 0, 63, 0, 0, 0, 61, 61, 0, + 0, 61, 61, 61, 61, 61, 312, 61, 0, 0, + 0, 0, 0, 0, 0, 237, 60, 60, 61, 61, + 61, 61, 61, 61, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 0, 0, 60, 0, 0, + 0, 0, 0, 61, 61, 0, 0, 169, 0, 0, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, + 11, 0, 0, 0, 61, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, + 59, 59, 59, 59, 59, 59, 162, 163, 164, 165, + 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, + 176, 0, 0, 0, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 62, 62, 62, 62, 62, 62, 62, + 62, 62, 62, 0, 0, 0, 101, 177, 103, 104, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, + 0, 0, 0, 0, 64, 64, 0, 0, 64, 64, + 64, 64, 64, 0, 64, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 64, 64, 64, 64, 64, + 64, 0, 0, 0, 0, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 60, 60, 60, 60, 60, 60, + 60, 60, 60, 60, 0, 0, 0, 0, 0, 0, + 64, 64, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, + 61, 64, 65, 65, 0, 0, 65, 65, 65, 65, + 65, 0, 65, 70, 0, 0, 70, 0, 70, 70, + 70, 0, 0, 65, 65, 65, 65, 65, 65, 0, + 0, 0, 0, 70, 70, 70, 0, 70, 70, 0, + 71, 0, 0, 71, 0, 71, 71, 71, 0, 0, + 72, 0, 0, 72, 0, 0, 72, 0, 65, 65, + 71, 71, 71, 0, 71, 71, 0, 0, 70, 70, + 72, 72, 72, 0, 72, 72, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 73, 0, 65, + 73, 0, 0, 73, 0, 71, 71, 0, 0, 70, + 0, 0, 0, 0, 0, 72, 72, 73, 73, 73, + 0, 73, 73, 74, 0, 0, 74, 0, 0, 74, + 0, 0, 0, 0, 0, 0, 71, 0, 0, 0, + 0, 0, 0, 74, 74, 74, 72, 74, 74, 0, + 0, 0, 73, 73, 0, 0, 0, 0, 0, 0, + 75, 0, 0, 75, 0, 0, 75, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 74, 74, + 75, 75, 75, 73, 75, 75, 0, 0, 0, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, + 64, 64, 64, 64, 64, 64, 64, 64, 0, 74, + 0, 0, 0, 0, 0, 75, 75, 0, 0, 0, + 76, 0, 0, 76, 0, 0, 76, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 76, 76, 76, 0, 76, 76, 75, 264, 265, 266, + 267, 268, 269, 270, 271, 272, 273, 274, 275, 276, + 277, 278, 279, 280, 281, 282, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 76, 76, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, + 65, 65, 65, 65, 65, 65, 43, 70, 70, 70, + 70, 70, 70, 70, 70, 70, 76, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 71, 71, 71, 71, 71, 71, + 71, 71, 71, 0, 72, 72, 72, 72, 72, 72, + 72, 72, 72, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 77, 0, 0, 77, 0, 0, 77, 0, 0, 0, + 0, 73, 73, 73, 73, 73, 73, 73, 73, 73, + 77, 77, 77, 0, 77, 77, 78, 0, 0, 78, + 0, 0, 78, 0, 0, 0, 0, 74, 74, 74, + 74, 74, 74, 74, 0, 0, 78, 78, 0, 0, + 0, 78, 0, 0, 0, 77, 77, 0, 0, 0, + 0, 0, 0, 79, 148, 0, 79, 0, 0, 79, + 0, 0, 0, 0, 75, 75, 75, 75, 75, 75, + 75, 78, 78, 79, 79, 0, 77, 0, 79, 80, + 0, 0, 80, 0, 0, 80, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, + 80, 0, 78, 0, 80, 0, 0, 0, 79, 79, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 76, 76, 76, 76, 76, 76, + 76, 0, 0, 0, 80, 80, 0, 0, 0, 79, + 0, 0, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 0, 0, 240, 0, 80, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 56, 56, 56, 0, 0, + 0, 0, 56, 0, 56, 0, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 25, 26, 0, 0, 0, 0, 29, 0, 30, 240, + 240, 240, 240, 240, 240, 240, 240, 240, 240, 240, + 240, 240, 240, 240, 240, 240, 240, 240, 0, 0, + 0, 0, 0, 0, 240, 0, 0, 0, 0, 0, + 0, 240, 240, 0, 77, 77, 77, 77, 77, 77, + 77, 1, 2, 3, 4, 5, 6, 7, 8, 9, + 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, + 78, 78, 78, 78, 78, 0, 0, 0, 0, 0, + 0, 0, 240, 0, 24, 25, 26, 0, 240, 0, + 0, 29, 0, 30, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 79, 79, 79, + 79, 79, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 80, 80, 80, 1, 2, 3, 4, + 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 24, + 25, 26, 27, 28, 0, 0, 29, 0, 30, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 56, 56, + 56, 56, 56, 56, 56, 56, 56, 56, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 56, 56, 56, 0, 0, 0, 0, 56, + 0, 56, 1, 2, 3, 4, 5, 6, 7, 8, + 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, + 19, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 29, 0, 30, +}; +short hazelParsecheck[] = { 33, + 41, 123, 37, 44, 46, 91, 40, 42, 43, 43, + 45, 45, 47, 41, 61, 40, 40, 58, 59, 44, + 44, 242, 63, 40, 137, 59, 44, 44, 0, 297, + 159, 145, 59, 40, 59, 59, 41, 0, 44, 279, + 37, 59, 59, 48, 91, 42, 43, 299, 45, 91, + 47, 319, 93, 94, 61, 41, 39, 44, 44, 299, + 32, 66, 123, 60, 279, 62, 95, 33, 73, 32, + 299, 58, 58, 59, 40, 188, 59, 43, 40, 45, + 37, 38, 44, 124, 91, 42, 43, 308, 45, 123, + 47, 125, 126, 59, 37, 38, 123, 59, 41, 42, + 43, 44, 45, 60, 47, 62, 40, 93, 44, 41, + 44, 41, 44, 299, 44, 58, 59, 60, 41, 62, + 63, 250, 236, 59, 40, 59, 58, 59, 44, 243, + 244, 63, 236, 44, 139, 59, 59, 94, 44, 243, + 244, 44, 44, 59, 59, 59, 41, 49, 59, 44, + 93, 94, 41, 59, 59, 44, 59, 123, 44, 125, + 126, 93, 33, 58, 59, 40, 40, 124, 63, 40, + 284, 40, 43, 59, 45, 41, 290, 299, 44, 41, + 284, 124, 44, 296, 37, 38, 290, 59, 59, 42, + 43, 41, 45, 306, 47, 40, 37, 38, 93, 44, + 44, 42, 43, 40, 45, 44, 47, 60, 41, 62, + 44, 44, 91, 299, 59, 59, 290, 291, 292, 60, + 59, 62, 63, 257, 258, 259, 260, 261, 262, 263, + 264, 265, 266, 267, 268, 269, 270, 271, 272, 273, + 274, 275, 276, 277, 278, 279, 280, 281, 282, 283, + 284, 285, 123, 94, 125, 126, 290, 291, 292, 293, + 294, 295, 296, 297, 298, 299, 300, 301, 297, 299, + 284, 312, 313, 314, 299, 299, 37, 299, 91, 321, + 322, 42, 299, 124, 319, 320, 47, 321, 322, 93, + 319, 257, 258, 259, 260, 261, 262, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, + 276, 277, 278, 279, 280, 281, 282, 283, 284, 285, + 317, 318, 319, 320, 290, 291, 292, 293, 294, 295, + 296, 297, 298, 299, 300, 301, 91, 299, 40, 44, + 44, 33, 105, 106, 107, 108, 109, 110, 40, 44, + 299, 43, 41, 45, 59, 321, 322, 314, 315, 316, + 317, 318, 319, 320, 59, 299, 93, 59, 93, 312, + 313, 314, 315, 316, 317, 318, 319, 320, 93, 93, + 312, 313, 314, 299, 41, 59, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 283, 284, 285, 61, 93, 312, 313, 290, + 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, + 301, 123, 33, 125, 126, 41, 59, 93, 44, 40, + 286, 0, 43, 41, 45, 287, 288, 289, 41, 41, + 321, 322, 58, 59, 299, 59, 93, 63, 59, 41, + 41, 32, 315, 316, 317, 318, 319, 320, 36, 59, + 65, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 139, 276, 277, 278, 279, 139, 27, 93, 41, 73, + 158, 44, 287, 288, 289, 158, 114, 250, 40, 294, + -1, -1, 44, -1, 33, 58, 59, -1, -1, -1, + 63, 40, -1, -1, 43, -1, 45, 59, 124, -1, + -1, -1, 123, 40, 125, 126, 37, 44, -1, -1, + 59, 42, 43, -1, 45, -1, 47, 40, 37, 38, + 93, 44, 59, 42, 43, -1, 45, 37, 47, 60, + -1, 62, 42, 43, -1, 45, 59, 47, -1, -1, + -1, 60, -1, 62, -1, 257, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, 123, 94, -1, 126, 290, 291, + 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, + -1, 33, -1, -1, -1, -1, -1, -1, 40, -1, + -1, 43, 40, 45, 40, 124, 44, 40, 44, 321, + 322, 44, 40, -1, 40, -1, 44, 59, 44, -1, + -1, 59, -1, 59, -1, -1, 59, -1, -1, -1, + -1, 59, -1, 59, -1, -1, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, 280, + 281, 282, 283, 284, 285, -1, -1, -1, -1, 290, + 291, 292, 293, 294, 295, 296, 297, 298, 299, 300, + 301, 123, 33, -1, 126, -1, 312, 313, 314, 40, + -1, -1, 43, -1, 45, -1, -1, -1, -1, -1, + 321, 322, -1, -1, -1, -1, -1, -1, 257, 258, + 259, 260, 261, 262, 263, 264, 265, 266, 267, 268, + 269, 270, 271, 272, 273, 274, 275, 276, 277, 278, + 279, 280, 281, 282, 283, 284, 285, 299, -1, 312, + -1, 290, 291, 292, 293, 294, 295, 296, 297, 298, + 299, 300, 301, 33, -1, -1, -1, -1, -1, -1, + 40, -1, 299, 43, -1, 45, -1, -1, -1, -1, + -1, -1, 321, 322, -1, 126, 299, -1, -1, 59, + -1, -1, -1, -1, 315, 316, 317, 318, 319, 320, + -1, -1, -1, -1, 313, 314, 315, 316, 317, 318, + 319, 320, -1, -1, -1, -1, -1, -1, -1, -1, + 61, -1, -1, -1, -1, 257, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, 273, 274, 275, 276, 277, 278, 279, 280, 281, + 282, 283, 284, 285, -1, -1, 126, -1, 290, 291, + 292, 293, 294, 295, 296, 297, 298, 299, 300, 301, + 33, 299, -1, 299, -1, -1, 299, 40, -1, -1, + 43, 299, 45, 299, -1, 33, -1, -1, -1, 321, + 322, -1, 40, -1, -1, 43, 59, 45, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 290, + 291, 292, -1, 294, -1, -1, 297, 298, 299, 300, + 301, 37, 38, 126, -1, -1, 42, 43, -1, 45, + -1, 47, -1, -1, -1, -1, -1, -1, 126, -1, + 321, 322, -1, -1, 60, -1, 62, 257, 258, 259, + 260, 261, 262, 263, 264, 265, 266, 267, 268, 269, + 270, 271, 272, 273, 274, 275, 276, 277, 278, 279, + -1, -1, -1, -1, -1, -1, -1, -1, 94, -1, + 290, 291, 292, 293, 294, -1, -1, 297, 298, 299, + 300, 301, -1, -1, -1, 37, 38, -1, -1, -1, + 42, 43, -1, 45, -1, 47, -1, -1, 124, -1, + -1, 321, 322, -1, -1, -1, -1, -1, 60, -1, + 62, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, -1, -1, 100, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 111, -1, -1, -1, -1, -1, + -1, -1, 94, -1, -1, 258, 259, 260, 261, 262, + 263, 264, 265, 266, 267, 268, 269, 270, 271, 272, + 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, -1, -1, -1, -1, -1, + -1, -1, 159, 160, -1, 298, 299, 300, 301, 37, + 38, -1, 40, 41, 42, 43, 44, 45, 46, 47, + 298, 299, 300, 301, -1, -1, -1, -1, 321, 322, + 58, 59, 60, 61, 62, 63, 193, -1, -1, -1, + -1, -1, -1, 321, 322, 37, 38, -1, 40, 41, + 42, 43, 44, 45, 46, 47, -1, -1, -1, -1, + -1, -1, -1, 91, -1, 93, 94, 59, 60, 61, + 62, 63, -1, 230, -1, -1, -1, -1, -1, -1, + 123, -1, 37, 38, -1, -1, 41, 42, 43, 44, + 45, -1, 47, 250, -1, -1, 124, -1, -1, 91, + 143, -1, 94, 58, 59, 60, 61, 62, 63, 315, + 316, 317, 318, 319, 320, -1, -1, -1, -1, 37, + 38, -1, -1, 41, 42, 43, 44, 45, -1, 47, + -1, -1, 124, -1, 291, -1, -1, -1, 93, 94, + 58, 59, 60, 61, 62, 63, 189, -1, 40, -1, + 307, -1, -1, 196, -1, -1, 37, 38, -1, -1, + 41, 42, 43, 44, 45, -1, 47, 210, -1, 124, + -1, -1, -1, -1, -1, 93, 94, 58, 59, 60, + 61, 62, 63, 315, 316, 317, 318, 319, 320, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 242, + -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, + 37, 38, 93, 94, 41, 42, 43, 44, 45, -1, + 47, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 58, 59, 60, 61, 62, 63, -1, -1, -1, + -1, -1, -1, 124, -1, -1, -1, 37, 38, -1, + -1, 41, 42, 43, 44, 45, 299, 47, -1, -1, + -1, -1, -1, -1, -1, 308, 93, 94, 58, 59, + 60, 61, 62, 63, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, 321, 322, -1, -1, 124, -1, -1, + -1, -1, -1, 93, 94, -1, -1, 299, -1, -1, + 302, 303, 304, 305, 306, 307, 308, 309, 310, 311, + 312, 313, 314, 315, 316, 317, 318, 319, 320, 321, + 322, -1, -1, -1, 124, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 258, 259, 260, 261, + 262, 263, 264, 265, 266, 267, 268, 269, 270, 271, + 272, -1, -1, -1, 302, 303, 304, 305, 306, 307, + 308, 309, 310, 311, 312, 313, 314, 315, 316, 317, + 318, 319, 320, -1, -1, -1, 298, 299, 300, 301, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 302, 303, 304, 305, 306, 307, 308, 309, 310, + 311, 312, 313, 314, 315, 316, 317, 318, 319, 320, + -1, -1, -1, -1, 37, 38, -1, -1, 41, 42, + 43, 44, 45, -1, 47, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 58, 59, 60, 61, 62, + 63, -1, -1, -1, -1, 302, 303, 304, 305, 306, + 307, 308, 309, 310, 311, 312, 313, 314, 315, 316, + 317, 318, 319, 320, -1, -1, -1, -1, -1, -1, + 93, 94, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 302, 303, 304, 305, 306, 307, 308, 309, + 310, 311, 312, 313, 314, 315, 316, 317, 318, 319, + 320, 124, 37, 38, -1, -1, 41, 42, 43, 44, + 45, -1, 47, 38, -1, -1, 41, -1, 43, 44, + 45, -1, -1, 58, 59, 60, 61, 62, 63, -1, + -1, -1, -1, 58, 59, 60, -1, 62, 63, -1, + 38, -1, -1, 41, -1, 43, 44, 45, -1, -1, + 38, -1, -1, 41, -1, -1, 44, -1, 93, 94, + 58, 59, 60, -1, 62, 63, -1, -1, 93, 94, + 58, 59, 60, -1, 62, 63, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 38, -1, 124, + 41, -1, -1, 44, -1, 93, 94, -1, -1, 124, + -1, -1, -1, -1, -1, 93, 94, 58, 59, 60, + -1, 62, 63, 38, -1, -1, 41, -1, -1, 44, + -1, -1, -1, -1, -1, -1, 124, -1, -1, -1, + -1, -1, -1, 58, 59, 60, 124, 62, 63, -1, + -1, -1, 93, 94, -1, -1, -1, -1, -1, -1, + 38, -1, -1, 41, -1, -1, 44, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, 93, 94, + 58, 59, 60, 124, 62, 63, -1, -1, -1, 302, + 303, 304, 305, 306, 307, 308, 309, 310, 311, 312, + 313, 314, 315, 316, 317, 318, 319, 320, -1, 124, + -1, -1, -1, -1, -1, 93, 94, -1, -1, -1, + 38, -1, -1, 41, -1, -1, 44, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 58, 59, 60, -1, 62, 63, 124, 211, 212, 213, + 214, 215, 216, 217, 218, 219, 220, 221, 222, 223, + 224, 225, 226, 227, 228, 229, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 93, 94, 302, 303, 304, + 305, 306, 307, 308, 309, 310, 311, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 41, 312, 313, 314, + 315, 316, 317, 318, 319, 320, 124, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 312, 313, 314, 315, 316, 317, + 318, 319, 320, -1, 312, 313, 314, 315, 316, 317, + 318, 319, 320, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 38, -1, -1, 41, -1, -1, 44, -1, -1, -1, + -1, 312, 313, 314, 315, 316, 317, 318, 319, 320, + 58, 59, 60, -1, 62, 63, 38, -1, -1, 41, + -1, -1, 44, -1, -1, -1, -1, 312, 313, 314, + 315, 316, 317, 318, -1, -1, 58, 59, -1, -1, + -1, 63, -1, -1, -1, 93, 94, -1, -1, -1, + -1, -1, -1, 38, 125, -1, 41, -1, -1, 44, + -1, -1, -1, -1, 312, 313, 314, 315, 316, 317, + 318, 93, 94, 58, 59, -1, 124, -1, 63, 38, + -1, -1, 41, -1, -1, 44, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 58, + 59, -1, 124, -1, 63, -1, -1, -1, 93, 94, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 312, 313, 314, 315, 316, 317, + 318, -1, -1, -1, 93, 94, -1, -1, -1, 124, + -1, -1, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, -1, -1, 145, -1, 124, -1, -1, -1, -1, + -1, -1, -1, -1, -1, 290, 291, 292, -1, -1, + -1, -1, 297, -1, 299, -1, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 290, + 291, 292, -1, -1, -1, -1, 297, -1, 299, 211, + 212, 213, 214, 215, 216, 217, 218, 219, 220, 221, + 222, 223, 224, 225, 226, 227, 228, 229, -1, -1, + -1, -1, -1, -1, 236, -1, -1, -1, -1, -1, + -1, 243, 244, -1, 312, 313, 314, 315, 316, 317, + 318, 257, 258, 259, 260, 261, 262, 263, 264, 265, + 266, 267, 268, 269, 270, 271, 272, 273, 274, 275, + 312, 313, 314, 315, 316, -1, -1, -1, -1, -1, + -1, -1, 284, -1, 290, 291, 292, -1, 290, -1, + -1, 297, -1, 299, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 312, 313, 314, + 315, 316, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 312, 313, 314, 257, 258, 259, 260, + 261, 262, 263, 264, 265, 266, 267, 268, 269, 270, + 271, 272, 273, 274, 275, 276, 277, 278, 279, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, 290, + 291, 292, 293, 294, -1, -1, 297, -1, 299, 257, + 258, 259, 260, 261, 262, 263, 264, 265, 266, 267, + 268, 269, 270, 271, 272, 273, 274, 275, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 290, 291, 292, -1, -1, -1, -1, 297, + -1, 299, 257, 258, 259, 260, 261, 262, 263, 264, + 265, 266, 267, 268, 269, 270, 271, 272, 273, 274, + 275, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 297, -1, 299, +}; +#define YYFINAL 31 +#ifndef YYDEBUG +#define YYDEBUG 0 +#endif +#define YYMAXTOKEN 324 +#if YYDEBUG +char *hazelParsename[] = { +"end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +"'!'",0,0,0,"'%'","'&'",0,"'('","')'","'*'","'+'","','","'-'","'.'","'/'",0,0,0, +0,0,0,0,0,0,0,"':'","';'","'<'","'='","'>'","'?'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,"'['",0,"']'","'^'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,"'{'","'|'","'}'","'~'",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"VOID","BOOL", +"INT","FLOAT","VEC2","VEC3","VEC4","BVEC2","BVEC3","BVEC4","IVEC2","IVEC3", +"IVEC4","MAT2","MAT3","MAT4","SAMPLER2D","SAMPLER3D","SAMPLERCUBE","ATTRIBUTE", +"CONST","UNIFORM","VARYING","BREAK","CONTINUE","DO","FOR","WHILE","IF","ELSE", +"IN","OUT","INOUT","LOW_PRECISION","MEDIUM_PRECISION","HIGH_PRECISION", +"PRECISION","INVARIANT","DISCARD","RETURN","STRUCT","BOOLCONSTANT","IDENTIFIER", +"INTCONSTANT","FLOATCONSTANT","ADD_ASSIGN","SUB_ASSIGN","MUL_ASSIGN", +"DIV_ASSIGN","MOD_ASSIGN","LEFT_ASSIGN","RIGHT_ASSIGN","AND_ASSIGN", +"XOR_ASSIGN","OR_ASSIGN","OR_OP","XOR_OP","AND_OP","EQ_OP","NE_OP","LE_OP", +"GE_OP","LEFT_OP","RIGHT_OP","INC_OP","DEC_OP","UPLUS","UMINUS", +}; +char *hazelParserule[] = { +"$accept : goal", +"goal : translation_unit", +"translation_unit : external_declaration", +"translation_unit : translation_unit external_declaration", +"external_declaration : function_definition", +"external_declaration : declaration", +"function_definition : function_prototype compound_statement_no_new_scope", +"primary_expression : INTCONSTANT", +"primary_expression : FLOATCONSTANT", +"primary_expression : BOOLCONSTANT", +"primary_expression : '(' expression ')'", +"primary_expression : IDENTIFIER", +"postfix_expression : primary_expression", +"postfix_expression : function_call", +"postfix_expression : postfix_expression INC_OP", +"postfix_expression : postfix_expression DEC_OP", +"postfix_expression : postfix_expression '[' integer_expression ']'", +"postfix_expression : postfix_expression '.' IDENTIFIER", +"integer_expression : expression", +"function_call : function_call_body ')'", +"function_call_body : function_call_header_with_parameters", +"function_call_body : function_call_header", +"function_call_header_with_parameters : function_call_header assignment_expression", +"function_call_header_with_parameters : function_call_header_with_parameters ',' assignment_expression", +"function_call_header : function_identifier '('", +"function_identifier : FLOAT", +"function_identifier : INT", +"function_identifier : BOOL", +"function_identifier : VEC2", +"function_identifier : VEC3", +"function_identifier : VEC4", +"function_identifier : BVEC2", +"function_identifier : BVEC3", +"function_identifier : BVEC4", +"function_identifier : IVEC2", +"function_identifier : IVEC3", +"function_identifier : IVEC4", +"function_identifier : MAT2", +"function_identifier : MAT3", +"function_identifier : MAT4", +"function_identifier : IDENTIFIER", +"function_prototype : function_declarator ')'", +"function_declarator : function_header_with_parameters", +"function_declarator : function_header", +"function_header_with_parameters : function_header parameter_declaration", +"function_header_with_parameters : function_header_with_parameters ',' parameter_declaration", +"function_header : fully_specified_type IDENTIFIER '('", +"parameter_declaration : type_qualifier parameter_qualifier parameter_declarator", +"parameter_declaration : parameter_qualifier parameter_declarator", +"parameter_declaration : type_qualifier parameter_qualifier parameter_type_specifier", +"parameter_declaration : parameter_qualifier parameter_type_specifier", +"parameter_declarator : type_specifier IDENTIFIER", +"parameter_declarator : type_specifier IDENTIFIER '[' constant_expression ']'", +"parameter_qualifier : IN", +"parameter_qualifier : OUT", +"parameter_qualifier : INOUT", +"parameter_qualifier :", +"parameter_type_specifier : type_specifier", +"parameter_type_specifier : type_specifier '[' constant_expression ']'", +"unary_expression : postfix_expression", +"unary_expression : INC_OP postfix_expression", +"unary_expression : DEC_OP postfix_expression", +"unary_expression : '+' postfix_expression", +"unary_expression : '-' postfix_expression", +"unary_expression : '~' postfix_expression", +"unary_expression : '!' postfix_expression", +"regular_expression : unary_expression", +"regular_expression : regular_expression '*' regular_expression", +"regular_expression : regular_expression '/' regular_expression", +"regular_expression : regular_expression '%' regular_expression", +"regular_expression : regular_expression '+' regular_expression", +"regular_expression : regular_expression '-' regular_expression", +"regular_expression : regular_expression LEFT_OP regular_expression", +"regular_expression : regular_expression RIGHT_OP regular_expression", +"regular_expression : regular_expression '<' regular_expression", +"regular_expression : regular_expression '>' regular_expression", +"regular_expression : regular_expression LE_OP regular_expression", +"regular_expression : regular_expression GE_OP regular_expression", +"regular_expression : regular_expression EQ_OP regular_expression", +"regular_expression : regular_expression NE_OP regular_expression", +"regular_expression : regular_expression '&' regular_expression", +"regular_expression : regular_expression '^' regular_expression", +"regular_expression : regular_expression '|' regular_expression", +"regular_expression : regular_expression AND_OP regular_expression", +"regular_expression : regular_expression XOR_OP regular_expression", +"regular_expression : regular_expression OR_OP regular_expression", +"conditional_expression : regular_expression", +"conditional_expression : regular_expression '?' expression ':' assignment_expression", +"assignment_expression : conditional_expression", +"assignment_expression : unary_expression assignment_operator assignment_expression", +"assignment_operator : '='", +"assignment_operator : MUL_ASSIGN", +"assignment_operator : DIV_ASSIGN", +"assignment_operator : ADD_ASSIGN", +"assignment_operator : SUB_ASSIGN", +"assignment_operator : MOD_ASSIGN", +"assignment_operator : LEFT_ASSIGN", +"assignment_operator : RIGHT_ASSIGN", +"assignment_operator : AND_ASSIGN", +"assignment_operator : XOR_ASSIGN", +"assignment_operator : OR_ASSIGN", +"expression : assignment_expression", +"expression : expression ',' assignment_expression", +"constant_expression : conditional_expression", +"declaration : function_prototype ';'", +"declaration : init_declarator_list ';'", +"declaration : PRECISION precision_qualifier type_specifier_no_prec ';'", +"init_declarator_list : single_declaration", +"init_declarator_list : init_declarator_list ',' IDENTIFIER", +"init_declarator_list : init_declarator_list ',' IDENTIFIER '[' constant_expression ']'", +"init_declarator_list : init_declarator_list ',' IDENTIFIER '=' initializer", +"single_declaration : fully_specified_type", +"single_declaration : fully_specified_type IDENTIFIER", +"single_declaration : fully_specified_type IDENTIFIER '=' initializer", +"single_declaration : fully_specified_type IDENTIFIER '[' constant_expression ']'", +"single_declaration : INVARIANT IDENTIFIER", +"var_fully_specified_type : fully_specified_type", +"type_qualifier : CONST", +"type_qualifier : VARYING", +"type_qualifier : UNIFORM", +"type_qualifier : ATTRIBUTE", +"type_qualifier : INVARIANT VARYING", +"precision_qualifier : HIGH_PRECISION", +"precision_qualifier : MEDIUM_PRECISION", +"precision_qualifier : LOW_PRECISION", +"var_type_specifier : FLOAT", +"var_type_specifier : INT", +"var_type_specifier : BOOL", +"var_type_specifier : VEC2", +"var_type_specifier : VEC3", +"var_type_specifier : VEC4", +"var_type_specifier : BVEC2", +"var_type_specifier : BVEC3", +"var_type_specifier : BVEC4", +"var_type_specifier : IVEC2", +"var_type_specifier : IVEC3", +"var_type_specifier : IVEC4", +"var_type_specifier : MAT2", +"var_type_specifier : MAT3", +"var_type_specifier : MAT4", +"var_type_specifier : SAMPLER2D", +"var_type_specifier : SAMPLER3D", +"var_type_specifier : SAMPLERCUBE", +"var_type_specifier : struct_specifier", +"var_type_specifier : IDENTIFIER", +"fully_specified_type : type_specifier", +"fully_specified_type : type_qualifier type_specifier", +"type_specifier : type_specifier_no_prec", +"type_specifier : precision_qualifier type_specifier_no_prec", +"type_specifier_no_prec : VOID", +"type_specifier_no_prec : FLOAT", +"type_specifier_no_prec : INT", +"type_specifier_no_prec : BOOL", +"type_specifier_no_prec : VEC2", +"type_specifier_no_prec : VEC3", +"type_specifier_no_prec : VEC4", +"type_specifier_no_prec : BVEC2", +"type_specifier_no_prec : BVEC3", +"type_specifier_no_prec : BVEC4", +"type_specifier_no_prec : IVEC2", +"type_specifier_no_prec : IVEC3", +"type_specifier_no_prec : IVEC4", +"type_specifier_no_prec : MAT2", +"type_specifier_no_prec : MAT3", +"type_specifier_no_prec : MAT4", +"type_specifier_no_prec : SAMPLER2D", +"type_specifier_no_prec : SAMPLER3D", +"type_specifier_no_prec : SAMPLERCUBE", +"type_specifier_no_prec : struct_specifier", +"type_specifier_no_prec : IDENTIFIER", +"struct_specifier : struct_header struct_declaration_list '}'", +"struct_header : STRUCT IDENTIFIER '{'", +"struct_header : STRUCT '{'", +"struct_declaration_list : struct_declaration ';'", +"struct_declaration_list : struct_declaration_list struct_declaration ';'", +"struct_declaration : single_struct_declaration", +"struct_declaration : struct_declaration ',' IDENTIFIER", +"struct_declaration : struct_declaration ',' IDENTIFIER '[' constant_expression ']'", +"single_struct_declaration : type_specifier IDENTIFIER", +"single_struct_declaration : type_specifier IDENTIFIER '[' constant_expression ']'", +"initializer : assignment_expression", +"declaration_statement : declaration", +"statement_no_new_scope : compound_statement_with_scope", +"statement_no_new_scope : simple_statement", +"simple_statement : declaration_statement", +"simple_statement : expression_statement", +"simple_statement : selection_statement", +"simple_statement : iteration_statement", +"simple_statement : jump_statement", +"compound_statement_with_scope : '{' '}'", +"compound_statement_with_scope : '{' statement_list '}'", +"statement_with_scope : compound_statement_no_new_scope", +"statement_with_scope : simple_statement", +"compound_statement_no_new_scope : '{' '}'", +"compound_statement_no_new_scope : '{' statement_list '}'", +"statement_list : statement_no_new_scope", +"statement_list : statement_list statement_no_new_scope", +"expression_statement : ';'", +"expression_statement : expression ';'", +"selection_statement : IF '(' expression ')' selection_rest_statement", +"selection_rest_statement : statement_with_scope ELSE statement_with_scope", +"selection_rest_statement : statement_with_scope", +"condition : expression", +"condition : fully_specified_type IDENTIFIER '=' initializer", +"iteration_statement : WHILE '(' condition ')' statement_no_new_scope", +"iteration_statement : DO statement_with_scope WHILE '(' expression ')' ';'", +"iteration_statement : FOR '(' for_init_statement for_rest_statement ')' statement_no_new_scope", +"for_init_statement : expression_statement", +"for_init_statement : declaration_statement", +"conditionopt : condition", +"conditionopt :", +"for_rest_statement : conditionopt ';'", +"for_rest_statement : conditionopt ';' expression", +"jump_statement : CONTINUE ';'", +"jump_statement : BREAK ';'", +"jump_statement : RETURN ';'", +"jump_statement : RETURN expression ';'", +"jump_statement : DISCARD ';'", +}; +#endif +#if YYDEBUG +#include <stdio.h> +#endif + +/* define the initial stack-sizes */ +#ifdef YYSTACKSIZE +#undef YYMAXDEPTH +#define YYMAXDEPTH YYSTACKSIZE +#else +#ifdef YYMAXDEPTH +#define YYSTACKSIZE YYMAXDEPTH +#else +#define YYSTACKSIZE 500 +#define YYMAXDEPTH 500 +#endif +#endif + +#define YYINITSTACKSIZE 500 + +int yydebug; +int yynerrs; +int yyerrflag; +int yychar; +short *yyssp; +YYSTYPE *yyvsp; +YYSTYPE yyval; +YYSTYPE yylval; + +/* variables for the parser stack */ +static short *yyss; +static short *yysslim; +static YYSTYPE *yyvs; +static int yystacksize; + +void hazelParsePrepare(struct ShaderObjectUnit* ptr, char* src, char* dst) { + assert(ptr != NULL); + pUnit = ptr; + eShaderType = ptr->eShaderType; + pSrcPtr = src; + pDstPtr = dst; + *pDstPtr = '\0'; + iSemError = 0; + iLine = 1; + ES2INTER(SymbolInit)(ptr); + yyclearin; + yyerrok; +} + +int yyerror(char* s) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "ERROR (line %d): %s\n", iLine, s); + yyclearin; + return 1; +} + +#include "ParseLex.inl" +/* allocate initial stack or double stack size, up to YYMAXDEPTH */ +static int yygrowstack(void) +{ + int newsize, i; + short *newss; + YYSTYPE *newvs; + + if ((newsize = yystacksize) == 0) + newsize = YYINITSTACKSIZE; + else if (newsize >= YYMAXDEPTH) + return -1; + else if ((newsize *= 2) > YYMAXDEPTH) + newsize = YYMAXDEPTH; + + i = yyssp - yyss; + newss = (yyss != 0) + ? (short *)realloc(yyss, newsize * sizeof(*newss)) + : (short *)malloc(newsize * sizeof(*newss)); + if (newss == 0) + return -1; + + yyss = newss; + yyssp = newss + i; + newvs = (yyvs != 0) + ? (YYSTYPE *)realloc(yyvs, newsize * sizeof(*newvs)) + : (YYSTYPE *)malloc(newsize * sizeof(*newvs)); + if (newvs == 0) + return -1; + + yyvs = newvs; + yyvsp = newvs + i; + yystacksize = newsize; + yysslim = yyss + newsize - 1; + return 0; +} + +#define YYABORT goto yyabort +#define YYREJECT goto yyabort +#define YYACCEPT goto yyaccept +#define YYERROR goto yyerrlab +int +yyparse(void) +{ + register int yym, yyn, yystate; +#if YYDEBUG + register const char *yys; + + if ((yys = getenv("YYDEBUG")) != 0) + { + yyn = *yys; + if (yyn >= '0' && yyn <= '9') + yydebug = yyn - '0'; + } +#endif + + yynerrs = 0; + yyerrflag = 0; + yychar = YYEMPTY; + + if (yyss == NULL && yygrowstack()) goto yyoverflow; + yyssp = yyss; + yyvsp = yyvs; + *yyssp = yystate = 0; + +yyloop: + if ((yyn = yydefred[yystate]) != 0) goto yyreduce; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + } + if ((yyn = yysindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, shifting to state %d\n", + YYPREFIX, yystate, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + yychar = YYEMPTY; + if (yyerrflag > 0) --yyerrflag; + goto yyloop; + } + if ((yyn = yyrindex[yystate]) && (yyn += yychar) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yychar) + { + yyn = yytable[yyn]; + goto yyreduce; + } + if (yyerrflag) goto yyinrecovery; + + yyerror("syntax error"); + +#ifdef lint + goto yyerrlab; +#endif + +yyerrlab: + ++yynerrs; + +yyinrecovery: + if (yyerrflag < 3) + { + yyerrflag = 3; + for (;;) + { + if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, error recovery shifting\ + to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate = yytable[yyn]; + *++yyvsp = yylval; + goto yyloop; + } + else + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: error recovery discarding state %d\n", + YYPREFIX, *yyssp); +#endif + if (yyssp <= yyss) goto yyabort; + --yyssp; + --yyvsp; + } + } + } + else + { + if (yychar == 0) goto yyabort; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, error recovery discards token %d (%s)\n", + YYPREFIX, yystate, yychar, yys); + } +#endif + yychar = YYEMPTY; + goto yyloop; + } + +yyreduce: +#if YYDEBUG + if (yydebug) + printf("%sdebug: state %d, reducing by rule %d (%s)\n", + YYPREFIX, yystate, yyn, yyrule[yyn]); +#endif + yym = yylen[yyn]; + if (yym) + yyval = yyvsp[1-yym]; + else + memset(&yyval, 0, sizeof yyval); + switch (yyn) + { +case 1: +{ + strcpy(pDstPtr, yyvsp[0].token.name); + free(yyvsp[0].token.name); + yyvsp[0].token.name = NULL; + } +break; +case 3: +{ MERGE(); } +break; +case 6: +{ + MERGE(); + } +break; +case 10: +{ + MERGE(); + yyval.token.type = yyvsp[-1].token.type; + } +break; +case 11: +{ /* referencing existing identifer*/ + if (strcmp(yyvsp[0].token.name, "gl_MaxFragmentUniformVectors") == 0) { + const char* subst = "(gl_MaxFragmentUniformComponents/4)"; + yyvsp[0].token.name = realloc(yyvsp[0].token.name, strlen(subst) + 1); + strcpy(yyvsp[0].token.name, subst); + } else if (strcmp(yyvsp[0].token.name, "gl_MaxVertexUniformVectors") == 0) { + const char* subst = "(gl_MaxVertexUniformComponents/4)"; + yyvsp[0].token.name = realloc(yyvsp[0].token.name, strlen(subst) + 1); + strcpy(yyvsp[0].token.name, subst); + } else if (strcmp(yyvsp[0].token.name, "gl_MaxVaryingVectors") == 0) { + const char* subst = "(gl_MaxVaryingFloats/4)"; + yyvsp[0].token.name = realloc(yyvsp[0].token.name, strlen(subst) + 1); + strcpy(yyvsp[0].token.name, subst); + } +/* + struct TableEntry* ptr = ES2INTER(SearchSymbol)(pUnit, $1.token.name, NULL); + if (ptr == NULL) { + UNDEFINED($1.token.name); + YYERROR; + } +*/ + MERGE(); +/* + $$.token.type = ptr->type; +*/ + } +break; +case 14: +{ MERGE(); } +break; +case 15: +{ MERGE(); } +break; +case 16: +{ MERGE(); } +break; +case 17: +{ /* FIELD_SELECTION xyzw, rgba, stpq: must be processed*/ +/* + $$.token.type = ES2INTER(ProcSwizzler)($1.token.type, $3.token.name); + if ($$.token.type == 0) { + yyerror("illegal swizzler"); + YYERROR; + } +*/ + MERGE(); + } +break; +case 19: +{ + MERGE(); + } +break; +case 22: +{ + MERGE(); + } +break; +case 23: +{ + MERGE(); + } +break; +case 24: +{ + MERGE(); + } +break; +case 41: +{ MERGE(); } +break; +case 44: +{ MERGE(); } +break; +case 45: +{ MERGE(); } +break; +case 46: +{ + MERGE(); + } +break; +case 47: +{ MERGE(); } +break; +case 48: +{ MERGE(); } +break; +case 49: +{ MERGE(); } +break; +case 50: +{ MERGE(); } +break; +case 51: +{ + MERGE(); + } +break; +case 52: +{ + MERGE(); + } +break; +case 56: +{ + memset(&(yyval.token), 0, sizeof(struct TableEntry)); + yyval.token.name = malloc(1); yyval.token.name[0] = '\0'; + yyval.token.type = S_IN; + } +break; +case 58: +{ MERGE(); } +break; +case 60: +{ MERGE(); yyval.token.type = yyvsp[-1].token.type; } +break; +case 61: +{ MERGE(); yyval.token.type = yyvsp[-1].token.type; } +break; +case 62: +{ MERGE(); yyval.token.type = yyvsp[-1].token.type; } +break; +case 63: +{ MERGE(); yyval.token.type = yyvsp[-1].token.type; } +break; +case 64: +{ FOUND_RESERVED("operator ~"); YYERROR; } +break; +case 65: +{ MERGE(); yyval.token.type = yyvsp[-1].token.type; } +break; +case 67: +{ MERGE(); } +break; +case 68: +{ MERGE(); } +break; +case 69: +{ FOUND_RESERVED("operator %%"); YYERROR; } +break; +case 70: +{ MERGE(); } +break; +case 71: +{ MERGE(); } +break; +case 72: +{ FOUND_RESERVED("operator <<"); YYERROR; } +break; +case 73: +{ FOUND_RESERVED("operator >>"); YYERROR; } +break; +case 74: +{ MERGE(); } +break; +case 75: +{ MERGE(); } +break; +case 76: +{ MERGE(); } +break; +case 77: +{ MERGE(); } +break; +case 78: +{ MERGE(); } +break; +case 79: +{ MERGE(); } +break; +case 80: +{ FOUND_RESERVED("operator &"); YYERROR; } +break; +case 81: +{ FOUND_RESERVED("operator ^"); YYERROR; } +break; +case 82: +{ FOUND_RESERVED("operator |"); YYERROR; } +break; +case 83: +{ MERGE(); } +break; +case 84: +{ MERGE(); } +break; +case 85: +{ MERGE(); } +break; +case 86: +{ MERGE(); } +break; +case 87: +{ MERGE(); } +break; +case 88: +{ MERGE(); } +break; +case 89: +{ MERGE(); } +break; +case 95: +{ FOUND_RESERVED("operator %%="); YYERROR; } +break; +case 96: +{ FOUND_RESERVED("operator <<="); YYERROR; } +break; +case 97: +{ FOUND_RESERVED("operator >>="); YYERROR; } +break; +case 98: +{ FOUND_RESERVED("operator &="); YYERROR; } +break; +case 99: +{ FOUND_RESERVED("operator ^="); YYERROR; } +break; +case 100: +{ FOUND_RESERVED("operator |="); YYERROR; } +break; +case 101: +{ MERGE(); } +break; +case 102: +{ MERGE(); } +break; +case 103: +{ MERGE(); } +break; +case 104: +{ + MERGE(); + } +break; +case 105: +{ MERGE(); } +break; +case 106: +{ + /* ignore the whole statement*/ + FREE(); + memset(&(yyval.token), 0, sizeof(struct TableEntry)); + yyval.token.name = malloc(1); yyval.token.name[0] = '\0'; + } +break; +case 108: +{ /* new identifier*/ + if ((yyvsp[-2].token.type & S_CONST) != 0) { + ERROR("const specifier", yyvsp[-2].token.name); /* const must be initialized*/ + } + if (strncmp(yyvsp[0].token.name, "gl_", 3) == 0) { + FOUND_RESERVED(yyvsp[-1].token.name); + YYERROR; + } + MERGE(); + } +break; +case 109: +{ + if ((yyvsp[-5].token.type & S_CONST) != 0) { + ERROR("const specifier", yyvsp[-5].token.name); + } + if ((yyvsp[-5].token.type & S_ATTRIBUTE) != 0) { + ERROR("attribute specifier", yyvsp[-5].token.name); + } + if (strncmp(yyvsp[-3].token.name, "gl_", 3) == 0) { + FOUND_RESERVED(yyvsp[-4].token.name); + YYERROR; + } + MERGE(); + } +break; +case 110: +{ + if ((yyvsp[-4].token.type & S_UNIFORM) != 0) { + ERROR("uniform specifier", yyvsp[-4].token.name); + } + if (strncmp(yyvsp[-2].token.name, "gl_", 3) == 0) { + FOUND_RESERVED(yyvsp[-3].token.name); + YYERROR; + } + MERGE(); + } +break; +case 112: +{ + switch (GET_TYPE(yyvsp[-1].token.type)) { + case T_BOOL: + case T_BVEC2: + case T_BVEC3: + case T_BVEC4: + case T_INT: + case T_IVEC2: + case T_IVEC3: + case T_IVEC4: + if ((yyvsp[-1].token.type & S_ATTRIBUTE) != 0) { + ERROR("attribute specifier", yyvsp[-1].token.name); + } + if ((yyvsp[-1].token.type & S_VARYING) != 0) { + ERROR("attribute specifier", yyvsp[-1].token.name); + } + break; + } + if ((yyvsp[-1].token.type & S_CONST) != 0) { + ERROR("const specifier", yyvsp[-1].token.name); + } + if (strncmp(yyvsp[0].token.name, "gl_", 3) == 0) { + FOUND_RESERVED(yyvsp[0].token.name); + YYERROR; + } + MERGE(); + yyval.token.type = yyvsp[-1].token.type; + } +break; +case 113: +{ + if ((yyvsp[-3].token.type & S_UNIFORM) != 0) { + ERROR("uniform specifier", yyvsp[-3].token.name); + } + if ((yyvsp[-3].token.type & S_VARYING) != 0) { + ERROR("attribute specifier", yyvsp[-3].token.name); + } + if (strncmp(yyvsp[-2].token.name, "gl_", 3) == 0) { + FOUND_RESERVED(yyvsp[-2].token.name); + YYERROR; + } + MERGE(); + yyval.token.type = yyvsp[-3].token.type; + } +break; +case 114: +{ + if ((yyvsp[-4].token.type & S_CONST) != 0) { + ERROR("const specifier", yyvsp[-4].token.name); + } + if ((yyvsp[-4].token.type & S_ATTRIBUTE) != 0) { + ERROR("attribute specifier", yyvsp[-4].token.name); + } + MERGE(); + yyval.token.type = yyvsp[-4].token.type; + } +break; +case 115: +{ + MERGE(); + yyval.token.type = yyvsp[-1].token.type; + } +break; +case 120: +{ /* Vertex only.*/ + if (eShaderType != GL_VERTEX_SHADER) { + UNSUPPORTED("'attribute' keyword out of vertex shaders"); + YYERROR; + } + MERGE(); + } +break; +case 121: +{ + MERGE(); + yyval.token.type = (yyvsp[-1].token.type | yyvsp[0].token.type); + } +break; +case 144: +{ /* TYPE_NAME*/ + MERGE(); + } +break; +case 146: +{ + MERGE(); + yyval.token.type = (yyvsp[-1].token.type | yyvsp[0].token.type); + } +break; +case 148: +{ + yyval = yyvsp[0]; + free(yyvsp[-1].token.name); + } +break; +case 169: +{ /* TYPE_NAME*/ + MERGE(); + } +break; +case 170: +{ + MERGE(); + } +break; +case 171: +{ /* new identifier*/ + MERGE(); + } +break; +case 172: +{ + MERGE(); + } +break; +case 173: +{ MERGE(); } +break; +case 174: +{ MERGE(); } +break; +case 176: +{ /* new identifier*/ + MERGE(); + } +break; +case 177: +{ /* new identifier*/ + MERGE(); + } +break; +case 178: +{ /* new identifier*/ + MERGE(); + } +break; +case 179: +{ /* new identifier*/ + MERGE(); + } +break; +case 189: +{ MERGE(); } +break; +case 190: +{ MERGE(); } +break; +case 193: +{ MERGE(); } +break; +case 194: +{ MERGE(); } +break; +case 196: +{ MERGE(); } +break; +case 198: +{ MERGE(); } +break; +case 199: +{ MERGE(); } +break; +case 200: +{ MERGE(); } +break; +case 203: +{ + MERGE(); + } +break; +case 204: +{ MERGE(); } +break; +case 205: +{ MERGE(); } +break; +case 206: +{ MERGE(); } +break; +case 210: +{ + memset(&(yyval.token), 0, sizeof(struct TableEntry)); + yyval.token.name = malloc(1); yyval.token.name[0] = '\0'; + } +break; +case 211: +{ MERGE(); } +break; +case 212: +{ MERGE(); } +break; +case 213: +{ MERGE(); } +break; +case 214: +{ MERGE(); } +break; +case 215: +{ MERGE(); } +break; +case 216: +{ MERGE(); } +break; +case 217: +{ /* Fragment shader only.*/ + if (eShaderType != GL_FRAGMENT_SHADER) { + UNSUPPORTED("'discard' keyword out of fragment shaders"); + YYERROR; + } else { + MERGE(); + } + } +break; + } + yyssp -= yym; + yystate = *yyssp; + yyvsp -= yym; + yym = yylhs[yyn]; + if (yystate == 0 && yym == 0) + { +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state 0 to\ + state %d\n", YYPREFIX, YYFINAL); +#endif + yystate = YYFINAL; + *++yyssp = YYFINAL; + *++yyvsp = yyval; + if (yychar < 0) + { + if ((yychar = yylex()) < 0) yychar = 0; +#if YYDEBUG + if (yydebug) + { + yys = 0; + if (yychar <= YYMAXTOKEN) yys = yyname[yychar]; + if (!yys) yys = "illegal-symbol"; + printf("%sdebug: state %d, reading %d (%s)\n", + YYPREFIX, YYFINAL, yychar, yys); + } +#endif + } + if (yychar == 0) goto yyaccept; + goto yyloop; + } + if ((yyn = yygindex[yym]) && (yyn += yystate) >= 0 && + yyn <= YYTABLESIZE && yycheck[yyn] == yystate) + yystate = yytable[yyn]; + else + yystate = yydgoto[yym]; +#if YYDEBUG + if (yydebug) + printf("%sdebug: after reduction, shifting from state %d \ +to state %d\n", YYPREFIX, *yyssp, yystate); +#endif + if (yyssp >= yysslim && yygrowstack()) + { + goto yyoverflow; + } + *++yyssp = yystate; + *++yyvsp = yyval; + goto yyloop; + +yyoverflow: + yyerror("yacc stack overflow"); + +yyabort: + return (1); + +yyaccept: + return (0); +} diff --git a/es_2_0/PrepLex.c b/es_2_0/PrepLex.c new file mode 100755 index 0000000..76d8a2c --- /dev/null +++ b/es_2_0/PrepLex.c @@ -0,0 +1,2836 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#line 3 "PrepLex.c" + +#define YY_INT_ALIGNED short int + +/* A lexical scanner generated by flex */ + +#define yy_create_buffer hazelPrep_create_buffer +#define yy_delete_buffer hazelPrep_delete_buffer +#define yy_flex_debug hazelPrep_flex_debug +#define yy_init_buffer hazelPrep_init_buffer +#define yy_flush_buffer hazelPrep_flush_buffer +#define yy_load_buffer_state hazelPrep_load_buffer_state +#define yy_switch_to_buffer hazelPrep_switch_to_buffer +#define yyin hazelPrepin +#define yyleng hazelPrepleng +#define yylex hazelPreplex +#define yylineno hazelPreplineno +#define yyout hazelPrepout +#define yyrestart hazelPreprestart +#define yytext hazelPreptext +#define yywrap hazelPrepwrap +#define yyalloc hazelPrepalloc +#define yyrealloc hazelPreprealloc +#define yyfree hazelPrepfree + +#define FLEX_SCANNER +#define YY_FLEX_MAJOR_VERSION 2 +#define YY_FLEX_MINOR_VERSION 5 +#define YY_FLEX_SUBMINOR_VERSION 35 +#if YY_FLEX_SUBMINOR_VERSION > 0 +#define FLEX_BETA +#endif + +/* First, we deal with platform-specific or compiler-specific issues. */ + +/* begin standard C headers. */ +#include <stdio.h> +#include <string.h> +#include <errno.h> +#include <stdlib.h> + +/* end standard C headers. */ + +/* flex integer type definitions */ + +#ifndef FLEXINT_H +#define FLEXINT_H + +/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */ + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L + +/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, + * if you want the limit (max/min) macros for int types. + */ +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS 1 +#endif + +#include <inttypes.h> +typedef int8_t flex_int8_t; +typedef uint8_t flex_uint8_t; +typedef int16_t flex_int16_t; +typedef uint16_t flex_uint16_t; +typedef int32_t flex_int32_t; +typedef uint32_t flex_uint32_t; +#else +typedef signed char flex_int8_t; +typedef short int flex_int16_t; +typedef int flex_int32_t; +typedef unsigned char flex_uint8_t; +typedef unsigned short int flex_uint16_t; +typedef unsigned int flex_uint32_t; +#endif /* ! C99 */ + +/* Limits of integral types. */ +#ifndef INT8_MIN +#define INT8_MIN (-128) +#endif +#ifndef INT16_MIN +#define INT16_MIN (-32767-1) +#endif +#ifndef INT32_MIN +#define INT32_MIN (-2147483647-1) +#endif +#ifndef INT8_MAX +#define INT8_MAX (127) +#endif +#ifndef INT16_MAX +#define INT16_MAX (32767) +#endif +#ifndef INT32_MAX +#define INT32_MAX (2147483647) +#endif +#ifndef UINT8_MAX +#define UINT8_MAX (255U) +#endif +#ifndef UINT16_MAX +#define UINT16_MAX (65535U) +#endif +#ifndef UINT32_MAX +#define UINT32_MAX (4294967295U) +#endif + +#endif /* ! FLEXINT_H */ + +#ifdef __cplusplus + +/* The "const" storage-class-modifier is valid. */ +#define YY_USE_CONST + +#else /* ! __cplusplus */ + +/* C99 requires __STDC__ to be defined as 1. */ +#if defined (__STDC__) + +#define YY_USE_CONST + +#endif /* defined (__STDC__) */ +#endif /* ! __cplusplus */ + +#ifdef YY_USE_CONST +#define yyconst const +#else +#define yyconst +#endif + +/* Returned upon end-of-file. */ +#define YY_NULL 0 + +/* Promotes a possibly negative, possibly signed char to an unsigned + * integer for use as an array index. If the signed char is negative, + * we want to instead treat it as an 8-bit unsigned char, hence the + * double cast. + */ +#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c) + +/* Enter a start condition. This macro really ought to take a parameter, + * but we do it the disgusting crufty way forced on us by the ()-less + * definition of BEGIN. + */ +#define BEGIN (yy_start) = 1 + 2 * + +/* Translate the current start state into a value that can be later handed + * to BEGIN to return to the state. The YYSTATE alias is for lex + * compatibility. + */ +#define YY_START (((yy_start) - 1) / 2) +#define YYSTATE YY_START + +/* Action number for EOF rule of a given start state. */ +#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1) + +/* Special action meaning "start processing a new file". */ +#define YY_NEW_FILE hazelPreprestart(hazelPrepin ) + +#define YY_END_OF_BUFFER_CHAR 0 + +/* Size of default input buffer. */ +#ifndef YY_BUF_SIZE +#define YY_BUF_SIZE 16384 +#endif + +/* The state buf must be large enough to hold one state per character in the main buffer. + */ +#define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type)) + +#ifndef YY_TYPEDEF_YY_BUFFER_STATE +#define YY_TYPEDEF_YY_BUFFER_STATE +typedef struct yy_buffer_state *YY_BUFFER_STATE; +#endif + +extern int hazelPrepleng; + +extern FILE *hazelPrepin, *hazelPrepout; + +#define EOB_ACT_CONTINUE_SCAN 0 +#define EOB_ACT_END_OF_FILE 1 +#define EOB_ACT_LAST_MATCH 2 + + #define YY_LESS_LINENO(n) + +/* Return all but the first "n" matched characters back to the input stream. */ +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up hazelPreptext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + *yy_cp = (yy_hold_char); \ + YY_RESTORE_YY_MORE_OFFSET \ + (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \ + YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ \ + } \ + while ( 0 ) + +#define unput(c) yyunput( c, (yytext_ptr) ) + +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +#ifndef YY_STRUCT_YY_BUFFER_STATE +#define YY_STRUCT_YY_BUFFER_STATE +struct yy_buffer_state + { + FILE *yy_input_file; + + char *yy_ch_buf; /* input buffer */ + char *yy_buf_pos; /* current position in input buffer */ + + /* Size of input buffer in bytes, not including room for EOB + * characters. + */ + yy_size_t yy_buf_size; + + /* Number of characters read into yy_ch_buf, not including EOB + * characters. + */ + int yy_n_chars; + + /* Whether we "own" the buffer - i.e., we know we created it, + * and can realloc() it to grow it, and should free() it to + * delete it. + */ + int yy_is_our_buffer; + + /* Whether this is an "interactive" input source; if so, and + * if we're using stdio for input, then we want to use getc() + * instead of fread(), to make sure we stop fetching input after + * each newline. + */ + int yy_is_interactive; + + /* Whether we're considered to be at the beginning of a line. + * If so, '^' rules will be active on the next match, otherwise + * not. + */ + int yy_at_bol; + + int yy_bs_lineno; /**< The line count. */ + int yy_bs_column; /**< The column count. */ + + /* Whether to try to fill the input buffer when we reach the + * end of it. + */ + int yy_fill_buffer; + + int yy_buffer_status; + +#define YY_BUFFER_NEW 0 +#define YY_BUFFER_NORMAL 1 + /* When an EOF's been seen but there's still some text to process + * then we mark the buffer as YY_EOF_PENDING, to indicate that we + * shouldn't try reading from the input source any more. We might + * still have a bunch of tokens to match, though, because of + * possible backing-up. + * + * When we actually see the EOF, we change the status to "new" + * (via hazelPreprestart()), so that the user can continue scanning by + * just pointing hazelPrepin at a new input file. + */ +#define YY_BUFFER_EOF_PENDING 2 + + }; +#endif /* !YY_STRUCT_YY_BUFFER_STATE */ + +/* Stack of input buffers. */ +static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */ +static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */ +static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ + +/* We provide macros for accessing buffer states in case in the + * future we want to put the buffer states in a more general + * "scanner state". + * + * Returns the top of the stack, or NULL. + */ +#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ + ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ + : NULL) + +/* Same as previous macro, but useful when we know that the buffer stack is not + * NULL or when we need an lvalue. For internal use only. + */ +#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)] + +/* yy_hold_char holds the character lost when hazelPreptext is formed. */ +static char yy_hold_char; +static int yy_n_chars; /* number of characters read into yy_ch_buf */ +int hazelPrepleng; + +/* Points to current character in buffer. */ +static char *yy_c_buf_p = (char *) 0; +static int yy_init = 0; /* whether we need to initialize */ +static int yy_start = 0; /* start state number */ + +/* Flag which is used to allow hazelPrepwrap()'s to do buffer switches + * instead of setting up a fresh hazelPrepin. A bit of a hack ... + */ +static int yy_did_buffer_switch_on_eof; + +void hazelPreprestart (FILE *input_file ); +void hazelPrep_switch_to_buffer (YY_BUFFER_STATE new_buffer ); +YY_BUFFER_STATE hazelPrep_create_buffer (FILE *file,int size ); +void hazelPrep_delete_buffer (YY_BUFFER_STATE b ); +void hazelPrep_flush_buffer (YY_BUFFER_STATE b ); +void hazelPreppush_buffer_state (YY_BUFFER_STATE new_buffer ); +void hazelPreppop_buffer_state (void ); + +static void hazelPrepensure_buffer_stack (void ); +static void hazelPrep_load_buffer_state (void ); +static void hazelPrep_init_buffer (YY_BUFFER_STATE b,FILE *file ); + +#define YY_FLUSH_BUFFER hazelPrep_flush_buffer(YY_CURRENT_BUFFER ) + +YY_BUFFER_STATE hazelPrep_scan_buffer (char *base,yy_size_t size ); +YY_BUFFER_STATE hazelPrep_scan_string (yyconst char *yy_str ); +YY_BUFFER_STATE hazelPrep_scan_bytes (yyconst char *bytes,int len ); + +void *hazelPrepalloc (yy_size_t ); +void *hazelPreprealloc (void *,yy_size_t ); +void hazelPrepfree (void * ); + +#define yy_new_buffer hazelPrep_create_buffer + +#define yy_set_interactive(is_interactive) \ + { \ + if ( ! YY_CURRENT_BUFFER ){ \ + hazelPrepensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + hazelPrep_create_buffer(hazelPrepin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \ + } + +#define yy_set_bol(at_bol) \ + { \ + if ( ! YY_CURRENT_BUFFER ){\ + hazelPrepensure_buffer_stack (); \ + YY_CURRENT_BUFFER_LVALUE = \ + hazelPrep_create_buffer(hazelPrepin,YY_BUF_SIZE ); \ + } \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \ + } + +#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol) + +/* Begin user sect3 */ + +typedef unsigned char YY_CHAR; + +FILE *hazelPrepin = (FILE *) 0, *hazelPrepout = (FILE *) 0; + +typedef int yy_state_type; + +extern int hazelPreplineno; + +int hazelPreplineno = 1; + +extern char *hazelPreptext; +#define yytext_ptr hazelPreptext + +static yy_state_type yy_get_previous_state (void ); +static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); +static int yy_get_next_buffer (void ); +static void yy_fatal_error (yyconst char msg[] ); + +/* Done after the current pattern has been matched and before the + * corresponding action - sets up hazelPreptext. + */ +#define YY_DO_BEFORE_ACTION \ + (yytext_ptr) = yy_bp; \ + hazelPrepleng = (size_t) (yy_cp - yy_bp); \ + (yy_hold_char) = *yy_cp; \ + *yy_cp = '\0'; \ + (yy_c_buf_p) = yy_cp; + +#define YY_NUM_RULES 30 +#define YY_END_OF_BUFFER 31 +/* This struct is not used in this scanner, + but its presence is necessary. */ +struct yy_trans_info + { + flex_int32_t yy_verify; + flex_int32_t yy_nxt; + }; +static yyconst flex_int16_t yy_accept[310] = + { 0, + 0, 0, 31, 29, 28, 29, 29, 29, 0, 0, + 26, 0, 0, 27, 0, 0, 0, 24, 0, 0, + 0, 0, 0, 0, 0, 0, 25, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 5, 0, 6, 0, 0, 0, 0, 0, + 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 7, 0, 0, 12, 0, 0, 0, 3, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 15, + 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, + 0, 0, 0, 0, 0, 11, 0, 0, 0, 23, + 0, 0, 0, 10, 0, 0, 0, 0, 2, 0, + + 0, 0, 0, 0, 0, 0, 0, 0, 21, 0, + 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, + 0, 0, 0, 0, 0, 0, 0, 0, 13, 0, + 0, 0, 0, 20, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 19, + 0, 0, 0, 0, 0, 14, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 17, 0, 18, + + 0, 0, 0, 0, 16, 0, 0, 16, 0 + } ; + +static yyconst flex_int32_t yy_ec[256] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 4, 1, 1, 1, 1, 5, + 6, 1, 1, 1, 1, 1, 1, 7, 8, 9, + 9, 9, 9, 9, 9, 9, 9, 10, 1, 1, + 1, 1, 1, 1, 11, 11, 11, 12, 11, 11, + 13, 11, 11, 11, 11, 14, 11, 11, 11, 11, + 11, 11, 15, 16, 11, 11, 11, 11, 11, 11, + 1, 1, 1, 1, 11, 1, 17, 18, 11, 19, + + 20, 21, 22, 11, 23, 11, 11, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 11, 37, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int32_t yy_meta[38] = + { 0, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1 + } ; + +static yyconst flex_int16_t yy_base[345] = + { 0, + 858, 0, 860, 862, 862, 3, 5, 8, 10, 856, + 862, 12, 14, 862, 41, 17, 74, 862, 19, 107, + 27, 22, 32, 44, 35, 855, 862, 20, 54, 30, + 49, 23, 47, 46, 65, 56, 80, 86, 89, 143, + 93, 98, 101, 109, 60, 82, 103, 111, 120, 169, + 114, 115, 123, 121, 127, 133, 156, 154, 158, 161, + 125, 163, 862, 180, 165, 184, 187, 190, 194, 175, + 191, 51, 188, 196, 135, 854, 198, 200, 202, 199, + 204, 177, 211, 237, 213, 224, 226, 228, 230, 853, + 232, 246, 248, 268, 250, 255, 257, 258, 284, 260, + + 243, 214, 274, 262, 276, 300, 288, 278, 289, 295, + 305, 314, 862, 316, 862, 318, 320, 322, 353, 324, + 326, 328, 862, 330, 332, 334, 340, 852, 336, 851, + 311, 363, 290, 850, 203, 338, 343, 346, 348, 849, + 369, 372, 862, 374, 848, 862, 376, 399, 409, 862, + 419, 378, 847, 380, 382, 429, 424, 384, 385, 450, + 460, 387, 441, 470, 455, 482, 492, 389, 488, 862, + 515, 391, 442, 846, 393, 525, 506, 395, 862, 535, + 545, 279, 439, 440, 404, 862, 555, 438, 502, 862, + 486, 845, 844, 862, 843, 565, 444, 446, 862, 575, + + 122, 569, 510, 579, 520, 842, 531, 587, 862, 349, + 233, 521, 595, 841, 862, 604, 614, 540, 561, 549, + 560, 619, 819, 638, 818, 597, 623, 550, 609, 862, + 673, 708, 718, 488, 607, 614, 660, 630, 862, 647, + 632, 648, 651, 862, 818, 632, 643, 638, 641, 684, + 670, 699, 704, 581, 674, 681, 580, 672, 713, 817, + 708, 715, 719, 685, 743, 721, 693, 816, 748, 706, + 730, 729, 731, 753, 760, 741, 737, 743, 765, 862, + 752, 754, 747, 753, 779, 862, 763, 764, 767, 765, + 814, 789, 791, 772, 777, 775, 799, 862, 801, 862, + + 786, 805, 790, 813, 862, 815, 817, 862, 862, 835, + 834, 833, 832, 831, 830, 829, 828, 826, 825, 824, + 823, 822, 821, 820, 810, 798, 777, 773, 739, 726, + 695, 668, 664, 655, 635, 622, 505, 480, 427, 343, + 308, 254, 55, 0 + } ; + +static yyconst flex_int16_t yy_def[345] = + { 0, + 310, 311, 309, 309, 309, 312, 313, 314, 312, 315, + 309, 312, 313, 309, 314, 314, 316, 309, 314, 314, + 314, 314, 314, 314, 314, 316, 309, 316, 316, 316, + 316, 316, 316, 316, 314, 314, 314, 314, 314, 314, + 314, 314, 314, 314, 316, 316, 316, 316, 316, 316, + 316, 316, 316, 316, 314, 314, 314, 314, 314, 314, + 317, 318, 309, 314, 314, 314, 314, 314, 314, 316, + 316, 316, 316, 316, 316, 318, 316, 316, 316, 316, + 316, 316, 314, 314, 314, 314, 314, 314, 317, 318, + 318, 314, 314, 314, 314, 314, 314, 316, 316, 316, + + 316, 316, 316, 316, 316, 316, 316, 316, 316, 314, + 319, 320, 309, 316, 309, 314, 321, 314, 314, 314, + 322, 323, 309, 314, 314, 314, 316, 320, 316, 324, + 316, 316, 316, 323, 316, 316, 316, 314, 319, 320, + 320, 316, 309, 321, 324, 309, 314, 314, 325, 309, + 314, 322, 323, 323, 326, 327, 314, 316, 316, 316, + 316, 328, 316, 329, 314, 330, 331, 326, 328, 309, + 332, 333, 316, 328, 334, 335, 314, 316, 309, 330, + 336, 328, 328, 328, 316, 309, 332, 333, 334, 309, + 316, 334, 337, 309, 338, 335, 339, 316, 309, 336, + + 328, 328, 328, 334, 340, 338, 339, 341, 309, 328, + 328, 328, 334, 340, 309, 342, 342, 328, 328, 328, + 334, 340, 217, 343, 217, 328, 328, 328, 334, 309, + 343, 344, 344, 233, 233, 233, 217, 328, 309, 328, + 328, 328, 340, 309, 233, 233, 233, 233, 233, 340, + 231, 328, 328, 328, 233, 233, 233, 233, 231, 233, + 233, 233, 233, 328, 328, 233, 233, 233, 233, 233, + 233, 233, 233, 328, 328, 233, 233, 233, 340, 309, + 233, 233, 233, 233, 328, 309, 233, 233, 233, 233, + 233, 233, 233, 233, 233, 233, 340, 309, 340, 309, + + 233, 233, 233, 340, 309, 233, 340, 309, 0, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309 + } ; + +static yyconst flex_int16_t yy_nxt[900] = + { 0, + 245, 7, 5, 8, 10, 11, 13, 14, 15, 17, + 18, 10, 11, 10, 11, 13, 14, 15, 26, 27, + 26, 27, 27, 26, 27, 27, 19, 20, 26, 27, + 21, 22, 27, 26, 27, 23, 26, 27, 35, 45, + 24, 25, 17, 18, 41, 26, 27, 40, 27, 27, + 50, 27, 52, 27, 44, 232, 27, 26, 27, 19, + 20, 42, 27, 21, 22, 54, 26, 27, 23, 43, + 100, 51, 53, 24, 25, 17, 18, 46, 56, 47, + 70, 26, 27, 48, 27, 55, 57, 26, 27, 49, + 26, 27, 28, 29, 26, 27, 30, 31, 58, 26, + + 27, 32, 26, 27, 71, 27, 33, 34, 26, 27, + 26, 27, 72, 27, 67, 59, 27, 27, 66, 68, + 60, 73, 27, 27, 170, 27, 90, 63, 26, 27, + 36, 80, 37, 210, 26, 27, 38, 27, 69, 79, + 74, 81, 39, 61, 62, 63, 61, 61, 61, 83, + 82, 75, 61, 84, 103, 26, 27, 26, 27, 26, + 27, 64, 26, 27, 91, 63, 26, 27, 65, 76, + 62, 63, 76, 76, 76, 85, 86, 27, 76, 27, + 88, 26, 27, 93, 87, 26, 27, 77, 26, 27, + 27, 26, 27, 27, 78, 26, 27, 98, 27, 92, + + 27, 27, 27, 94, 27, 27, 27, 109, 95, 96, + 101, 99, 26, 27, 114, 115, 27, 104, 105, 162, + 107, 106, 102, 108, 97, 26, 27, 26, 27, 26, + 27, 90, 63, 91, 63, 170, 110, 111, 112, 113, + 111, 111, 111, 130, 116, 27, 111, 26, 27, 26, + 27, 26, 27, 118, 223, 117, 26, 27, 26, 27, + 27, 114, 115, 129, 27, 219, 119, 120, 121, 122, + 123, 121, 121, 121, 124, 125, 27, 121, 27, 126, + 27, 170, 132, 127, 128, 112, 113, 128, 128, 128, + 27, 27, 27, 128, 201, 133, 26, 27, 136, 131, + + 134, 122, 123, 134, 134, 134, 140, 113, 216, 134, + 161, 137, 135, 27, 138, 141, 113, 114, 115, 142, + 143, 145, 146, 26, 27, 26, 27, 153, 123, 154, + 123, 26, 27, 156, 27, 26, 27, 142, 143, 156, + 27, 159, 27, 214, 151, 27, 155, 164, 27, 140, + 113, 170, 147, 148, 149, 150, 148, 148, 148, 158, + 157, 218, 148, 160, 149, 150, 160, 160, 160, 163, + 141, 113, 160, 142, 143, 145, 146, 26, 27, 153, + 123, 154, 123, 169, 170, 164, 27, 27, 169, 170, + 174, 170, 189, 190, 189, 190, 178, 179, 165, 148, + + 160, 150, 148, 148, 148, 185, 186, 173, 148, 160, + 149, 150, 160, 160, 160, 26, 26, 26, 160, 148, + 167, 150, 148, 148, 148, 26, 27, 207, 148, 26, + 156, 27, 26, 26, 26, 26, 26, 26, 26, 192, + 190, 170, 170, 27, 27, 208, 209, 198, 199, 172, + 160, 160, 150, 160, 160, 160, 26, 27, 202, 160, + 160, 167, 150, 160, 160, 160, 175, 203, 191, 160, + 26, 164, 27, 26, 26, 26, 26, 26, 26, 26, + 206, 177, 26, 178, 179, 26, 26, 26, 27, 169, + 170, 26, 160, 167, 150, 160, 160, 160, 26, 26, + + 26, 160, 182, 189, 190, 193, 183, 26, 27, 204, + 245, 205, 170, 247, 184, 26, 185, 186, 26, 26, + 26, 208, 209, 170, 26, 193, 193, 194, 193, 195, + 193, 197, 214, 209, 193, 26, 178, 179, 26, 26, + 26, 212, 170, 220, 26, 26, 198, 199, 26, 26, + 26, 170, 170, 226, 26, 26, 185, 186, 26, 26, + 26, 229, 230, 170, 26, 193, 193, 194, 193, 195, + 193, 170, 242, 228, 193, 26, 198, 199, 26, 26, + 26, 190, 227, 170, 26, 213, 211, 214, 208, 209, + 214, 214, 214, 214, 214, 214, 214, 190, 238, 239, + + 227, 221, 245, 217, 214, 222, 209, 214, 214, 214, + 229, 230, 268, 224, 214, 222, 209, 214, 214, 214, + 222, 209, 200, 224, 240, 170, 248, 241, 224, 245, + 249, 238, 239, 252, 170, 196, 245, 225, 214, 231, + 209, 214, 214, 214, 214, 214, 214, 214, 240, 170, + 170, 241, 243, 244, 245, 192, 233, 234, 253, 256, + 245, 250, 255, 245, 188, 245, 257, 235, 187, 251, + 258, 259, 236, 214, 231, 209, 214, 214, 214, 214, + 214, 214, 214, 223, 254, 250, 209, 170, 260, 261, + 266, 233, 234, 251, 245, 181, 245, 269, 267, 262, + + 252, 170, 235, 245, 263, 265, 170, 236, 214, 243, + 244, 214, 214, 214, 259, 245, 277, 214, 214, 243, + 244, 214, 214, 214, 264, 253, 180, 214, 245, 265, + 245, 260, 261, 271, 272, 273, 281, 245, 276, 176, + 246, 245, 262, 245, 274, 170, 282, 263, 275, 279, + 280, 245, 245, 245, 274, 170, 269, 283, 275, 245, + 284, 285, 286, 245, 287, 245, 279, 280, 289, 245, + 245, 290, 288, 174, 245, 245, 245, 171, 292, 291, + 285, 286, 269, 293, 294, 245, 245, 245, 295, 245, + 297, 298, 299, 300, 245, 301, 302, 245, 168, 245, + + 297, 298, 299, 300, 303, 292, 304, 305, 245, 306, + 166, 245, 245, 245, 304, 305, 307, 308, 307, 308, + 145, 153, 152, 144, 140, 139, 90, 245, 89, 26, + 10, 16, 12, 9, 6, 4, 296, 245, 278, 270, + 245, 237, 223, 209, 215, 194, 194, 190, 170, 123, + 146, 113, 123, 146, 113, 63, 63, 27, 11, 309, + 5, 3, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309 + + } ; + +static yyconst flex_int16_t yy_chk[900] = + { 0, + 344, 2, 2, 2, 6, 6, 7, 7, 7, 8, + 8, 9, 9, 12, 12, 13, 13, 13, 16, 16, + 19, 19, 28, 22, 22, 32, 8, 8, 21, 21, + 8, 8, 30, 23, 23, 8, 25, 25, 19, 28, + 8, 8, 15, 15, 22, 24, 24, 21, 34, 33, + 30, 31, 32, 72, 25, 343, 29, 36, 36, 15, + 15, 23, 45, 15, 15, 34, 35, 35, 15, 24, + 72, 31, 33, 15, 15, 17, 17, 29, 36, 29, + 45, 37, 37, 29, 46, 35, 36, 38, 38, 29, + 39, 39, 17, 17, 41, 41, 17, 17, 37, 42, + + 42, 17, 43, 43, 46, 47, 17, 17, 20, 20, + 44, 44, 46, 48, 42, 38, 51, 52, 41, 43, + 39, 47, 49, 54, 201, 53, 61, 61, 55, 55, + 20, 52, 20, 201, 56, 56, 20, 75, 44, 51, + 48, 53, 20, 40, 40, 40, 40, 40, 40, 55, + 54, 49, 40, 56, 75, 58, 58, 57, 57, 59, + 59, 40, 60, 60, 62, 62, 65, 65, 40, 50, + 50, 50, 50, 50, 50, 57, 58, 70, 50, 82, + 60, 64, 64, 65, 59, 66, 66, 50, 67, 67, + 73, 68, 68, 71, 50, 69, 69, 70, 74, 64, + + 77, 80, 78, 66, 79, 135, 81, 82, 67, 68, + 73, 71, 83, 83, 85, 85, 102, 77, 78, 135, + 80, 79, 74, 81, 69, 86, 86, 87, 87, 88, + 88, 89, 89, 91, 91, 211, 83, 84, 84, 84, + 84, 84, 84, 102, 86, 101, 84, 92, 92, 93, + 93, 95, 95, 88, 342, 87, 96, 96, 97, 97, + 98, 100, 100, 101, 104, 211, 92, 93, 94, 94, + 94, 94, 94, 94, 95, 96, 103, 94, 105, 97, + 108, 182, 104, 98, 99, 99, 99, 99, 99, 99, + 107, 109, 133, 99, 182, 105, 110, 110, 108, 103, + + 106, 106, 106, 106, 106, 106, 111, 111, 341, 106, + 133, 109, 107, 131, 110, 112, 112, 114, 114, 116, + 116, 117, 117, 118, 118, 120, 120, 121, 121, 122, + 122, 124, 124, 125, 125, 126, 126, 129, 129, 136, + 136, 131, 127, 340, 120, 137, 124, 138, 138, 139, + 139, 210, 118, 119, 119, 119, 119, 119, 119, 127, + 126, 210, 119, 132, 132, 132, 132, 132, 132, 137, + 141, 141, 132, 142, 142, 144, 144, 147, 147, 152, + 152, 154, 154, 155, 155, 158, 158, 159, 162, 162, + 168, 168, 172, 172, 175, 175, 178, 178, 147, 148, + + 148, 148, 148, 148, 148, 185, 185, 159, 148, 149, + 149, 149, 149, 149, 149, 149, 149, 149, 149, 151, + 151, 151, 151, 151, 151, 157, 157, 339, 151, 156, + 156, 156, 156, 156, 156, 156, 156, 156, 156, 188, + 188, 183, 184, 163, 173, 197, 197, 198, 198, 157, + 160, 160, 160, 160, 160, 160, 165, 165, 183, 160, + 161, 161, 161, 161, 161, 161, 163, 184, 173, 161, + 164, 164, 164, 164, 164, 164, 164, 164, 164, 164, + 338, 165, 166, 166, 166, 166, 166, 166, 191, 169, + 169, 166, 167, 167, 167, 167, 167, 167, 167, 167, + + 167, 167, 169, 189, 189, 337, 169, 177, 177, 189, + 234, 191, 203, 234, 169, 171, 171, 171, 171, 171, + 171, 205, 205, 212, 171, 176, 176, 176, 176, 176, + 176, 177, 207, 207, 176, 180, 180, 180, 180, 180, + 180, 203, 218, 212, 180, 181, 181, 181, 181, 181, + 181, 220, 228, 218, 181, 187, 187, 187, 187, 187, + 187, 221, 221, 219, 187, 196, 196, 196, 196, 196, + 196, 202, 228, 220, 196, 200, 200, 200, 200, 200, + 200, 204, 219, 254, 200, 204, 202, 208, 208, 208, + 208, 208, 208, 208, 208, 208, 208, 213, 226, 226, + + 254, 213, 257, 208, 216, 216, 216, 216, 216, 216, + 229, 229, 257, 216, 217, 217, 217, 217, 217, 217, + 222, 222, 336, 217, 227, 227, 235, 227, 222, 235, + 236, 238, 238, 241, 241, 335, 236, 217, 224, 224, + 224, 224, 224, 224, 224, 224, 224, 224, 240, 240, + 242, 240, 243, 243, 246, 334, 224, 224, 241, 247, + 248, 237, 246, 249, 333, 247, 248, 224, 332, 237, + 249, 251, 224, 231, 231, 231, 231, 231, 231, 231, + 231, 231, 231, 237, 242, 250, 250, 264, 251, 251, + 255, 231, 231, 250, 258, 331, 255, 258, 256, 251, + + 252, 252, 231, 256, 251, 264, 253, 231, 232, 232, + 232, 232, 232, 232, 259, 267, 267, 232, 233, 233, + 233, 233, 233, 233, 253, 252, 330, 233, 270, 253, + 261, 259, 259, 261, 262, 263, 270, 262, 266, 329, + 233, 263, 259, 266, 265, 265, 271, 259, 265, 269, + 269, 272, 271, 273, 274, 274, 277, 272, 274, 277, + 273, 275, 275, 276, 276, 278, 279, 279, 281, 283, + 269, 282, 278, 328, 281, 284, 282, 327, 284, 283, + 285, 285, 287, 288, 289, 287, 288, 290, 290, 289, + 292, 292, 293, 293, 294, 294, 295, 296, 326, 295, + + 297, 297, 299, 299, 296, 301, 302, 302, 301, 303, + 325, 292, 303, 293, 304, 304, 306, 306, 307, 307, + 324, 323, 322, 321, 320, 319, 318, 302, 317, 316, + 315, 314, 313, 312, 311, 310, 291, 306, 268, 260, + 245, 225, 223, 214, 206, 195, 193, 192, 174, 153, + 145, 140, 134, 130, 128, 90, 76, 26, 10, 3, + 1, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309, 309, + 309, 309, 309, 309, 309, 309, 309, 309, 309 + + } ; + +static yy_state_type yy_last_accepting_state; +static char *yy_last_accepting_cpos; + +extern int hazelPrep_flex_debug; +int hazelPrep_flex_debug = 0; + +/* The intent behind this definition is that it'll catch + * any uses of REJECT which flex missed. + */ +#define REJECT reject_used_but_not_detected +#define yymore() yymore_used_but_not_detected +#define YY_MORE_ADJ 0 +#define YY_RESTORE_YY_MORE_OFFSET +char *hazelPreptext; +#include "es2front.h" +#include <ctype.h> + +/* hooking for EvalLex and EvalYacc */ +extern void hazelEvalPrepare(char* ptr); +extern int hazelEvalparse(void); +extern int hazelEvalGetResult(int* pEvalA, int* pEvalB); +extern void hazelEvalTerminate(void); + +extern int hazelEnableTexture3D; + +static struct ShaderObjectUnit* pUnit; +static int iIndex; +static char* pSrcPtr; + +static char strBuf[32]; +static int iFILE = 0; +static int iLINE = 1; +static int iState = 0; +static int iErrorCode = 0; +static int bOutputed = 0; +static int delayed_newline = 0; + +static int ifStack[128]; +static int ifStackTop = -1; +enum { + STATE_FALSE_PARENT = 1, + STATE_TRUE_AFTER_IF = 2, + STATE_FALSE_AFTER_ELIF = 3, + STATE_FALSE_AFTER_ELSE = 4, + STATE_FALSE_AFTER_IF = 5, + STATE_TRUE_AFTER_ELSE = 6, +}; + +static int VALID_STACK_TOP(void) { + return ((-1 <= ifStackTop) + && (ifStackTop < (int)(sizeof(ifStack) / sizeof(ifStack[0])))) ? GL_TRUE : GL_FALSE; +} + +static int IN_TRUE_SECTION(void) { + int i; + assert(VALID_STACK_TOP() == GL_TRUE); + if (ifStackTop < 0) { + return GL_TRUE; + } + for (i = ifStackTop; i >= 0; i--) { + if ((ifStack[i] == STATE_FALSE_PARENT) + || (ifStack[i] == STATE_FALSE_AFTER_ELIF) + || (ifStack[i] == STATE_FALSE_AFTER_ELSE) + || (ifStack[i] == STATE_FALSE_AFTER_IF)) return GL_FALSE; + } + return GL_TRUE; +} + +int hazelPrepGetError(void) { + return iErrorCode; +} + +void hazelPrepPrepare(struct ShaderObjectUnit* pShaderObject) { + assert(pShaderObject->nSourceUsed > 0); + pUnit = pShaderObject; + iIndex = 0; + pSrcPtr = pUnit->aStrSource[iIndex]; + iFILE = 0; + iLINE = 0; + iState = 0; + iErrorCode = 0; + bOutputed = 0; + delayed_newline = 0; + ifStackTop = -1; +} + +extern int hazelPreplex_destroy(void); + +void hazelPrepTerminate(void) { + hazelPreplex_destroy(); +} + +static void OUTPUT(const char* str, int len) { + ES2INTER(ShaderObjectPrepedAppend)(pUnit, str, len); +} + +static int hazelPrepwrap(void) { + iIndex++; + if (iIndex >= pUnit->nSourceUsed) { + if (iState != 0) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "ERROR: unexpected EOF"); + iErrorCode = 1; + } + return 1; + } + pSrcPtr = pUnit->aStrSource[iIndex]; + iFILE++; + iLINE = 0; + return 0; +} + +#define PUTCHAR(c) (*dst++ = c, num++) +#define PUTLINE(c) (*dst++ = c, iLINE++, num++) + +static int INPUT(char* dst) { + int num = 0; + int c; + while (1) { + do { + c = *pSrcPtr++; + } while (c == '\r'); + if (c == '\0') { + return YY_NULL; + } + switch (iState) { + case 0: + if (c == '/') { iState = 1; } + else if (c == '\\') { iState = 5; } + else if (c == '\n') { + while (delayed_newline > 0) { delayed_newline--; PUTLINE('\n'); } + PUTLINE('\n'); iState = 0; return num; + } else { PUTCHAR(c); iState = 0; return num; } + break; + case 1: + if (c == '*') { iState = 2; } + else if (c == '/') { iState = 4; } + else { PUTCHAR('/'); PUTCHAR(c); iState = 0; return num; } + break; + case 2: + if (c == '*') { iState = 3; } + else if (c == '\n') { delayed_newline++; iState = 2; } + else { iState = 2; } + break; + case 3: + if (c == '/') { PUTCHAR(' '); iState = 0; return num; } + else { iState = 2; } + break; + case 4: + if (c == '\n') { PUTLINE('\n'); iState = 0; return num; } + else { iState = 4; } + break; + case 5: + if (c == '\n') { delayed_newline++; iState = 0; } + else { PUTCHAR('\\'); PUTCHAR(c); iState = 0; return num; } + break; + } + } +} + +#undef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + { \ + result = INPUT(buf); \ + } + +#define INITIAL 0 + +#ifndef YY_EXTRA_TYPE +#define YY_EXTRA_TYPE void * +#endif + +static int yy_init_globals (void ); + +/* Accessor methods to globals. + These are made visible to non-reentrant scanners for convenience. */ + +int hazelPreplex_destroy (void ); + +int hazelPrepget_debug (void ); + +void hazelPrepset_debug (int debug_flag ); + +YY_EXTRA_TYPE hazelPrepget_extra (void ); + +void hazelPrepset_extra (YY_EXTRA_TYPE user_defined ); + +FILE *hazelPrepget_in (void ); + +void hazelPrepset_in (FILE * in_str ); + +FILE *hazelPrepget_out (void ); + +void hazelPrepset_out (FILE * out_str ); + +int hazelPrepget_leng (void ); + +char *hazelPrepget_text (void ); + +int hazelPrepget_lineno (void ); + +void hazelPrepset_lineno (int line_number ); + +/* Macros after this point can all be overridden by user definitions in + * section 1. + */ + +#ifndef YY_SKIP_YYWRAP +#ifdef __cplusplus +extern "C" int hazelPrepwrap (void ); +#else +extern int hazelPrepwrap (void ); +#endif +#endif + + static void yyunput (int c,char *buf_ptr ); + +#ifndef yytext_ptr +static void yy_flex_strncpy (char *,yyconst char *,int ); +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * ); +#endif + +#ifndef YY_NO_INPUT + +#ifdef __cplusplus +static int yyinput (void ); +#else +static int input (void ); +#endif + +#endif + +/* Amount of stuff to slurp up with each read. */ +#ifndef YY_READ_BUF_SIZE +#define YY_READ_BUF_SIZE 8192 +#endif + +/* Copy whatever the last rule matched to the standard output. */ +#ifndef ECHO +/* This used to be an fputs(), but since the string might contain NUL's, + * we now use fwrite(). + */ +#define ECHO fwrite( hazelPreptext, hazelPrepleng, 1, hazelPrepout ) +#endif + +/* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, + * is returned in "result". + */ +#ifndef YY_INPUT +#define YY_INPUT(buf,result,max_size) \ + if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ + { \ + int c = '*'; \ + unsigned n; \ + for ( n = 0; n < max_size && \ + (c = getc( hazelPrepin )) != EOF && c != '\n'; ++n ) \ + buf[n] = (char) c; \ + if ( c == '\n' ) \ + buf[n++] = (char) c; \ + if ( c == EOF && ferror( hazelPrepin ) ) \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + result = n; \ + } \ + else \ + { \ + errno=0; \ + while ( (result = fread(buf, 1, max_size, hazelPrepin))==0 && ferror(hazelPrepin)) \ + { \ + if( errno != EINTR) \ + { \ + YY_FATAL_ERROR( "input in flex scanner failed" ); \ + break; \ + } \ + errno=0; \ + clearerr(hazelPrepin); \ + } \ + }\ +\ + +#endif + +/* No semi-colon after return; correct usage is to write "yyterminate();" - + * we don't want an extra ';' after the "return" because that will cause + * some compilers to complain about unreachable statements. + */ +#ifndef yyterminate +#define yyterminate() return YY_NULL +#endif + +/* Number of entries by which start-condition stack grows. */ +#ifndef YY_START_STACK_INCR +#define YY_START_STACK_INCR 25 +#endif + +/* Report a fatal error. */ +#ifndef YY_FATAL_ERROR +#define YY_FATAL_ERROR(msg) yy_fatal_error( msg ) +#endif + +/* end tables serialization structures and prototypes */ + +/* Default declaration of generated scanner - a define so the user can + * easily add parameters. + */ +#ifndef YY_DECL +#define YY_DECL_IS_OURS 1 + +extern int hazelPreplex (void); + +#define YY_DECL int hazelPreplex (void) +#endif /* !YY_DECL */ + +/* Code executed at the beginning of each rule, after hazelPreptext and hazelPrepleng + * have been set up. + */ +#ifndef YY_USER_ACTION +#define YY_USER_ACTION +#endif + +/* Code executed at the end of each rule. */ +#ifndef YY_BREAK +#define YY_BREAK break; +#endif + +#define YY_RULE_SETUP \ + if ( hazelPrepleng > 0 ) \ + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \ + (hazelPreptext[hazelPrepleng - 1] == '\n'); \ + YY_USER_ACTION + +/** The main scanner function which does all the work. + */ +YY_DECL +{ + register yy_state_type yy_current_state; + register char *yy_cp, *yy_bp; + register int yy_act; + + /* #ifdef, #ifndef ---------------------------------------------- */ + + if ( !(yy_init) ) + { + (yy_init) = 1; + +#ifdef YY_USER_INIT + YY_USER_INIT; +#endif + + if ( ! (yy_start) ) + (yy_start) = 1; /* first start state */ + + if ( ! hazelPrepin ) + hazelPrepin = stdin; + + if ( ! hazelPrepout ) + hazelPrepout = stdout; + + if ( ! YY_CURRENT_BUFFER ) { + hazelPrepensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + hazelPrep_create_buffer(hazelPrepin,YY_BUF_SIZE ); + } + + hazelPrep_load_buffer_state( ); + } + + while ( 1 ) /* loops until end-of-file is reached */ + { + yy_cp = (yy_c_buf_p); + + /* Support of hazelPreptext. */ + *yy_cp = (yy_hold_char); + + /* yy_bp points to the position in yy_ch_buf of the start of + * the current run. + */ + yy_bp = yy_cp; + + yy_current_state = (yy_start); + yy_current_state += YY_AT_BOL(); +yy_match: + do + { + register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 310 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + ++yy_cp; + } + while ( yy_base[yy_current_state] != 862 ); + +yy_find_action: + yy_act = yy_accept[yy_current_state]; + if ( yy_act == 0 ) + { /* have to back up */ + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + yy_act = yy_accept[yy_current_state]; + } + + YY_DO_BEFORE_ACTION; + +do_action: /* This label is used only to access EOF actions. */ + + switch ( yy_act ) + { /* beginning of action switch */ + case 0: /* must back up */ + /* undo the effects of YY_DO_BEFORE_ACTION */ + *yy_cp = (yy_hold_char); + yy_cp = (yy_last_accepting_cpos); + yy_current_state = (yy_last_accepting_state); + goto yy_find_action; + +case 1: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr; + int n = 0; + int state; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (n++ < 2) { while (*ptr++ != 'f') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + *qtr = '\0'; + state = + (ES2INTER(MacroSearchMacro)(ptr) != NULL) ? STATE_TRUE_AFTER_IF : STATE_FALSE_AFTER_IF; + } else { + state = STATE_FALSE_PARENT; + } + ifStack[++ifStackTop] = state; + assert(VALID_STACK_TOP() == GL_TRUE); + bOutputed = 1; +} + YY_BREAK +case 2: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr; + int n = 0; + int state; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (n++ < 2) { while (*ptr++ != 'f') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + *qtr = '\0'; + state = + (ES2INTER(MacroSearchMacro)(ptr) == NULL) ? STATE_TRUE_AFTER_IF : STATE_FALSE_AFTER_IF; + } else { + state = STATE_FALSE_PARENT; + } + ifStack[++ifStackTop] = state; + assert(VALID_STACK_TOP() == GL_TRUE); + bOutputed = 1; +} + YY_BREAK +case 3: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #ifdef/#ifndef: syntax error\n", iLINE, iFILE); + iErrorCode = 1; + } else { + ifStack[++ifStackTop] = STATE_FALSE_PARENT; + } + assert(VALID_STACK_TOP() == GL_TRUE); + bOutputed = 1; +} + YY_BREAK +/* #if ---------------------------------------------------------- */ +case 4: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr = &(hazelPreptext[hazelPrepleng-1]); + char* expanded; + int evalA = GL_FALSE; + int evalB = GL_FALSE; + int state; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (*qtr == ' ' || *qtr == '\t') *qtr-- = '\0'; + while (*ptr++ != 'f') ; + while (*ptr == ' ' || *ptr == '\t') ptr++; + if (ptr > qtr) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #if: syntax error\n", iLINE, iFILE); + iErrorCode = 1; + state = STATE_FALSE_AFTER_IF; + } else { + ES2INTER(MacroSetLineFile)(iLINE, iFILE); + expanded = ES2INTER(MacroExpand)(ptr, 1); + hazelEvalPrepare(expanded); + if (expanded == NULL + || hazelEvalparse() != 0 + || hazelEvalGetResult(&evalA, &evalB) != 1) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #if: expression parsing error.\n", iLINE, iFILE); + iErrorCode = 1; + evalA = GL_FALSE; + } + hazelEvalTerminate(); + state = (evalA == GL_FALSE) ? STATE_FALSE_AFTER_IF : STATE_TRUE_AFTER_IF; + } + } else { + state = STATE_FALSE_PARENT; + } + ifStack[++ifStackTop] = state; + assert(VALID_STACK_TOP() == GL_TRUE); + bOutputed = 1; +} + YY_BREAK +/* #elif -------------------------------------------------------- */ +case 5: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr = &(hazelPreptext[hazelPrepleng-1]); + char* expanded; + int evalA = GL_FALSE; + int evalB = GL_FALSE; + int state; + if (ifStackTop < 0 || (! VALID_STACK_TOP())) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #elif: dangling elif\n", iLINE, iFILE); + iErrorCode = 1; + } else if (ifStack[ifStackTop] == STATE_FALSE_AFTER_IF) { + while (*qtr == ' ' || *qtr == '\t') *qtr-- = '\0'; + while (*ptr++ != 'f') ; + while (*ptr == ' ' || *ptr == '\t') ptr++; + if (ptr > qtr) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #elif: syntax error\n", iLINE, iFILE); + iErrorCode = 1; + } else { + ES2INTER(MacroSetLineFile)(iLINE, iFILE); + expanded = ES2INTER(MacroExpand)(ptr, 1); + hazelEvalPrepare(expanded); + if (expanded == NULL + || hazelEvalparse() != 0 + || hazelEvalGetResult(&evalA, &evalB) != 1) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #elif: expression parsing error.\n", iLINE, iFILE); + iErrorCode = 1; + evalA = GL_FALSE; + } + } + } + switch (ifStack[ifStackTop]) { + case STATE_FALSE_PARENT: + break; + case STATE_TRUE_AFTER_IF: + ifStack[ifStackTop] = STATE_FALSE_AFTER_ELIF; + break; + case STATE_FALSE_AFTER_IF: + ifStack[ifStackTop] = (evalA == GL_FALSE) ? STATE_FALSE_AFTER_IF : STATE_TRUE_AFTER_IF; + break; + default: + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #elif: illegal elif .\n", iLINE, iFILE); + iErrorCode = 1; + break; + } + bOutputed = 1; +} + YY_BREAK +/* #else -------------------------------------------------------- */ +case 6: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (ifStackTop < 0 || (! VALID_STACK_TOP())) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #else: dangling else\n", iLINE, iFILE); + iErrorCode = 1; + } else { + switch (ifStack[ifStackTop]) { + case STATE_FALSE_PARENT: + break; + case STATE_TRUE_AFTER_IF: + ifStack[ifStackTop] = STATE_FALSE_AFTER_ELSE; + break; + case STATE_FALSE_AFTER_ELIF: + ifStack[ifStackTop] = STATE_FALSE_AFTER_ELSE; + break; + case STATE_FALSE_AFTER_IF: + ifStack[ifStackTop] = STATE_TRUE_AFTER_ELSE; + break; + default: + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #else: illegal else\n", iLINE, iFILE); + iErrorCode = 1; + break; + } + } + bOutputed = 1; +} + YY_BREAK +/* #endif ------------------------------------------------------- */ +case 7: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (ifStackTop < 0 || (! VALID_STACK_TOP())) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #endif: dangling endif\n", iLINE, iFILE); + iErrorCode = 1; + } else { + ifStackTop--; + } + assert(VALID_STACK_TOP() == GL_TRUE); + bOutputed = 1; +} + YY_BREAK +/* #line -------------------------------------------------------- */ +case 8: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr = &(hazelPreptext[hazelPrepleng-1]); + char* expanded; + int evalA = 0; + int evalB = 0; + int nEval; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (*qtr == ' ' || *qtr == '\t') *qtr-- = '\0'; + while (*ptr++ != 'e') ; + while (*ptr == ' ' || *ptr == '\t') ptr++; + if (ptr > qtr) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #line: syntax error\n", iLINE, iFILE); + iErrorCode = 1; + } else { + ES2INTER(MacroSetLineFile)(iLINE, iFILE); + expanded = ES2INTER(MacroExpand)(ptr, 0); + hazelEvalPrepare(expanded); + if (expanded == NULL + || hazelEvalparse() != 0 + || (nEval = hazelEvalGetResult(&evalA, &evalB)) <= 0) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #line: expression parsing error.\n", + iLINE, iFILE); + iErrorCode = 1; + } else { + iLINE = evalA; + if (nEval >= 2) iFILE = evalB; + } + } + } + bOutputed = 1; +} + YY_BREAK +/* #define ------------------------------------------------------ */ +case 9: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr = &(hazelPreptext[hazelPrepleng-1]); + int n = 0; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (isspace(*qtr)) *qtr-- = '\0'; + while (n++ < 2) { while (*ptr++ != 'e') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + assert(*qtr == '('); + *qtr = '\0'; + if (strcmp(ptr, "defined") == 0 + || strncmp(ptr, "GL_", 3) == 0 + || strstr(ptr, "__") != NULL) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #define: illegal identifier name '%s'\n", + iLINE, iFILE, ptr); + iErrorCode = 1; + } else { + for (*qtr++ = '('; *qtr != '\0' && *qtr != ')'; qtr++) ; + if (qtr == '\0') { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #define: unexpected end of string\n", + iLINE, iFILE); + iErrorCode = 1; + } else { + assert(*qtr == ')'); + qtr++; + if (qtr == '\0') { + qtr = ""; + } else { + *qtr++ = '\0'; + while (isspace(*qtr)) qtr++; + } + if (ES2INTER(MacroDefineFunc)(ptr, qtr) == GL_FALSE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #define: trying to redefine '%s'\n", + iLINE, iFILE, ptr); + iErrorCode = 1; + } + } + } + } + bOutputed = 1; +} + YY_BREAK +case 10: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr = &(hazelPreptext[hazelPrepleng-1]); + int n = 0; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (isspace(*qtr)) *qtr-- = '\0'; + while (n++ < 2) { while (*ptr++ != 'e') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + if (*qtr == '\0') { + qtr = "1"; + } else { + *qtr++ = '\0'; + while (*qtr == ' ' || *qtr == '\t') qtr++; + } + if (strcmp(ptr, "defined") == 0 + || strncmp(ptr, "GL_", 3) == 0 + || strstr(ptr, "__") != NULL) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #define: illegal identifier name '%s'\n", + iLINE, iFILE, ptr); + iErrorCode = 1; + } else if (ES2INTER(MacroDefineName)(ptr, qtr) == GL_FALSE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #define: trying to redefine '%s'\n", + iLINE, iFILE, ptr); + iErrorCode = 1; + } + } + bOutputed = 1; +} + YY_BREAK +/* #undef */ +case 11: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (*ptr++ != 'f') ; + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + *qtr++ = '\0'; + if (ES2INTER(MacroUndef)(ptr) == GL_FALSE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #undef: cannot undefine '%s'\n", iLINE, iFILE, ptr); + iErrorCode = 1; + } + } + bOutputed = 1; +} + YY_BREAK +/* #error */ +case 12: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + int n = 0; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (n++ < 3) { while (*ptr++ != 'r') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #error: %s\n", iLINE, iFILE, ptr); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +/* #pragma : just ignore it */ +case 13: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + bOutputed = 1; +} + YY_BREAK +case 14: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + bOutputed = 1; +} + YY_BREAK +case 15: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "Warning (line %d, file %d): #pragma: ignore unrecognizable string\n", + iLINE, iFILE); + } + bOutputed = 1; +} + YY_BREAK +/* #extension */ +case 16: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #extension: cannot use 'require' or 'enable' with 'all'\n", + iLINE, iFILE); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +case 17: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + bOutputed = 1; +} + YY_BREAK +case 18: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr; + int n = 0; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (n++ < 2) { while (*ptr++ != 'n') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + *qtr = '\0'; + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #extension: unsupported extension '%s'\n", + iLINE, iFILE, ptr); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +case 19: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + char* ptr = hazelPreptext; + char* qtr; + int n = 0; + if (IN_TRUE_SECTION() == GL_TRUE) { + while (n++ < 2) { while (*ptr++ != 'n') ; } + while (*ptr == ' ' || *ptr == '\t') ptr++; + for (qtr = ptr + 1; *qtr == '_' || isalnum(*qtr); qtr++) ; + *qtr = '\0'; + if (strcmp(ptr, "GL_OES_texture_3D") == 0) { + hazelEnableTexture3D = GL_TRUE; + } else { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "Warning (line %d, file %d): #extension: unsupported extension '%s'\n", + iLINE, iFILE, ptr); + } + } + bOutputed = 1; +} + YY_BREAK +case 20: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #extension: illegal behavior\n", + iLINE, iFILE); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +case 21: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #extension: syntax error\n", iLINE, iFILE); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +/* #version : no macro expansion */ +case 22: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + if (bOutputed != 0) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #version: must be the first statement and may not be repeated.\n", iLINE, iFILE); + iErrorCode = 1; + } + } + bOutputed = 1; +} + YY_BREAK +case 23: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): #version: illegal version number\n", iLINE, iFILE); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +/* only-# lines : just ignore it */ +case 24: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + bOutputed = 1; +} + YY_BREAK +/* other #-lines */ +case 25: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, + "ERROR (line %d, file %d): invalid macro line: %s\n", iLINE, iFILE, hazelPreptext); + iErrorCode = 1; + } + bOutputed = 1; +} + YY_BREAK +/* plain text */ +case 26: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ + if (IN_TRUE_SECTION() == GL_TRUE) { + char* expanded; + ES2INTER(MacroSetLineFile)(iLINE, iFILE); + expanded = ES2INTER(MacroExpand)(hazelPreptext, 2); + if (expanded == NULL) { + OUTPUT(hazelPreptext, hazelPrepleng); + } else { + OUTPUT(expanded, strlen(expanded)); + } + } + bOutputed = 1; +} + YY_BREAK +case 27: +*yy_cp = (yy_hold_char); /* undo effects of setting up hazelPreptext */ +(yy_c_buf_p) = yy_cp -= 1; +YY_DO_BEFORE_ACTION; /* set up hazelPreptext again */ +YY_RULE_SETUP +{ } + YY_BREAK +case 28: +/* rule 28 can match eol */ +YY_RULE_SETUP +{ OUTPUT("\n", 1); } + YY_BREAK +case 29: +YY_RULE_SETUP +{ OUTPUT(hazelPreptext, 1); } + YY_BREAK +case 30: +YY_RULE_SETUP +ECHO; + YY_BREAK +case YY_STATE_EOF(INITIAL): + yyterminate(); + + case YY_END_OF_BUFFER: + { + /* Amount of text matched not including the EOB char. */ + int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1; + + /* Undo the effects of YY_DO_BEFORE_ACTION. */ + *yy_cp = (yy_hold_char); + YY_RESTORE_YY_MORE_OFFSET + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW ) + { + /* We're scanning a new file or input source. It's + * possible that this happened because the user + * just pointed hazelPrepin at a new source and called + * hazelPreplex(). If so, then we have to assure + * consistency between YY_CURRENT_BUFFER and our + * globals. Here is the right place to do so, because + * this is the first action (other than possibly a + * back-up) that will match for the new input source. + */ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + YY_CURRENT_BUFFER_LVALUE->yy_input_file = hazelPrepin; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL; + } + + /* Note that here we test for yy_c_buf_p "<=" to the position + * of the first EOB in the buffer, since yy_c_buf_p will + * already have been incremented past the NUL character + * (since all states make transitions on EOB to the + * end-of-buffer state). Contrast this with the test + * in input(). + */ + if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + { /* This was really a NUL. */ + yy_state_type yy_next_state; + + (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + /* Okay, we're now positioned to make the NUL + * transition. We couldn't have + * yy_get_previous_state() go ahead and do it + * for us because it doesn't know how to deal + * with the possibility of jamming (and we don't + * want to build jamming into it because then it + * will run more slowly). + */ + + yy_next_state = yy_try_NUL_trans( yy_current_state ); + + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + + if ( yy_next_state ) + { + /* Consume the NUL. */ + yy_cp = ++(yy_c_buf_p); + yy_current_state = yy_next_state; + goto yy_match; + } + + else + { + yy_cp = (yy_c_buf_p); + goto yy_find_action; + } + } + + else switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_END_OF_FILE: + { + (yy_did_buffer_switch_on_eof) = 0; + + if ( hazelPrepwrap( ) ) + { + /* Note: because we've taken care in + * yy_get_next_buffer() to have set up + * hazelPreptext, we can now set up + * yy_c_buf_p so that if some total + * hoser (like flex itself) wants to + * call the scanner after we return the + * YY_NULL, it'll still work - another + * YY_NULL will get returned. + */ + (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ; + + yy_act = YY_STATE_EOF(YY_START); + goto do_action; + } + + else + { + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; + } + break; + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = + (yytext_ptr) + yy_amount_of_matched_text; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_match; + + case EOB_ACT_LAST_MATCH: + (yy_c_buf_p) = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)]; + + yy_current_state = yy_get_previous_state( ); + + yy_cp = (yy_c_buf_p); + yy_bp = (yytext_ptr) + YY_MORE_ADJ; + goto yy_find_action; + } + break; + } + + default: + YY_FATAL_ERROR( + "fatal flex scanner internal error--no action found" ); + } /* end of action switch */ + } /* end of scanning one token */ +} /* end of hazelPreplex */ + +/* yy_get_next_buffer - try to read in a new buffer + * + * Returns a code representing an action: + * EOB_ACT_LAST_MATCH - + * EOB_ACT_CONTINUE_SCAN - continue scanning from current position + * EOB_ACT_END_OF_FILE - end of file + */ +static int yy_get_next_buffer (void) +{ + register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + register char *source = (yytext_ptr); + register int number_to_move, i; + int ret_val; + + if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) + YY_FATAL_ERROR( + "fatal flex scanner internal error--end of buffer missed" ); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 ) + { /* Don't try to fill the buffer, so this is an EOF. */ + if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 ) + { + /* We matched a single character, the EOB, so + * treat this as a final EOF. + */ + return EOB_ACT_END_OF_FILE; + } + + else + { + /* We matched some text prior to the EOB, first + * process it. + */ + return EOB_ACT_LAST_MATCH; + } + } + + /* Try to read more data. */ + + /* First move last chars to start of buffer. */ + number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1; + + for ( i = 0; i < number_to_move; ++i ) + *(dest++) = *(source++); + + if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING ) + /* don't do the read, it's not guaranteed to return an EOF, + * just force an EOF + */ + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0; + + else + { + int num_to_read = + YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; + + while ( num_to_read <= 0 ) + { /* Not enough room in the buffer - grow it. */ + + /* just a shorter name for the current buffer */ + YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + + int yy_c_buf_p_offset = + (int) ((yy_c_buf_p) - b->yy_ch_buf); + + if ( b->yy_is_our_buffer ) + { + int new_size = b->yy_buf_size * 2; + + if ( new_size <= 0 ) + b->yy_buf_size += b->yy_buf_size / 8; + else + b->yy_buf_size *= 2; + + b->yy_ch_buf = (char *) + /* Include room in for 2 EOB chars. */ + hazelPreprealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ); + } + else + /* Can't grow it, we don't own it. */ + b->yy_ch_buf = 0; + + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( + "fatal error - scanner input buffer overflow" ); + + (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset]; + + num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - + number_to_move - 1; + + } + + if ( num_to_read > YY_READ_BUF_SIZE ) + num_to_read = YY_READ_BUF_SIZE; + + /* Read in more data. */ + YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), + (yy_n_chars), (size_t) num_to_read ); + + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + if ( (yy_n_chars) == 0 ) + { + if ( number_to_move == YY_MORE_ADJ ) + { + ret_val = EOB_ACT_END_OF_FILE; + hazelPreprestart(hazelPrepin ); + } + + else + { + ret_val = EOB_ACT_LAST_MATCH; + YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = + YY_BUFFER_EOF_PENDING; + } + } + + else + ret_val = EOB_ACT_CONTINUE_SCAN; + + if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) { + /* Extend the array by 50%, plus the number we really need. */ + yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1); + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) hazelPreprealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ); + if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" ); + } + + (yy_n_chars) += number_to_move; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR; + YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR; + + (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0]; + + return ret_val; +} + +/* yy_get_previous_state - get the state just before the EOB char was reached */ + + static yy_state_type yy_get_previous_state (void) +{ + register yy_state_type yy_current_state; + register char *yy_cp; + + yy_current_state = (yy_start); + yy_current_state += YY_AT_BOL(); + + for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) + { + register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 310 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + } + + return yy_current_state; +} + +/* yy_try_NUL_trans - try to make a transition on the NUL character + * + * synopsis + * next_state = yy_try_NUL_trans( current_state ); + */ + static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) +{ + register int yy_is_jam; + register char *yy_cp = (yy_c_buf_p); + + register YY_CHAR yy_c = 1; + if ( yy_accept[yy_current_state] ) + { + (yy_last_accepting_state) = yy_current_state; + (yy_last_accepting_cpos) = yy_cp; + } + while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state ) + { + yy_current_state = (int) yy_def[yy_current_state]; + if ( yy_current_state >= 310 ) + yy_c = yy_meta[(unsigned int) yy_c]; + } + yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; + yy_is_jam = (yy_current_state == 309); + + return yy_is_jam ? 0 : yy_current_state; +} + + static void yyunput (int c, register char * yy_bp ) +{ + register char *yy_cp; + + yy_cp = (yy_c_buf_p); + + /* undo effects of setting up hazelPreptext */ + *yy_cp = (yy_hold_char); + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + { /* need to shift things up to make room */ + /* +2 for EOB chars. */ + register int number_to_move = (yy_n_chars) + 2; + register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; + register char *source = + &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; + + while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) + *--dest = *--source; + + yy_cp += (int) (dest - source); + yy_bp += (int) (dest - source); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size; + + if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) + YY_FATAL_ERROR( "flex scanner push-back overflow" ); + } + + *--yy_cp = (char) c; + + (yytext_ptr) = yy_bp; + (yy_hold_char) = *yy_cp; + (yy_c_buf_p) = yy_cp; +} + +#ifndef YY_NO_INPUT +#ifdef __cplusplus + static int yyinput (void) +#else + static int input (void) +#endif + +{ + int c; + + *(yy_c_buf_p) = (yy_hold_char); + + if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) + { + /* yy_c_buf_p now points to the character we want to return. + * If this occurs *before* the EOB characters, then it's a + * valid NUL; if not, then we've hit the end of the buffer. + */ + if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] ) + /* This was really a NUL. */ + *(yy_c_buf_p) = '\0'; + + else + { /* need more input */ + int offset = (yy_c_buf_p) - (yytext_ptr); + ++(yy_c_buf_p); + + switch ( yy_get_next_buffer( ) ) + { + case EOB_ACT_LAST_MATCH: + /* This happens because yy_g_n_b() + * sees that we've accumulated a + * token and flags that we need to + * try matching the token before + * proceeding. But for input(), + * there's no matching to consider. + * So convert the EOB_ACT_LAST_MATCH + * to EOB_ACT_END_OF_FILE. + */ + + /* Reset buffer status. */ + hazelPreprestart(hazelPrepin ); + + /*FALLTHROUGH*/ + + case EOB_ACT_END_OF_FILE: + { + if ( hazelPrepwrap( ) ) + return EOF; + + if ( ! (yy_did_buffer_switch_on_eof) ) + YY_NEW_FILE; +#ifdef __cplusplus + return yyinput(); +#else + return input(); +#endif + } + + case EOB_ACT_CONTINUE_SCAN: + (yy_c_buf_p) = (yytext_ptr) + offset; + break; + } + } + } + + c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */ + *(yy_c_buf_p) = '\0'; /* preserve hazelPreptext */ + (yy_hold_char) = *++(yy_c_buf_p); + + YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n'); + + return c; +} +#endif /* ifndef YY_NO_INPUT */ + +/** Immediately switch to a different input stream. + * @param input_file A readable stream. + * + * @note This function does not reset the start condition to @c INITIAL . + */ + void hazelPreprestart (FILE * input_file ) +{ + + if ( ! YY_CURRENT_BUFFER ){ + hazelPrepensure_buffer_stack (); + YY_CURRENT_BUFFER_LVALUE = + hazelPrep_create_buffer(hazelPrepin,YY_BUF_SIZE ); + } + + hazelPrep_init_buffer(YY_CURRENT_BUFFER,input_file ); + hazelPrep_load_buffer_state( ); +} + +/** Switch to a different input buffer. + * @param new_buffer The new input buffer. + * + */ + void hazelPrep_switch_to_buffer (YY_BUFFER_STATE new_buffer ) +{ + + /* TODO. We should be able to replace this entire function body + * with + * hazelPreppop_buffer_state(); + * hazelPreppush_buffer_state(new_buffer); + */ + hazelPrepensure_buffer_stack (); + if ( YY_CURRENT_BUFFER == new_buffer ) + return; + + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + YY_CURRENT_BUFFER_LVALUE = new_buffer; + hazelPrep_load_buffer_state( ); + + /* We don't actually know whether we did this switch during + * EOF (hazelPrepwrap()) processing, but the only time this flag + * is looked at is after hazelPrepwrap() is called, so it's safe + * to go ahead and always set it. + */ + (yy_did_buffer_switch_on_eof) = 1; +} + +static void hazelPrep_load_buffer_state (void) +{ + (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars; + (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos; + hazelPrepin = YY_CURRENT_BUFFER_LVALUE->yy_input_file; + (yy_hold_char) = *(yy_c_buf_p); +} + +/** Allocate and initialize an input buffer state. + * @param file A readable stream. + * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. + * + * @return the allocated buffer state. + */ + YY_BUFFER_STATE hazelPrep_create_buffer (FILE * file, int size ) +{ + YY_BUFFER_STATE b; + + b = (YY_BUFFER_STATE) hazelPrepalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in hazelPrep_create_buffer()" ); + + b->yy_buf_size = size; + + /* yy_ch_buf has to be 2 characters longer than the size given because + * we need to put in 2 end-of-buffer characters. + */ + b->yy_ch_buf = (char *) hazelPrepalloc(b->yy_buf_size + 2 ); + if ( ! b->yy_ch_buf ) + YY_FATAL_ERROR( "out of dynamic memory in hazelPrep_create_buffer()" ); + + b->yy_is_our_buffer = 1; + + hazelPrep_init_buffer(b,file ); + + return b; +} + +/** Destroy the buffer. + * @param b a buffer created with hazelPrep_create_buffer() + * + */ + void hazelPrep_delete_buffer (YY_BUFFER_STATE b ) +{ + + if ( ! b ) + return; + + if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */ + YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0; + + if ( b->yy_is_our_buffer ) + hazelPrepfree((void *) b->yy_ch_buf ); + + hazelPrepfree((void *) b ); +} + +#ifndef __cplusplus +extern int isatty (int ); +#endif /* __cplusplus */ + +/* Initializes or reinitializes a buffer. + * This function is sometimes called more than once on the same buffer, + * such as during a hazelPreprestart() or at EOF. + */ + static void hazelPrep_init_buffer (YY_BUFFER_STATE b, FILE * file ) + +{ + int oerrno = errno; + + hazelPrep_flush_buffer(b ); + + b->yy_input_file = file; + b->yy_fill_buffer = 1; + + /* If b is the current buffer, then hazelPrep_init_buffer was _probably_ + * called from hazelPreprestart() or through yy_get_next_buffer. + * In that case, we don't want to reset the lineno or column. + */ + if (b != YY_CURRENT_BUFFER){ + b->yy_bs_lineno = 1; + b->yy_bs_column = 0; + } + + b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; + + errno = oerrno; +} + +/** Discard all buffered characters. On the next scan, YY_INPUT will be called. + * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. + * + */ + void hazelPrep_flush_buffer (YY_BUFFER_STATE b ) +{ + if ( ! b ) + return; + + b->yy_n_chars = 0; + + /* We always need two end-of-buffer characters. The first causes + * a transition to the end-of-buffer state. The second causes + * a jam in that state. + */ + b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR; + b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR; + + b->yy_buf_pos = &b->yy_ch_buf[0]; + + b->yy_at_bol = 1; + b->yy_buffer_status = YY_BUFFER_NEW; + + if ( b == YY_CURRENT_BUFFER ) + hazelPrep_load_buffer_state( ); +} + +/** Pushes the new state onto the stack. The new state becomes + * the current state. This function will allocate the stack + * if necessary. + * @param new_buffer The new state. + * + */ +void hazelPreppush_buffer_state (YY_BUFFER_STATE new_buffer ) +{ + if (new_buffer == NULL) + return; + + hazelPrepensure_buffer_stack(); + + /* This block is copied from hazelPrep_switch_to_buffer. */ + if ( YY_CURRENT_BUFFER ) + { + /* Flush out information for old buffer. */ + *(yy_c_buf_p) = (yy_hold_char); + YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p); + YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); + } + + /* Only push if top exists. Otherwise, replace top. */ + if (YY_CURRENT_BUFFER) + (yy_buffer_stack_top)++; + YY_CURRENT_BUFFER_LVALUE = new_buffer; + + /* copied from hazelPrep_switch_to_buffer. */ + hazelPrep_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; +} + +/** Removes and deletes the top of the stack, if present. + * The next element becomes the new top. + * + */ +void hazelPreppop_buffer_state (void) +{ + if (!YY_CURRENT_BUFFER) + return; + + hazelPrep_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + if ((yy_buffer_stack_top) > 0) + --(yy_buffer_stack_top); + + if (YY_CURRENT_BUFFER) { + hazelPrep_load_buffer_state( ); + (yy_did_buffer_switch_on_eof) = 1; + } +} + +/* Allocates the stack if it does not exist. + * Guarantees space for at least one push. + */ +static void hazelPrepensure_buffer_stack (void) +{ + int num_to_alloc; + + if (!(yy_buffer_stack)) { + + /* First allocation is just for 2 elements, since we don't know if this + * scanner will even need a stack. We use 2 instead of 1 to avoid an + * immediate realloc on the next call. + */ + num_to_alloc = 1; + (yy_buffer_stack) = (struct yy_buffer_state**)hazelPrepalloc + (num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in hazelPrepensure_buffer_stack()" ); + + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); + + (yy_buffer_stack_max) = num_to_alloc; + (yy_buffer_stack_top) = 0; + return; + } + + if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){ + + /* Increase the buffer to prepare for a possible push. */ + int grow_size = 8 /* arbitrary grow size */; + + num_to_alloc = (yy_buffer_stack_max) + grow_size; + (yy_buffer_stack) = (struct yy_buffer_state**)hazelPreprealloc + ((yy_buffer_stack), + num_to_alloc * sizeof(struct yy_buffer_state*) + ); + if ( ! (yy_buffer_stack) ) + YY_FATAL_ERROR( "out of dynamic memory in hazelPrepensure_buffer_stack()" ); + + /* zero only the new slots.*/ + memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*)); + (yy_buffer_stack_max) = num_to_alloc; + } +} + +/** Setup the input buffer state to scan directly from a user-specified character buffer. + * @param base the character buffer + * @param size the size in bytes of the character buffer + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE hazelPrep_scan_buffer (char * base, yy_size_t size ) +{ + YY_BUFFER_STATE b; + + if ( size < 2 || + base[size-2] != YY_END_OF_BUFFER_CHAR || + base[size-1] != YY_END_OF_BUFFER_CHAR ) + /* They forgot to leave room for the EOB's. */ + return 0; + + b = (YY_BUFFER_STATE) hazelPrepalloc(sizeof( struct yy_buffer_state ) ); + if ( ! b ) + YY_FATAL_ERROR( "out of dynamic memory in hazelPrep_scan_buffer()" ); + + b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */ + b->yy_buf_pos = b->yy_ch_buf = base; + b->yy_is_our_buffer = 0; + b->yy_input_file = 0; + b->yy_n_chars = b->yy_buf_size; + b->yy_is_interactive = 0; + b->yy_at_bol = 1; + b->yy_fill_buffer = 0; + b->yy_buffer_status = YY_BUFFER_NEW; + + hazelPrep_switch_to_buffer(b ); + + return b; +} + +/** Setup the input buffer state to scan a string. The next call to hazelPreplex() will + * scan from a @e copy of @a str. + * @param yystr a NUL-terminated string to scan + * + * @return the newly allocated buffer state object. + * @note If you want to scan bytes that may contain NUL values, then use + * hazelPrep_scan_bytes() instead. + */ +YY_BUFFER_STATE hazelPrep_scan_string (yyconst char * yystr ) +{ + + return hazelPrep_scan_bytes(yystr,strlen(yystr) ); +} + +/** Setup the input buffer state to scan the given bytes. The next call to hazelPreplex() will + * scan from a @e copy of @a bytes. + * @param bytes the byte buffer to scan + * @param len the number of bytes in the buffer pointed to by @a bytes. + * + * @return the newly allocated buffer state object. + */ +YY_BUFFER_STATE hazelPrep_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +{ + YY_BUFFER_STATE b; + char *buf; + yy_size_t n; + int i; + + /* Get memory for full buffer, including space for trailing EOB's. */ + n = _yybytes_len + 2; + buf = (char *) hazelPrepalloc(n ); + if ( ! buf ) + YY_FATAL_ERROR( "out of dynamic memory in hazelPrep_scan_bytes()" ); + + for ( i = 0; i < _yybytes_len; ++i ) + buf[i] = yybytes[i]; + + buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR; + + b = hazelPrep_scan_buffer(buf,n ); + if ( ! b ) + YY_FATAL_ERROR( "bad buffer in hazelPrep_scan_bytes()" ); + + /* It's okay to grow etc. this buffer, and we should throw it + * away when we're done. + */ + b->yy_is_our_buffer = 1; + + return b; +} + +#ifndef YY_EXIT_FAILURE +#define YY_EXIT_FAILURE 2 +#endif + +static void yy_fatal_error (yyconst char* msg ) +{ + (void) fprintf( stderr, "%s\n", msg ); + exit( YY_EXIT_FAILURE ); +} + +/* Redefine yyless() so it works in section 3 code. */ + +#undef yyless +#define yyless(n) \ + do \ + { \ + /* Undo effects of setting up hazelPreptext. */ \ + int yyless_macro_arg = (n); \ + YY_LESS_LINENO(yyless_macro_arg);\ + hazelPreptext[hazelPrepleng] = (yy_hold_char); \ + (yy_c_buf_p) = hazelPreptext + yyless_macro_arg; \ + (yy_hold_char) = *(yy_c_buf_p); \ + *(yy_c_buf_p) = '\0'; \ + hazelPrepleng = yyless_macro_arg; \ + } \ + while ( 0 ) + +/* Accessor methods (get/set functions) to struct members. */ + +/** Get the current line number. + * + */ +int hazelPrepget_lineno (void) +{ + + return hazelPreplineno; +} + +/** Get the input stream. + * + */ +FILE *hazelPrepget_in (void) +{ + return hazelPrepin; +} + +/** Get the output stream. + * + */ +FILE *hazelPrepget_out (void) +{ + return hazelPrepout; +} + +/** Get the length of the current token. + * + */ +int hazelPrepget_leng (void) +{ + return hazelPrepleng; +} + +/** Get the current token. + * + */ + +char *hazelPrepget_text (void) +{ + return hazelPreptext; +} + +/** Set the current line number. + * @param line_number + * + */ +void hazelPrepset_lineno (int line_number ) +{ + + hazelPreplineno = line_number; +} + +/** Set the input stream. This does not discard the current + * input buffer. + * @param in_str A readable stream. + * + * @see hazelPrep_switch_to_buffer + */ +void hazelPrepset_in (FILE * in_str ) +{ + hazelPrepin = in_str ; +} + +void hazelPrepset_out (FILE * out_str ) +{ + hazelPrepout = out_str ; +} + +int hazelPrepget_debug (void) +{ + return hazelPrep_flex_debug; +} + +void hazelPrepset_debug (int bdebug ) +{ + hazelPrep_flex_debug = bdebug ; +} + +static int yy_init_globals (void) +{ + /* Initialization is the same as for the non-reentrant scanner. + * This function is called from hazelPreplex_destroy(), so don't allocate here. + */ + + (yy_buffer_stack) = 0; + (yy_buffer_stack_top) = 0; + (yy_buffer_stack_max) = 0; + (yy_c_buf_p) = (char *) 0; + (yy_init) = 0; + (yy_start) = 0; + +/* Defined in main.c */ +#ifdef YY_STDINIT + hazelPrepin = stdin; + hazelPrepout = stdout; +#else + hazelPrepin = (FILE *) 0; + hazelPrepout = (FILE *) 0; +#endif + + /* For future reference: Set errno on error, since we are called by + * hazelPreplex_init() + */ + return 0; +} + +/* hazelPreplex_destroy is for both reentrant and non-reentrant scanners. */ +int hazelPreplex_destroy (void) +{ + + /* Pop the buffer stack, destroying each element. */ + while(YY_CURRENT_BUFFER){ + hazelPrep_delete_buffer(YY_CURRENT_BUFFER ); + YY_CURRENT_BUFFER_LVALUE = NULL; + hazelPreppop_buffer_state(); + } + + /* Destroy the stack itself. */ + hazelPrepfree((yy_buffer_stack) ); + (yy_buffer_stack) = NULL; + + /* Reset the globals. This is important in a non-reentrant scanner so the next time + * hazelPreplex() is called, initialization will occur. */ + yy_init_globals( ); + + return 0; +} + +/* + * Internal utility routines. + */ + +#ifndef yytext_ptr +static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) +{ + register int i; + for ( i = 0; i < n; ++i ) + s1[i] = s2[i]; +} +#endif + +#ifdef YY_NEED_STRLEN +static int yy_flex_strlen (yyconst char * s ) +{ + register int n; + for ( n = 0; s[n]; ++n ) + ; + + return n; +} +#endif + +void *hazelPrepalloc (yy_size_t size ) +{ + return (void *) malloc( size ); +} + +void *hazelPreprealloc (void * ptr, yy_size_t size ) +{ + /* The cast to (char *) in the following accommodates both + * implementations that use char* generic pointers, and those + * that use void* generic pointers. It works with the latter + * because both ANSI C and C++ allow castless assignment from + * any pointer type to void*, and deal with argument conversions + * as though doing an assignment. + */ + return (void *) realloc( (char *) ptr, size ); +} + +void hazelPrepfree (void * ptr ) +{ + free( (char *) ptr ); /* see hazelPreprealloc() for (char *) cast */ +} + +#define YYTABLES_NAME "yytables" + + + diff --git a/es_2_0/Primitive.c b/es_2_0/Primitive.c new file mode 100755 index 0000000..d782078 --- /dev/null +++ b/es_2_0/Primitive.c @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(LineWidth)(GLfloat width) { + if (width <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(LineWidth)(width); +} + +void GL_APIENTRY ES2ENTRY(DepthRangef)(GLclampf zNear, GLclampf zFar) { + FNPTR(DepthRange)((GLclampd)zNear, (GLclampd)zFar); +} + +void GL_APIENTRY ES2ENTRY(Viewport)(GLint x, GLint y, GLsizei width, GLsizei height) { + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(Viewport)(x, y, width, height); +} + +void GL_APIENTRY ES2ENTRY(CullFace)(GLenum mode) { + switch (mode) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_FRONT: + case GL_BACK: + case GL_FRONT_AND_BACK: + break; + } + FNPTR(CullFace)(mode); +} + +void GL_APIENTRY ES2ENTRY(FrontFace)(GLenum mode) { + switch (mode) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_CW: + case GL_CCW: + break; + } + FNPTR(FrontFace)(mode); +} + +void GL_APIENTRY ES2ENTRY(PolygonOffset)(GLfloat factor, GLfloat units) { + FNPTR(PolygonOffset)(factor, units); +} diff --git a/es_2_0/Program.c b/es_2_0/Program.c new file mode 100755 index 0000000..1d1f2b9 --- /dev/null +++ b/es_2_0/Program.c @@ -0,0 +1,381 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <stdarg.h> + + +void GL_APIENTRY ES2INTER(ProgramObjectInit)(struct ProgramObjectUnit* pUnit) { + pUnit->bLinkStatus = GL_FALSE; + pUnit->strInfoLog = NULL; +} + +void GL_APIENTRY ES2INTER(ProgramObjectRelease)(struct ProgramObjectUnit* pUnit) { + register int i; + if (pUnit->strInfoLog != NULL) { + free(pUnit->strInfoLog); + } + pUnit->bLinkStatus = GL_FALSE; + pUnit->strInfoLog = NULL; +} + +void GL_APIENTRY ES2INTER(ProgramObjectInfoLogReset)(struct ProgramObjectUnit* pUnit) { + pUnit->strInfoLog = realloc(pUnit->strInfoLog, 1024 * sizeof(GLchar)); + assert(pUnit->strInfoLog != NULL); + pUnit->strInfoLog[0] = '\0'; +} + +void GL_APIENTRY ES2INTER(ProgramObjectInfoLogAppend)(struct ProgramObjectUnit* pUnit, + const char* format, ...) { + static char cBuf[1024]; + int len; + va_list ap; + va_start(ap, format); + vsnprintf(cBuf, 1024, format, ap); + if (pUnit->strInfoLog == NULL) { + pUnit->strInfoLog = realloc(pUnit->strInfoLog, 1024 * sizeof(GLchar)); + assert(pUnit->strInfoLog != NULL); + pUnit->strInfoLog[0] = '\0'; + } + len = strlen(pUnit->strInfoLog) + strlen(cBuf); + pUnit->strInfoLog = realloc(pUnit->strInfoLog, (len + 1) * sizeof(GLchar)); + assert(pUnit->strInfoLog != NULL); + strcat(pUnit->strInfoLog, cBuf); + va_end(ap); +} + +GLuint GL_APIENTRY ES2ENTRY(CreateProgram)(void) { + register GLuint uResult; + register GLint nAllocated; + register int i; + uResult = FNPTR(CreateProgram)(); + nAllocated = CCV(nProgramObjectAllocated); + while (nAllocated <= uResult) { + nAllocated *= 2; + } + if (CCV(nProgramObjectAllocated) < nAllocated) { + register struct ProgramObjectUnit* pUnit = realloc(CCV(pProgramObject), + nAllocated * sizeof(struct ProgramObjectUnit)); + assert(pUnit != NULL); + for (i = CCV(nProgramObjectAllocated); i < nAllocated; i++) { + ES2INTER(ProgramObjectInit)(&(pUnit[i])); + } + CCV(pProgramObject) = pUnit; + CCV(nProgramObjectAllocated) = nAllocated; + } + return uResult; +} + +void GL_APIENTRY ES2ENTRY(DeleteProgram)(GLuint program) { + if (program == 0) { + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (program < CCV(nProgramObjectAllocated)) { + GLint nAttachedShaders = 0; + FNPTR(GetProgramiv)(program, GL_ATTACHED_SHADERS, &nAttachedShaders); + if (nAttachedShaders > 0) { + GLuint* pAttachedShaders = NULL; + int i; + pAttachedShaders = (GLuint*)realloc(pAttachedShaders, + nAttachedShaders * sizeof(GLuint)); + assert(pAttachedShaders != NULL); + FNPTR(GetAttachedShaders)(program, nAttachedShaders, &i, pAttachedShaders); + assert(nAttachedShaders == i); + for (i = 0; i < nAttachedShaders; i++) { + int index = pAttachedShaders[i]; + if (index < CCV(nShaderObjectAllocated)) { + struct ShaderObjectUnit* pShader = &(CCV(pShaderObject)[index]); + if (pShader->nAttached > 0) pShader->nAttached--; + if (pShader->bDeleteStatus == GL_TRUE && pShader->nAttached == 0) { + ES2INTER(ShaderObjectRelease)(pShader); + } + } + } + } + ES2INTER(ProgramObjectRelease)(&(CCV(pProgramObject)[program])); + } + FNPTR(DeleteProgram)(program); +} + +GLboolean GL_APIENTRY ES2ENTRY(IsProgram)(GLuint program) { + register GLboolean bResult; + bResult = FNPTR(IsProgram)(program); + return bResult; +} + +void GL_APIENTRY ES2ENTRY(AttachShader)(GLuint program, GLuint shader) { + struct ShaderObjectUnit* pShader; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + if (program == 30) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } else { + ES2INTER(SetError)(GL_INVALID_OPERATION); + } + return; + } + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(AttachShader)(program, shader); + pShader = &(CCV(pShaderObject)[shader]); + pShader->nAttached++; +} + +void GL_APIENTRY ES2ENTRY(DetachShader)(GLuint program, GLuint shader) { + struct ShaderObjectUnit* pShader; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(DetachShader)(program, shader); + pShader = &(CCV(pShaderObject)[shader]); + if (pShader->nAttached > 0) pShader->nAttached--; + if (pShader->nAttached == 0 && pShader->bDeleteStatus == GL_TRUE) { + ES2INTER(ShaderObjectRelease)(pShader); + } +} + +void GL_APIENTRY ES2ENTRY(GetAttachedShaders)(GLuint program, + GLsizei maxcount, GLsizei* count, GLuint* shaders) { + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (maxcount < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetAttachedShaders)(program, maxcount, count, shaders); +} + +void GL_APIENTRY ES2ENTRY(LinkProgram)(GLuint program) { + struct ProgramObjectUnit* pUnit; + int nAttachedShaders; + int iResult; + GLboolean bFlag; + int nVertexShader = 0; + int nFragmentShader = 0; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetProgramiv)(program, GL_ATTACHED_SHADERS, &nAttachedShaders); + bFlag = GL_TRUE; + assert(program < CCV(nProgramObjectAllocated)); + pUnit = &(CCV(pProgramObject)[program]); + ES2INTER(ProgramObjectInfoLogReset)(pUnit); + if (nAttachedShaders > 0) { + GLuint* pAttachedShaders = NULL; + int i; + pAttachedShaders = (GLuint*)realloc(pAttachedShaders, nAttachedShaders * sizeof(GLuint)); + assert(pAttachedShaders != NULL); + FNPTR(GetAttachedShaders)(program, nAttachedShaders, &i, pAttachedShaders); + assert(nAttachedShaders == i); + for (i = 0; i < nAttachedShaders; i++) { + int index = pAttachedShaders[i]; + if (index < CCV(nShaderObjectAllocated)) { + struct ShaderObjectUnit* pShader = &(CCV(pShaderObject)[index]); + if (pShader->eShaderType == GL_VERTEX_SHADER) { + nVertexShader++; + } else if (pShader->eShaderType == GL_FRAGMENT_SHADER) { + nFragmentShader++; + } + if (pShader->bCompileStatus == GL_FALSE) { + bFlag = GL_FALSE; + ES2INTER(ProgramObjectInfoLogAppend)(pUnit, + "ERROR: shader=%d was not compiled or failed to compile\n", index); + } + } + } + } + if (nVertexShader == 0) { + ES2INTER(ProgramObjectInfoLogAppend)(pUnit, "ERROR: no vertex shader found\n"); + bFlag = GL_FALSE; + } + if (nFragmentShader == 0) { + ES2INTER(ProgramObjectInfoLogAppend)(pUnit, "ERROR: no fragment shader found\n"); + bFlag = GL_FALSE; + } + if (bFlag == GL_FALSE) { + CCV(pProgramObject)[program].bLinkStatus = GL_FALSE; + ES2INTER(ProgramObjectInfoLogAppend)(pUnit, "ERROR: link failed\n"); + return; + } + FNPTR(LinkProgram)(program); + FNPTR(GetProgramiv)(program, GL_LINK_STATUS, &iResult); + pUnit->bLinkStatus = (iResult == GL_FALSE) ? GL_FALSE : GL_TRUE; +} + +void GL_APIENTRY ES2ENTRY(UseProgram)(GLuint program) { + if ((GLint)(program) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } else if (program != 0 && FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(UseProgram)(program); +} + +void GL_APIENTRY ES2ENTRY(ValidateProgram)(GLuint program) { + struct ProgramObjectUnit* pUnit; + GLint valid; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + pUnit = &(CCV(pProgramObject)[program]); + ES2INTER(ProgramObjectInfoLogReset)(pUnit); + FNPTR(ValidateProgram)(program); + FNPTR(GetProgramiv)(program, GL_VALIDATE_STATUS, &valid); + if (valid != GL_FALSE) { + ES2ENTRY(LinkProgram)(program); + } +} + +void GL_APIENTRY ES2ENTRY(GetProgramiv)(GLuint program, GLenum pname, GLint* params) { + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_LINK_STATUS: + if (program < CCV(nProgramObjectAllocated)) { + *params = CCV(pProgramObject)[program].bLinkStatus; + } else { + FNPTR(GetProgramiv)(program, pname, params); + } + break; + case GL_DELETE_STATUS: + FNPTR(GetProgramiv)(program, pname, params); + break; + case GL_VALIDATE_STATUS: + FNPTR(GetProgramiv)(program, pname, params); + if (*params != GL_FALSE) { + if (program < CCV(nProgramObjectAllocated)) { + *params = CCV(pProgramObject)[program].bLinkStatus; + } else { + FNPTR(GetProgramiv)(program, GL_LINK_STATUS, params); + } + } + break; + case GL_INFO_LOG_LENGTH: + if (program < CCV(nProgramObjectAllocated) + && CCV(pProgramObject)[program].strInfoLog != NULL) { + *params = strlen(CCV(pProgramObject)[program].strInfoLog) + 1; + if (*params <= 1) { + FNPTR(GetProgramiv)(program, pname, params); + } + } else { + FNPTR(GetProgramiv)(program, pname, params); + } + break; + case GL_ATTACHED_SHADERS: + case GL_ACTIVE_ATTRIBUTES: + case GL_ACTIVE_ATTRIBUTE_MAX_LENGTH: + case GL_ACTIVE_UNIFORMS: + case GL_ACTIVE_UNIFORM_MAX_LENGTH: + FNPTR(GetProgramiv)(program, pname, params); + break; + } +} + +void GL_APIENTRY ES2ENTRY(GetProgramInfoLog)(GLuint program, + GLsizei bufsize, GLsizei* length, char* infolog) { + struct ProgramObjectUnit* pUnit; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (bufsize < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + assert(program < CCV(nProgramObjectAllocated)); + pUnit = &CCV(pProgramObject[program]); + if (pUnit->strInfoLog != NULL) { + int len = strlen(pUnit->strInfoLog); + if (len >= bufsize) { + len = bufsize - 1; + } + if (len > 0) { + if (length != NULL) { + *length = len; + } + if (infolog != NULL) { + strncpy(infolog, pUnit->strInfoLog, len); + infolog[len] = '\0'; + } + } else { + FNPTR(GetProgramInfoLog)(program, bufsize, length, infolog); + } + } else { + FNPTR(GetProgramInfoLog)(program, bufsize, length, infolog); + } +} + diff --git a/es_2_0/Shader.c b/es_2_0/Shader.c new file mode 100755 index 0000000..1e661d4 --- /dev/null +++ b/es_2_0/Shader.c @@ -0,0 +1,549 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <stdarg.h> + + +void GL_APIENTRY ES2INTER(ShaderObjectInit)(struct ShaderObjectUnit* pUnit) { + pUnit->eShaderType = 0; + pUnit->bDeleteStatus = GL_FALSE; + pUnit->bCompileStatus = GL_FALSE; + pUnit->nAttached = 0; + pUnit->aStrSource = NULL; + pUnit->nSourceAlloc = 0; + pUnit->nSourceUsed = 0; + pUnit->nSourceLength = 0; + pUnit->strInfoLog = NULL; + pUnit->nInfoLogAlloc = 0; + pUnit->strPreped = NULL; + pUnit->nPrepedAlloc = 0; + pUnit->symbolLevel = -1; +} + +void GL_APIENTRY ES2INTER(ShaderObjectRelease)(struct ShaderObjectUnit* pUnit) { + register int i; + assert(pUnit->bDeleteStatus == GL_TRUE && pUnit->nAttached == 0); + for (i = 0; pUnit->aStrSource != NULL && i < pUnit->nSourceAlloc; i++) { + if (pUnit->aStrSource[i] != NULL) { + free(pUnit->aStrSource[i]); + } + } + if (pUnit->aStrSource != NULL) { + free(pUnit->aStrSource); + } + if (pUnit->strInfoLog != NULL) { + free(pUnit->strInfoLog); + } + if (pUnit->strPreped != NULL) { + free(pUnit->strPreped); + } + pUnit->eShaderType = 0; + pUnit->bDeleteStatus = GL_FALSE; + pUnit->bCompileStatus = GL_FALSE; + pUnit->nAttached = 0; + pUnit->aStrSource = NULL; + pUnit->nSourceAlloc = 0; + pUnit->nSourceUsed = 0; + pUnit->nSourceLength = 0; + pUnit->strInfoLog = NULL; + pUnit->nInfoLogAlloc = 0; + pUnit->strPreped = NULL; + pUnit->nPrepedAlloc = 0; + ES2INTER(SymbolRelease)(pUnit); +} + +void GL_APIENTRY ES2INTER(ShaderObjectInfoLogReset)(struct ShaderObjectUnit* pUnit) { + if (pUnit->strInfoLog == NULL) { + assert(pUnit->nInfoLogAlloc == 0); + pUnit->nInfoLogAlloc = 1024; + pUnit->strInfoLog = realloc(pUnit->strInfoLog, pUnit->nInfoLogAlloc * sizeof(GLchar)); + assert(pUnit->strInfoLog != NULL); + } + pUnit->strInfoLog[0] = '\0'; +} + +void GL_APIENTRY ES2INTER(ShaderObjectInfoLogAppend)(struct ShaderObjectUnit* pUnit, + const char* format, ...) { + static char cBuf[1024]; + int nLenBuf; + int nLenLog; + va_list ap; + va_start(ap, format); + vsnprintf(cBuf, 1024, format, ap); + if (pUnit->bDeleteStatus != GL_TRUE) { + if (pUnit->strInfoLog == NULL) { + assert(pUnit->nInfoLogAlloc == 0); + pUnit->nInfoLogAlloc = 1024; + pUnit->strInfoLog = realloc(pUnit->strInfoLog, pUnit->nInfoLogAlloc * sizeof(GLchar)); + assert(pUnit->strInfoLog != NULL); + pUnit->strInfoLog[0] = '\0'; + } + nLenBuf = strlen(cBuf) + 1; + nLenLog = strlen(pUnit->strInfoLog); + if (nLenBuf + nLenLog >= pUnit->nInfoLogAlloc) { + while (nLenBuf + nLenLog >= pUnit->nInfoLogAlloc) { + pUnit->nInfoLogAlloc *= 2; + } + pUnit->strInfoLog = realloc(pUnit->strInfoLog, pUnit->nInfoLogAlloc * sizeof(GLchar)); + assert(pUnit->strInfoLog != NULL); + } + strcat(pUnit->strInfoLog, cBuf); + } else { + ES2INTER(SetError)(GL_NO_ERROR); + } + va_end(ap); +} + +void GL_APIENTRY ES2INTER(ShaderObjectPrepedReset)(struct ShaderObjectUnit* pUnit) { + if (pUnit->strPreped == NULL) { + assert(pUnit->nPrepedAlloc == 0); + pUnit->nPrepedAlloc = 1024; + pUnit->strPreped = realloc(pUnit->strPreped, pUnit->nPrepedAlloc * sizeof(GLchar)); + assert(pUnit->strPreped != NULL); + } + pUnit->strPreped[0] = '\0'; +} + +void GL_APIENTRY ES2INTER(ShaderObjectPrepedAppend)(struct ShaderObjectUnit* pUnit, + const char* strBuf, int nLenBuf) { + int nLenPreped; + if (pUnit->strPreped == NULL) { + assert(pUnit->nPrepedAlloc == 0); + pUnit->nPrepedAlloc = 1024; + pUnit->strPreped = realloc(pUnit->strPreped, pUnit->nPrepedAlloc * sizeof(GLchar)); + assert(pUnit->strPreped != NULL); + pUnit->strPreped[0] = '\0'; + } + nLenPreped = strlen(pUnit->strPreped); + if (nLenBuf + nLenPreped >= pUnit->nPrepedAlloc) { + while (nLenBuf + nLenPreped >= pUnit->nPrepedAlloc) { + pUnit->nPrepedAlloc *= 2; + } + pUnit->strPreped = realloc(pUnit->strPreped, pUnit->nPrepedAlloc * sizeof(GLchar)); + assert(pUnit->strPreped != NULL); + } + strncat(pUnit->strPreped, strBuf, nLenBuf); +} + +GLuint GL_APIENTRY ES2ENTRY(CreateShader)(GLenum type) { + register GLuint uResult; + register GLint nAllocated; + register int i; + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return 0; + case GL_VERTEX_SHADER: + case GL_FRAGMENT_SHADER: + uResult = FNPTR(CreateShader)(type); + nAllocated = CCV(nShaderObjectAllocated); + while (nAllocated <= uResult) { + nAllocated *= 2; + } + if (CCV(nShaderObjectAllocated) < nAllocated) { + register struct ShaderObjectUnit* pUnit = realloc(CCV(pShaderObject), + nAllocated * sizeof(struct ShaderObjectUnit)); + assert(pUnit != NULL); + for (i = CCV(nShaderObjectAllocated); i < nAllocated; i++) { + ES2INTER(ShaderObjectInit)(&(pUnit[i])); + } + CCV(pShaderObject) = pUnit; + CCV(nShaderObjectAllocated) = nAllocated; + } + CCV(pShaderObject)[uResult].eShaderType = type; + return uResult; + } +} + +void GL_APIENTRY ES2ENTRY(DeleteShader)(GLuint shader) { + if (shader == 0) { + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(DeleteShader)(shader); + if (shader < CCV(nShaderObjectAllocated)) { + struct ShaderObjectUnit* pUnit = &CCV(pShaderObject[shader]); + pUnit->bDeleteStatus = GL_TRUE; + if (pUnit->nAttached == 0) { + ES2INTER(ShaderObjectRelease)(pUnit); + } + } +} + +GLboolean GL_APIENTRY ES2ENTRY(IsShader)(GLuint shader) { + register GLboolean bResult; + bResult = FNPTR(IsShader)(shader); + return bResult; +} + +void GL_APIENTRY ES2ENTRY(ShaderSource)(GLuint shader, + GLsizei count, const char** string, const GLint* length) { + register struct ShaderObjectUnit* pUnit; + register int i; + if (CCV(bShaderCompiler) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (count < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + assert(shader < CCV(nShaderObjectAllocated)); + pUnit = &CCV(pShaderObject[shader]); + pUnit->bCompileStatus = GL_FALSE; + pUnit->nSourceUsed = count; + if (pUnit->nSourceAlloc < count) { + pUnit->aStrSource = (GLchar**)realloc(pUnit->aStrSource, count * sizeof(GLchar*)); + assert(pUnit->aStrSource != NULL); + for (i = pUnit->nSourceAlloc; i < count; i++) { + pUnit->aStrSource[i] = NULL; + } + pUnit->nSourceAlloc = count; + } + pUnit->nSourceLength = 0; + for (i = 0; i < count; i++) { + register int len = (length == NULL) ? strlen(string[i]) : length[i]; + pUnit->aStrSource[i] = (GLchar*)realloc(pUnit->aStrSource[i], (len + 2) * sizeof(GLchar)); + if (pUnit->aStrSource[i] == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + } + strncpy(pUnit->aStrSource[i], string[i], len); + pUnit->aStrSource[i][len] = (pUnit->aStrSource[i][len - 1] != '\n') ? '\n' : '\0'; + pUnit->aStrSource[i][len + 1] = '\0'; + pUnit->nSourceLength += (pUnit->aStrSource[i][len - 1] != '\n') ? (len + 1) : len; + } + if (pUnit->nSourceLength > 0) pUnit->nSourceLength++; + ES2INTER(ShaderObjectInfoLogReset)(pUnit); + ES2INTER(ShaderObjectPrepedReset)(pUnit); + FNPTR(ShaderSource)(shader, pUnit->nSourceUsed, (const GLchar**)pUnit->aStrSource, NULL); +} + +void GL_APIENTRY ES2ENTRY(GetShaderSource)(GLuint shader, + GLsizei bufsize, GLsizei* length, char* source) { + register struct ShaderObjectUnit* pUnit; + register char* pDst; + register char* pSrc; + register int i; + register int len; + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (bufsize < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (bufsize == 0) { + return; + } else if (bufsize == 1) { + *source = '\0'; + if (length != NULL) *length = 0; + return; + } + pUnit = &CCV(pShaderObject[shader]); + pDst = source; + for (i = 0; bufsize > 1 && i < pUnit->nSourceUsed; i++) { + pSrc = pUnit->aStrSource[i]; + while (bufsize-- > 1) { + *pDst++ = *pSrc++; + } + } + *pDst = '\0'; + len = (int)(pDst - source); + if (length != NULL) { + *length = len; + } +} + +void GL_APIENTRY ES2ENTRY(ShaderBinary)(GLsizei n, const GLuint* shaders, + GLenum binaryformat, const void* binary, GLsizei length) { + register int i; + if (n < 0 || length < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + for (i = 0; i < n; i++) { + if (shaders[i] == 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shaders[i]) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + } + + ES2INTER(SetError)(GL_INVALID_OPERATION); +} + +/* hooking for PrepLex analyzer */ +extern void hazelPrepPrepare(struct ShaderObjectUnit* pShaderObject); +extern int hazelPrepGetError(void); +extern int hazelPreplex(void); +extern void hazelPrepTerminate(void); + +extern void hazelParsePrepare(struct ShaderObjectUnit* ptr, const char* src, char* dst); +extern int hazelParseparse(void); +extern int hazelParseGetError(void); +extern void hazelParseTerminate(void); + +int hazelEnableTexture3D = GL_FALSE; + +void GL_APIENTRY ES2ENTRY(CompileShader)(GLuint shader) { + register struct ShaderObjectUnit* pUnit; + char* pExpanded; + static char* pParsed = NULL; + GLint nResult; + GLint nSemError; + if (CCV(bShaderCompiler) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + assert(shader < CCV(nShaderObjectAllocated)); + pUnit = &CCV(pShaderObject[shader]); + ES2INTER(ShaderObjectInfoLogReset)(pUnit); + ES2INTER(ShaderObjectPrepedReset)(pUnit); + if (pUnit->nSourceUsed <= 0) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "ERROR: no source code available\n"); + pUnit->bCompileStatus = GL_FALSE; + return; + } + ES2INTER(MacroInit)(); + hazelPrepPrepare(pUnit); + hazelPreplex(); + nResult = hazelPrepGetError(); + hazelPrepTerminate(); + if (nResult != 0) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "ERROR: stopped during preprocessing\n"); + pUnit->bCompileStatus = GL_FALSE; + ES2INTER(MacroRelease)(); + return; + } + ES2INTER(MacroUndef)("__LINE__"); + ES2INTER(MacroUndef)("__FILE__"); + pExpanded = ES2INTER(MacroExpand)(pUnit->strPreped, 0); + if (pExpanded == NULL) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "ERROR: stopped during source expansion\n"); + pUnit->bCompileStatus = GL_FALSE; + ES2INTER(MacroRelease)(); + return; + } + ES2INTER(MacroRelease)(); + if (strncmp (pExpanded, "#version", 8) != 0) { + /* here pParsed has removed all the useless characters like comments. + * If the first strig is not version, set the version number to be 120. + */ + const char *versionStr = "#version 120\n"; + pParsed = realloc(pParsed, 2 * strlen(pExpanded) + strlen(versionStr)); + memset(pParsed, 0, 2 * strlen(pExpanded) + strlen(versionStr)); + + strncpy(pParsed, versionStr, strlen(versionStr)); + hazelParsePrepare(pUnit, pExpanded, &pParsed[strlen(versionStr)]); + } else { + pParsed = realloc(pParsed, 2 * strlen(pExpanded)); + memset(pParsed, 0, 2 * strlen(pExpanded)); + hazelParsePrepare(pUnit, pExpanded, pParsed); + } + + nResult = hazelParseparse(); + nSemError = hazelParseGetError(); + hazelParseTerminate(); + if (nResult != 0 || nSemError != 0) { + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "ERROR: stopped during parsing\n"); + pUnit->bCompileStatus = GL_FALSE; + return; + } + FNPTR(ShaderSource)(shader, 1, (const GLchar**)&(pParsed), NULL); + FNPTR(CompileShader)(shader); + FNPTR(GetShaderiv)(shader, GL_COMPILE_STATUS, &nResult); + pUnit->bCompileStatus = (nResult == 0) ? GL_FALSE : GL_TRUE; + FNPTR(GetShaderiv)(shader, GL_INFO_LOG_LENGTH, &nResult); + if (nResult > 1) { + GLchar* str = malloc((nResult + 1) * sizeof(GLchar)); + FNPTR(GetShaderInfoLog)(shader, nResult + 1, NULL, str); + ES2INTER(ShaderObjectInfoLogAppend)(pUnit, "%s", str); + free(str); + } +} + +void GL_APIENTRY ES2ENTRY(ReleaseShaderCompiler)(void) { + if (CCV(bShaderCompiler) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + +} + +void GL_APIENTRY ES2ENTRY(GetShaderiv)(GLuint shader, GLenum pname, GLint* params) { + register struct ShaderObjectUnit* pUnit; + int nLenInfoLog; + if (pname == GL_COMPILE_STATUS + || pname == GL_INFO_LOG_LENGTH + || pname == GL_SHADER_SOURCE_LENGTH) { + if (CCV(bShaderCompiler) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + } + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + pUnit = &CCV(pShaderObject[shader]); + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_SHADER_TYPE: + if (params != NULL) { + *params = pUnit->eShaderType; + } + break; + case GL_DELETE_STATUS: + if (params != NULL) { + *params = pUnit->bDeleteStatus; + } + break; + case GL_COMPILE_STATUS: + if (params != NULL) { + *params = pUnit->bCompileStatus; + } + break; + case GL_INFO_LOG_LENGTH: + if (pUnit->strInfoLog != NULL + && (nLenInfoLog = strlen(pUnit->strInfoLog)) > 0) { + if (params != NULL) { + *params = nLenInfoLog + 1; + } + } else { + FNPTR(GetShaderiv)(shader, pname, params); + } + break; + case GL_SHADER_SOURCE_LENGTH: + if (params != NULL) { + params[0] = pUnit->nSourceLength; + } + } +} + +void GL_APIENTRY ES2ENTRY(GetShaderInfoLog)(GLuint shader, + GLsizei bufsize, GLsizei* length, char* infolog) { + register struct ShaderObjectUnit* pUnit; + int len; + GLboolean done; + if ((GLint)(shader) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsShader)(shader) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (bufsize < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + done = GL_FALSE; + if (shader < CCV(nShaderObjectAllocated)) { + pUnit = &CCV(pShaderObject[shader]); + if (pUnit->strInfoLog != NULL) { + len = strlen(pUnit->strInfoLog); + if (len + 1 <= bufsize) { + strcpy(infolog, pUnit->strInfoLog); + if (length != NULL) *length = len; + done = GL_TRUE; + } else if (bufsize > 0) { + strncpy(infolog, pUnit->strInfoLog, bufsize - 1); + infolog[bufsize - 1] = '\0'; + if (length != NULL) *length = bufsize - 1; + done = GL_TRUE; + } + } + } + if (done == GL_FALSE) { + FNPTR(GetShaderInfoLog)(shader, bufsize, length, infolog); + } +} + +void GL_APIENTRY ES2ENTRY(GetShaderPrecisionFormat)(GLenum shadertype, + GLenum precisiontype, GLint* range, GLint* precision) { + if (CCV(bShaderCompiler) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (shadertype) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_VERTEX_SHADER: + case GL_FRAGMENT_SHADER: + switch (precisiontype) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_LOW_FLOAT: + case GL_MEDIUM_FLOAT: + case GL_HIGH_FLOAT: + range[0] = -10; + range[1] = 10; + precision[0] = 1; + break; + case GL_LOW_INT: + case GL_MEDIUM_INT: + case GL_HIGH_INT: + range[0] = -10; + range[1] = 10; + precision[0] = 0; + break; + } + break; + } +} diff --git a/es_2_0/Tex3D.c b/es_2_0/Tex3D.c new file mode 100755 index 0000000..9ae7645 --- /dev/null +++ b/es_2_0/Tex3D.c @@ -0,0 +1,387 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <GLES2/gl2ext.h> + + +#ifndef GL_TEXTURE_WIDTH +#define GL_TEXTURE_WIDTH 0x1000 +#endif + +#ifndef GL_TEXTURE_HEIGHT +#define GL_TEXTURE_HEIGHT 0x1001 +#endif + +#ifndef GL_TEXTURE_DEPTH +#define GL_TEXTURE_DEPTH 0x8071 +#endif + +#ifndef GL_TEXTURE_INTERNAL_FORMAT +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#endif + + + +#if defined(PROVIDING_OES_texture_3D) + +static GLint ES2INTER(mapFormat)[] = { 0, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; + + +void GL_APIENTRY ES2ENTRY(TexImage3DOES)(GLenum target, + GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLenum format, GLenum type, const void* pixels) { + int iMaxSize; + if (1 <= internalformat && internalformat <= 4) { + internalformat = ES2INTER(mapFormat)[internalformat]; + } + if (1 <= format && format <= 4) { + format = ES2INTER(mapFormat)[format]; + } + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_3D_OES: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + } + switch (format) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (internalformat) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (format != GL_RGB) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (format != GL_RGBA) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || iMaxSize < width || height < 0 || iMaxSize < height + || depth < 0 || iMaxSize < depth) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (border != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(TexImage3D)(target, level, internalformat, width, height, depth, + border, format, type, pixels); +} + +void GL_APIENTRY ES2ENTRY(TexSubImage3DOES)(GLenum target, + GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLenum type, const GLvoid* pixels) { + int iMaxSize; + int iWidth, iHeight, iDepth; + int iInternalFormat; + if (1 <= format && format <= 4) { + format = ES2INTER(mapFormat)[format]; + } + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_3D_OES: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + } + switch (format) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (format != GL_RGB) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (format != GL_RGBA) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || height < 0 || depth < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_WIDTH, &iWidth); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_HEIGHT, &iHeight); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_DEPTH, &iDepth); + if (xoffset < 0 || iWidth < (xoffset + width) || yoffset < 0 || iHeight < (yoffset + height) + || zoffset < 0 || iDepth < (zoffset + depth)) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + FNPTR(TexSubImage3D)(target, level, xoffset, yoffset, zoffset, + width, height, depth, format, type, pixels); +} + +void GL_APIENTRY ES2ENTRY(CopyTexSubImage3DOES)(GLenum target, + GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLint x, GLint y, GLsizei width, GLsizei height) { + int iMaxSize; + int iWidth, iHeight, iDepth; + int iInternalFormat; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_3D_OES: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_WIDTH, &iWidth); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_HEIGHT, &iHeight); + if (xoffset < 0 || iWidth < (xoffset + width) || yoffset < 0 || iHeight < (yoffset + height) + || zoffset < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + FNPTR(CopyTexSubImage3D)(target, level, xoffset, yoffset, zoffset, x, y, width, height); +} + +void GL_APIENTRY ES2ENTRY(CompressedTexImage3DOES)(GLenum target, + GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, + GLint border, GLsizei imageSize, const void* data) { + GLint iCompressedTexFormats[64]; + GLint nCompressedTexFormats; + int iMaxSize; + int i; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_3D_OES: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + } + FNPTR(GetIntegerv)(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nCompressedTexFormats); + FNPTR(GetIntegerv)(GL_COMPRESSED_TEXTURE_FORMATS, iCompressedTexFormats); + for (i = 0; i < nCompressedTexFormats; i++) { + if (iCompressedTexFormats[i] == internalformat) break; + } + if (i == nCompressedTexFormats) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || iMaxSize < width || height < 0 || iMaxSize < height + || depth < 0 || iMaxSize < depth) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (border != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + + FNPTR(CompressedTexImage3D)(target, level, internalformat, width, height, depth, border, + imageSize, data); +} + +void GL_APIENTRY ES2ENTRY(CompressedTexSubImage3DOES)(GLenum target, + GLint level, GLint xoffset, GLint yoffset, GLint zoffset, + GLsizei width, GLsizei height, GLsizei depth, + GLenum format, GLsizei imageSize, const GLvoid* data) { + GLint iCompressedTexFormats[64]; + GLint nCompressedTexFormats; + int iMaxSize; + int iWidth, iHeight, iDepth; + int iInternalFormat; + int i; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_3D_OES: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + } + FNPTR(GetIntegerv)(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &nCompressedTexFormats); + FNPTR(GetIntegerv)(GL_COMPRESSED_TEXTURE_FORMATS, iCompressedTexFormats); + for (i = 0; i < nCompressedTexFormats; i++) { + if (iCompressedTexFormats[i] == format) break; + } + if (i == nCompressedTexFormats) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || height < 0 || depth < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_WIDTH, &iWidth); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_HEIGHT, &iHeight); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_DEPTH, &iDepth); + if (xoffset < 0 || iWidth < (xoffset + width) || yoffset < 0 || iHeight < (yoffset + height) + || zoffset < 0 || iDepth < (zoffset + depth)) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + FNPTR(CompressedTexSubImage3D)(target, level, xoffset, yoffset, zoffset, width, height, depth, + format, imageSize, data); +} + +void GL_APIENTRY ES2ENTRY(FramebufferTexture3DOES)(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level, GLint zoffset) { + GLuint uBuffer; + if (target != GL_FRAMEBUFFER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(GetIntegerv)(GL_FRAMEBUFFER_BINDING, &uBuffer); + if (uBuffer == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + switch (attachment) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_COLOR_ATTACHMENT0: + case GL_DEPTH_ATTACHMENT: + case GL_STENCIL_ATTACHMENT: + break; + } + if (texture == 0) { + FNPTR(FramebufferTexture2D)(target, attachment, textarget, texture, level); + return; + } + if (FNPTR(IsTexture)(texture) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + if (level != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + switch (textarget) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_3D_OES: + FNPTR(GenerateMipmap)(GL_TEXTURE_3D_OES); + break; + } + if (zoffset < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(FramebufferTexture3D)(target, attachment, textarget, texture, level, zoffset); +} + + +#endif diff --git a/es_2_0/TexImage.c b/es_2_0/TexImage.c new file mode 100755 index 0000000..7dfa33f --- /dev/null +++ b/es_2_0/TexImage.c @@ -0,0 +1,346 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <GLES2/gl2ext.h> + + +#ifndef GL_TEXTURE_WIDTH +#define GL_TEXTURE_WIDTH 0x1000 +#endif + +#ifndef GL_TEXTURE_HEIGHT +#define GL_TEXTURE_HEIGHT 0x1001 +#endif + +#ifndef GL_TEXTURE_INTERNAL_FORMAT +#define GL_TEXTURE_INTERNAL_FORMAT 0x1003 +#endif + + +static GLint ES2INTER(mapFormat)[] = { 0, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_RGB, GL_RGBA }; + +int GL_APIENTRY ES2INTER(Log2)(GLint x) { + register int val = 0; + if (x <= 0) return -1; + if ((x & 0xFFFF0000) != 0) { val += 16; x >>= 16; } + if ((x & 0x0000FF00) != 0) { val += 8; x >>= 8; } + if ((x & 0x000000F0) != 0) { val += 4; x >>= 4; } + if ((x & 0x0000000C) != 0) { val += 2; x >>= 2; } + if ((x & 0x00000002) != 0) { val += 1; x >>= 1; } + return val; +} + +void GL_APIENTRY ES2ENTRY(TexImage2D)(GLenum target, + GLint level, GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLenum format, GLenum type, const void* pixels) { + int iMaxSize; + if (1 <= internalformat && internalformat <= 4) { + internalformat = ES2INTER(mapFormat)[internalformat]; + } + if (1 <= format && format <= 4) { + format = ES2INTER(mapFormat)[format]; + } + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &iMaxSize); + break; + } + switch (format) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; +#if defined(PROVIDING_OES_packed_depth_stencil) + case GL_DEPTH_STENCIL_OES: +#endif + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (internalformat) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; +#if defined(PROVIDING_OES_packed_depth_stencil) + case GL_DEPTH_STENCIL_OES: +#endif + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; +#if defined(PROVIDING_OES_packed_depth_stencil) + case GL_UNSIGNED_INT_24_8_OES: +#endif + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (format != GL_RGB) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (format != GL_RGBA) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || iMaxSize < width || height < 0 || iMaxSize < height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (border != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(TexImage2D)(target, level, internalformat, width, height, border, format, type, pixels); +} + +void GL_APIENTRY ES2ENTRY(TexSubImage2D)(GLenum target, + GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, + GLenum format, GLenum type, const GLvoid* pixels) { + int iMaxSize; + int iWidth, iHeight; + int iInternalFormat; + if (1 <= format && format <= 4) { + format = ES2INTER(mapFormat)[format]; + } + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &iMaxSize); + break; + } + switch (format) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; +#if defined(PROVIDING_OES_packed_depth_stencil) + case GL_DEPTH_STENCIL_OES: +#endif + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; +#if defined(PROVIDING_OES_packed_depth_stencil) + case GL_UNSIGNED_INT_24_8_OES: +#endif + case GL_UNSIGNED_BYTE: + break; + case GL_UNSIGNED_SHORT_5_6_5: + if (format != GL_RGB) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + case GL_UNSIGNED_SHORT_4_4_4_4: + case GL_UNSIGNED_SHORT_5_5_5_1: + if (format != GL_RGBA) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_WIDTH, &iWidth); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_HEIGHT, &iHeight); + if (xoffset < 0 || iWidth < (xoffset + width) || yoffset < 0 || iHeight < (yoffset + height)) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + FNPTR(TexSubImage2D)(target, level, xoffset, yoffset, width, height, format, type, pixels); +} + +void GL_APIENTRY ES2ENTRY(CopyTexImage2D)(GLenum target, + GLint level, GLenum internalformat, + GLint x, GLint y, GLsizei width, GLsizei height, GLint border) { + int iMaxSize; + if (1 <= internalformat && internalformat <= 4) { + internalformat = ES2INTER(mapFormat)[internalformat]; + } + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &iMaxSize); + break; + } + switch (internalformat) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_ALPHA: + case GL_LUMINANCE: + case GL_LUMINANCE_ALPHA: + case GL_RGB: + case GL_RGBA: + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || iMaxSize < width || height < 0 || iMaxSize < height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (border != 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + + FNPTR(CopyTexImage2D)(target, level, internalformat, x, y, width, height, border); +} + +void GL_APIENTRY ES2ENTRY(CopyTexSubImage2D)(GLenum target, + GLint level, GLint xoffset, GLint yoffset, + GLint x, GLint y, GLsizei width, GLsizei height) { + int iMaxSize; + int iWidth, iHeight; + int iInternalFormat; + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + FNPTR(GetIntegerv)(GL_MAX_TEXTURE_SIZE, &iMaxSize); + break; + case GL_TEXTURE_CUBE_MAP_POSITIVE_X: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_X: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Y: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Y: + case GL_TEXTURE_CUBE_MAP_POSITIVE_Z: + case GL_TEXTURE_CUBE_MAP_NEGATIVE_Z: + if (width != height) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetIntegerv)(GL_MAX_CUBE_MAP_TEXTURE_SIZE, &iMaxSize); + break; + } + if (level < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (ES2INTER(Log2)(iMaxSize) < level) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (width < 0 || height < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_WIDTH, &iWidth); + FNPTR(GetTexLevelParameteriv)(target, level, GL_TEXTURE_HEIGHT, &iHeight); + if (xoffset < 0 || iWidth < (xoffset + width) || yoffset < 0 || iHeight < (yoffset + height)) { + ES2INTER(SetError)(GL_INVALID_VALUE); + } + FNPTR(CopyTexSubImage2D)(target, level, xoffset, yoffset, x, y, width, height); +} diff --git a/es_2_0/Texture.c b/es_2_0/Texture.c new file mode 100755 index 0000000..5529ee6 --- /dev/null +++ b/es_2_0/Texture.c @@ -0,0 +1,246 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <GLES2/gl2ext.h> + + +void GL_APIENTRY ES2ENTRY(GenTextures)(GLsizei n, GLuint* textures) { + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (n == 0) { + ES2INTER(SetError)(GL_NO_ERROR); + return; + } + FNPTR(GenTextures)(n, textures); +} + +void GL_APIENTRY ES2ENTRY(DeleteTextures)(GLsizei n, const GLuint* textures) { + if (n < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(DeleteTextures)(n, textures); +} + +GLboolean GL_APIENTRY ES2ENTRY(IsTexture)(GLuint texture) { + return FNPTR(IsTexture)(texture); +} + +#if ! defined(GL_GENERATE_MIPMAP) +#define GL_GENERATE_MIPMAP 0x8191 +#endif + +void GL_APIENTRY ES2ENTRY(BindTexture)(GLenum target, GLuint texture) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + FNPTR(BindTexture)(target, texture); + break; + } +} + +void GL_APIENTRY ES2ENTRY(PixelStorei)(GLenum pname, GLint param) { + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_PACK_ALIGNMENT: + case GL_UNPACK_ALIGNMENT: + break; + } + if (param != 1 && param != 2 && param != 4 && param != 8) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(PixelStorei)(pname, param); +} + +void GL_APIENTRY ES2ENTRY(ActiveTexture)(GLenum texture) { + GLint iMaxCombinedTextureImageUnits; + FNPTR(GetIntegerv)(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &iMaxCombinedTextureImageUnits); + if (texture < GL_TEXTURE0 || GL_TEXTURE0 + iMaxCombinedTextureImageUnits <= texture) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(ActiveTexture)(texture); +} + +void GL_APIENTRY ES2ENTRY(GenerateMipmap)(GLenum target) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + break; + } + FNPTR(GenerateMipmap)(target); +} + +void GL_APIENTRY ES2ENTRY(TexParameterf)(GLenum target, GLenum pname, GLfloat param) { + GLint iParam = (GLint)(param); + GLfloat fError = param - iParam; + if (fError != 0.0F) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + ES2ENTRY(TexParameteri)(target, pname, iParam); +} + +void GL_APIENTRY ES2ENTRY(TexParameterfv)(GLenum target, GLenum pname, const GLfloat* params) { + GLint iParam = (GLint)(*params); + GLfloat fError = *params - iParam; + if (fError != 0.0F) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + ES2ENTRY(TexParameteri)(target, pname, iParam); +} + +void GL_APIENTRY ES2ENTRY(TexParameteri)(GLenum target, GLenum pname, GLint param) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: + break; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_MIN_FILTER: + switch (param) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_NEAREST: + case GL_LINEAR: + case GL_NEAREST_MIPMAP_NEAREST: + case GL_LINEAR_MIPMAP_NEAREST: + case GL_NEAREST_MIPMAP_LINEAR: + case GL_LINEAR_MIPMAP_LINEAR: + break; + } + break; + case GL_TEXTURE_MAG_FILTER: + switch (param) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_NEAREST: + case GL_LINEAR: + break; + } + break; + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_WRAP_R_OES: +#endif + switch (param) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_CLAMP_TO_EDGE: + case GL_MIRRORED_REPEAT: + case GL_REPEAT: + break; + } + } + FNPTR(TexParameteri)(target, pname, param); +} + +void GL_APIENTRY ES2ENTRY(TexParameteriv)(GLenum target, GLenum pname, const GLint* params) { + ES2ENTRY(TexParameteri)(target, pname, *params); +} + +void GL_APIENTRY ES2ENTRY(GetTexParameterfv)(GLenum target, GLenum pname, GLfloat* params) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_3D_OES: +#endif + break; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_WRAP_R_OES: +#endif + break; + } + FNPTR(GetTexParameterfv)(target, pname, params); +} + +void GL_APIENTRY ES2ENTRY(GetTexParameteriv)(GLenum target, GLenum pname, GLint* params) { + switch (target) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_2D: + case GL_TEXTURE_CUBE_MAP: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_3D_OES: +#endif + break; + } + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_TEXTURE_MAG_FILTER: + case GL_TEXTURE_MIN_FILTER: + case GL_TEXTURE_WRAP_S: + case GL_TEXTURE_WRAP_T: +#if defined(PROVIDING_OES_texture_3D) + case GL_TEXTURE_WRAP_R_OES: +#endif + break; + } + FNPTR(GetTexParameteriv)(target, pname, params); +} diff --git a/es_2_0/Uniform.c b/es_2_0/Uniform.c new file mode 100755 index 0000000..d488f04 --- /dev/null +++ b/es_2_0/Uniform.c @@ -0,0 +1,918 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + +/* Disable the using of glGetActiveUniform(). The previous code is to use the location + * returned from glGetUniformLocation() as the index to call glGetActiveUniform(). However + * the index may not always corresponds to the value of the location. Especially on Intel + * graphic driver, it caused errors. Seems that the only valid usage of glGetActiveUniform() + * is to iterate every index from 0 to the number of uniforms. It does not match the usage + * here. + */ +#undef ENABLE_USING_GETACTIVEUNIFORM + +static GLint* ES2INTER(pValue) = NULL; + +#ifdef ENABLE_USING_GETACTIVEUNIFORM +GLboolean GL_APIENTRY ES2INTER(GetUniformSizeType)(const char* funcname, + GLint location, GLint* size, GLenum* type) { + GLuint program; + GLint nActiveUniforms; + GLsizei nLength; + GLchar strName[256]; + FNPTR(GetIntegerv)(GL_CURRENT_PROGRAM, &program); + if (program == 0) { + SET_ERROR(GL_INVALID_OPERATION, "%s: no current program object", funcname); + return GL_FALSE; + } + FNPTR(GetProgramiv)(program, GL_ACTIVE_UNIFORMS, &nActiveUniforms); + if (location < -1 || nActiveUniforms <= location) { + SET_ERROR(GL_INVALID_OPERATION, "%s: location=%d is out of range[%d,%d]", + funcname, location, -1, nActiveUniforms); + return GL_FALSE; + } + if (location == -1) { + return GL_FALSE; + } + FNPTR(GetActiveUniform)(program, location, sizeof(strName) / sizeof(strName[0]), + &nLength, size, type, strName); + return GL_TRUE; +} +#endif + +void GL_APIENTRY ES2ENTRY(GetUniformfv)(GLuint program, GLint location, GLfloat* params) { + GLint iLinkStatus; + GLint nActiveUniforms; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetProgramiv)(program, GL_LINK_STATUS, &iLinkStatus); + if (iLinkStatus == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } +/* + FNPTR(GetProgramiv)(program, GL_ACTIVE_UNIFORMS, &nActiveUniforms); + if (location < 0 || nActiveUniforms <= location) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } +*/ + FNPTR(GetUniformfv)(program, location, params); +} + +void GL_APIENTRY ES2ENTRY(GetUniformiv)(GLuint program, GLint location, GLint* params) { + GLint iLinkStatus; + GLint nActiveUniforms; + if ((GLint)(program) <= 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } else if (FNPTR(IsProgram)(program) == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetProgramiv)(program, GL_LINK_STATUS, &iLinkStatus); + if (iLinkStatus == GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } +/* + FNPTR(GetProgramiv)(program, GL_ACTIVE_UNIFORMS, &nActiveUniforms); + if (location < 0 || nActiveUniforms <= location) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } +*/ + FNPTR(GetUniformiv)(program, location, params); +} + +void GL_APIENTRY ES2ENTRY(Uniform1f)(GLint location, GLfloat x) { +#define FUNC_NAME "Uniform1f" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL: + FNPTR(Uniform1i)(location, (x != 0.0F)); + break; + case GL_FLOAT: + FNPTR(Uniform1f)(location, x); + break; + } +#else + FNPTR(Uniform1f)(location, x); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform2f)(GLint location, GLfloat x, GLfloat y) { +#define FUNC_NAME "Uniform2f" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)("Uniform2f", location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL_VEC2: + FNPTR(Uniform2i)(location, (x != 0.0F), (y != 0.0F)); + break; + case GL_FLOAT_VEC2: + FNPTR(Uniform2f)(location, x, y); + break; + } +#else + FNPTR(Uniform2f)(location, x, y); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform3f)(GLint location, GLfloat x, GLfloat y, GLfloat z) { +#define FUNC_NAME "Uniform3f" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL_VEC3: + FNPTR(Uniform3i)(location, (x != 0.0F), (y != 0.0F), (z != 0.0F)); + break; + case GL_FLOAT_VEC3: + FNPTR(Uniform3f)(location, x, y, z); + break; + } +#else + FNPTR(Uniform3f)(location, x, y, z); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform4f)(GLint location, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { +#define FUNC_NAME "Uniform4f" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL_VEC4: + FNPTR(Uniform4i)(location, (x != 0.0F), (y != 0.0F), (z != 0.0F), (w != 0.0F)); + break; + case GL_FLOAT_VEC4: + FNPTR(Uniform4f)(location, x, y, z, w); + break; + } +#else + FNPTR(Uniform4f)(location, x, y, z, w); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform1fv)(GLint location, GLsizei count, const GLfloat* v) { +#define FUNC_NAME "Uniform1fv" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + register int i; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL: + ES2INTER(pValue) = (GLint*)realloc(ES2INTER(pValue), count * sizeof(GLint)); + for (i = 0; i < count; i++) { + ES2INTER(pValue)[i] = (v[i] == 0.0F) ? GL_FALSE : GL_TRUE; + } + FNPTR(Uniform1iv)(location, count, ES2INTER(pValue)); + break; + case GL_FLOAT: + FNPTR(Uniform1fv)(location, count, v); + break; + } +#else + FNPTR(Uniform1fv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform2fv)(GLint location, GLsizei count, const GLfloat* v) { +#define FUNC_NAME "Uniform2fv" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + register int i; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL_VEC2: + ES2INTER(pValue) = (GLint*)realloc(ES2INTER(pValue), 2 * count * sizeof(GLint)); + for (i = 0; i < 2 * count; i++) { + ES2INTER(pValue)[i] = (v[i] == 0.0F) ? GL_FALSE : GL_TRUE; + } + FNPTR(Uniform2iv)(location, count, ES2INTER(pValue)); + break; + case GL_FLOAT_VEC2: + FNPTR(Uniform2fv)(location, count, v); + break; + } +#else + FNPTR(Uniform2fv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform3fv)(GLint location, GLsizei count, const GLfloat* v) { +#define FUNC_NAME "Uniform3fv" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + register int i; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL_VEC3: + ES2INTER(pValue) = (GLint*)realloc(ES2INTER(pValue), 3 * count * sizeof(GLint)); + for (i = 0; i < 3 * count; i++) { + ES2INTER(pValue)[i] = (v[i] == 0.0F) ? GL_FALSE : GL_TRUE; + } + FNPTR(Uniform3iv)(location, count, ES2INTER(pValue)); + break; + case GL_FLOAT_VEC3: + FNPTR(Uniform3fv)(location, count, v); + break; + } +#else + FNPTR(Uniform3fv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform4fv)(GLint location, GLsizei count, const GLfloat* v) { +#define FUNC_NAME "Uniform4fv" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + register int i; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_BOOL_VEC4: + ES2INTER(pValue) = (GLint*)realloc(ES2INTER(pValue), 4 * count * sizeof(GLint)); + for (i = 0; i < 4 * count; i++) { + ES2INTER(pValue)[i] = (v[i] == 0.0F) ? GL_FALSE : GL_TRUE; + } + FNPTR(Uniform4iv)(location, count, ES2INTER(pValue)); + break; + case GL_FLOAT_VEC4: + FNPTR(Uniform4fv)(location, count, v); + break; + } +#else + FNPTR(Uniform4fv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform1i)(GLint location, GLint x) { +#define FUNC_NAME "Uniform1i" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT: + case GL_BOOL: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + FNPTR(Uniform1i)(location, x); + break; + } +#else + FNPTR(Uniform1i)(location, x); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform2i)(GLint location, GLint x, GLint y) { +#define FUNC_NAME "Uniform2i" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT_VEC2: + case GL_BOOL_VEC2: + FNPTR(Uniform2i)(location, x, y); + break; + } +#else + FNPTR(Uniform2i)(location, x, y); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform3i)(GLint location, GLint x, GLint y, GLint z) { +#define FUNC_NAME "Uniform3i" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + FNPTR(Uniform3i)(location, x, y, z); + break; + } +#else + FNPTR(Uniform3i)(location, x, y, z); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform4i)(GLint location, GLint x, GLint y, GLint z, GLint w) { +#define FUNC_NAME "Uniform4i" +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT_VEC4: + case GL_BOOL_VEC4: + FNPTR(Uniform4i)(location, x, y, z, w); + break; + } +#else + FNPTR(Uniform4i)(location, x, y, z, w); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform1iv)(GLint location, GLsizei count, const GLint* v) { +#define FUNC_NAME "Uniform1iv" + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT: + case GL_BOOL: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + FNPTR(Uniform1iv)(location, count, v); + break; + } +#else + FNPTR(Uniform1iv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform2iv)(GLint location, GLsizei count, const GLint* v) { +#define FUNC_NAME "Uniform2iv" + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC3: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC3: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT_VEC2: + case GL_BOOL_VEC2: + FNPTR(Uniform2iv)(location, count, v); + break; + } +#else + FNPTR(Uniform2iv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform3iv)(GLint location, GLsizei count, const GLint* v) { +#define FUNC_NAME "Uniform3iv" + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC4: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC4: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT_VEC3: + case GL_BOOL_VEC3: + FNPTR(Uniform3iv)(location, count, v); + break; + } +#else + FNPTR(Uniform3iv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(Uniform4iv)(GLint location, GLsizei count, const GLint* v) { +#define FUNC_NAME "Uniform4iv" + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } +#ifdef ENABLE_USING_GETACTIVEUNIFORM + GLint iSize; + GLenum eType; + if (ES2INTER(GetUniformSizeType)(FUNC_NAME, location, &iSize, &eType) == GL_FALSE) { + return; + } + if (1 < count && iSize == 1) { + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": uniform of (size=%d,type=%s) is not an array.", + iSize, GET_NAME(eType)); + return; + } + switch (eType) { + default: + assert(0); + case GL_FLOAT: + case GL_FLOAT_VEC2: + case GL_FLOAT_VEC3: + case GL_FLOAT_VEC4: + case GL_INT: + case GL_INT_VEC2: + case GL_INT_VEC3: + case GL_BOOL: + case GL_BOOL_VEC2: + case GL_BOOL_VEC3: + case GL_FLOAT_MAT2: + case GL_FLOAT_MAT3: + case GL_FLOAT_MAT4: + case GL_SAMPLER_2D: + case GL_SAMPLER_CUBE: + SET_ERROR(GL_INVALID_OPERATION, FUNCNAME ": cannot handle uniform of (size=%d,type=%s).", + iSize, GET_NAME(eType)); + return; + case GL_INT_VEC4: + case GL_BOOL_VEC4: + FNPTR(Uniform4iv)(location, count, v); + break; + } +#else + FNPTR(Uniform4iv)(location, count, v); +#endif +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(UniformMatrix2fv)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { +#define FUNC_NAME "UniformMatrix2fv" + GLint iSize; + GLenum eType; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (transpose != GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(UniformMatrix2fv)(location, count, transpose, value); +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(UniformMatrix3fv)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { +#define FUNC_NAME "UniformMatrix3fv" + GLint iSize; + GLenum eType; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (transpose != GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(UniformMatrix3fv)(location, count, transpose, value); +#undef FUNC_NAME +} + +void GL_APIENTRY ES2ENTRY(UniformMatrix4fv)(GLint location, + GLsizei count, GLboolean transpose, const GLfloat* value) { +#define FUNC_NAME "UniformMatrix4fv" + GLint iSize; + GLenum eType; + if ((GLint)(count) < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (transpose != GL_FALSE) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + FNPTR(UniformMatrix4fv)(location, count, transpose, value); +#undef FUNC_NAME +} diff --git a/es_2_0/VertexAttrib.c b/es_2_0/VertexAttrib.c new file mode 100755 index 0000000..041698b --- /dev/null +++ b/es_2_0/VertexAttrib.c @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2ENTRY(VertexAttrib1f)(GLuint indx, GLfloat x) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib1f)(indx, x); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib2f)(GLuint indx, GLfloat x, GLfloat y) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib2f)(indx, x, y); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib3f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib3f)(indx, x, y, z); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib4f)(GLuint indx, GLfloat x, GLfloat y, GLfloat z, GLfloat w) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib4f)(indx, x, y, z, w); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib1fv)(GLuint indx, const GLfloat* values) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib1fv)(indx, values); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib2fv)(GLuint indx, const GLfloat* values) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib2fv)(indx, values); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib3fv)(GLuint indx, const GLfloat* values) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib3fv)(indx, values); +} + +void GL_APIENTRY ES2ENTRY(VertexAttrib4fv)(GLuint indx, const GLfloat* values) { + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + FNPTR(VertexAttrib4fv)(indx, values); +} diff --git a/es_2_0/VertexPointer.c b/es_2_0/VertexPointer.c new file mode 100755 index 0000000..8150641 --- /dev/null +++ b/es_2_0/VertexPointer.c @@ -0,0 +1,211 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + + +void GL_APIENTRY ES2INTER(VertexAttribInit)(struct VertexAttribUnit* pUnit) { + pUnit->bEnabled = GL_FALSE; + pUnit->iSize = 4; + pUnit->eType = GL_FLOAT; + pUnit->bNormalized = GL_FALSE; + pUnit->uStride = 0; + pUnit->pData = NULL; + pUnit->pConverted = NULL; + pUnit->uBufferBinding = 0; +} + +void GL_APIENTRY ES2INTER(VertexAttribRelease)(struct VertexAttribUnit* pUnit) { + if (pUnit->pConverted != NULL) { + free(pUnit->pConverted); + pUnit->pConverted = NULL; + } +} + +void GL_APIENTRY ES2ENTRY(VertexAttribPointer)(GLuint indx, + GLint size, GLenum type, GLboolean normalized, GLsizei stride, const GLvoid* ptr) { + struct VertexAttribUnit* pVertexAttrib; + if (CCV(nMaxVertexAttribs) <= indx) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (size < 1 || 4 < size) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + if (stride < 0) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + switch (type) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_BYTE: + case GL_UNSIGNED_BYTE: + case GL_SHORT: + case GL_UNSIGNED_SHORT: + case GL_FIXED: + case GL_FLOAT: + break; + } + pVertexAttrib = &(CCV(pVertexAttrib[indx])); + pVertexAttrib->iSize = size; + pVertexAttrib->eType = type; + pVertexAttrib->bNormalized = normalized; + if (stride == 0) { + switch (type) { + case GL_BYTE: pVertexAttrib->uStride = size * sizeof(GLbyte); break; + case GL_UNSIGNED_BYTE: pVertexAttrib->uStride = size * sizeof(GLubyte); break; + case GL_SHORT: pVertexAttrib->uStride = size * sizeof(GLshort); break; + case GL_UNSIGNED_SHORT: pVertexAttrib->uStride = size * sizeof(GLushort); break; + case GL_FIXED: pVertexAttrib->uStride = size * sizeof(GLfixed); break; + case GL_FLOAT: pVertexAttrib->uStride = size * sizeof(GLfloat); break; + } + } else { + pVertexAttrib->uStride = stride; + } + pVertexAttrib->pData = ptr; + pVertexAttrib->uBufferBinding = CCV(uArrayBufferBinding); + if (type == GL_FIXED) { + FNPTR(VertexAttribPointer)(indx, size, GL_FLOAT, normalized, stride, ptr); + } else { + FNPTR(VertexAttribPointer)(indx, size, type, normalized, stride, ptr); + } +} + +void GL_APIENTRY ES2ENTRY(EnableVertexAttribArray)(GLuint index) { + if (CCV(nMaxVertexAttribs) <= index) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + CCV(pVertexAttrib[index].bEnabled) = GL_TRUE; + FNPTR(EnableVertexAttribArray)(index); +} + +void GL_APIENTRY ES2ENTRY(DisableVertexAttribArray)(GLuint index) { + if (CCV(nMaxVertexAttribs) <= index) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + CCV(pVertexAttrib[index].bEnabled) = GL_FALSE; + FNPTR(DisableVertexAttribArray)(index); +} + +void GL_APIENTRY ES2ENTRY(GetVertexAttribPointerv)(GLuint index, GLenum pname, void** pointer) { + if (pname != GL_VERTEX_ATTRIB_ARRAY_POINTER) { + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + } + if (CCV(nMaxVertexAttribs) <= index) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + *pointer = (void*)CCV(pVertexAttrib[index].pData); +} + +void GL_APIENTRY ES2ENTRY(GetVertexAttribfv)(GLuint index, GLenum pname, GLfloat* params) { + struct VertexAttribUnit* pVertexAttrib; + if (CCV(nMaxVertexAttribs) <= index) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + pVertexAttrib = &(CCV(pVertexAttrib[index])); + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + *params = (GLfloat)(pVertexAttrib->uBufferBinding); + break; + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + *params = (GLfloat)(pVertexAttrib->bEnabled); + break; + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + *params = (GLfloat)(pVertexAttrib->iSize); + break; + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + *params = (GLfloat)(pVertexAttrib->uStride); + break; + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + *params = (GLfloat)(pVertexAttrib->eType); + break; + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + *params = (GLfloat)(pVertexAttrib->bNormalized); + break; + case GL_CURRENT_VERTEX_ATTRIB: + if (index == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetVertexAttribfv)(index, pname, params); + break; + } +} + +void GL_APIENTRY ES2ENTRY(GetVertexAttribiv)(GLuint index, GLenum pname, GLint* params) { + struct VertexAttribUnit* pVertexAttrib; + if (CCV(nMaxVertexAttribs) <= index) { + ES2INTER(SetError)(GL_INVALID_VALUE); + return; + } + pVertexAttrib = &(CCV(pVertexAttrib[index])); + switch (pname) { + default: + ES2INTER(SetError)(GL_INVALID_ENUM); + return; + case GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING: + *params = (GLint)(pVertexAttrib->uBufferBinding); + break; + case GL_VERTEX_ATTRIB_ARRAY_ENABLED: + *params = (GLint)(pVertexAttrib->bEnabled); + break; + case GL_VERTEX_ATTRIB_ARRAY_SIZE: + *params = (GLint)(pVertexAttrib->iSize); + break; + case GL_VERTEX_ATTRIB_ARRAY_STRIDE: + *params = (GLint)(pVertexAttrib->uStride); + break; + case GL_VERTEX_ATTRIB_ARRAY_TYPE: + *params = (GLint)(pVertexAttrib->eType); + break; + case GL_VERTEX_ATTRIB_ARRAY_NORMALIZED: + *params = (GLint)(pVertexAttrib->bNormalized); + break; + case GL_CURRENT_VERTEX_ATTRIB: + if (index == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } + FNPTR(GetVertexAttribiv)(index, pname, params); + break; + } +} diff --git a/es_2_0/es2front.h b/es_2_0/es2front.h new file mode 100755 index 0000000..f75e206 --- /dev/null +++ b/es_2_0/es2front.h @@ -0,0 +1,411 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef _ES2_FRONT_H_ +#define _ES2_FRONT_H_ + +#include <assert.h> +#include <stdio.h> +#include <string.h> +#include <malloc.h> + +#if defined(WIN32) +#include <windows.h> +#include <GLee/GLee.h> +#define ES2ENTRY(name) OGL2_gl##name +#endif + +#include <GLES2/gl2.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +#if ! defined(WIN32) +#define ES2ENTRY(name) gl##name +#endif +#define ES2INTER(name) _hazel_es2_##name + +#define INTERNAL_NUM_BUFFER_OBJECTS 16 +#define INTERNAL_NUM_SHADER_OBJECTS 16 +#define INTERNAL_NUM_PROGRAM_OBJECTS 16 + +#define fixed_to_float(v) ((float)(v)/(1 << 16)) + +#ifndef GL_VERSION_2_0 +/* GL type for program/shader text */ +typedef char GLchar; /* native character */ +typedef double GLclampd; +#endif + +struct VertexAttribUnit { + GLboolean bEnabled; + GLint iSize; + GLenum eType; + GLboolean bNormalized; + GLsizei uStride; + const GLvoid* pData; + GLvoid* pConverted; + GLuint uBufferBinding; +}; +GL_APICALL void GL_APIENTRY ES2INTER(VertexAttribInit)(struct VertexAttribUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(VertexAttribRelease)(struct VertexAttribUnit* pUnit); + +struct BufferObjectUnit { + GLboolean bGenerated; + GLsizei uSize; + GLenum eUsage; + GLvoid* pData; + GLvoid* pConverted; + GLintptr uOffset; +}; +GL_APICALL void GL_APIENTRY ES2INTER(BufferObjectInit)(struct BufferObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(BufferObjectRelease)(struct BufferObjectUnit* pUnit); + +struct SymbolEntry { + char* formal; + char* actual; + int nparams; + int start; +}; +GL_APICALL void GL_APIENTRY ES2INTER(MacroInit)(void); +GL_APICALL void GL_APIENTRY ES2INTER(MacroSetLineFile)(int iLine, int iFile); +GL_APICALL void GL_APIENTRY ES2INTER(MacroRelease)(void); +GL_APICALL struct SymbolEntry* GL_APIENTRY ES2INTER(MacroSearchParam)(char* name, int start, int n); +GL_APICALL struct SymbolEntry* GL_APIENTRY ES2INTER(MacroSearchMacro)(char* name); +GL_APICALL struct SymbolEntry* GL_APIENTRY ES2INTER(MacroAppend)(char* name, char* body); +GL_APICALL GLboolean GL_APIENTRY ES2INTER(MacroUndef)(char* name); +GL_APICALL GLboolean GL_APIENTRY ES2INTER(MacroDefineName)(char* name, char* body); +GL_APICALL GLboolean GL_APIENTRY ES2INTER(MacroDefineFunc)(char* head, char* body); +GL_APICALL char* GL_APIENTRY ES2INTER(MacroExpand)(char* src, int detailed); + + +#define T_VOID 0x0010 +#define T_BOOL 0x0021 +#define T_INT 0x0031 +#define T_FLOAT 0x0041 +#define T_BVEC2 0x0022 +#define T_BVEC3 0x0023 +#define T_BVEC4 0x0024 +#define T_IVEC2 0x0032 +#define T_IVEC3 0x0033 +#define T_IVEC4 0x0034 +#define T_VEC2 0x0042 +#define T_VEC3 0x0043 +#define T_VEC4 0x0044 +#define T_MAT2 0x0052 +#define T_MAT3 0x0053 +#define T_MAT4 0x0054 +#define T_SAMPLER2D 0x0062 +#define T_SAMPLER3D 0x0063 +#define T_SAMPLERCUBE 0x0072 +#define T_STRUCT_DCL 0x0081 +#define T_STRUCT_DEF 0x0082 +#define T_STRUCT_VAR 0x0083 +#define T_FUNC_DCL 0x0091 +#define T_FUNC_DEF 0x0092 +#define T_FUNC_CALL 0x0093 +#define T_IDENTIFER 0x00F1 +#define T_KEYWORD 0x00F2 +#define T_OPERATOR 0x00F3 +#define GET_TYPE(type) ((type) & 0xFFFF) +#define S_HIGHP 0x00001000 +#define S_MEDIUMP 0x00002000 +#define S_LOWP 0x00004000 +#define S_IN 0x00010000 +#define S_OUT 0x00020000 +#define S_INOUT 0x00040000 +#define S_CONST 0x00100000 +#define S_ATTRIBUTE 0x00200000 +#define S_VARYING 0x00400000 +#define S_UNIFORM 0x00800000 +#define IS_CONST(type) (((type) & S_CONST) != 0) +#define S_INVARIANT 0x10000000 + +struct TableEntry { + char* name; + int type; + int dim; + struct TableEntry* ptr; + union { + int nparams; + int ival; + float fval; + void* data; + }; +}; + +int GL_APIENTRY ES2INTER(ProcSwizzler)(int basetype, char* swizzler); + +#define MAX_SYMBOL_LEVEL 32 +struct ShaderObjectUnit { + GLenum eShaderType; + GLboolean bDeleteStatus; + GLboolean bCompileStatus; + GLint nAttached; + GLchar** aStrSource; + GLsizei nSourceAlloc; + GLsizei nSourceUsed; + GLsizei nSourceLength; + GLchar* strInfoLog; + GLsizei nInfoLogAlloc; + GLchar* strPreped; + GLsizei nPrepedAlloc; + struct TableEntry* symbolTable[MAX_SYMBOL_LEVEL]; + int symbolAllocated[MAX_SYMBOL_LEVEL]; + int symbolUsed[MAX_SYMBOL_LEVEL]; + int symbolLevel; +}; +GL_APICALL void GL_APIENTRY ES2INTER(ShaderObjectInit)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ShaderObjectRelease)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ShaderObjectInfoLogReset)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ShaderObjectInfoLogAppend)(struct ShaderObjectUnit* pUnit, + const char* format, ...); +GL_APICALL void GL_APIENTRY ES2INTER(ShaderObjectPrepedReset)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ShaderObjectPrepedAppend)(struct ShaderObjectUnit* pUnit, + const char* strBuf, int nLenBuf); + +GL_APICALL void GL_APIENTRY ES2INTER(LevelInit)(struct ShaderObjectUnit* pUnit, int level); +GL_APICALL void GL_APIENTRY ES2INTER(LevelRelease)(struct ShaderObjectUnit* pUnit, int level); +GL_APICALL void GL_APIENTRY ES2INTER(ScopeBegin)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ScopeEnd)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(SymbolInit)(struct ShaderObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(SymbolRelease)(struct ShaderObjectUnit* pUnit); + +GL_APICALL struct TableEntry* GL_APIENTRY ES2INTER(SearchSymbol)(struct ShaderObjectUnit* pUnit, + char* name, int* pLevelReturn); +GL_APICALL struct TableEntry* GL_APIENTRY ES2INTER(AppendSymbol)(struct ShaderObjectUnit* pUnit, + char* name, int type); + +struct ProgramObjectUnit { + GLboolean bLinkStatus; + GLchar* strInfoLog; +}; +GL_APICALL void GL_APIENTRY ES2INTER(ProgramObjectInit)(struct ProgramObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ProgramObjectRelease)(struct ProgramObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ProgramObjectInfoLogReset)(struct ProgramObjectUnit* pUnit); +GL_APICALL void GL_APIENTRY ES2INTER(ProgramObjectInfoLogAppend)(struct ProgramObjectUnit* pUnit, + const char* format, ...); + +struct es2Context { + + GLboolean bShaderCompiler; + GLint nMaxVertexAttribs; + GLenum eError; + struct VertexAttribUnit* pVertexAttrib; + GLuint uArrayBufferBinding; + GLuint uElementArrayBufferBinding; + struct BufferObjectUnit* pBufferObject; + GLint nBufferObjectAllocated; + struct ShaderObjectUnit* pShaderObject; + GLint nShaderObjectAllocated; + struct ProgramObjectUnit* pProgramObject; + GLint nProgramObjectAllocated; + GLenum (*fpGetError)(void); + void (*fpEnable)(GLenum); + void (*fpDisable)(GLenum); + GLboolean (*fpIsEnabled)(GLenum); + void (*fpVertexAttrib1f)(GLuint, GLfloat); + void (*fpVertexAttrib2f)(GLuint, GLfloat, GLfloat); + void (*fpVertexAttrib3f)(GLuint, GLfloat, GLfloat, GLfloat); + void (*fpVertexAttrib4f)(GLuint, GLfloat, GLfloat, GLfloat, GLfloat); + void (*fpVertexAttrib1fv)(GLuint, const GLfloat*); + void (*fpVertexAttrib2fv)(GLuint, const GLfloat*); + void (*fpVertexAttrib3fv)(GLuint, const GLfloat*); + void (*fpVertexAttrib4fv)(GLuint, const GLfloat*); + GLuint (*fpCreateShader)(GLenum); + void (*fpShaderSource)(GLuint, GLsizei, const GLchar**, const GLint*); + void (*fpCompileShader)(GLuint); + void (*fpDeleteShader)(GLuint); + void (*fpGetShaderInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*); + void (*fpGetShaderSource)(GLuint, GLsizei, GLsizei*, GLchar*); + void (*fpGetShaderiv)(GLuint, GLenum, GLint*); + GLboolean (*fpIsShader)(GLuint); + GLuint (*fpCreateProgram)(void); + void (*fpAttachShader)(GLuint, GLuint); + void (*fpDetachShader)(GLuint, GLuint); + void (*fpLinkProgram)(GLuint); + void (*fpUseProgram)(GLuint); + void (*fpDeleteProgram)(GLuint); + void (*fpValidateProgram)(GLuint); + void (*fpGetAttachedShaders)(GLuint, GLsizei, GLsizei*, GLuint*); + void (*fpGetProgramInfoLog)(GLuint, GLsizei, GLsizei*, GLchar*); + void (*fpGetProgramiv)(GLuint, GLenum, GLint*); + GLboolean (*fpIsProgram)(GLuint); + void (*fpGetActiveUniform)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*); + GLint (*fpGetUniformLocation)(GLuint, const GLchar*); + void (*fpGetUniformfv)(GLuint, GLint, GLfloat*); + void (*fpGetUniformiv)(GLuint, GLint, GLint*); + void (*fpUniform1f)(GLint, GLfloat); + void (*fpUniform2f)(GLint, GLfloat, GLfloat); + void (*fpUniform3f)(GLint, GLfloat, GLfloat, GLfloat); + void (*fpUniform4f)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); + void (*fpUniform1i)(GLint, GLint); + void (*fpUniform2i)(GLint, GLint, GLint); + void (*fpUniform3i)(GLint, GLint, GLint, GLint); + void (*fpUniform4i)(GLint, GLint, GLint, GLint, GLint); + void (*fpUniform1fv)(GLint, GLsizei, const GLfloat*); + void (*fpUniform2fv)(GLint, GLsizei, const GLfloat*); + void (*fpUniform3fv)(GLint, GLsizei, const GLfloat*); + void (*fpUniform4fv)(GLint, GLsizei, const GLfloat*); + void (*fpUniform1iv)(GLint, GLsizei, const GLint*); + void (*fpUniform2iv)(GLint, GLsizei, const GLint*); + void (*fpUniform3iv)(GLint, GLsizei, const GLint*); + void (*fpUniform4iv)(GLint, GLsizei, const GLint*); + void (*fpUniformMatrix2fv)(GLint, GLsizei, GLboolean, const GLfloat*); + void (*fpUniformMatrix3fv)(GLint, GLsizei, GLboolean, const GLfloat*); + void (*fpUniformMatrix4fv)(GLint, GLsizei, GLboolean, const GLfloat*); + void (*fpVertexAttribPointer)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*); + void (*fpEnableVertexAttribArray)(GLuint); + void (*fpDisableVertexAttribArray)(GLuint); + void (*fpGetVertexAttribPointerv)(GLuint, GLenum, void**); + void (*fpGetVertexAttribfv)(GLuint, GLenum, GLfloat*); + void (*fpGetVertexAttribiv)(GLuint, GLenum, GLint*); + void (*fpGetActiveAttrib)(GLuint, GLuint, GLsizei, GLsizei*, GLint*, GLenum*, GLchar*); + GLint (*fpGetAttribLocation)(GLuint, const GLchar*); + void (*fpBindAttribLocation)(GLuint, GLuint, const GLchar*); + void (*fpGenBuffers)(GLsizei, GLuint*); + void (*fpDeleteBuffers)(GLsizei, const GLuint*); + GLboolean (*fpIsBuffer)(GLuint); + void (*fpBindBuffer)(GLenum, GLuint); + void (*fpBufferData)(GLenum, GLsizeiptr, const GLvoid*, GLenum); + void (*fpBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid*); + void (*fpGetBufferSubData)(GLenum, GLintptr, GLsizeiptr, const GLvoid* data); + void (*fpDrawArrays)(GLenum, GLint, GLsizei); + void (*fpDrawElements)(GLenum, GLsizei, GLenum, const void*); + void (*fpLineWidth)(GLfloat); + void (*fpDepthRange)(GLclampd, GLclampd); + void (*fpViewport)(GLint, GLint, GLsizei, GLsizei); + void (*fpCullFace)(GLenum); + void (*fpFrontFace)(GLenum); + void (*fpPolygonOffset)(GLfloat, GLfloat); + void (*fpGenTextures)(GLsizei, GLuint*); + void (*fpDeleteTextures)(GLsizei, const GLuint*); + GLboolean (*fpIsTexture)(GLuint); + void (*fpBindTexture)(GLenum, GLuint); + void (*fpPixelStorei)(GLenum, GLint); + void (*fpActiveTexture)(GLenum); + void (*fpGenerateMipmap)(GLenum); + void (*fpTexParameteri)(GLenum, GLenum, GLint); + void (*fpGetTexParameterfv)(GLenum, GLenum, GLfloat*); + void (*fpGetTexParameteriv)(GLenum, GLenum, GLint*); + void (*fpTexImage2D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); + void (*fpTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); + void (*fpGetTexLevelParameteriv)(GLenum, GLint, GLenum, GLint*); + void (*fpCopyTexImage2D)(GLenum, GLint, GLenum, GLint, GLint, GLsizei, GLsizei, GLint); + void (*fpCopyTexSubImage2D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); + void (*fpCompressedTexImage2D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); + void (*fpCompressedTexSubImage2D)(GLenum, GLint, GLint, GLint, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); + void (*fpClear)(GLbitfield); + void (*fpClearColor)(GLclampf, GLclampf, GLclampf, GLclampf); + void (*fpClearDepth)(GLclampd); + void (*fpClearStencil)(GLint); + void (*fpColorMask)(GLboolean, GLboolean, GLboolean, GLboolean); + void (*fpDepthMask)(GLboolean); + void (*fpStencilMask)(GLuint); + void (*fpStencilMaskSeparate)(GLenum, GLuint); + void (*fpScissor)(GLint, GLint, GLsizei, GLsizei); + void (*fpStencilFunc)(GLenum, GLint, GLuint); + void (*fpStencilFuncSeparate)(GLenum, GLenum, GLint, GLuint); + void (*fpStencilOp)(GLenum, GLenum, GLenum); + void (*fpStencilOpSeparate)(GLenum, GLenum, GLenum, GLenum); + void (*fpDepthFunc)(GLenum); + void (*fpBlendFunc)(GLenum, GLenum); + void (*fpBlendFuncSeparate)(GLenum, GLenum, GLenum, GLenum); + void (*fpBlendColor)(GLclampf, GLclampf, GLclampf, GLclampf); + void (*fpBlendEquation)(GLenum); + void (*fpBlendEquationSeparate)(GLenum, GLenum); + void (*fpSampleCoverage)(GLclampf, GLboolean); + void (*fpReadPixels)(GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*); + void (*fpFlush)(void); + void (*fpFinish)(void); + void (*fpHint)(GLenum, GLenum); + const GLubyte* (*fpGetString)(GLenum); + void (*fpGetFloatv)(GLenum, GLfloat*); + void (*fpGetIntegerv)(GLenum, GLint*); + void (*fpGetBooleanv)(GLenum, GLboolean*); + void (*fpGenFramebuffers)(GLsizei, GLuint*); + void (*fpGenRenderbuffers)(GLsizei, GLuint*); + void (*fpDeleteFramebuffers)(GLsizei, const GLuint*); + void (*fpDeleteRenderbuffers)(GLsizei, const GLuint*); + GLboolean (*fpIsFramebuffer)(GLuint); + GLboolean (*fpIsRenderbuffer)(GLuint); + void (*fpBindFramebuffer)(GLenum, GLuint); + void (*fpBindRenderbuffer)(GLenum, GLuint); + void (*fpRenderbufferStorage)(GLenum, GLenum, GLsizei, GLsizei); + void (*fpGetRenderbufferParameteriv)(GLenum, GLenum, GLint*); + void (*fpFramebufferRenderbuffer)(GLenum, GLenum, GLenum, GLuint); + void (*fpFramebufferTexture2D)(GLenum, GLenum, GLenum, GLuint, GLint); + void (*fpGetFramebufferAttachmentParameteriv)(GLenum, GLenum, GLenum, GLint*); + GLenum (*fpCheckFramebufferStatus)(GLenum); +#if defined(PROVIDING_OES_texture_3D) + void (*fpTexImage3D)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); + void (*fpTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*); + void (*fpCopyTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLint, GLint, GLsizei, GLsizei); + void (*fpCompressedTexImage3D)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*); + void (*fpCompressedTexSubImage3D)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLsizei, const GLvoid*); + void (*fpFramebufferTexture3D)(GLenum, GLenum, GLenum, GLuint, GLint, GLint); +#endif +}; + +extern struct es2Context* ES2INTER(curContext); + +#define CCV(name) (ES2INTER(curContext)->name) +#if defined(WIN32) +#define FNPTR(name) gl##name +#else +#define FNPTR(name) (ES2INTER(curContext)->fp##name) +#endif + +GL_APICALL void GL_APIENTRY ES2INTER(NotBound)(void); +GL_APICALL void GL_APIENTRY ES2INTER(ResetFnptrs)(struct es2Context* pContext); +GL_APICALL void GL_APIENTRY ES2INTER(BindFnptrs)(struct es2Context* pContext); + +#define EGLCROSS(name) __hazel_cross__##name + +GL_APICALL void* GL_APIENTRY EGLCROSS(CreateContext)(void); +GL_APICALL void GL_APIENTRY EGLCROSS(MakeCurrent)(void*); +GL_APICALL void GL_APIENTRY EGLCROSS(ReleaseContext)(void*); + +#define CHECK_ERROR (void)(0) + +GL_APICALL void GL_APIENTRY ES2INTER(SetError)(GLenum eErrorCode); +#define SET_ERROR(code,...) ES2INTER(SetError)(code) + +GL_APICALL int GL_APIENTRY ES2INTER(Log2)(GLint x); + +#ifdef __cplusplus +} +#endif + + +#endif diff --git a/es_2_0/funcaction.inl b/es_2_0/funcaction.inl new file mode 100755 index 0000000..22a29f8 --- /dev/null +++ b/es_2_0/funcaction.inl @@ -0,0 +1,145 @@ + ACTION( GetError ); + ACTION( Enable ); + ACTION( Disable ); + ACTION( IsEnabled ); + ACTION( VertexAttrib1f ); + ACTION( VertexAttrib2f ); + ACTION( VertexAttrib3f ); + ACTION( VertexAttrib4f ); + ACTION( VertexAttrib1fv ); + ACTION( VertexAttrib2fv ); + ACTION( VertexAttrib3fv ); + ACTION( VertexAttrib4fv ); + ACTION( CreateShader ); + ACTION( ShaderSource ); + ACTION( CompileShader ); + ACTION( DeleteShader ); + ACTION( GetShaderInfoLog ); + ACTION( GetShaderSource ); + ACTION( GetShaderiv ); + ACTION( IsShader ); + ACTION( CreateProgram ); + ACTION( AttachShader ); + ACTION( DetachShader ); + ACTION( LinkProgram ); + ACTION( UseProgram ); + ACTION( DeleteProgram ); + ACTION( ValidateProgram ); + ACTION( GetAttachedShaders ); + ACTION( GetProgramInfoLog ); + ACTION( GetProgramiv ); + ACTION( IsProgram ); + ACTION( GetActiveUniform ); + ACTION( GetUniformLocation ); + ACTION( GetUniformfv ); + ACTION( GetUniformiv ); + ACTION( Uniform1f ); + ACTION( Uniform2f ); + ACTION( Uniform3f ); + ACTION( Uniform4f ); + ACTION( Uniform1i ); + ACTION( Uniform2i ); + ACTION( Uniform3i ); + ACTION( Uniform4i ); + ACTION( Uniform1fv ); + ACTION( Uniform2fv ); + ACTION( Uniform3fv ); + ACTION( Uniform4fv ); + ACTION( Uniform1iv ); + ACTION( Uniform2iv ); + ACTION( Uniform3iv ); + ACTION( Uniform4iv ); + ACTION( UniformMatrix2fv ); + ACTION( UniformMatrix3fv ); + ACTION( UniformMatrix4fv ); + ACTION( VertexAttribPointer ); + ACTION( EnableVertexAttribArray ); + ACTION( DisableVertexAttribArray ); + ACTION( GetVertexAttribPointerv ); + ACTION( GetVertexAttribfv ); + ACTION( GetVertexAttribiv ); + ACTION( GetActiveAttrib ); + ACTION( GetAttribLocation ); + ACTION( BindAttribLocation ); + ACTION( GenBuffers ); + ACTION( DeleteBuffers ); + ACTION( IsBuffer ); + ACTION( BindBuffer ); + ACTION( BufferData ); + ACTION( BufferSubData ); + ACTION( GetBufferSubData ); + ACTION( DrawArrays ); + ACTION( DrawElements ); + ACTION( LineWidth ); + ACTION( DepthRange ); + ACTION( Viewport ); + ACTION( CullFace ); + ACTION( FrontFace ); + ACTION( PolygonOffset ); + ACTION( GenTextures ); + ACTION( DeleteTextures ); + ACTION( IsTexture ); + ACTION( BindTexture ); + ACTION( PixelStorei ); + ACTION( ActiveTexture ); + ACTION( GenerateMipmap ); + ACTION( TexParameteri ); + ACTION( GetTexParameterfv ); + ACTION( GetTexParameteriv ); + ACTION( TexImage2D ); + ACTION( TexSubImage2D ); + ACTION( GetTexLevelParameteriv ); + ACTION( CopyTexImage2D ); + ACTION( CopyTexSubImage2D ); + ACTION( CompressedTexImage2D ); + ACTION( CompressedTexSubImage2D ); + ACTION( Clear ); + ACTION( ClearColor ); + ACTION( ClearDepth ); + ACTION( ClearStencil ); + ACTION( ColorMask ); + ACTION( DepthMask ); + ACTION( StencilMask ); + ACTION( StencilMaskSeparate ); + ACTION( Scissor ); + ACTION( StencilFunc ); + ACTION( StencilFuncSeparate ); + ACTION( StencilOp ); + ACTION( StencilOpSeparate ); + ACTION( DepthFunc ); + ACTION( BlendFunc ); + ACTION( BlendFuncSeparate ); + ACTION( BlendColor ); + ACTION( BlendEquation ); + ACTION( BlendEquationSeparate ); + ACTION( SampleCoverage ); + ACTION( ReadPixels ); + ACTION( Flush ); + ACTION( Finish ); + ACTION( Hint ); + ACTION( GetString ); + ACTION( GetFloatv ); + ACTION( GetIntegerv ); + ACTION( GetBooleanv ); + ACTION( GenFramebuffers ); + ACTION( GenRenderbuffers ); + ACTION( DeleteFramebuffers ); + ACTION( DeleteRenderbuffers ); + ACTION( IsFramebuffer ); + ACTION( IsRenderbuffer ); + ACTION( BindFramebuffer ); + ACTION( BindRenderbuffer ); + ACTION( RenderbufferStorage ); + ACTION( GetRenderbufferParameteriv ); + ACTION( FramebufferRenderbuffer ); + ACTION( FramebufferTexture2D ); + ACTION( GetFramebufferAttachmentParameteriv ); + ACTION( CheckFramebufferStatus ); +#if defined(PROVIDING_OES_texture_3D) + ACTION( TexImage3D ); + ACTION( TexSubImage3D ); + ACTION( CopyTexSubImage3D ); + ACTION( CompressedTexImage3D ); + ACTION( CompressedTexSubImage3D ); + ACTION( FramebufferTexture3D ); +#endif diff --git a/es_2_0/internal.c b/es_2_0/internal.c new file mode 100755 index 0000000..65647d1 --- /dev/null +++ b/es_2_0/internal.c @@ -0,0 +1,226 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" + +#if ! defined(WIN32) +#include <dlfcn.h> +#endif +#include <malloc.h> + +static struct es2Context s_defaultContext = { + GL_FALSE, + 0, + GL_NO_ERROR, + NULL, 0, 0, + NULL, 0, + NULL, 0, + NULL, 0, + (void*)(&(ES2INTER(NotBound))), +}; + +static struct es2Context s_context = { + GL_FALSE, + 0, + GL_NO_ERROR, + NULL, 0, 0, + NULL, 0, + NULL, 0, + NULL, 0, + (void*)(&(ES2INTER(NotBound))), +}; + +struct es2Context* ES2INTER(curContext) = &s_context; + +void GL_APIENTRY ES2INTER(NotBound)(void) { + fprintf(stderr, "ES2 internal error: you are calling not-bound function\n"); +} + +void GL_APIENTRY ES2INTER(ResetFnptrs)(struct es2Context* pContext) { +#define ACTION(name) do { \ + *(void**)(&pContext->fp##name) = (void*)(&(ES2INTER(NotBound))); \ + } while (0) +#include "funcaction.inl" +#undef ACTION +} + +void GL_APIENTRY ES2INTER(BindFnptrs)(struct es2Context* pContext) { +#if ! defined(WIN32) + void* dl; + if ((dl = dlopen("libGL.so", RTLD_NOW | RTLD_GLOBAL)) == 0) { + ES2INTER(SetError)(GL_INVALID_OPERATION); + return; + } +#define ACTION(name) do { \ + *(void**)(&pContext->fp##name) = dlsym(dl, "gl" #name ); \ + if (pContext->fp##name == NULL) { \ + *(void**)(&pContext->fp##name) = dlsym(dl, "gl" #name "EXT"); \ + assert(pContext->fp##name != NULL) ; \ + if (pContext->fp##name == NULL) { \ + *(void**)(&pContext->fp##name) = (void*)(&(ES2INTER(NotBound))); \ + } \ + } \ + } while (0) +#include "funcaction.inl" +#undef ACTION + dlclose(dl); +#endif +} + + +void* GL_APIENTRY EGLCROSS(CreateContext)(void) { + struct es2Context* pContext = malloc(sizeof(struct es2Context)); + if (pContext == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return NULL; + } + memcpy(pContext, &s_defaultContext, sizeof(struct es2Context)); + ES2INTER(ResetFnptrs)(pContext); + return pContext; +} + +void GL_APIENTRY EGLCROSS(MakeCurrent)(void* ptr) { + int i; + struct es2Context* pContext = (struct es2Context*)ptr; + if (ptr == NULL) { + ES2INTER(curContext) = &s_context; + return; + } + ES2INTER(BindFnptrs)(pContext); + ES2INTER(curContext) = pContext; + pContext->bShaderCompiler = GL_TRUE; + FNPTR(GetIntegerv)(GL_MAX_VERTEX_ATTRIBS, &pContext->nMaxVertexAttribs); + assert(8 <= pContext->nMaxVertexAttribs); + if (pContext->pVertexAttrib == NULL) { + pContext->pVertexAttrib = calloc(pContext->nMaxVertexAttribs, + sizeof(struct VertexAttribUnit)); + if (pContext->pVertexAttrib == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return; + } + for (i = 0; i < pContext->nMaxVertexAttribs; i++) { + ES2INTER(VertexAttribInit)(&(pContext->pVertexAttrib[i])); + } + pContext->uArrayBufferBinding = 0; + pContext->uElementArrayBufferBinding = 0; + } + if (pContext->pBufferObject == NULL) { + pContext->pBufferObject = calloc(INTERNAL_NUM_BUFFER_OBJECTS, + sizeof(struct BufferObjectUnit)); + if (pContext->pBufferObject == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return; + } + pContext->nBufferObjectAllocated = INTERNAL_NUM_BUFFER_OBJECTS; + for (i = 0; i < pContext->nBufferObjectAllocated; i++) { + ES2INTER(BufferObjectInit)(&(pContext->pBufferObject[i])); + } + pContext->pBufferObject[0].bGenerated = GL_TRUE; + } + if (pContext->pShaderObject == NULL) { + pContext->pShaderObject = calloc(INTERNAL_NUM_SHADER_OBJECTS, + sizeof(struct ShaderObjectUnit)); + if (pContext->pShaderObject == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return; + } + pContext->nShaderObjectAllocated = INTERNAL_NUM_SHADER_OBJECTS; + for (i = 0; i < pContext->nShaderObjectAllocated; i++) { + ES2INTER(ShaderObjectInit)(&(pContext->pShaderObject[i])); + } + } + if (pContext->pProgramObject == NULL) { + pContext->pProgramObject = calloc(INTERNAL_NUM_PROGRAM_OBJECTS, + sizeof(struct ProgramObjectUnit)); + if (pContext->pProgramObject == NULL) { + ES2INTER(SetError)(GL_OUT_OF_MEMORY); + return; + } + pContext->nProgramObjectAllocated = INTERNAL_NUM_PROGRAM_OBJECTS; + for (i = 0; i < pContext->nProgramObjectAllocated; i++) { + ES2INTER(ProgramObjectInit)(&(pContext->pProgramObject[i])); + } + } + /* from the sepc., + The values in gl_PointCoord are two-dimensional coordinates indicating + where within a point primitive the current fragment is located, when point + sprites are enabled. They range from 0.0 to 1.0 across the point. If the + current primitive is not a point, or if point sprites are not enabled, + then the values read from gl_PointCoord are undefined. + */ +#if ! defined(GL_POINT_SPRITE) +#define GL_POINT_SPRITE 0x8861 +#endif +#if ! defined(GL_VERTEX_PROGRAM_POINT_SIZE) +#define GL_VERTEX_PROGRAM_POINT_SIZE 0x8642 +#endif + FNPTR(Enable)(GL_POINT_SPRITE); + FNPTR(Enable)(GL_VERTEX_PROGRAM_POINT_SIZE); +} + +void GL_APIENTRY EGLCROSS(ReleaseContext)(void* ptr) { + int i; + struct es2Context* pContext = (struct es2Context*)ptr; + if (ptr == NULL) return; + if (pContext == &s_context) return; + if (pContext->pVertexAttrib != NULL) { + for (i = 0; i < pContext->nMaxVertexAttribs; i++) { + ES2INTER(VertexAttribRelease)(&(pContext->pVertexAttrib[i])); + } + free(pContext->pVertexAttrib); + pContext->pVertexAttrib = NULL; + } + if (pContext->pBufferObject == NULL) { + for (i = 0; i < pContext->nBufferObjectAllocated; i++) { + ES2INTER(BufferObjectRelease)(&(pContext->pBufferObject[i])); + } + free(pContext->pBufferObject); + pContext->pBufferObject = NULL; + } + if (pContext->pShaderObject == NULL) { + for (i = 0; i < pContext->nShaderObjectAllocated; i++) { + ES2INTER(ShaderObjectRelease)(&(pContext->pShaderObject[i])); + } + free(pContext->pShaderObject); + pContext->pShaderObject = NULL; + } + if (pContext->pProgramObject == NULL) { + for (i = 0; i < pContext->nProgramObjectAllocated; i++) { + ES2INTER(ProgramObjectRelease)(&(pContext->pProgramObject[i])); + } + free(pContext->pProgramObject); + pContext->pProgramObject = NULL; + } + free(pContext); + if (pContext == ES2INTER(curContext)) { + ES2INTER(curContext) = &s_context; + } +} diff --git a/es_2_0/macro.c b/es_2_0/macro.c new file mode 100755 index 0000000..a2ff857 --- /dev/null +++ b/es_2_0/macro.c @@ -0,0 +1,508 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <ctype.h> + + +#define SIMPLE_MACRO -2 + +static struct SymbolEntry* symbolTable = NULL; +static int symbolAllocated = 0; +static int symbolUsed = 0; + +struct SymbolEntry* GL_APIENTRY ES2INTER(MacroAppend)(char* name, char* body); + +void GL_APIENTRY ES2INTER(MacroInit)(void) { + struct SymbolEntry* ptr; + assert(symbolTable == NULL); + assert(symbolAllocated == 0); + symbolAllocated = 64; + symbolUsed = 0; + symbolTable = calloc(symbolAllocated, sizeof(struct SymbolEntry)); + ptr = ES2INTER(MacroAppend)("__LINE__", " "); + ptr->nparams = SIMPLE_MACRO; + ptr = ES2INTER(MacroAppend)("__FILE__", " "); + ptr->nparams = SIMPLE_MACRO; + ptr = ES2INTER(MacroAppend)("__VERSION__", "100"); + ptr->nparams = SIMPLE_MACRO; + ptr = ES2INTER(MacroAppend)("GL_ES", "1"); + ptr->nparams = SIMPLE_MACRO; +} + +void GL_APIENTRY ES2INTER(MacroSetLineFile)(int iLine, int iFile) { + sprintf(symbolTable[0].actual, "%d", iLine); + sprintf(symbolTable[1].actual, "%d", iFile); +} + +void GL_APIENTRY ES2INTER(MacroRelease)(void) { + int i; + assert(symbolTable != NULL); + assert(symbolAllocated != 0); + for (i = 0; i < symbolUsed; i++) { + if (symbolTable[i].formal != NULL) free(symbolTable[i].formal); + if (symbolTable[i].actual != NULL) free(symbolTable[i].actual); + } + free(symbolTable); + symbolTable = NULL; + symbolAllocated = 0; + symbolUsed = 0; +} + +struct SymbolEntry* GL_APIENTRY ES2INTER(MacroSearchParam)(char* name, int start, int nparams) { + struct SymbolEntry* ptr = &(symbolTable[start]); + while (nparams--) { + assert(ptr->formal != NULL); + assert(ptr->nparams == -1); + if (strcmp(name, ptr->formal) == 0) { + return ptr; + } + ptr++; + } + return NULL; +} + +struct SymbolEntry* GL_APIENTRY ES2INTER(MacroSearchMacro)(char* name) { + struct SymbolEntry* ptr = &(symbolTable[0]); + int count = symbolUsed; + while (count--) { + if (ptr->formal != NULL && ptr->nparams != -1 && strcmp(name, ptr->formal) == 0) { + return ptr; + } + ptr++; + } + return NULL; +} + +struct SymbolEntry* GL_APIENTRY ES2INTER(MacroAppend)(char* name, char* body) { + struct SymbolEntry* ptr; + assert(name != NULL && name[0] != '\0'); + if (symbolUsed == symbolAllocated) { + int oldAllocated = symbolAllocated; + symbolAllocated *= 2; + symbolTable = realloc(symbolTable, symbolAllocated * sizeof(struct SymbolEntry)); + memset(&(symbolTable[oldAllocated]), 0, oldAllocated * sizeof(struct SymbolEntry)); + } + ptr = &(symbolTable[symbolUsed++]); + ptr->formal = malloc(strlen(name) + 1); + strcpy(ptr->formal, name); + if (body != NULL) { + ptr->actual = realloc(ptr->actual, strlen(body) + 1); + strcpy(ptr->actual, body); + } else { + ptr->actual = NULL; + } + return ptr; +} + + +void ES2INTER(MacroSetActualValue)(struct SymbolEntry* ptrParam, char* first, char* last) { + int len; + last--; + while (isspace(*last)) last--; + len = last - first + 1; + assert(len > 0); + ptrParam->actual = realloc(ptrParam->actual, len + 1); + strncpy(ptrParam->actual, first, len); + ptrParam->actual[len] = '\0'; +} + + +int ES2INTER(MacroExpandFunc)(struct SymbolEntry* ptrIden, int nparams, char* dst) { +#define PUTCHAR(c) do { \ + if (dst != NULL) *dst++ = c; n++; \ + } while (0) + struct SymbolEntry* ptrParam; + int n = 0; + int state = 0; + char* src = ptrIden->actual; + char* iden; + int c; + if (nparams != ptrIden->nparams) return -1; + PUTCHAR(' '); + do { + c = *src++; + switch (state) { + case 0: + if (isalpha(c) || c == '_') { iden = (src - 1); state = 1; } + else if (c != '\0') { PUTCHAR(c); /* state = 0; */ } + break; + case 1: + if (isalnum(c) || c == '_') { state = 1; } + else { + *--src = '\0'; + ptrParam = ES2INTER(MacroSearchParam)(iden, ptrIden->start, ptrIden->nparams); + if (ptrParam == NULL) { + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + assert(iden == src); + } else { + iden = ptrParam->actual; + PUTCHAR(' '); + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + } + *src = c; + state = 0; + } + break; + default: + assert(0); + break; + } + } while (c != '\0'); + assert(state == 0); + return n; +#undef PUTCHAR +} + +GLboolean GL_APIENTRY ES2INTER(MacroUndef)(char* name) { + register struct SymbolEntry* ptr = ES2INTER(MacroSearchMacro)(name); + if (ptr == NULL) return GL_FALSE; + if (ptr->nparams > 0) { + register struct SymbolEntry* qtr = &(symbolTable[ptr->start]); + register int nparams = ptr->nparams; + while (nparams--) { + assert(qtr->formal != NULL); + assert(qtr->nparams == -1); + free(qtr->formal); + qtr->formal = NULL; + if (qtr->actual != NULL) { + free(qtr->actual); + qtr->actual = NULL; + } + qtr++; + } + } + assert(ptr->formal != NULL); + assert(ptr->actual != NULL); + assert(ptr->nparams != -1); + free(ptr->formal); + ptr->formal = NULL; + free(ptr->actual); + ptr->actual = NULL; + return GL_TRUE; +} + +GLboolean GL_APIENTRY ES2INTER(MacroDefineName)(char* name, char* body) { + register struct SymbolEntry* ptr = ES2INTER(MacroSearchMacro)(name); + if (ptr != NULL) return GL_FALSE; + ptr = ES2INTER(MacroAppend)(name, body); + if (ptr == NULL) return GL_FALSE; + ptr->nparams = SIMPLE_MACRO; + return GL_TRUE; +} + +GLboolean GL_APIENTRY ES2INTER(MacroDefineFunc)(char* head, char* body) { + struct SymbolEntry* ptr; + struct SymbolEntry* qtr; + char* p; + char* s; + int iState; + for (p = head; *p != '('; p++) ; + *p++ = '\0'; + ptr = ES2INTER(MacroSearchMacro)(head); + if (ptr != NULL) return GL_FALSE; + ptr = ES2INTER(MacroAppend)(head, body); + if (ptr == NULL) return GL_FALSE; + ptr->nparams = 0; + ptr->start = symbolUsed; + iState = 0; + while (1) { + register char c = *p; + switch (iState) { + case 0: + if (isspace(c)) { iState = 0; } + else if (isalpha(c) || c == '_') { s = p; iState = 1; } + else if (c == '.') { iState = 5; } + else if (c == ')') goto SUCCESS_STATE; + else goto ERROR_STATE; + break; + case 1: + if (isalnum(c) || c == '_') { iState = 1; } + else if (isspace(c) || c == ',' || c == ')') { + *p = '\0'; + qtr = ES2INTER(MacroSearchParam)(s, ptr->start, ptr->nparams); + if (qtr != NULL) goto ERROR_STATE; + qtr = ES2INTER(MacroAppend)(s, ""); + if (qtr == NULL) goto ERROR_STATE; + qtr->nparams = -1; + ptr->nparams++; + *p = c; + if (c == ',') { iState = 3; } + else if (c == ')') goto SUCCESS_STATE; + else { iState = 2; } + } else goto ERROR_STATE; + break; + case 2: + if (isspace(c)) { iState = 2; } + else if (c == ',') { iState = 3; } + else if (c == ')') goto SUCCESS_STATE; + else goto ERROR_STATE; + break; + case 3: + if (isspace(c)) { iState = 3; } + else if (isalpha(c) || c == '_') { s = p; iState = 1; } + else if (c == '.') { iState = 5; } + else goto ERROR_STATE; + break; + case 5: + if (c == '.') { iState = 6; } + else goto ERROR_STATE; + break; + case 6: + if (c == '.') { + qtr = ES2INTER(MacroSearchParam)("__VA_ARGS__", ptr->start, ptr->nparams); + if (qtr != NULL) goto ERROR_STATE; + qtr = ES2INTER(MacroAppend)("__VA_ARGS__", ""); + if (qtr == NULL) goto ERROR_STATE; + qtr->nparams = -1; + ptr->nparams++; + iState = 7; + } else goto ERROR_STATE; + break; + case 7: + if (isspace(c)) { iState = 7; } + else if (c == ')') goto SUCCESS_STATE; + else goto ERROR_STATE; + break; + } + p++; + } +SUCCESS_STATE: + return GL_TRUE; +ERROR_STATE: + qtr = &(symbolTable[ptr->start]); + while (ptr->nparams--) { + if (qtr->formal != NULL) free(qtr->formal); + if (qtr->actual != NULL) free(qtr->actual); + qtr->formal = NULL; + qtr->actual = NULL; + qtr++; + } + if (ptr->formal != NULL) free(ptr->formal); + if (ptr->actual != NULL) free(ptr->actual); + ptr->formal = NULL; + ptr->actual = NULL; + return GL_FALSE; +} + +int GL_APIENTRY ES2INTER(MacroExpandLow)(char* src, char* dst, int detailed) { +#define PUTCHAR(c) do { \ + if (dst != NULL) *dst++ = c; \ + n++; \ + } while (0) + struct SymbolEntry* ptrIden; + struct SymbolEntry* ptrParam; + char* iden; + char* param; + int n = 0; + int state = 0; + int nparams; + int parens; + int len; + int c; + do { + c = *src++; + switch (state) { + case 0: + if (isalpha(c) || c == '_') { iden = (src - 1); state = 1; } + else if (c != '\0') { PUTCHAR(c); /* state = 0; */ } + break; + case 1: + if (isalnum(c) || c == '_') { /* state = 1; */ } + else { + *--src = '\0'; + if (detailed == 1 && strcmp(iden, "defined") == 0) { + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + assert(iden == src); + state = 11; + } else { + ptrIden = ES2INTER(MacroSearchMacro)(iden); + if (ptrIden != NULL && ptrIden->nparams == -2 + && (detailed != 2 + || strcmp(iden, "__LINE__") == 0 + || strcmp(iden, "__FILE__") == 0)) { + iden = ptrIden->actual; + PUTCHAR(' '); + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + state = 0; + } else if (ptrIden != NULL && detailed != 2) { + assert(ptrIden->nparams >= 0); + nparams = 0; + state = 2; + } else { + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + assert(iden == src); + state = 0; + } + } + *src = c; + } + break; + case 2: + if (isspace(c)) { /* state = 2; */ } + else if (c == '(') { state = 3; } + else { return -1; } + break; + case 3: + if (isspace(c)) { /* state = 3; */ } + else if (c == ',') { return -1; } + else if (c == ')') { + len = ES2INTER(MacroExpandFunc)(ptrIden, nparams, dst); + if (len < 0) return -1; + if (dst != NULL) dst += len; + n += len; + state = 0; + } else { + param = --src; + parens = 0; + state = 4; + } + break; + case 6: + if (c == ',') { return -1; } + else if (c == ')') { + len = ES2INTER(MacroExpandFunc)(ptrIden, nparams, dst); + if (len < 0) return -1; + if (dst != NULL) dst += len; + n += len; + state = 0; + } else { + --src; + parens = 0; + state = 4; + } + break; + case 4: + if (c == '(') { parens++; /* state = 4; */ } + else if (c == '"' && (param == (src - 1) || *(src - 2) != '\\')) { state = 5; } + else if (c == ',' && parens == 0) { + ptrParam = &(symbolTable[ptrIden->start + nparams]); + if (strcmp(ptrParam->formal, "__VA_ARGS__") == 0) { + state = 6; + } else { + ES2INTER(MacroSetActualValue)(ptrParam, param, src - 1); + nparams++; + state = 3; + } + } else if (c == ')') { + if (--parens < 0) { + ptrParam = &(symbolTable[ptrIden->start + nparams]); + ES2INTER(MacroSetActualValue)(ptrParam, param, src - 1); + nparams++; + len = ES2INTER(MacroExpandFunc)(ptrIden, nparams, dst); + if (len < 0) return -1; + if (dst != NULL) dst += len; + n += len; + state = 0; + } else { + /* state = 4; */ + } + } else { /* state = 4; */ } + break; + case 5: + if (c == '"' && *(src - 2) != '\\') { state = 4; } + else { /* state = 5; */ } + break; + case 11: + if (isspace(c)) { /* state = 11; */ } + else if (isalpha(c) || c == '_') { iden = (src - 1); state = 12; } + else if (c == '(') { PUTCHAR('('); state = 13; } + else { return -1; } + break; + case 12: + if (isalnum(c) || c == '_') { /* state = 12; */ } + else { + *--src = '\0'; + PUTCHAR(' '); + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + assert(iden == src); + state = 0; + *src = c; + } + break; + case 13: + if (isspace(c)) { /* state = 13; */ } + else if (isalpha(c) || c == '_') { iden = (src - 1); state = 14; } + else { return -1; } + break; + case 14: + if (isalnum(c) || c == '_') { /* state = 14; */ } + else { + *--src = '\0'; + PUTCHAR(' '); + while (*iden != '\0') { PUTCHAR(*iden); iden++; } + assert(iden == src); + state = 15; + *src = c; + } + break; + case 15: + if (isspace(c)) { /* state = 15; */ } + else if (c == ')') { PUTCHAR(')'); state = 0; } + else { return -1; } + break; + default: + assert(0); + break; + } + } while (c != '\0'); + PUTCHAR('\0'); + return (state == 0) ? n : -1; +#undef PUTCHAR +} + +char* GL_APIENTRY ES2INTER(MacroExpand)(char* src, int detailed) { + static int len[2] = { 0, 0 }; + static char* buf[2] = { NULL, NULL }; + int step = 0; + int srcIndex; + int dstIndex; + int result; + result = strlen(src); + if (len[0] < result + 1) { + buf[0] = (char*)realloc(buf[0], result + 1); + } + strcpy(buf[0], src); + do { + step++; + srcIndex = (step - 1) % 2; + dstIndex = step % 2; + result = ES2INTER(MacroExpandLow)(buf[srcIndex], NULL, detailed); + if (result < 0) return NULL; + if (len[dstIndex] < result + 1) { + buf[dstIndex] = (char*)realloc(buf[dstIndex], result + 1); + len[dstIndex] = result + 1; + } + result = ES2INTER(MacroExpandLow)(buf[srcIndex], buf[dstIndex], detailed); + assert(result < len[dstIndex]); + } while (strcmp(buf[srcIndex], buf[dstIndex]) != 0 && step < 100); + return (step < 100) ? buf[dstIndex] : NULL; +} diff --git a/es_2_0/makefile b/es_2_0/makefile new file mode 100755 index 0000000..50420ef --- /dev/null +++ b/es_2_0/makefile @@ -0,0 +1,22 @@ +#!make + +default: +# make -f makefile-static clean + make -f makefile-dynamic clean +# make -f makefile-static install +# make -f makefile-static clean + make -f makefile-dynamic install + +install: + make -f makefile-dynamic install + +clean: +# make -f makefile-static clean + make -f makefile-dynamic clean + +clobber: +# make -f makefile-static clobber + make -f makefile-dynamic clobber + +wc: + make -f makefile-dynamic wc diff --git a/es_2_0/makefile-dynamic b/es_2_0/makefile-dynamic new file mode 100755 index 0000000..1fde268 --- /dev/null +++ b/es_2_0/makefile-dynamic @@ -0,0 +1,89 @@ +#!/bin/make + +CFLAGS = -I. -I../include -fPIC -Werror-implicit-function-declaration -O0 -g3 +ARFLAGS = rucv + +CFLAGS += -DPROVIDING_OES_blend_func_separate +CFLAGS += -DPROVIDING_OES_blend_subtract + # never CFLAGS += -DPROVIDING_OES_byte_coordinates # N/A for ES 2.0 +CFLAGS += -DPROVIDING_OES_fixed_point # always ON + # never CFLAGS += -DPROVIDING_OES_matrix_get # N/A for ES 2.0 + # never CFLAGS += -DPROVIDING_OES_point_size_array # N/A for ES 2.0 + # never CFLAGS += -DPROVIDING_OES_point_sprite # N/A for ES 2.0 + # never CFLAGS += -DPROVIDING_OES_query_matrix # N/A for ES 2.0 +CFLAGS += -DPROVIDING_OES_single_precision +CFLAGS += -DPROVIDING_OES_stencil_wrap # always ON + # never CFLAGS += -DPROVIDING_OES_texture_cube_map # N/A for ES 2.0 + # never CFLAGS += -DPROVIDING_OES_texture_env_crossbar # N/A for ES 2.0 +CFLAGS += -DPROVIDING_OES_texture_mirrored_repeat # always ON +CFLAGS += -DPROVIDING_OES_element_index_uint +CFLAGS += -DPROVIDING_OES_texture_3D +CFLAGS += -DPROVIDING_OES_texture_npot +CFLAGS += -DPROVIDING_OES_rgb8_rgba8 +CFLAGS += -DPROVIDING_OES_packed_depth_stencil + +LIBBASE = libGLESv2.so +LIBVER = 1.0 +LIB = $(LIBBASE).$(LIBVER) + +END = +SRCS = \ + Enable.c \ + Error.c \ + Flush.c \ + Shader.c \ + Program.c \ + Link.c \ + Uniform.c \ + VertexAttrib.c \ + VertexPointer.c \ + Buffer.c \ + DrawArray.c \ + DrawElement.c \ + Primitive.c \ + Texture.c \ + TexImage.c \ + Tex3D.c \ + Compressed.c \ + Clear.c \ + Fragment.c \ + Get.c \ + Framebuffer.c \ + Extend.c \ + PrepLex.c \ + EvalParse.c \ + ParseParse.c \ + internal.c \ + macro.c \ + symbol.c \ + EGLImage.c \ + $(END) +OBJS = $(SRCS:.c=.o) + + +default: __touch__ $(LIB) + + +__touch__: + touch Get.c + +$(LIB): $(OBJS) + $(CC) -shared -Wl,-soname,$(LIBBASE).1 -o $@ $(OBJS) -ldl -lX11 + +install: $(LIB) + cp $(LIB) ../lib + +# supports + +clean: + $(RM) $(RMFLAGS) $(OBJS) + +wc: + wc $(SRCS) *.h *.inl + +#$(OBJS): GLES2/gl2.h es2front.h + + +clobber: clean + $(RM) $(RMFLAGS) $(LIB) core a.out + diff --git a/es_2_0/makefile-static b/es_2_0/makefile-static new file mode 100755 index 0000000..75bf10f --- /dev/null +++ b/es_2_0/makefile-static @@ -0,0 +1,62 @@ +#!/bin/make + +CFLAGS = -I. -Werror-implicit-function-declaration -O0 -g3 + + +LIB = libGLESv2.a +ARFLAGS = rucv + +END = +SRCS = \ + Enable.c \ + Error.c \ + Flush.c \ + Shader.c \ + Program.c \ + Link.c \ + Uniform.c \ + VertexAttrib.c \ + VertexPointer.c \ + Buffer.c \ + DrawArray.c \ + DrawElement.c \ + Primitive.c \ + Texture.c \ + TexImage.c \ + Compressed.c \ + Clear.c \ + Fragment.c \ + Get.c \ + Framebuffer.c \ + internal.c \ + macro.c \ + EGLImage.c \ + $(END) +OBJS = $(SRCS:.c=.o) + + +default: __touch__ $(LIB) + + +__touch__: + touch Get.c + +$(LIB): $(OBJS) + $(AR) $(ARFLAGS) $@ $(OBJS) + +install: $(LIB) + cp $(LIB) ../lib + +# supports + +clean: + $(RM) $(RMFLAGS) $(OBJS) + +clobber: clean + $(RM) $(RMFLAGS) $(LIB) core a.out + +wc: + wc $(SRCS) *.inl *.h + +$(OBJS): GLES2/gl2.h + diff --git a/es_2_0/symbol.c b/es_2_0/symbol.c new file mode 100755 index 0000000..2ddb40a --- /dev/null +++ b/es_2_0/symbol.c @@ -0,0 +1,180 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "es2front.h" +#include <ctype.h> + + +int GL_APIENTRY ES2INTER(ProcSwizzler)(int basetype, char* swizzler) { + return basetype; +} + +void GL_APIENTRY ES2INTER(LevelInit)(struct ShaderObjectUnit* pUnit, int level) { + assert(0 <= level && level < MAX_SYMBOL_LEVEL); + assert(pUnit->symbolTable[level] == NULL); + assert(pUnit->symbolAllocated[level] == 0); + pUnit->symbolAllocated[level] = 64; + pUnit->symbolUsed[level] = 0; + pUnit->symbolTable[level] = calloc(pUnit->symbolAllocated[level], sizeof(struct TableEntry)); +} + +void GL_APIENTRY ES2INTER(LevelRelease)(struct ShaderObjectUnit* pUnit, int level) { + int i; + assert(pUnit->symbolTable[level] != NULL); + assert(pUnit->symbolAllocated[level] > 0); + for (i = 0; i < pUnit->symbolUsed[level]; i++) { + if (pUnit->symbolTable[level][i].name != NULL) free(pUnit->symbolTable[level][i].name); + } + free(pUnit->symbolTable[level]); + pUnit->symbolTable[level] = NULL; + pUnit->symbolAllocated[level] = 0; + pUnit->symbolUsed[level] = 0; +} + +void GL_APIENTRY ES2INTER(ScopeBegin)(struct ShaderObjectUnit* pUnit) { + pUnit->symbolLevel++; + assert(pUnit->symbolLevel < MAX_SYMBOL_LEVEL); + ES2INTER(LevelInit)(pUnit, pUnit->symbolLevel); +} + +void GL_APIENTRY ES2INTER(ScopeEnd)(struct ShaderObjectUnit* pUnit) { + assert(pUnit->symbolLevel >= 0); + ES2INTER(LevelRelease)(pUnit, pUnit->symbolLevel); + pUnit->symbolLevel--; +} + +void GL_APIENTRY ES2INTER(SymbolRelease)(struct ShaderObjectUnit* pUnit) { + for (; pUnit->symbolLevel >= 0; pUnit->symbolLevel--) { + ES2INTER(LevelRelease)(pUnit, pUnit->symbolLevel); + } +} + +void GL_APIENTRY ES2INTER(SymbolInit)(struct ShaderObjectUnit* pUnit) { + if (pUnit->symbolLevel == -1) { + memset(pUnit->symbolTable, 0, sizeof(pUnit->symbolTable)); + memset(pUnit->symbolAllocated, 0, sizeof(pUnit->symbolAllocated)); + memset(pUnit->symbolUsed, 0, sizeof(pUnit->symbolUsed)); + ES2INTER(ScopeBegin)(pUnit); + /* as defiend in the ES SL specification, + const mediump int gl_MaxVertexAttribs = 8; + const mediump int gl_MaxVertexUniformVectors = 128; + const mediump int gl_MaxVaryingVectors = 8; + const mediump int gl_MaxVertexTextureImageUnits = 0; + const mediump int gl_MaxCombinedTextureImageUnits = 8; + const mediump int gl_MaxTextureImageUnits = 8; + const mediump int gl_MaxFragmentUniformVectors = 16; + const mediump int gl_MaxDrawBuffers = 1; + */ + ES2INTER(AppendSymbol)(pUnit, "gl_MaxVertexAttribs", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_MaxVertexUniformVectros", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_VaryingVectors", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_MaxVertexTextureImageUnits", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_MaxCombinedTextureImageUnits", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_MaxTextureImageUnits", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_MaxFragmentUniformVectors", T_INT | S_CONST); + ES2INTER(AppendSymbol)(pUnit, "gl_MaxDrawBuffers", T_INT | S_CONST); + /* as defiend in the ES SL specification, + struct gl_DepthRangeParameters { + highp float near; + highp float far; + highp float diff; + }; + uniform gl_DepthRangeParameters gl_DepthRange; + */ + ES2INTER(AppendSymbol)(pUnit, "gl_DepthRange", T_STRUCT_DEF); + /* as defiend in the ES SL specification, + highp vec4 gl_Position; + mediump float gl_PointSize; + */ + if (pUnit->eShaderType == GL_VERTEX_SHADER) { + ES2INTER(AppendSymbol)(pUnit, "gl_Position", T_VEC4); + ES2INTER(AppendSymbol)(pUnit, "gl_PointSize", T_FLOAT); + } + /* as defiend in the ES SL specification, + mediump vec4 gl_FragCoord; + bool gl_FrontFacing; + mediump vec4 gl_FragColor; + mediump vec4 gl_FragData[gl_MaxDrawBuffers]; + mediump vec2 gl_PointCoord; + */ + if (pUnit->eShaderType == GL_FRAGMENT_SHADER) { + ES2INTER(AppendSymbol)(pUnit, "gl_FragCoord", T_VEC4); + ES2INTER(AppendSymbol)(pUnit, "gl_FrontFacing", T_BOOL); + ES2INTER(AppendSymbol)(pUnit, "gl_FragColor", T_VEC4); + ES2INTER(AppendSymbol)(pUnit, "gl_FragData", T_VEC4); + ES2INTER(AppendSymbol)(pUnit, "gl_PointCoord", T_VEC2); + } + } + for (; pUnit->symbolLevel >= 1; pUnit->symbolLevel--) { + ES2INTER(LevelRelease)(pUnit, pUnit->symbolLevel); + } + ES2INTER(ScopeBegin)(pUnit); +} + +struct TableEntry* GL_APIENTRY ES2INTER(SearchSymbol)(struct ShaderObjectUnit* pUnit, + char* name, int* pLevelReturn) { + int k; + for (k = pUnit->symbolLevel; k >= 0; k--) { + struct TableEntry* ptr = pUnit->symbolTable[k]; + int n = pUnit->symbolUsed[k]; + while (n-- > 0) { + assert(ptr->name != NULL); + if (ptr->nparams >= -1 && strcmp(name, ptr->name) == 0) { + if (pLevelReturn != NULL) *pLevelReturn = k; + return ptr; + } + ptr++; + } + } + return NULL; +} + +struct TableEntry* GL_APIENTRY ES2INTER(AppendSymbol)(struct ShaderObjectUnit* pUnit, + char* name, int type) { + int level = pUnit->symbolLevel; + struct TableEntry* ptr; + assert(name != NULL && name[0] != '\0'); + if (pUnit->symbolUsed[level] == pUnit->symbolAllocated[level]) { + int oldAllocated = pUnit->symbolAllocated[level]; + pUnit->symbolAllocated[level] *= 2; + pUnit->symbolTable[level] = realloc(pUnit->symbolTable[level], + pUnit->symbolAllocated[level] * sizeof(struct TableEntry)); + memset(&(pUnit->symbolTable[level][oldAllocated]), 0, + oldAllocated * sizeof(struct TableEntry)); + } + ptr = &(pUnit->symbolTable[level][pUnit->symbolUsed[level]++]); + ptr->name = malloc(strlen(name) + 1); + strcpy(ptr->name, name); + ptr->type = type; + return ptr; +} + + diff --git a/es_2_0/symbol.h b/es_2_0/symbol.h new file mode 100755 index 0000000..e2d868c --- /dev/null +++ b/es_2_0/symbol.h @@ -0,0 +1,79 @@ +/* + * Copyright (C) 2010 - 2011 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: + * DongKyun Yun <dk77.yun@samsung.com> + * SangJin Kim <sangjin3.kim@samsung.com> + * HyunGoo Kang <hyungoo1.kang@samsung.com> + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + * of the Software, and to permit persons to whom the Software is furnished to do + * so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef _HAZEL_SYMBOL_H_ +#define _HAZEL_SYMBOL_H_ + +#ifndef _ES2_FRONT_H_ +#error symbol.h shoule be used in the es2front.h +#endif + +struct SymbolEntry { + char* formal; + char* actual; + int nparams; + int start; +}; +GL_APICALL void GL_APIENTRY ES2INTER(MacroInit)(void); +GL_APICALL void GL_APIENTRY ES2INTER(MacroSetLineFile)(int iLine, int iFile); +GL_APICALL void GL_APIENTRY ES2INTER(MacroRelease)(void); +GL_APICALL struct SymbolEntry* GL_APIENTRY ES2INTER(MacroSearchParam)(char* name, int start, int n); +GL_APICALL struct SymbolEntry* GL_APIENTRY ES2INTER(MacroSearchMacro)(char* name); +GL_APICALL struct SymbolEntry* GL_APIENTRY ES2INTER(MacroAppend)(char* name, char* body); +GL_APICALL GLboolean GL_APIENTRY ES2INTER(MacroUndef)(char* name); +GL_APICALL GLboolean GL_APIENTRY ES2INTER(MacroDefineName)(char* name, char* body); +GL_APICALL GLboolean GL_APIENTRY ES2INTER(MacroDefineFunc)(char* head, char* body); +GL_APICALL char* GL_APIENTRY ES2INTER(MacroExpand)(char* src, int detailed); + +struct TableEntry { + char* name; + int type; + int dim; + int nparams; + int start; + int specifier; +}; + +GL_APICALL void GL_APIENTRY ES2INTER(LevelInit)(int level); +GL_APICALL void GL_APIENTRY ES2INTER(LevelRelease)(int level); + +GL_APICALL void GL_APIENTRY ES2INTER(SymbolInit)(void); +GL_APICALL void GL_APIENTRY ES2INTER(SymbolPrepare)(GLenum type); +GL_APICALL void GL_APIENTRY ES2INTER(SymbolRelease)(void); + +GL_APICALL void GL_APIENTRY ES2INTER(ScopeBegin)(void); +GL_APICALL void GL_APIENTRY ES2INTER(ScopeEnd)(void); + +GL_APICALL struct TableEntry* GL_APIENTRY ES2INTER(SearchSymbol)(char* name, int* pLevelReturn); +GL_APICALL struct TableEntry* GL_APIENTRY ES2INTER(AppendSymbolLevel)(char* name, int level); +GL_APICALL struct TableEntry* GL_APIENTRY ES2INTER(AppendSymbol)(char* name); + +#endif |