Beispiel #1
0
void upb_stringsrc_init(upb_stringsrc *s) {
  static upb_bytesrc_vtbl vtbl = {
    &upb_stringsrc_fetch,
    &upb_stringsrc_read,
    &upb_stringsrc_getptr,
    NULL, NULL, NULL, NULL
  };
  upb_bytesrc_init(&s->bytesrc, &vtbl);
  s->str = NULL;
}
Beispiel #2
0
upb_stdio *upb_stdio_new() {
  static upb_bytesrc_vtbl bytesrc_vtbl = {
    upb_stdio_read,
    upb_stdio_getstr,
  };

  static upb_bytesink_vtbl bytesink_vtbl = {
    upb_stdio_putstr,
    upb_stdio_vprintf
  };

  upb_stdio *stdio = malloc(sizeof(*stdio));
  upb_bytesrc_init(&stdio->bytesrc, &bytesrc_vtbl);
  upb_bytesink_init(&stdio->bytesink, &bytesink_vtbl);
  return stdio;
}
Beispiel #3
0
void upb_stdio_init(upb_stdio *stdio) {
  static upb_bytesrc_vtbl bytesrc_vtbl = {
    upb_stdio_fetch,
    upb_stdio_read,
    upb_stdio_getptr,
    upb_stdio_refregion,
    upb_stdio_unrefregion,
    NULL,
    NULL
  };
  upb_bytesrc_init(&stdio->src, &bytesrc_vtbl);

  //static upb_bytesink_vtbl bytesink_vtbl = {
  //  upb_stdio_putstr,
  //  upb_stdio_vprintf
  //};
  //upb_bytesink_init(&stdio->bytesink, &bytesink_vtbl);
}