Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit daed524c authored by Joe Onorato's avatar Joe Onorato
Browse files

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

conform to that.
parent c028d094
Loading
Loading
Loading
Loading
+1 −10
Original line number Diff line number Diff line
@@ -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)
+6 −6
Original line number Diff line number Diff line


#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);

libs/rs/spec.h

0 → 100644
+38 −0
Original line number Diff line number Diff line
#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
+4 −18
Original line number Diff line number Diff line
@@ -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);
    }