Commit 9aefa1a2 authored by Kevin Modzelewski's avatar Kevin Modzelewski

Add structseq.{c,h} and sliceobject.h

Haven't added structseq.c to the build quite yet
parent 7c7bb89b
......@@ -52,6 +52,7 @@
#include "tupleobject.h"
#include "methodobject.h"
#include "pycapsule.h"
#include "sliceobject.h"
#include "iterobject.h"
#include "descrobject.h"
#include "warnings.h"
......
// This file is originally from CPython 2.7, with modifications for Pyston
#ifndef Py_SLICEOBJECT_H
#define Py_SLICEOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
/* The unique ellipsis object "..." */
PyAPI_DATA(PyObject) _Py_EllipsisObject; /* Don't use this directly */
#define Py_Ellipsis (&_Py_EllipsisObject)
/* Slice object interface */
/*
A slice object containing start, stop, and step data members (the
names are from range). After much talk with Guido, it was decided to
let these be any arbitrary python type. Py_None stands for omitted values.
*/
// Pyston change: comment this out since this is not the format we're using
#if 0
typedef struct {
PyObject_HEAD
PyObject *start, *stop, *step; /* not NULL */
} PySliceObject;
#endif
struct _PySliceObject;
typedef struct _PySliceObject PySliceObject;
// Pyston change: these are no longer static objects
PyAPI_DATA(PyTypeObject*) slice_cls;
#define PySlice_Type (*slice_cls)
PyAPI_DATA(PyTypeObject*) ellipsis_cls;
#define PyEllipsis_Type (*ellipsis_cls)
// Pyston changes: these aren't direct macros any more [they potentially could be though]
//#define PySlice_Check(op) (Py_TYPE(op) == &PySlice_Type)
PyAPI_FUNC(bool) PySlice_Check(PyObject*);
PyAPI_FUNC(PyObject *) PySlice_New(PyObject* start, PyObject* stop,
PyObject* step);
PyAPI_FUNC(PyObject *) _PySlice_FromIndices(Py_ssize_t start, Py_ssize_t stop);
PyAPI_FUNC(int) PySlice_GetIndices(PySliceObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop, Py_ssize_t *step);
PyAPI_FUNC(int) PySlice_GetIndicesEx(PySliceObject *r, Py_ssize_t length,
Py_ssize_t *start, Py_ssize_t *stop,
Py_ssize_t *step, Py_ssize_t *slicelength);
#ifdef __cplusplus
}
#endif
#endif /* !Py_SLICEOBJECT_H */
// This file is originally from CPython 2.7, with modifications for Pyston
/* Tuple object interface */
#ifndef Py_STRUCTSEQ_H
#define Py_STRUCTSEQ_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct PyStructSequence_Field {
char *name;
char *doc;
} PyStructSequence_Field;
typedef struct PyStructSequence_Desc {
char *name;
char *doc;
struct PyStructSequence_Field *fields;
int n_in_sequence;
} PyStructSequence_Desc;
extern char* PyStructSequence_UnnamedField;
PyAPI_FUNC(void) PyStructSequence_InitType(PyTypeObject *type,
PyStructSequence_Desc *desc);
PyAPI_FUNC(PyObject *) PyStructSequence_New(PyTypeObject* type);
typedef struct {
PyObject_VAR_HEAD
PyObject *ob_item[1];
} PyStructSequence;
/* Macro, *only* to be used to fill in brand new objects */
#define PyStructSequence_SET_ITEM(op, i, v) \
(((PyStructSequence *)(op))->ob_item[i] = v)
#ifdef __cplusplus
}
#endif
#endif /* !Py_STRUCTSEQ_H */
This diff is collapsed.
Files in this directory were originally obtained from the CPython mercurial repository,
revision 90928 (2.7.7 release). The "2.7" directory is a copy of the Lib directory, and the
"2.7_Modules" directory is a copy of the Modules directory.
The 2.7_Objects directory contains some of the Objects/ directory.
The original code is redistributed under the original license (see main LICENSE file);
modifications are distributed under the Apache License, Version 2.0 (again, see main LICENSE file).
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment