diff options
author | Jason Sams <rjsams@android.com> | 2011-04-28 18:26:48 -0700 |
---|---|---|
committer | Jason Sams <rjsams@android.com> | 2011-04-28 18:26:48 -0700 |
commit | c975cf4a71b63ccbd20f1f3b3341c5f2e6025b45 (patch) | |
tree | 74faddc5fe76f9cc15099f25a54023fee81501ea /rsg_generator.c | |
parent | 5fb1aeb6374f814d72117803682bc141cc6b0895 (diff) | |
download | rs-c975cf4a71b63ccbd20f1f3b3341c5f2e6025b45.tar.gz |
Pipe rsa function though the RS api table.
Change-Id: Ic8a3bef5d337be1d8fc5ca961eec6be4761701c5
Diffstat (limited to 'rsg_generator.c')
-rw-r--r-- | rsg_generator.c | 109 |
1 files changed, 98 insertions, 11 deletions
diff --git a/rsg_generator.c b/rsg_generator.c index 0059f192..ed20fef1 100644 --- a/rsg_generator.c +++ b/rsg_generator.c @@ -97,9 +97,20 @@ void printStructures(FILE *f) { } } -void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext) { +void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addContext, int isFnPtr) { printVarTypeAndName(f, &api->ret); - fprintf(f, " %s%s (", prefix, api->name); + if (isFnPtr) { + char t[1024]; + strcpy(t, api->name); + if (strlen(prefix) == 0) { + if (t[0] > 'A' && t[0] < 'Z') { + t[0] -= 'A' - 'a'; + } + } + fprintf(f, " (* %s%s) (", prefix, api->name); + } else { + fprintf(f, " %s%s (", prefix, api->name); + } if (!api->nocontext) { if (addContext) { fprintf(f, "Context *"); @@ -114,12 +125,24 @@ void printFuncDecl(FILE *f, const ApiEntry *api, const char *prefix, int addCont void printFuncDecls(FILE *f, const char *prefix, int addContext) { int ct; for (ct=0; ct < apiCount; ct++) { - printFuncDecl(f, &apis[ct], prefix, addContext); + printFuncDecl(f, &apis[ct], prefix, addContext, 0); fprintf(f, ";\n"); } fprintf(f, "\n\n"); } +void printFuncPointers(FILE *f, int addContext) { + fprintf(f, "\n"); + fprintf(f, "typedef struct RsApiEntrypoints {\n"); + int ct; + for (ct=0; ct < apiCount; ct++) { + fprintf(f, " "); + printFuncDecl(f, &apis[ct], "", addContext, 1); + fprintf(f, ";\n"); + } + fprintf(f, "} RsApiEntrypoints_t;\n\n"); +} + void printPlaybackFuncs(FILE *f, const char *prefix) { int ct; for (ct=0; ct < apiCount; ct++) { @@ -172,21 +195,35 @@ void printApiCpp(FILE *f) { fprintf(f, "#include \"rsHandcode.h\"\n"); fprintf(f, "\n"); + printFuncPointers(f, 0); + + // Generate RS funcs for local fifo for (ct=0; ct < apiCount; ct++) { int needFlush = 0; const ApiEntry * api = &apis[ct]; - if (api->direct) { - continue; - } - - printFuncDecl(f, api, "rs", 0); + fprintf(f, "static "); + printFuncDecl(f, api, "LF_", 0, 0); fprintf(f, "\n{\n"); - if (api->handcodeApi) { - fprintf(f, " rsHCAPI_%s(rsc", api->name); + if (api->handcodeApi || api->direct) { + if (api->handcodeApi) { + fprintf(f, " rsHCAPI_%s(rsc", api->name); + } else { + fprintf(f, " "); + if (api->ret.typeName[0]) { + fprintf(f, "return "); + } + fprintf(f, "rsi_%s(", api->name); + if (!api->nocontext) { + fprintf(f, "(Context *)rsc"); + } + } for (ct2=0; ct2 < api->paramCount; ct2++) { const VarType *vt = &api->params[ct2]; - fprintf(f, ", %s", vt->name); + if (ct2 > 0 || !api->nocontext) { + fprintf(f, ", "); + } + fprintf(f, "%s", vt->name); } fprintf(f, ");\n"); } else { @@ -252,6 +289,43 @@ void printApiCpp(FILE *f) { } fprintf(f, "};\n\n"); } + + fprintf(f, "\n"); + fprintf(f, "static RsApiEntrypoints_t s_LocalTable = {\n"); + for (ct=0; ct < apiCount; ct++) { + fprintf(f, " LF_%s,\n", apis[ct].name); + } + fprintf(f, "};\n"); + + fprintf(f, "static RsApiEntrypoints_t *s_CurrentTable = &s_LocalTable;\n\n"); + + for (ct=0; ct < apiCount; ct++) { + int needFlush = 0; + const ApiEntry * api = &apis[ct]; + + printFuncDecl(f, api, "rs", 0, 0); + fprintf(f, "\n{\n"); + fprintf(f, " "); + if (api->ret.typeName[0]) { + fprintf(f, "return "); + } + fprintf(f, "s_CurrentTable->%s(", api->name); + + if (!api->nocontext) { + fprintf(f, "(Context *)rsc"); + } + + for (ct2=0; ct2 < api->paramCount; ct2++) { + const VarType *vt = &api->params[ct2]; + if (ct2 > 0 || !api->nocontext) { + fprintf(f, ", "); + } + fprintf(f, "%s", vt->name); + } + fprintf(f, ");\n"); + fprintf(f, "}\n\n"); + } + } void printPlaybackCpp(FILE *f) { @@ -373,6 +447,19 @@ int main(int argc, char **argv) { printPlaybackCpp(f); } break; + + case '4': // rsgApiStream.cpp + { + printFileHeader(f); + printPlaybackCpp(f); + } + + case '5': // rsgApiStreamReplay.cpp + { + printFileHeader(f); + printPlaybackCpp(f); + } + break; } fclose(f); return 0; |