Esempio n. 1
0
BoxIterator& BoxIterator::operator++() {
    static std::string hasnext_str("__hasnext__");
    static std::string next_str("next");

    Box* hasnext = callattrInternal(iter, &hasnext_str, CLASS_ONLY, NULL, ArgPassSpec(0), NULL, NULL, NULL, NULL, NULL);
    if (nonzero(hasnext)) {
        value = callattrInternal(iter, &next_str, CLASS_ONLY, NULL, ArgPassSpec(0), NULL, NULL, NULL, NULL, NULL);
    } else {
        iter = nullptr;
        value = nullptr;
    }
    return *this;
}
Esempio n. 2
0
extern "C" int PyDict_SetItem(PyObject* mp, PyObject* _key, PyObject* _item) {
    Box* b = static_cast<Box*>(mp);
    Box* key = static_cast<Box*>(_key);
    Box* item = static_cast<Box*>(_item);

    static std::string setitem_str("__setitem__");
    Box* r;
    try {
        // TODO should demote GIL?
        r = callattrInternal(b, &setitem_str, CLASS_ONLY, NULL, ArgPassSpec(2), key, item, NULL, NULL, NULL);
    } catch (Box* b) {
        fprintf(stderr, "Error: uncaught error would be propagated to C code!\n");
        Py_FatalError("unimplemented");
    }

    RELEASE_ASSERT(r, "");
    return 0;
}