Beispiel #1
0
void p_txt(char* s, choiceparser* p) {
    if (*s == '[') {
        //p->txt[s - p->now->txt] = 0;
        p_reset(s, p);
        p->examine = &p_label;
    }
}
Beispiel #2
0
void p_label(char* s, choiceparser* p) {
    if (*s == ':') {
        p->choice->nxt = malloc(sizeof(char) * (s - p->start +1));
        p_clip(s, p, p->choice->nxt);
        p_reset(s, p);
        p->choose = &p_choose;
        p->dischoice = &p_dischoice;
        p->examine = &p_title;
    }
}
Beispiel #3
0
void p_title(char* s, choiceparser* p) {
    if (*s == ';') {
        p->choice->txt = malloc(sizeof(char) * (s - p->start + 1));
        p_clip(s, p, p->choice->txt);
        p_reset(s, p);
        p->choice->next = malloc(sizeof(scene));
        p->choice->next->prev = p->choice;
        p->choice = p->choice->next;
        p->choice->txt = 0;
        p->choice->nxt = 0;
        p->choice->next = 0;
        p->examine = &p_label;
    }
    else if (*s == ']') {
        p->choice->txt = malloc(sizeof(char) * (s - p->start + 1));
        p_clip(s, p, p->choice->txt);
        p_reset(s, p);
        p->choice->next = 0;
        p->examine = &p_skip;
    }
}
Beispiel #4
0
int main(void) {
  struct object *p;
  struct methods *mtable;
  void (*p_reset) (struct object *self);
  int (*p_twiddle) (struct object *self, int i);
  int i;

  /* Create a [foo] object */
  p = make_foo();

  /* Do a dynamic method call to the [reset] method */  
  mtable = p->mtable;
  p_reset = mtable->reset;
  p_reset(p);

  /* Do a dynamic method call to the [twiddle] method */  
  mtable = p->mtable;
  p_twiddle = mtable->twiddle;
  i = p_twiddle(p,3);

  /* Done. */
  return i;
}