aboutsummaryrefslogtreecommitdiffstats
path: root/emulator
diff options
context:
space:
mode:
authorDavid 'Digit' Turner <digit@google.com>2014-09-25 12:47:32 -0700
committerbohu <bohu@google.com>2014-11-25 12:30:47 -0800
commit7f0f4aab2a307626c13b860179f46017480f7985 (patch)
treeb742ce6a4dd387759f648f6b183f534853b7c797 /emulator
parentde4e8c9fa8431abc06cf6fb147beeb675dd9cef5 (diff)
downloadsdk-7f0f4aab2a307626c13b860179f46017480f7985.zip
sdk-7f0f4aab2a307626c13b860179f46017480f7985.tar.gz
sdk-7f0f4aab2a307626c13b860179f46017480f7985.tar.bz2
emulator/opengl/emugen: Introduce helper macros.
This patch introduces two helper macros in the generated decoder to make its source code slightly more readable (DEBUG and SET_LASCALL). Change-Id: I6659fe69a5533e5194d8db5f1882abaf1a5daee5
Diffstat (limited to 'emulator')
-rw-r--r--emulator/opengl/host/tools/emugen/ApiGen.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/emulator/opengl/host/tools/emugen/ApiGen.cpp b/emulator/opengl/host/tools/emugen/ApiGen.cpp
index e7f6d0b..8b2548b 100644
--- a/emulator/opengl/host/tools/emugen/ApiGen.cpp
+++ b/emulator/opengl/host/tools/emugen/ApiGen.cpp
@@ -756,6 +756,21 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "#include <stdio.h>\n\n");
fprintf(fp, "typedef unsigned int tsize_t; // Target \"size_t\", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.\n\n");
+ // helper macros
+ fprintf(fp,
+ "#ifdef DEBUG_PRINTOUT\n"
+ "# define DEBUG(...) fprintf(stderr, __VA_ARGS__)\n"
+ "#else\n"
+ "# define DEBUG(...) ((void)0)\n"
+ "#endif\n\n");
+
+ fprintf(fp,
+ "#ifdef CHECK_GLERROR\n"
+ "# define SET_LASTCALL(name) sprintf(lastCall, #name)\n"
+ "#else\n"
+ "# define SET_LASTCALL(name) ((void)0)\n"
+ "#endif\n\n");
+
// helper templates
fprintf(fp, "using namespace emugl;\n\n");
@@ -817,9 +832,8 @@ int ApiGen::genDecoderImpl(const std::string &filename)
fprintf(fp, "this"); // add a context to the call
}
} else if (pass == PASS_DebugPrint) {
- fprintf(fp, "#ifdef DEBUG_PRINTOUT\n");
fprintf(fp,
- "\t\t\tfprintf(stderr,\"%s(%%p): %s(%s)\\n\", stream",
+ "\t\t\tDEBUG(\"%s(%%p): %s(%s)\\n\", stream",
m_basename.c_str(),
e->name().c_str(),
printString.c_str());
@@ -1010,9 +1024,6 @@ int ApiGen::genDecoderImpl(const std::string &filename)
pass == PASS_DebugPrint) {
fprintf(fp, ");\n");
}
- if (pass == PASS_DebugPrint) {
- fprintf(fp, "#endif\n");
- }
if (pass == PASS_TmpBuffAlloc) {
if (!e->retval().isVoid() && !e->retval().isPointer()) {
@@ -1045,9 +1056,7 @@ int ApiGen::genDecoderImpl(const std::string &filename)
} // pass;
fprintf(fp, "\t\t\t}\n");
- fprintf(fp, "#ifdef CHECK_GL_ERROR\n");
- fprintf(fp, "\t\t\tsprintf(lastCall, \"%s\");\n", e->name().c_str());
- fprintf(fp, "#endif\n");
+ fprintf(fp, "\t\t\tSET_LASTCALL(\"%s\");\n", e->name().c_str());
fprintf(fp, "\t\t\tbreak;\n");
delete [] tmpBufOffset;