提交 fac8ac88 编写于 作者: dengyihao's avatar dengyihao

update fst search frame

上级 f07045c1
...@@ -38,8 +38,18 @@ typedef struct Complement { ...@@ -38,8 +38,18 @@ typedef struct Complement {
// automation // automation
typedef struct AutomationCtx { typedef struct AutomationCtx {
AutomationType type; AutomationType type;
void *data;
} AutomationCtx; } AutomationCtx;
typedef enum StartWithStateKind { Done, Running } StartWithStateKind;
typedef struct StartWithStateValue {
StartWithStateKind kind;
void *value;
} StartWithStateValue;
typedef struct AutomationFunc { typedef struct AutomationFunc {
void* (*start)(AutomationCtx *ctx) ; void* (*start)(AutomationCtx *ctx) ;
bool (*isMatch)(AutomationCtx *ctx, void *); bool (*isMatch)(AutomationCtx *ctx, void *);
......
...@@ -17,8 +17,9 @@ ...@@ -17,8 +17,9 @@
// prefix query, impl later // prefix query, impl later
static void* prefixStart(AutomationCtx *ctx) { static void* prefixStart(AutomationCtx *ctx) {
return NULL; StartWithStateValue *data = (StartWithStateValue *)(ctx->data);
return data;
}; };
static bool prefixIsMatch(AutomationCtx *ctx, void *data) { static bool prefixIsMatch(AutomationCtx *ctx, void *data) {
return true; return true;
...@@ -82,16 +83,24 @@ AutomationCtx* automCtxCreate(void *data, AutomationType type) { ...@@ -82,16 +83,24 @@ AutomationCtx* automCtxCreate(void *data, AutomationType type) {
AutomationCtx *ctx = calloc(1, sizeof(AutomationCtx)); AutomationCtx *ctx = calloc(1, sizeof(AutomationCtx));
if (ctx == NULL) { return NULL; } if (ctx == NULL) { return NULL; }
ctx->type = type; if (type == AUTOMATION_PREFIX) {
if (ctx->type == AUTOMATION_PREFIX) { StartWithStateValue *swsv = (StartWithStateValue *)calloc(1, sizeof(StartWithStateValue));
swsv->kind = Done;
} else if (ctx->type == AUTMMATION_MATCH) { swsv->value = NULL;
ctx->data = (void *)swsv;
} else if (type == AUTMMATION_MATCH) {
} else { } else {
// add more search type // add more search type
} }
ctx->type = type;
return ctx; return ctx;
} }
void automCtxDestroy(AutomationCtx *ctx) { void automCtxDestroy(AutomationCtx *ctx) {
if (ctx->type == AUTOMATION_PREFIX) {
free(ctx->data);
} else if (ctx->type == AUTMMATION_MATCH) {
}
free(ctx); free(ctx);
} }
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册