示例#1
0
文件: upb.c 项目: chenbk85/upb
// TODO: update to allow user to choose type of defs.
static PyObject *PyUpb_SymbolTable_defs(PyObject *o, PyObject *none) {
  upb_symtab *s = Check_SymbolTable(o, NULL);
  int count;
  const upb_def **defs = upb_symtab_getdefs(s, &count, UPB_DEF_ANY);
  PyObject *ret = PyList_New(count);
  int i;
  for(i = 0; i < count; i++)
    PyList_SetItem(ret, i, PyUpb_Def_GetOrCreate(defs[i]));
  return ret;
}
示例#2
0
int main() {
  upb_symtab *s = upb_symtab_new();

  // Will be empty atm since we haven't added anything to the symtab.
  int count;
  const upb_def **defs = upb_symtab_getdefs(s, &count, UPB_DEF_ANY);
  for (int i = 0; i < count; i++) {
    upb_def_unref(defs[i]);
  }
  free(defs);

  upb_symtab_unref(s);
  return 0;
}