aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2014-11-28 10:03:40 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2014-11-28 10:03:41 +0000
commitb8f9fbd141ca6d878d5d3f4525e53bd0a2ee16ef (patch)
tree7f9e794e46048062b3d029e6e2076351f18eec51 /emulator
parenta01dd53f93a56259ab600266b67ee387e1795629 (diff)
parentce28cffe356f16a1e326bac2e23d0d069c441bd5 (diff)
downloadsdk-b8f9fbd141ca6d878d5d3f4525e53bd0a2ee16ef.tar.gz
sdk-b8f9fbd141ca6d878d5d3f4525e53bd0a2ee16ef.tar.bz2
sdk-b8f9fbd141ca6d878d5d3f4525e53bd0a2ee16ef.zip
Merge changes I58865946,I582d5ab6,Ib1b6bcba
* changes: emulator/opengl: Fix pixelDataSize() ambiguity. emulator/opengl: Update declarations to fix const issue. emulator/opengl/emugen: Fix type parsing.
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/Android.mk6
-rw-r--r--emulator/opengl/googletest.mk9
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/gl.attrib12
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/gl.in4
-rw-r--r--emulator/opengl/host/libs/GLESv1_dec/gl.types1
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/gl2.attrib18
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/gl2.in4
-rw-r--r--emulator/opengl/host/libs/GLESv2_dec/gl2.types1
-rw-r--r--emulator/opengl/host/tools/emugen/Android.mk33
-rw-r--r--emulator/opengl/host/tools/emugen/EntryPoint.cpp90
-rw-r--r--emulator/opengl/host/tools/emugen/Parser.cpp191
-rw-r--r--emulator/opengl/host/tools/emugen/Parser.h68
-rw-r--r--emulator/opengl/host/tools/emugen/Parser_unittest.cpp120
-rw-r--r--emulator/opengl/host/tools/emugen/TypeFactory.cpp9
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp8
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h3
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp18
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp7
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h3
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp7
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in1
-rw-r--r--emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types3
32 files changed, 514 insertions, 112 deletions
diff --git a/emulator/opengl/Android.mk b/emulator/opengl/Android.mk
index 244b874b3..42d12ca0c 100644
--- a/emulator/opengl/Android.mk
+++ b/emulator/opengl/Android.mk
@@ -56,6 +56,9 @@ include $(EMUGL_PATH)/common.mk
# module that hasn't been declared yet anyway.
#
+# Required by our units test.
+include $(EMUGL_PATH)/googletest.mk
+
# First, build the emugen host source-generation tool
#
# It will be used by other modules to generate wire protocol encode/decoder
@@ -63,9 +66,6 @@ include $(EMUGL_PATH)/common.mk
#
include $(EMUGL_PATH)/host/tools/emugen/Android.mk
-# Required by our units test.
-include $(EMUGL_PATH)/googletest.mk
-
include $(EMUGL_PATH)/shared/emugl/common/Android.mk
include $(EMUGL_PATH)/shared/OpenglCodecCommon/Android.mk
diff --git a/emulator/opengl/googletest.mk b/emulator/opengl/googletest.mk
index 753139431..12760b2dd 100644
--- a/emulator/opengl/googletest.mk
+++ b/emulator/opengl/googletest.mk
@@ -39,3 +39,12 @@ $(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
$(call emugl-export,LDLIBS,$(common_LDLIBS))
$(call emugl-end-module)
+$(call emugl-begin-host-static-library,libemugl_gtest_host)
+LOCAL_SRC_FILES := $(common_SRC_FILES)
+LOCAL_CFLAGS += $(common_CFLAGS)
+LOCAL_C_INCLUDES += $(LOCAL_PATH)/include
+LOCAL_CPP_EXTENSION := .cc
+$(call emugl-export,C_INCLUDES,$(LOCAL_PATH)/include)
+$(call emugl-export,LDLIBS,$(common_LDLIBS))
+LOCAL_HOST_BUILD := true
+$(call emugl-end-module)
diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.attrib b/emulator/opengl/host/libs/GLESv1_dec/gl.attrib
index 9b84f89ca..26b793eb1 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/gl.attrib
+++ b/emulator/opengl/host/libs/GLESv1_dec/gl.attrib
@@ -221,7 +221,7 @@ glPointParameterxv
#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glReadPixels
dir pixels out
- len pixels pixelDataSize(self, width, height, format, type, 1)
+ len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 1)
#void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
glTexCoordPointer
@@ -239,7 +239,7 @@ glTexEnvxv
#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage2D
dir pixels in
- len pixels pixelDataSize(self, width, height, format, type, 0)
+ len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexParameteriv(GLenum target, GLenum pname, GLint *params)
@@ -252,7 +252,7 @@ glTexParameterxv
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage2D
- len pixels pixelDataSize(self, width, height, format, type, 0)
+ len pixels glesv1_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels isLarge
#void glVertexPointer(GLint size, GLenum type, GLsizei stride, GLvoid *pointer)
@@ -583,11 +583,11 @@ glDiscardFramebufferEXT
dir attachments in
len attachments (numAttachments * sizeof(const GLenum))
-#void glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
+#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
glMultiDrawArraysEXT
flag unsupported
-#void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount)
+#void glMultiDrawElementsEXT(GLenum mode, const GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount)
glMultiDrawElementsEXT
flag unsupported
@@ -666,7 +666,7 @@ glExtGetTexLevelParameterivQCOM
#void glExtGetTexSubImageQCOM(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *texels)
glExtGetTexSubImageQCOM
dir texels out
- len texels (depth * pixelDataSize(self, width, height, format, type, 0))
+ len texels (depth * glesv1_enc::pixelDataSize(self, width, height, format, type, 0))
#void glExtGetBufferPointervQCOM(GLenum target, GLvoid **params)
glExtGetBufferPointervQCOM
diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.in b/emulator/opengl/host/libs/GLESv1_dec/gl.in
index 434060893..cb4859dc1 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/gl.in
+++ b/emulator/opengl/host/libs/GLESv1_dec/gl.in
@@ -265,8 +265,8 @@ GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays)
GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays)
GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array)
GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments)
-GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
-GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)
+GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
+GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const *indices, GLsizei primcount)
GL_ENTRY(void, glMultiDrawArraysSUN, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
GL_ENTRY(void, glMultiDrawElementsSUN, GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)
GL_ENTRY(void, glRenderbufferStorageMultisampleIMG, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height)
diff --git a/emulator/opengl/host/libs/GLESv1_dec/gl.types b/emulator/opengl/host/libs/GLESv1_dec/gl.types
index 2bc2a9e03..2d9a3b037 100644
--- a/emulator/opengl/host/libs/GLESv1_dec/gl.types
+++ b/emulator/opengl/host/libs/GLESv1_dec/gl.types
@@ -31,3 +31,4 @@ GLvoid* 32 0x%08x
GLchar* 32 0x%08x
GLvoid** 32 0x%08x
void* 32 0x%08x
+GLvoid*const* 32 0x%08x
diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib b/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib
index d90a7e5b8..3a6da47e9 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib
+++ b/emulator/opengl/host/libs/GLESv2_dec/gl2.attrib
@@ -206,12 +206,12 @@ glGetTexParameteriv
#void glGetUniformfv(GLuint program, GLint location, GLfloat *params)
glGetUniformfv
dir params out
- len params glSizeof(uniformType(self, program, location))
+ len params glSizeof(glesv2_enc::uniformType(self, program, location))
#void glGetUniformiv(GLuint program, GLint location, GLint *params)
glGetUniformiv
dir params out
- len params glSizeof(uniformType(self, program, location))
+ len params glSizeof(glesv2_enc::uniformType(self, program, location))
#int glGetUniformLocation(GLuint program, GLchar *name)
glGetUniformLocation
@@ -236,7 +236,7 @@ glGetVertexAttribiv
#void glReadPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glReadPixels
dir pixels out
- len pixels pixelDataSize(self, width, height, format, type, 1)
+ len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 1)
#void glShaderBinary(GLsizei n, GLuint *shaders, GLenum binaryformat, GLvoid *binary, GLsizei length)
glShaderBinary
@@ -245,7 +245,7 @@ glShaderBinary
#void glTexImage2D(GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage2D
dir pixels in
- len pixels pixelDataSize(self, width, height, format, type, 0)
+ len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexParameterfv(GLenum target, GLenum pname, GLfloat *params)
@@ -257,7 +257,7 @@ glTexParameteriv
#void glTexSubImage2D(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage2D
- len pixels pixelDataSize(self, width, height, format, type, 0)
+ len pixels glesv2_enc::pixelDataSize(self, width, height, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glUniform1fv(GLint location, GLsizei count, GLfloat *v)
@@ -337,12 +337,12 @@ glMapBufferOES
#void glTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, GLvoid *pixels)
glTexImage3DOES
- len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
+ len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels nullAllowed isLarge
#void glTexSubImage3DOES(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint zoffset, GLsizei width, GLsizei height, GLsizei depth, GLenum format, GLenum type, GLvoid *pixels)
glTexSubImage3DOES
- len pixels pixelDataSize3D(self, width, height, depth, format, type, 0)
+ len pixels glesv2_enc::pixelDataSize3D(self, width, height, depth, format, type, 0)
var_flag pixels isLarge
#void glCompressedTexImage3DOES(GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLsizei imageSize, GLvoid *data)
@@ -371,10 +371,10 @@ glGenVertexArraysOES
glDiscardFramebufferEXT
len attachments (numAttachments * sizeof(GLenum))
-#void glMultiDrawArraysEXT(GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
+#void glMultiDrawArraysEXT(GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
glMultiDrawArraysEXT
flag unsupported
-#void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, GLvoid *indices, GLsizei primcount)
+#void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid* const *indices, GLsizei primcount)
glMultiDrawElementsEXT
flag unsupported
diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.in b/emulator/opengl/host/libs/GLESv2_dec/gl2.in
index 925eb98cb..f60db16bf 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/gl2.in
+++ b/emulator/opengl/host/libs/GLESv2_dec/gl2.in
@@ -158,8 +158,8 @@ GL_ENTRY(void, glDeleteVertexArraysOES, GLsizei n, const GLuint *arrays)
GL_ENTRY(void, glGenVertexArraysOES, GLsizei n, GLuint *arrays)
GL_ENTRY(GLboolean, glIsVertexArrayOES, GLuint array)
GL_ENTRY(void, glDiscardFramebufferEXT, GLenum target, GLsizei numAttachments, const GLenum *attachments)
-GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, GLint *first, GLsizei *count, GLsizei primcount)
-GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid* *indices, GLsizei primcount)
+GL_ENTRY(void, glMultiDrawArraysEXT, GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount)
+GL_ENTRY(void, glMultiDrawElementsEXT, GLenum mode, const GLsizei *count, GLenum type, const GLvoid*const* indices, GLsizei primcount)
#not supported
GL_ENTRY(void, glGetPerfMonitorGroupsAMD, GLint *numGroups, GLsizei groupsSize, GLuint *groups)
diff --git a/emulator/opengl/host/libs/GLESv2_dec/gl2.types b/emulator/opengl/host/libs/GLESv2_dec/gl2.types
index 2f5c0c333..86e10f941 100644
--- a/emulator/opengl/host/libs/GLESv2_dec/gl2.types
+++ b/emulator/opengl/host/libs/GLESv2_dec/gl2.types
@@ -35,3 +35,4 @@ void* 32 0x%08x
GLstr* 32 0x%08x
GLvoidptr* 32 0x%08x
GLchar*const* 32 0x%08x
+GLvoid*const* 32 0x%08x
diff --git a/emulator/opengl/host/tools/emugen/Android.mk b/emulator/opengl/host/tools/emugen/Android.mk
index e2f3939d9..4d09c42c0 100644
--- a/emulator/opengl/host/tools/emugen/Android.mk
+++ b/emulator/opengl/host/tools/emugen/Android.mk
@@ -1,35 +1,18 @@
# Determine if the emugen build needs to be builts from
# sources.
-EMUGL_BUILD_EMUGEN :=
-ifeq (true,$(BUILD_STANDALONE_EMULATOR))
- # The emulator's standalone build system can build host Linux
- # binaries even when it targets Windows by setting
- # LOCAL_HOST_BUILD to true, so rebuild from sources.
- EMUGL_BUILD_EMUGEN := true
-else
- ifneq ($(HOST_OS),windows)
- # The platform build can only build emugen when targetting
- # the same host sytem.
- EMUGL_BUILD_EMUGEN := true
- endif
-endif
-
LOCAL_PATH:=$(call my-dir)
-ifeq (true,$(EMUGL_BUILD_EMUGEN))
-
$(call emugl-begin-host-executable,emugen)
LOCAL_SRC_FILES := \
ApiGen.cpp \
EntryPoint.cpp \
main.cpp \
+ Parser.cpp \
strUtils.cpp \
TypeFactory.cpp \
-ifeq (true,$(BUILD_STANDALONE_EMULATOR))
LOCAL_HOST_BUILD := true
-endif
$(call emugl-end-module)
@@ -37,10 +20,10 @@ $(call emugl-end-module)
# protocol encoders/ decoders. This variable is used by other emugl modules.
EMUGL_EMUGEN := $(LOCAL_BUILT_MODULE)
-else # windows platform build
-
-# on windows use the build host emugen executable
-# (that will be the linux exeutable when using mingw build)
-EMUGL_EMUGEN := $(BUILD_OUT_EXECUTABLES)/emugen
-
-endif
+$(call emugl-begin-host-executable,emugen_unittests)
+LOCAL_SRC_FILES := \
+ Parser.cpp \
+ Parser_unittest.cpp
+LOCAL_HOST_BUILD := true
+$(call emugl-import,libemugl_gtest_host)
+$(call emugl-end-module)
diff --git a/emulator/opengl/host/tools/emugen/EntryPoint.cpp b/emulator/opengl/host/tools/emugen/EntryPoint.cpp
index 55b30cfe7..cc3bef1e6 100644
--- a/emulator/opengl/host/tools/emugen/EntryPoint.cpp
+++ b/emulator/opengl/host/tools/emugen/EntryPoint.cpp
@@ -13,13 +13,16 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-#include <stdio.h>
#include "EntryPoint.h"
-#include <string>
+
+#include "Parser.h"
#include "TypeFactory.h"
#include "strUtils.h"
+
#include <sstream>
+#include <string>
+#include <stdio.h>
EntryPoint::EntryPoint()
{
@@ -39,59 +42,6 @@ void EntryPoint::reset()
m_vars.empty();
}
-bool parseTypeField(const std::string & f, std::string *vartype, std::string *varname)
-{
- size_t pos = 0, last;
- bool done = false;
-
-
- *vartype = "";
- if (varname != NULL) *varname = "";
-
- enum { ST_TYPE, ST_NAME, ST_END } state = ST_TYPE;
-
- while(!done) {
-
- std::string str = getNextToken(f, pos, &last, WHITESPACE);
- if (str.size() == 0) break;
-
- switch(state) {
- case ST_TYPE:
- if (str == "const") {
- pos = last;
- *vartype = "const ";
- } else {
- // must be a type name;
- *vartype += str;
- state = ST_NAME;
- pos = last;
- }
- break;
- case ST_NAME:
- if (str.size() == 0) {
- done = true;
- } else if (str == "*") {
- (*vartype) += "*";
- pos = last;
- } else if (varname == NULL) {
- done = true;
- } else {
- while (str[0] == '*') {
- (*vartype) += "*";
- str[0] = ' ';
- str = trim(str);
- }
- *varname = str;
- done = true;
- }
- break;
- case ST_END:
- break;
- }
- }
- return true;
-}
-
// return true for valid line (need to get into the entry points list)
bool EntryPoint::parse(unsigned int lc, const std::string & str)
{
@@ -109,9 +59,15 @@ bool EntryPoint::parse(unsigned int lc, const std::string & str)
pos = last + 1;
// return type
field = getNextToken(linestr, pos, &last, ",)");
+
+ std::string error;
std::string retTypeName;
- if (!parseTypeField(field, &retTypeName, NULL)) {
- fprintf(stderr, "line: %d: Parsing error in field <%s>\n", lc, field.c_str());
+ if (!parseTypeDeclaration(field, &retTypeName, &error)) {
+ fprintf(stderr,
+ "line: %d: Parsing error in field <%s>: %s\n",
+ lc,
+ field.c_str(),
+ error.c_str());
return false;
}
pos = last + 1;
@@ -120,7 +76,12 @@ bool EntryPoint::parse(unsigned int lc, const std::string & str)
fprintf(stderr, "UNKNOWN retval: %s\n", linestr.c_str());
}
- m_retval.init(std::string(""), theType, std::string(""), Var::POINTER_OUT, std::string(""), std::string(""));
+ m_retval.init(std::string(""),
+ theType,
+ std::string(""),
+ Var::POINTER_OUT,
+ std::string(""),
+ std::string(""));
// function name
m_name = getNextToken(linestr, pos, &last, ",)");
@@ -130,9 +91,18 @@ bool EntryPoint::parse(unsigned int lc, const std::string & str)
int nvars = 0;
while (pos < linestr.size() - 1) {
field = getNextToken(linestr, pos, &last, ",)");
+ if (field == "void") {
+ // 'void' is used as a special case for functions that don't take
+ // parameters at all.
+ break;
+ }
std::string vartype, varname;
- if (!parseTypeField(field, &vartype, &varname)) {
- fprintf(stderr, "line: %d: Parsing error in field <%s>\n", lc, field.c_str());
+ if (!parseParameterDeclaration(field, &vartype, &varname, &error)) {
+ fprintf(stderr,
+ "line: %d: Parsing error in field <%s>\n",
+ lc,
+ field.c_str(),
+ error.c_str());
return false;
}
nvars++;
diff --git a/emulator/opengl/host/tools/emugen/Parser.cpp b/emulator/opengl/host/tools/emugen/Parser.cpp
new file mode 100644
index 000000000..0839f2023
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/Parser.cpp
@@ -0,0 +1,191 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "Parser.h"
+
+#include <vector>
+
+#define WHITESPACE " \t\n"
+
+// Parse the |input| string as a list of type-specific tokens.
+// This tokenizes the input, using whitespace as separators and '*' as
+// a single token too. On success, return true and sets |*out| to the
+// list of tokens. On failure, return false.
+//
+// Example: 'const char**foo' -> ['const', 'char', '*', '*', 'foo']
+//
+static bool parseTypeTokens(const std::string& input,
+ std::vector<std::string>* out,
+ std::string* error) {
+ out->clear();
+ size_t pos = 0U;
+
+ // Parse all tokens in the input, treat '*' as a single token.
+ // I.e.
+ for (;;) {
+ // skip leading whitespace.
+ pos = input.find_first_not_of(WHITESPACE, pos);
+ if (pos == std::string::npos) {
+ break; // end of parse.
+ }
+
+ // If this is a star, ensure it follows a type name.
+ // otherwise treat it as part of the final type.
+ if (input[pos] == '*') {
+ out->push_back(std::string("*"));
+ pos += 1U;
+ continue;
+ }
+
+ // find end of type/token.
+ size_t end = input.find_first_of(WHITESPACE "*", pos);
+ if (end == std::string::npos) {
+ end = input.size();
+ }
+
+ std::string str = input.substr(pos, end - pos);
+ if (str.size() == 0) {
+ // Sanity check: should not happen.
+ if (error != NULL) {
+ *error = "Unexpected empty token !?";
+ }
+ return false;
+ }
+
+ out->push_back(str);
+ pos = end;
+ }
+
+ if (error != NULL) {
+ // Sanity check: require non-empty input
+ if (out->empty()) {
+ *error = "Empty parameter declaration!";
+ return false;
+ }
+
+ // Sanity check: There must be base type name before any '*'
+ for (size_t n = 0; n < out->size(); ++n) {
+ std::string& token = (*out)[n];
+ if (token == "*") {
+ *error = "Unexpected '*' before type name";
+ return false;
+ } else if (token != "const") {
+ break;
+ }
+ }
+ }
+
+ return true;
+}
+
+// Given |tokens|, an input vector of strings, join the first |count| items
+// into a normalized type string, and return it.
+static std::string buildTypeString(const std::vector<std::string>& tokens,
+ size_t count) {
+ std::string result;
+
+ for (size_t n = 0; n < count; ++n) {
+ const std::string& token = tokens[n];
+ if (n > 0 && token != "*") {
+ result.append(" ");
+ }
+ result.append(token);
+ }
+ return result;
+}
+
+
+std::string normalizeTypeDeclaration(const std::string& input) {
+ std::vector<std::string> tokens;
+ if (!parseTypeTokens(input, &tokens, NULL)) {
+ return "";
+ }
+ return buildTypeString(tokens, tokens.size());
+}
+
+bool parseTypeDeclaration(const std::string& input,
+ std::string* typeName,
+ std::string* error) {
+ // The type name can be made of several tokens, e.g. 'unsigned int'
+ // use an array to store them, and a count variable. Each item can be
+ // one of '*', 'const' or a type name component (e.g. 'struct', 'unsigned')
+ std::vector<std::string> tokens;
+
+ if (!parseTypeTokens(input, &tokens, error)) {
+ return false;
+ }
+
+ // Sanity check, there must be a least one non-special tokens.
+ size_t nonSpecialCount = 0;
+ for (size_t n = 0; n < tokens.size(); ++n) {
+ if (tokens[n] != "*" && tokens[n] != "const") {
+ nonSpecialCount++;
+ }
+ }
+ if (nonSpecialCount == 0) {
+ *error = "Missing type name";
+ return false;
+ }
+ // Build the type name from all tokens before it.
+ *typeName = buildTypeString(tokens, tokens.size());
+ return true;
+}
+
+
+bool parseParameterDeclaration(const std::string& param,
+ std::string* typeName,
+ std::string* variableName,
+ std::string* error) {
+ std::vector<std::string> tokens;
+
+ if (!parseTypeTokens(param, &tokens, error)) {
+ return false;
+ }
+
+ // Sanity check, there must be a least two non-special tokens.
+ size_t nonSpecialCount = 0;
+ for (size_t n = 0; n < tokens.size(); ++n) {
+ if (tokens[n] != "*" && tokens[n] != "const") {
+ nonSpecialCount++;
+ }
+ }
+ if (nonSpecialCount == 0) {
+ *error = "Missing type name";
+ return false;
+ }
+ if (nonSpecialCount == 1) {
+ *error = "Missing variable name";
+ return false;
+ }
+
+ // Sanity check: variable name must not be followed by 'const' or '*'
+ const std::string& lastToken = tokens[tokens.size() - 1U];
+ if (lastToken == "*") {
+ *error = "Extra '*' after variable name";
+ return false;
+ }
+ if (lastToken == "const") {
+ *error = "Extra 'const' after variable name";
+ return false;
+ }
+
+ // Extract the variable name as the last token.
+ if (variableName) {
+ *variableName = lastToken;
+ }
+ // Build the type name from all tokens before it.
+ *typeName = buildTypeString(tokens, tokens.size() - 1U);
+ return true;
+}
diff --git a/emulator/opengl/host/tools/emugen/Parser.h b/emulator/opengl/host/tools/emugen/Parser.h
new file mode 100644
index 000000000..f62c0763b
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/Parser.h
@@ -0,0 +1,68 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#ifndef PARSER_H
+#define PARSER_H
+
+#include <string>
+
+// Normalize a type declaration. This gets rid of leading/trailing whitespace
+// as well as ensure there is a single space separating all input tokens,
+// with the exception of '*' which is treated specially by never being
+// prepended with a space.
+// |input| is the input type declaration. Return normalized form.
+// Note that this doesn't try to validate the input.
+std::string normalizeTypeDeclaration(const std::string& input);
+
+// Parse a return type declaration. |input| is the type declaration
+// (e.g. 'const char**'). On success return true and sets |*typeName| to
+// the appropriate normalized type string. On failure, return false and
+// sets |*error| with a human-friendly message explaining the reason for
+// failure.
+//
+// Note that the returned type string is normalized, see comment for
+// parseParameterDeclaration() for examples.
+//
+// NOTE: This does not support declarations of arrays or functions!
+//
+bool parseTypeDeclaration(const std::string& input,
+ std::string* typeName,
+ std::string* error);
+
+// Parse a function parameter declaration and extract the type and variable
+// name from it. |param| is the individual parameter declaration from the
+// function's signature (e.g. 'const char *items')
+//
+// On success, returns true and sets |*vartype| and |*varname| to the
+// appropriate type name and variable name. |varname| can be NULL if the caller
+// isn't interested in the variable name.
+//
+// On failure, return false and sets |*error| to a human-friendly message
+// explaining the reason for failure.
+//
+// Note that the returned type name is normalized with regards to whitespace
+// and star location, e.g.:
+//
+// const void *items -> 'const void*'
+// char* *items -> 'char**'
+// const void * const * items -> 'const void* const*'
+// unsigned int *const data -> 'unsigned int* const'
+//
+bool parseParameterDeclaration(const std::string& param,
+ std::string* typeName,
+ std::string* variableName,
+ std::string* error);
+
+#endif // PARSER_H
diff --git a/emulator/opengl/host/tools/emugen/Parser_unittest.cpp b/emulator/opengl/host/tools/emugen/Parser_unittest.cpp
new file mode 100644
index 000000000..904b24737
--- /dev/null
+++ b/emulator/opengl/host/tools/emugen/Parser_unittest.cpp
@@ -0,0 +1,120 @@
+/*
+* Copyright 2014 The Android Open Source Project
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+*/
+#include "Parser.h"
+
+#include <gtest/gtest.h>
+
+#define ARRAYLEN(x) (sizeof(x) / sizeof(x[0]))
+
+TEST(ParserTest, normalizeTypeDeclaration) {
+ static const struct {
+ const char* expected;
+ const char* input;
+ } kData[] = {
+ { "char", "char" },
+ { "const unsigned int", " const unsigned\tint\n" },
+ { "char* const**", "char *const* *" },
+ };
+ const size_t kDataSize = ARRAYLEN(kData);
+ for (size_t n = 0; n < kDataSize; ++n) {
+ std::string result;
+ std::string text = "When parsing '";
+ text += kData[n].input;
+ text += "'";
+
+ result = normalizeTypeDeclaration(kData[n].input);
+ EXPECT_STREQ(kData[n].expected, result.c_str()) << text;
+ }
+}
+
+TEST(ParserTest, parseTypeDeclaration) {
+ static const struct {
+ const char* input;
+ bool expected;
+ const char* expectedType;
+ const char* expectedError;
+ } kData[] = {
+ { "const", false, NULL, "Missing type name" },
+ { "const const", false, NULL, "Missing type name" },
+ { "foo", true, "foo", NULL },
+ { "void", true, "void", NULL },
+ { "const foo", true, "const foo", NULL },
+ { "foo *", true, "foo*", NULL },
+ { "char foo", true, "char foo", NULL },
+ { "\tunsigned \t int\n", true, "unsigned int", NULL },
+ { "const * char", false, NULL, "Unexpected '*' before type name" },
+ { "const char * ", true, "const char*", NULL },
+ { "const void*const * *", true, "const void* const**", NULL },
+ };
+ const size_t kDataSize = ARRAYLEN(kData);
+ for (size_t n = 0; n < kDataSize; ++n) {
+ std::string varname, vartype, error;
+ std::string text = "When parsing '";
+ text += kData[n].input;
+ text += "'";
+
+ EXPECT_EQ(kData[n].expected,
+ parseTypeDeclaration(kData[n].input,
+ &vartype,
+ &error)) << text;
+ if (kData[n].expected) {
+ EXPECT_STREQ(kData[n].expectedType, vartype.c_str()) << text;
+ } else {
+ EXPECT_STREQ(kData[n].expectedError, error.c_str()) << text;
+ }
+ }
+}
+
+TEST(ParserTest, parseParameterDeclaration) {
+ static const struct {
+ const char* input;
+ bool expected;
+ const char* expectedType;
+ const char* expectedVariable;
+ const char* expectedError;
+ } kData[] = {
+ { "foo", false, NULL, NULL, "Missing variable name" },
+ { "const", false, NULL, NULL, "Missing type name" },
+ { "const foo", false, NULL, NULL, "Missing variable name" },
+ { "const const", false, NULL, NULL, "Missing type name" },
+ { "char foo", true, "char", "foo", NULL },
+ { "unsigned int\t bar\n", true, "unsigned int", "bar", NULL },
+ { "const * char foo", false, NULL, NULL, "Unexpected '*' before type name" },
+ { "const char * foo", true, "const char*", "foo", NULL },
+ { "const void*const *data", true, "const void* const*", "data", NULL },
+ { "char foo const", false, NULL, NULL, "Extra 'const' after variable name" },
+ { "int bar*", false, NULL, NULL, "Extra '*' after variable name" },
+ };
+ const size_t kDataSize = ARRAYLEN(kData);
+ for (size_t n = 0; n < kDataSize; ++n) {
+ std::string varname, vartype, error;
+ std::string text = "When parsing '";
+ text += kData[n].input;
+ text += "'";
+
+ EXPECT_EQ(kData[n].expected,
+ parseParameterDeclaration(kData[n].input,
+ &vartype,
+ &varname,
+ &error)) << text;
+ if (kData[n].expected) {
+ EXPECT_STREQ(kData[n].expectedType, vartype.c_str()) << text;
+ EXPECT_STREQ(kData[n].expectedVariable, varname.c_str()) << text;
+ } else {
+ EXPECT_STREQ(kData[n].expectedError, error.c_str()) << text;
+ }
+ }
+}
diff --git a/emulator/opengl/host/tools/emugen/TypeFactory.cpp b/emulator/opengl/host/tools/emugen/TypeFactory.cpp
index 7f495caac..1e0cc96e0 100644
--- a/emulator/opengl/host/tools/emugen/TypeFactory.cpp
+++ b/emulator/opengl/host/tools/emugen/TypeFactory.cpp
@@ -14,12 +14,16 @@
* limitations under the License.
*/
#include "TypeFactory.h"
+
+#include "Parser.h"
#include "VarType.h"
-#include <string>
+#include "strUtils.h"
+
#include <map>
+#include <string>
+
#include <stdio.h>
#include <stdlib.h>
-#include "strUtils.h"
TypeFactory * TypeFactory::m_instance = NULL;
@@ -66,6 +70,7 @@ int TypeFactory::initFromFile(const std::string &filename)
size_t pos = 0, last;
std::string name;
name = getNextToken(str, pos, &last, WHITESPACE);
+ name = normalizeTypeDeclaration(name);
if (name.size() == 0) {
fprintf(stderr, "Error: %d : missing type name\n", lc);
return -2;
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
index d56653fb5..03192845c 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_dec.cpp
@@ -77,6 +77,14 @@ size_t foo_decoder_context_t::decode(void *buf, size_t len, IOStream *stream)
SET_LASTCALL("fooDoEncoderFlush");
break;
}
+ case OP_fooTakeConstVoidPtrConstPtr: {
+ uint32_t size_param __attribute__((unused)) = Unpack<uint32_t,uint32_t>(ptr + 8);
+ InputBuffer inptr_param(ptr + 8 + 4, size_param);
+ DEBUG("foo(%p): fooTakeConstVoidPtrConstPtr(%p(%u) )\n", stream,(const void* const*)(inptr_param.get()), size_param);
+ this->fooTakeConstVoidPtrConstPtr((const void* const*)(inptr_param.get()));
+ SET_LASTCALL("fooTakeConstVoidPtrConstPtr");
+ break;
+ }
default:
unknownOpcode = true;
} //switch
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
index 154f2e1e2..7219caaf1 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_opcodes.h
@@ -7,7 +7,8 @@
#define OP_fooIsBuffer 201
#define OP_fooUnsupported 202
#define OP_fooDoEncoderFlush 203
-#define OP_last 204
+#define OP_fooTakeConstVoidPtrConstPtr 204
+#define OP_last 205
#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
index e310e2f26..22ff47f9d 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.cpp
@@ -14,6 +14,7 @@ int foo_server_context_t::initDispatchByName(void *(*getProc)(const char *, void
fooIsBuffer = (fooIsBuffer_server_proc_t) getProc("fooIsBuffer", userData);
fooUnsupported = (fooUnsupported_server_proc_t) getProc("fooUnsupported", userData);
fooDoEncoderFlush = (fooDoEncoderFlush_server_proc_t) getProc("fooDoEncoderFlush", userData);
+ fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_server_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData);
return 0;
}
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
index 3cc0fd5d5..186a3d102 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_context.h
@@ -12,6 +12,7 @@ struct foo_server_context_t {
fooIsBuffer_server_proc_t fooIsBuffer;
fooUnsupported_server_proc_t fooUnsupported;
fooDoEncoderFlush_server_proc_t fooDoEncoderFlush;
+ fooTakeConstVoidPtrConstPtr_server_proc_t fooTakeConstVoidPtrConstPtr;
virtual ~foo_server_context_t() {}
int initDispatchByName( void *(*getProc)(const char *name, void *userData), void *userData);
};
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
index e67ea2a64..da104a13b 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/decoder/foo_server_proc.h
@@ -13,6 +13,7 @@ typedef void (foo_APIENTRY *fooAlphaFunc_server_proc_t) (FooInt, FooFloat);
typedef FooBoolean (foo_APIENTRY *fooIsBuffer_server_proc_t) (void*);
typedef void (foo_APIENTRY *fooUnsupported_server_proc_t) (void*);
typedef void (foo_APIENTRY *fooDoEncoderFlush_server_proc_t) (FooInt);
+typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_server_proc_t) (const void* const*);
#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
index 70a5f645a..f09e8811c 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.cpp
@@ -14,6 +14,7 @@ int foo_client_context_t::initDispatchByName(void *(*getProc)(const char *, void
fooIsBuffer = (fooIsBuffer_client_proc_t) getProc("fooIsBuffer", userData);
fooUnsupported = (fooUnsupported_client_proc_t) getProc("fooUnsupported", userData);
fooDoEncoderFlush = (fooDoEncoderFlush_client_proc_t) getProc("fooDoEncoderFlush", userData);
+ fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_client_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData);
return 0;
}
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
index 2dfc76a0f..84e9d6f0e 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_context.h
@@ -12,6 +12,7 @@ struct foo_client_context_t {
fooIsBuffer_client_proc_t fooIsBuffer;
fooUnsupported_client_proc_t fooUnsupported;
fooDoEncoderFlush_client_proc_t fooDoEncoderFlush;
+ fooTakeConstVoidPtrConstPtr_client_proc_t fooTakeConstVoidPtrConstPtr;
virtual ~foo_client_context_t() {}
typedef foo_client_context_t *CONTEXT_ACCESSOR_TYPE(void);
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
index d39b73a3b..6fc27f060 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_client_proc.h
@@ -13,6 +13,7 @@ typedef void (foo_APIENTRY *fooAlphaFunc_client_proc_t) (void * ctx, FooInt, Foo
typedef FooBoolean (foo_APIENTRY *fooIsBuffer_client_proc_t) (void * ctx, void*);
typedef void (foo_APIENTRY *fooUnsupported_client_proc_t) (void * ctx, void*);
typedef void (foo_APIENTRY *fooDoEncoderFlush_client_proc_t) (void * ctx, FooInt);
+typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_client_proc_t) (void * ctx, const void* const*);
#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
index 5e1758e33..3a7a94b7a 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_enc.cpp
@@ -70,6 +70,23 @@ void fooDoEncoderFlush_enc(void *self , FooInt param)
stream->flush();
}
+void fooTakeConstVoidPtrConstPtr_enc(void *self , const void* const* param)
+{
+
+ foo_encoder_context_t *ctx = (foo_encoder_context_t *)self;
+ IOStream *stream = ctx->m_stream;
+
+ const unsigned int __size_param = ;
+ unsigned char *ptr;
+ const size_t packetSize = 8 + __size_param + 1*4;
+ ptr = stream->alloc(packetSize);
+ int tmp = OP_fooTakeConstVoidPtrConstPtr;memcpy(ptr, &tmp, 4); ptr += 4;
+ memcpy(ptr, &packetSize, 4); ptr += 4;
+
+ *(unsigned int *)(ptr) = __size_param; ptr += 4;
+ memcpy(ptr, param, __size_param);ptr += __size_param;
+}
+
} // namespace
foo_encoder_context_t::foo_encoder_context_t(IOStream *stream)
@@ -80,5 +97,6 @@ foo_encoder_context_t::foo_encoder_context_t(IOStream *stream)
this->fooIsBuffer = &fooIsBuffer_enc;
this->fooUnsupported = (fooUnsupported_client_proc_t) &enc_unsupported;
this->fooDoEncoderFlush = &fooDoEncoderFlush_enc;
+ this->fooTakeConstVoidPtrConstPtr = &fooTakeConstVoidPtrConstPtr_enc;
}
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
index 697f143a9..b91129c03 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_entry.cpp
@@ -10,6 +10,7 @@ extern "C" {
FooBoolean fooIsBuffer(void* stuff);
void fooUnsupported(void* params);
void fooDoEncoderFlush(FooInt param);
+ void fooTakeConstVoidPtrConstPtr(const void* const* param);
};
#endif
@@ -44,3 +45,9 @@ void fooDoEncoderFlush(FooInt param)
ctx->fooDoEncoderFlush(ctx, param);
}
+void fooTakeConstVoidPtrConstPtr(const void* const* param)
+{
+ GET_CONTEXT;
+ ctx->fooTakeConstVoidPtrConstPtr(ctx, param);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
index cba476bec..e397e50e2 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_ftable.h
@@ -12,6 +12,7 @@ static const struct _foo_funcs_by_name {
{"fooIsBuffer", (void*)fooIsBuffer},
{"fooUnsupported", (void*)fooUnsupported},
{"fooDoEncoderFlush", (void*)fooDoEncoderFlush},
+ {"fooTakeConstVoidPtrConstPtr", (void*)fooTakeConstVoidPtrConstPtr},
};
static const int foo_num_funcs = sizeof(foo_funcs_by_name) / sizeof(struct _foo_funcs_by_name);
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
index 154f2e1e2..7219caaf1 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/encoder/foo_opcodes.h
@@ -7,7 +7,8 @@
#define OP_fooIsBuffer 201
#define OP_fooUnsupported 202
#define OP_fooDoEncoderFlush 203
-#define OP_last 204
+#define OP_fooTakeConstVoidPtrConstPtr 204
+#define OP_last 205
#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
index 46eb6ceb4..6e132b104 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.cpp
@@ -14,6 +14,7 @@ int foo_wrapper_context_t::initDispatchByName(void *(*getProc)(const char *, voi
fooIsBuffer = (fooIsBuffer_wrapper_proc_t) getProc("fooIsBuffer", userData);
fooUnsupported = (fooUnsupported_wrapper_proc_t) getProc("fooUnsupported", userData);
fooDoEncoderFlush = (fooDoEncoderFlush_wrapper_proc_t) getProc("fooDoEncoderFlush", userData);
+ fooTakeConstVoidPtrConstPtr = (fooTakeConstVoidPtrConstPtr_wrapper_proc_t) getProc("fooTakeConstVoidPtrConstPtr", userData);
return 0;
}
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
index 166be4453..e5e30e683 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_context.h
@@ -12,6 +12,7 @@ struct foo_wrapper_context_t {
fooIsBuffer_wrapper_proc_t fooIsBuffer;
fooUnsupported_wrapper_proc_t fooUnsupported;
fooDoEncoderFlush_wrapper_proc_t fooDoEncoderFlush;
+ fooTakeConstVoidPtrConstPtr_wrapper_proc_t fooTakeConstVoidPtrConstPtr;
virtual ~foo_wrapper_context_t() {}
typedef foo_wrapper_context_t *CONTEXT_ACCESSOR_TYPE(void);
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
index 2e32e9ca0..7591393c1 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_entry.cpp
@@ -10,6 +10,7 @@ extern "C" {
FooBoolean fooIsBuffer(void* stuff);
void fooUnsupported(void* params);
void fooDoEncoderFlush(FooInt param);
+ void fooTakeConstVoidPtrConstPtr(const void* const* param);
};
#endif
@@ -43,3 +44,9 @@ void fooDoEncoderFlush(FooInt param)
ctx->fooDoEncoderFlush( param);
}
+void fooTakeConstVoidPtrConstPtr(const void* const* param)
+{
+ GET_CONTEXT;
+ ctx->fooTakeConstVoidPtrConstPtr( param);
+}
+
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
index 2fafa24d0..294b9587d 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/expected/wrapper/foo_wrapper_proc.h
@@ -13,6 +13,7 @@ typedef void (foo_APIENTRY *fooAlphaFunc_wrapper_proc_t) (FooInt, FooFloat);
typedef FooBoolean (foo_APIENTRY *fooIsBuffer_wrapper_proc_t) (void*);
typedef void (foo_APIENTRY *fooUnsupported_wrapper_proc_t) (void*);
typedef void (foo_APIENTRY *fooDoEncoderFlush_wrapper_proc_t) (FooInt);
+typedef void (foo_APIENTRY *fooTakeConstVoidPtrConstPtr_wrapper_proc_t) (const void* const*);
#endif
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
index e61fe572a..4e98f88b6 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.in
@@ -2,3 +2,4 @@ FOO_ENTRY(void, fooAlphaFunc, FooInt func, FooFloat ref)
FOO_ENTRY(FooBoolean, fooIsBuffer, void* stuff)
FOO_ENTRY(void, fooUnsupported, void* params)
FOO_ENTRY(void, fooDoEncoderFlush, FooInt param)
+FOO_ENTRY(void, fooTakeConstVoidPtrConstPtr, const void* const* param)
diff --git a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
index c4140d197..05d72fbe2 100644
--- a/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
+++ b/emulator/opengl/host/tools/emugen/tests/t.001/input/foo.types
@@ -6,4 +6,5 @@ FooEnum 32 %08x
FooVoid 0 %x
FooChar 8 %d
FooChar* 32 0x%08x
-void* 32 0x%08x \ No newline at end of file
+void* 32 0x%08x
+void*const* 32 0x%08x