~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/_static_tuple_c.c

  • Committer: Matt Nordhoff
  • Date: 2009-10-21 17:18:58 UTC
  • mto: This revision was merged to the branch mainline in revision 4768.
  • Revision ID: mnordhoff@mattnordhoff.com-20091021171858-hpigwzm0ztip5wis
Working C implemention.

The refcounts are probably horribly wrong, though.

Show diffs side-by-side

added added

removed removed

Lines of Context:
574
574
 
575
575
 
576
576
static PyObject *
 
577
StaticTuple_reduce(StaticTuple *self)
 
578
{
 
579
    PyObject *result = NULL, *as_tuple = NULL;
 
580
 
 
581
    result = PyTuple_New(2);
 
582
    if (!result) {
 
583
        return NULL;
 
584
    }
 
585
    as_tuple = StaticTuple_as_tuple(self);
 
586
    if (as_tuple == NULL) {
 
587
        return NULL;
 
588
    }
 
589
    PyTuple_SET_ITEM(result, 0, (PyObject *)&StaticTuple_Type);
 
590
    PyTuple_SET_ITEM(result, 1, as_tuple);
 
591
    return result;
 
592
}
 
593
 
 
594
static char StaticTuple_reduce_doc[] = "__reduce__() => tuple\n";
 
595
 
 
596
 
 
597
static PyObject *
577
598
StaticTuple_add(PyObject *v, PyObject *w)
578
599
{
579
600
    Py_ssize_t i, len_v, len_w;
688
709
     METH_STATIC | METH_VARARGS,
689
710
     "Create a StaticTuple from a given sequence. This functions"
690
711
     " the same as the tuple() constructor."},
 
712
    {"__reduce__", (PyCFunction)StaticTuple_reduce, METH_NOARGS, StaticTuple_reduce_doc},
691
713
    {NULL, NULL} /* sentinel */
692
714
};
693
715