Example #1
0
static PyObject *
_base_info_richcompare (PyGIBaseInfo *self, PyObject *other, int op)
{
    PyObject *res;
    GIBaseInfo *other_info;

    if (!PyObject_TypeCheck(other, &PyGIBaseInfo_Type)) {
        Py_INCREF(Py_NotImplemented);
        return Py_NotImplemented;
    }

    other_info = ((PyGIBaseInfo *)other)->info;

    switch (op) {
        case Py_EQ:
            res = g_base_info_equal (self->info, other_info) ? Py_True : Py_False;
            break;
        case Py_NE:
            res = g_base_info_equal (self->info, other_info) ? Py_False : Py_True;
            break;
        default:
            res = Py_NotImplemented;
            break;
    }
    Py_INCREF(res);
    return res;
}
Example #2
0
/* Check to see if jsval passed in is another Boxed object of the same,
 * and if so, retrieves the Boxed private structure for it.
 */
static JSBool
boxed_get_copy_source(JSContext *context,
                      Boxed     *priv,
                      jsval      value,
                      Boxed    **source_priv_out)
{
    Boxed *source_priv;

    if (!JSVAL_IS_OBJECT(value))
        return JS_FALSE;

    if (!priv_from_js_with_typecheck(context, JSVAL_TO_OBJECT(value), &source_priv))
        return JS_FALSE;

    if (!g_base_info_equal((GIBaseInfo*) priv->info, (GIBaseInfo*) source_priv->info))
        return JS_FALSE;

    *source_priv_out = source_priv;

    return JS_TRUE;
}