コード例 #1
0
// Imitate Exclude::get(ExcludeLite& excludeLite).
static void
toExcludeLite(PyObject* exclude, ExcludeLite& excludeLite)
{
  excludeLite.clear();
  PyObjectRef entries(PyObject_GetAttr(exclude, str._entries));
  for (size_t i = 0; i < PyList_GET_SIZE(entries.obj); ++i) {
    PyObject* entry = PyList_GET_ITEM(entries.obj, i);
    ndn_Error error;
    if (toLongByMethod(entry, str.getType) == Exclude_COMPONENT) {
      PyObjectRef component(PyObject_CallMethodObjArgs
        (entry, str.getComponent, NULL));
      NameLite::Component componentLite;
      toNameComponentLite(component, componentLite);
      if ((error = excludeLite.appendComponent(componentLite)))
        // TODO: Handle the error!
        return;
    }
    else {
      if ((error = excludeLite.appendAny()))
        // TODO: Handle the error!
        return;
    }
  }
}