Example #1
0
static int
Per_p_set_or_delattro(cPersistentObject *self, PyObject *name, PyObject *v)
{
    int result = -1;    /* guilty until proved innocent */
    PyObject *converted;
    char *s;

    converted = convert_name(name);
    if (!converted)
        goto Done;
    s = PyBytes_AS_STRING(converted);

    if (strncmp(s, "_p_", 3))
    {
        if (unghostify(self) < 0)
            goto Done;
        accessed(self);

        result = 0;
    }
    else
    {
        if (PyObject_GenericSetAttr((PyObject *)self, name, v) < 0)
            goto Done;
        result = 1;
    }

Done:
  Py_XDECREF(converted);
  return result;
}
Example #2
0
/* Exposed as _p_getattr method.  Test whether base getattr should be used */
static PyObject *
Per__p_getattr(cPersistentObject *self, PyObject *name)
{
    PyObject *result = NULL;    /* guilty until proved innocent */
    PyObject *converted;
    char *s;

    converted = convert_name(name);
    if (!converted)
        goto Done;
    s = PyBytes_AS_STRING(converted);

    if (*s != '_' || unghost_getattr(s))
    {
        if (unghostify(self) < 0)
            goto Done;
        accessed(self);
        result = Py_False;
    }
    else
        result = Py_True;

    Py_INCREF(result);

Done:
    Py_XDECREF(converted);
    return result;
}
Example #3
0
static int
Per_setattro(cPersistentObject *self, PyObject *name, PyObject *v)
{
    int result = -1;    /* guilty until proved innocent */
    PyObject *converted;
    char *s;

    converted = convert_name(name);
    if (!converted)
        goto Done;
    s = PyBytes_AS_STRING(converted);

    if (strncmp(s, "_p_", 3) != 0)
    {
        if (unghostify(self) < 0)
            goto Done;
        accessed(self);
        if (strncmp(s, "_v_", 3) != 0
            && self->state != cPersistent_CHANGED_STATE)
            {
            if (changed(self) < 0)
                goto Done;
            }
    }
    result = PyObject_GenericSetAttr((PyObject *)self, name, v);

Done:
    Py_XDECREF(converted);
    return result;
}
Example #4
0
static PyObject *
Per_get_mtime(cPersistentObject *self)
{
    PyObject *t, *v;

    if (unghostify(self) < 0)
        return NULL;

    accessed(self);

    if (memcmp(self->serial, "\0\0\0\0\0\0\0\0", 8) == 0)
    {
        Py_INCREF(Py_None);
        return Py_None;
    }

#ifdef PY3K
    t = PyObject_CallFunction(TimeStamp, "y#", self->serial, 8);
#else
    t = PyObject_CallFunction(TimeStamp, "s#", self->serial, 8);
#endif
    if (!t)
    {
        return NULL;
    }
    v = PyObject_CallMethod(t, "timeTime", "");
    Py_DECREF(t);
    return v;
}
Example #5
0
QVariant SuovaFileInfo::information(const QString &key) const
{
    QString shortKey = withoutContext(key); // nie:title --> title

    if( shortKey == "fileLastAccessed")
        return accessed();
    else if( shortKey == "fileLastModified")
        return modified();
    else if( shortKey == "fileName")
        return fileName();
    else if( shortKey == "fileSize")
        return bytes();
    else if( shortKey == "contentCreated")
        return created();
    else if( shortKey == "isStoredAs")
        return urn();
    else if( shortKey == "mimeType")
        return mimetype();
    else if( shortKey == "title")
        return title();
    else if( shortKey == "url")
        return url();

    return QVariant();
}
Example #6
0
QList<QVariant> SuovaFileInfo::allInformation() const
{
    QList<QVariant> information;
    information << accessed() << modified() << fileName()
                << bytes() << created() << urn()
                << mimetype() << title() << url();
    return information;
}
// takes a list of nodes and modifies it such that all nodes of the same loop are consecutive
//  - 'nodes' is in some traversal order
//  - that order is preserved for all nodes outside loops
//  - each node that belongs to a loop is replaced by all nodes of that loop in loop order
// Called only from FormRecurrentLoops().
void ComputationNetwork::ReorderLoops(list<ComputationNodeBasePtr>& nodes,
                                      const map<int, list<ComputationNodeBasePtr>>& /*recurrentNodes*/,
                                      const list<ComputationNodeBasePtr>& /*noRecurrentNodes*/)
{
    list<ComputationNodeBasePtr> newList;

    list<ComputationNodeBasePtr> vTmp;
    list<ComputationNodeBasePtr> vRecurrentTmp;
    vector<bool> accessed(m_allSEQNodes.size(), false);
    for (auto nodeIter = nodes.begin(); nodeIter != nodes.end(); nodeIter++)
    {
        const shared_ptr<SEQTraversalFlowControlNode> recInfo = FindInRecurrentLoops(m_allSEQNodes, *nodeIter);
        if (recInfo)
        {
            int iId = recInfo->m_loopId;
            if (!accessed[iId])
            {
                newList.insert(newList.end(), recInfo->m_nestedNodes.begin(), recInfo->m_nestedNodes.end());
                accessed[iId] = true;
            }
        }
        else
        {
            newList.push_back(*nodeIter);
        }
    }

    if (vRecurrentTmp.size() > 0)
    {
        newList.insert(newList.end(), vRecurrentTmp.begin(), vRecurrentTmp.end());
        vRecurrentTmp.clear();
    }

    if (vTmp.size() > 0)
    {
        newList.insert(newList.end(), vTmp.begin(), vTmp.end());
        vTmp.clear();
    }

    nodes = newList;
}
Example #8
0
static PyObject*
Per_getattro(cPersistentObject *self, PyObject *name)
{
    PyObject *result = NULL;    /* guilty until proved innocent */
    PyObject *converted;
    char *s;

    converted = convert_name(name);
    if (!converted)
        goto Done;
    s = PyBytes_AS_STRING(converted);

    if (unghost_getattr(s))
    {
        if (unghostify(self) < 0)
            goto Done;
        accessed(self);
    }
    result = PyObject_GenericGetAttr((PyObject *)self, name);

Done:
    Py_XDECREF(converted);
    return result;
}