The build system knows how to deal with lex files, but it treats them as c++, so make spec.lex

conform to that.
This commit is contained in:
Joe Onorato
2009-08-10 15:01:51 -07:00
parent c028d09409
commit daed524c35
4 changed files with 49 additions and 34 deletions

View File

@@ -14,17 +14,8 @@ LOCAL_IS_HOST_MODULE := true
LOCAL_MODULE_CLASS := EXECUTABLES
intermediates := $(local-intermediates-dir)
GEN := $(addprefix $(intermediates)/, \
lex.yy.c \
)
$(GEN): PRIVATE_CUSTOM_TOOL = flex -o $@ $<
$(intermediates)/lex.yy.c : $(LOCAL_PATH)/spec.lex
$(transform-generated-source)
$(LOCAL_PATH)/rsg_generator.c : $(intermediates)/lex.yy.c
LOCAL_SRC_FILES:= \
spec.l \
rsg_generator.c
include $(BUILD_HOST_EXECUTABLE)

View File

@@ -1,6 +1,6 @@
#include "lex.yy.c"
#include "spec.h"
#include <stdio.h>
void printFileHeader(FILE *f)
{
@@ -45,7 +45,7 @@ void printVarType(FILE *f, const VarType *vt)
fprintf(f, "double");
break;
case 4:
fprintf(f, "%s", vt->typename);
fprintf(f, "%s", vt->typeName);
break;
}
@@ -157,7 +157,7 @@ void printApiCpp(FILE *f)
needFlush += vt->ptrLevel;
fprintf(f, " cmd->%s = %s;\n", vt->name, vt->name);
}
if (api->ret.typename[0]) {
if (api->ret.typeName[0]) {
needFlush = 1;
}
@@ -167,7 +167,7 @@ void printApiCpp(FILE *f)
}
fprintf(f, "(RS_CMD_ID_%s, size);\n", api->name);
if (api->ret.typename[0]) {
if (api->ret.typeName[0]) {
fprintf(f, " return reinterpret_cast<");
printVarType(f, &api->ret);
fprintf(f, ">(io->mToCoreRet);\n");
@@ -199,7 +199,7 @@ void printPlaybackCpp(FILE *f)
//fprintf(f, " LOGE(\"play command %s\\n\");\n", api->name);
fprintf(f, " const RS_CMD_%s *cmd = static_cast<const RS_CMD_%s *>(vp);\n", api->name, api->name);
fprintf(f, " ");
if (api->ret.typename[0]) {
if (api->ret.typeName[0]) {
fprintf(f, "gIO->mToCoreRet = (intptr_t)");
}
fprintf(f, "rsi_%s(con", api->name);

38
libs/rs/spec.h Normal file
View File

@@ -0,0 +1,38 @@
#ifndef SPEC_H
#define SPEC_H
#if __cplusplus
extern "C" {
#endif
extern int num_lines;
typedef struct {
int isConst;
int type;
int bits;
int ptrLevel;
char name[256];
char typeName[256];
} VarType;
extern VarType *currType;
typedef struct {
char name[256];
int sync;
int paramCount;
VarType ret;
VarType params[16];
} ApiEntry;
extern ApiEntry apis[128];
extern int apiCount;
extern int typeNextState;
#if __cplusplus
} // extern "C"
#endif
#endif // SPEC_H

View File

@@ -9,33 +9,19 @@
DIGIT [0-9]
ID [a-zA-Z_][a-zA-Z0-9_]*
#include "spec.h"
int num_lines = 0;
typedef struct {
int isConst;
int type;
int bits;
int ptrLevel;
char name[256];
char typename[256];
} VarType;
VarType *currType = 0;
typedef struct {
char name[256];
int sync;
int paramCount;
VarType ret;
VarType params[16];
} ApiEntry;
ApiEntry apis[128];
int apiCount = 0;
int typeNextState;
extern "C" int yylex();
%%
"/*" BEGIN(comment);
@@ -141,7 +127,7 @@ ID [a-zA-Z_][a-zA-Z0-9_]*
<var_type>{ID} {
currType->type = 4;
currType->bits = 32;
memcpy(currType->typename, yytext, yyleng);
memcpy(currType->typeName, yytext, yyleng);
BEGIN(typeNextState);
}