diff options
author | David 'Digit' Turner <digit@google.com> | 2014-09-25 12:47:32 -0700 |
---|---|---|
committer | David 'Digit' Turner <digit@google.com> | 2014-09-25 15:44:10 -0700 |
commit | 9319d29db93b728947a32d30a1b109d237130ffd (patch) | |
tree | 1e52b61023c85220f253d6f6386e3deb9abc8530 /emulator | |
parent | e3803760bc279db27e997b17a0941c34a7d61b5a (diff) | |
download | sdk-9319d29db93b728947a32d30a1b109d237130ffd.zip sdk-9319d29db93b728947a32d30a1b109d237130ffd.tar.gz sdk-9319d29db93b728947a32d30a1b109d237130ffd.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.cpp | 25 |
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; |