~free.ekanayaka/storm/any-expr

« back to all changes in this revision

Viewing changes to storm/cextensions.c

  • Committer: James Henstridge
  • Date: 2009-08-07 00:36:10 UTC
  • mfrom: (305.2.3 storm.bug-268151)
  • Revision ID: james@jamesh.id.au-20090807003610-mbgig050oo5qt13x
Fix build of C extension on Windows.

[r=jkakar, therve]

Show diffs side-by-side

added added

removed removed

Lines of Context:
527
527
    0,                      /*tp_hash*/
528
528
    0,                      /*tp_call*/
529
529
    0,                      /*tp_str*/
530
 
    PyObject_GenericGetAttr,/*tp_getattro*/
531
 
    PyObject_GenericSetAttr,/*tp_setattro*/
 
530
    0,                      /*tp_getattro*/
 
531
    0,                      /*tp_setattro*/
532
532
    0,                      /*tp_as_buffer*/
533
533
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
534
534
    0,                      /*tp_doc*/
547
547
    0,                      /*tp_descr_set*/
548
548
    0,                      /*tp_dictoffset*/
549
549
    (initproc)EventSystem_init, /*tp_init*/
550
 
    PyType_GenericAlloc,    /*tp_alloc*/
551
 
    PyType_GenericNew,      /*tp_new*/
552
 
    PyObject_GC_Del,        /*tp_free*/
 
550
    0,                      /*tp_alloc*/
 
551
    0,                      /*tp_new*/
 
552
    0,                      /*tp_free*/
553
553
    0,                      /*tp_is_gc*/
554
554
};
555
555
 
1122
1122
    0,            /*tp_hash*/
1123
1123
    0,                      /*tp_call*/
1124
1124
    0,                      /*tp_str*/
1125
 
    PyObject_GenericGetAttr,/*tp_getattro*/
1126
 
    PyObject_GenericSetAttr,/*tp_setattro*/
 
1125
    0,                      /*tp_getattro*/
 
1126
    0,                      /*tp_setattro*/
1127
1127
    0,                      /*tp_as_buffer*/
1128
1128
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1129
1129
    0,                      /*tp_doc*/
1142
1142
    0,                      /*tp_descr_set*/
1143
1143
    0,                      /*tp_dictoffset*/
1144
1144
    (initproc)Variable_init, /*tp_init*/
1145
 
    PyType_GenericAlloc,    /*tp_alloc*/
 
1145
    0,                       /*tp_alloc*/
1146
1146
    Variable_new,      /*tp_new*/
1147
 
    PyObject_GC_Del,        /*tp_free*/
 
1147
    0,                      /*tp_free*/
1148
1148
    0,                      /*tp_is_gc*/
1149
1149
};
1150
1150
 
1786
1786
    0,                      /*tp_hash*/
1787
1787
    (ternaryfunc)Compile__call__, /*tp_call*/
1788
1788
    0,                      /*tp_str*/
1789
 
    PyObject_GenericGetAttr,/*tp_getattro*/
1790
 
    PyObject_GenericSetAttr,/*tp_setattro*/
 
1789
    0,                      /*tp_getattro*/
 
1790
    0,                      /*tp_setattro*/
1791
1791
    0,                      /*tp_as_buffer*/
1792
1792
    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE | Py_TPFLAGS_HAVE_GC, /*tp_flags*/
1793
1793
    0,                      /*tp_doc*/
1806
1806
    0,                      /*tp_descr_set*/
1807
1807
    0,                      /*tp_dictoffset*/
1808
1808
    (initproc)Compile_init, /*tp_init*/
1809
 
    PyType_GenericAlloc,    /*tp_alloc*/
1810
 
    PyType_GenericNew,      /*tp_new*/
1811
 
    PyObject_GC_Del,        /*tp_free*/
 
1809
    0,                      /*tp_alloc*/
 
1810
    0,                      /*tp_new*/
 
1811
    0,                      /*tp_free*/
1812
1812
    0,                      /*tp_is_gc*/
1813
1813
};
1814
1814
 
2000
2000
    return PyDict_Type.tp_clear((PyObject *)self);
2001
2001
}
2002
2002
 
 
2003
static PyObject *
 
2004
ObjectInfo_richcompare(PyObject *self, PyObject *other, int op)
 
2005
{
 
2006
    PyObject *res;
 
2007
 
 
2008
    /* Implement equality via object identity. */
 
2009
    switch (op) {
 
2010
    case Py_EQ:
 
2011
        res = (self == other) ? Py_True : Py_False;
 
2012
        break;
 
2013
    case Py_NE:
 
2014
        res = (self != other) ? Py_True : Py_False;
 
2015
        break;
 
2016
    default:
 
2017
        res = Py_NotImplemented;
 
2018
    }
 
2019
    Py_INCREF(res);
 
2020
    return res;
 
2021
}
 
2022
 
2003
2023
static void
2004
2024
ObjectInfo_dealloc(ObjectInfoObject *self)
2005
2025
{
2054
2074
    0,            /*tp_as_number*/
2055
2075
    0,            /*tp_as_sequence*/
2056
2076
    0,            /*tp_as_mapping*/
2057
 
    (hashfunc)_Py_HashPointer, /*tp_hash*/
 
2077
    0,                      /*tp_hash*/
2058
2078
    0,                      /*tp_call*/
2059
2079
    0,                      /*tp_str*/
2060
 
    PyObject_GenericGetAttr, /*tp_getattro*/
2061
 
    PyObject_GenericSetAttr, /*tp_setattro*/
 
2080
    0,                      /*tp_getattro*/
 
2081
    0,                      /*tp_setattro*/
2062
2082
    0,                      /*tp_as_buffer*/
2063
2083
    Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
2064
2084
    0,                      /*tp_doc*/
2065
2085
    (traverseproc)ObjectInfo_traverse, /*tp_traverse*/
2066
2086
    (inquiry)ObjectInfo_clear, /*tp_clear*/
2067
 
    0,                      /*tp_richcompare*/
 
2087
    ObjectInfo_richcompare, /*tp_richcompare*/
2068
2088
    offsetof(ObjectInfoObject, __weakreflist), /*tp_weaklistoffset*/
2069
2089
    0,                      /*tp_iter*/
2070
2090
    0,                      /*tp_iternext*/
2077
2097
    0,                      /*tp_descr_set*/
2078
2098
    0,                      /*tp_dictoffset*/
2079
2099
    (initproc)ObjectInfo_init, /*tp_init*/
2080
 
    PyType_GenericAlloc,    /*tp_alloc*/
 
2100
    0,                      /*tp_alloc*/
2081
2101
    0,                      /*tp_new*/
2082
 
    PyObject_GC_Del,        /*tp_free*/
 
2102
    0,                      /*tp_free*/
2083
2103
    0,                      /*tp_is_gc*/
2084
2104
};
2085
2105
 
2125
2145
};
2126
2146
 
2127
2147
 
 
2148
static int
 
2149
prepare_type(PyTypeObject *type)
 
2150
{
 
2151
    if (!type->tp_getattro && !type->tp_getattr)
 
2152
        type->tp_getattro = PyObject_GenericGetAttr;
 
2153
    if (!type->tp_setattro && !type->tp_setattr)
 
2154
        type->tp_setattro = PyObject_GenericSetAttr;
 
2155
    if (!type->tp_alloc)
 
2156
        type->tp_alloc = PyType_GenericAlloc;
 
2157
    /* Don't fill in tp_new if this class has a base class */
 
2158
    if (!type->tp_base && !type->tp_new)
 
2159
        type->tp_new = PyType_GenericNew;
 
2160
    if (!type->tp_free) {
 
2161
        assert((type->tp_flags & Py_TPFLAGS_HAVE_GC) != 0);
 
2162
        type->tp_free = PyObject_GC_Del;
 
2163
    }
 
2164
    return PyType_Ready(type);
 
2165
}
 
2166
 
2128
2167
DL_EXPORT(void)
2129
2168
initcextensions(void)
2130
2169
{
2131
2170
    PyObject *module;
2132
2171
 
2133
 
    PyType_Ready(&EventSystem_Type);
2134
 
    PyType_Ready(&Variable_Type);
2135
 
    PyType_Ready(&Compile_Type);
2136
 
 
 
2172
    prepare_type(&EventSystem_Type);
 
2173
    prepare_type(&Compile_Type);
2137
2174
    ObjectInfo_Type.tp_base = &PyDict_Type;
2138
 
    PyType_Ready(&ObjectInfo_Type);
 
2175
    ObjectInfo_Type.tp_hash = (hashfunc)_Py_HashPointer;
 
2176
    prepare_type(&ObjectInfo_Type);
 
2177
    prepare_type(&Variable_Type);
2139
2178
 
2140
2179
    module = Py_InitModule3("cextensions", cextensions_methods, "");
2141
2180
    Py_INCREF(&Variable_Type);