update fst search frame

This commit is contained in:
yihaoDeng 2021-12-12 23:22:26 +08:00
parent f07045c1d8
commit fac8ac88b9
2 changed files with 26 additions and 7 deletions

View File

@ -38,8 +38,18 @@ typedef struct Complement {
// automation
typedef struct AutomationCtx {
AutomationType type;
void *data;
} AutomationCtx;
typedef enum StartWithStateKind { Done, Running } StartWithStateKind;
typedef struct StartWithStateValue {
StartWithStateKind kind;
void *value;
} StartWithStateValue;
typedef struct AutomationFunc {
void* (*start)(AutomationCtx *ctx) ;
bool (*isMatch)(AutomationCtx *ctx, void *);

View File

@ -18,7 +18,8 @@
// prefix query, impl later
static void* prefixStart(AutomationCtx *ctx) {
return NULL;
StartWithStateValue *data = (StartWithStateValue *)(ctx->data);
return data;
};
static bool prefixIsMatch(AutomationCtx *ctx, void *data) {
return true;
@ -82,16 +83,24 @@ AutomationCtx* automCtxCreate(void *data, AutomationType type) {
AutomationCtx *ctx = calloc(1, sizeof(AutomationCtx));
if (ctx == NULL) { return NULL; }
ctx->type = type;
if (ctx->type == AUTOMATION_PREFIX) {
} else if (ctx->type == AUTMMATION_MATCH) {
if (type == AUTOMATION_PREFIX) {
StartWithStateValue *swsv = (StartWithStateValue *)calloc(1, sizeof(StartWithStateValue));
swsv->kind = Done;
swsv->value = NULL;
ctx->data = (void *)swsv;
} else if (type == AUTMMATION_MATCH) {
} else {
// add more search type
}
ctx->type = type;
return ctx;
}
void automCtxDestroy(AutomationCtx *ctx) {
if (ctx->type == AUTOMATION_PREFIX) {
free(ctx->data);
} else if (ctx->type == AUTMMATION_MATCH) {
}
free(ctx);
}