*/
typedef struct MovPosChange { /* valid in: filled in by and when: */
- const KindInfo *ki; /* ARCDE indep after allocate() */
+ const KindInfo **ki; /* ARCDE indep after allocate() */
Segment *move; /* ARCDE indep after allocate() */
MovPosComb actual; /* CD see below */
MovPosComb intent; /* RCD indep after allocate() */
pt_check_action();
}
+static const KindInfo point_method= {
+ "point", point_allocate, point_reserve, point_confirm, point_destroy
+};
+
/*========== dummy `nomove' kind ==========*/
static Change *nomove_allocate(int alloc_motions) {
return 0;
}
+static const KindInfo nomove_method= {
+ "nomove", nomove_allocate, nomove_reserve, nomove_confirm, nomove_destroy
+};
+
/*========== method-independent machinery ==========*/
-static const KindInfo methodinfos[]= {
- { "nomove", nomove_allocate, nomove_reserve, nomove_confirm, nomove_destroy },
- { "point", point_allocate, point_reserve, point_confirm, point_destroy },
- { 0 },
- { 0 }
+static const KindInfo *methodinfos[]= {
+ &nomove_method,
+ &point_method,
+ 0,
+ 0
};
-static Change *mp_allocate(const KindInfo *ki, Segment *move,
+static Change *mp_allocate(const KindInfo **ki, Segment *move,
int alloc_motions, MovPosComb target) {
assert(sta_state >= Sta_Resolving);
- Change *chg= ki->allocate(alloc_motions);
+ Change *chg= (*ki)->allocate(alloc_motions);
chg->ki= ki;
chg->move= move;
chg->intent= target;
r= startpoint<0 ||
(target - startpoint) / feati->weight % feati->posns;
oprintf(DUPO("movpos/change-needed") "%s:%s(%d*%d) %d..%d => %d\n",
- methodinfos[feati->kind].pname, feati->pname,
+ methodinfos[feati->kind]->pname, feati->pname,
feati->posns, feati->weight,
startpoint, target, r);
return r;
if (kind_r) *kind_r= kind;
oprintf(DUPO("movpos/eval") "changes=%d kind=%s\n",
- tchanges, methodinfos[kind].pname);
+ tchanges, methodinfos[kind]->pname);
return tchanges;
}
move->i->pname, posnpname(move,target),
maxdelay_ms, posnpname(move, actual));
if (chg) oprintf(DUPO("movpos/change") " chg=%s:%s/%s\n",
- chg->ki->pname, chg->move->i->pname,
+ (*chg->ki)->pname, chg->move->i->pname,
posnpname(chg->move, chg->intent));
{ /* provide horizon for visibility of motions[] */
n_motions++;
}
- const KindInfo *ki= &methodinfos[kind];
+ const KindInfo **ki= &methodinfos[kind];
if (chg) {
if (chg->ki != ki ||
}
chg->actual= actual;
- oprintf(DUPO("movpos/change") "confirm %s:%d...\n", ki->pname, n_motions);
- ec= ki->confirm(chg, move, n_motions, motions, maxdelay_ms);
+ oprintf(DUPO("movpos/change") "confirm %s:%d...\n",
+ (*ki)->pname, n_motions);
+ ec= (*ki)->confirm(chg, move, n_motions, motions, maxdelay_ms);
oprintf(DUPO("movpos/change") "confirm => %s\n",errorcodelist[ec]);
if (ec) goto x;
}
nchanges= evaluate_target(move,target,startpoint,&kind);
if (nchanges==-1) return EC_MovFeatKindsCombination;
- const KindInfo *ki= &methodinfos[kind];
- oprintf(DUPO("movpos/reserve") "allocate %s:%d...\n", ki->pname, nchanges);
+ const KindInfo **ki= &methodinfos[kind];
+ oprintf(DUPO("movpos/reserve") "allocate %s:%d...\n",
+ (*ki)->pname, nchanges);
Change *chg= mp_allocate(ki, move, nchanges, target);
- ec= ki->reserve(chg, move, maxdelay_ms);
+ ec= (*ki)->reserve(chg, move, maxdelay_ms);
oprintf(DUPO("movpos/reserve") "reserve => %s\n",errorcodelist[ec]);
if (ec) goto x;
void movpos_unreserve(MovPosChange *res) {
if (!res) return;
oprintf(DUPO("movpos/unreserve") "%s:%s/%s\n",
- res->ki->pname, res->move->i->pname,
+ (*res->ki)->pname, res->move->i->pname,
posnpname(res->move, res->intent));
- res->ki->destroy(res);
+ (*res->ki)->destroy(res);
}
MovPosComb movpos_poscomb_actual(Segment *seg) {