Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
f2d125bd
Kaydet (Commit)
f2d125bd
authored
Tem 30, 1996
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added sliceobject.c
üst
310968dc
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
189 additions
and
2 deletions
+189
-2
Makefile.in
Objects/Makefile.in
+5
-2
sliceobject.c
Objects/sliceobject.c
+184
-0
No files found.
Objects/Makefile.in
Dosyayı görüntüle @
f2d125bd
...
...
@@ -31,7 +31,8 @@ OBJS= abstract.o accessobject.o \
fileobject.o floatobject.o
\
frameobject.o funcobject.o intobject.o listobject.o
\
longobject.o mappingobject.o methodobject.o
\
moduleobject.o object.o rangeobject.o stringobject.o
\
moduleobject.o object.o rangeobject.o
\
sliceobject.o stringobject.o
\
tupleobject.o typeobject.o
SRCS
=
abstract.c accessobject.c
\
...
...
@@ -39,7 +40,8 @@ SRCS= abstract.c accessobject.c \
fileobject.c floatobject.c
\
frameobject.c funcobject.c intobject.c listobject.c
\
longobject.c mappingobject.c methodobject.c
\
moduleobject.c object.c rangeobject.c stringobject.c
\
moduleobject.c object.c rangeobject.c
\
sliceobject.c stringobject.c
\
tupleobject.c typeobject.c
LIB
=
libObjects.a
...
...
@@ -87,6 +89,7 @@ methodobject.o: methodobject.c
moduleobject.o
:
moduleobject.c
object.o
:
object.c
rangeobject.o
:
rangeobject.c
sliceobject.o
:
sliceobject.c
stringobject.o
:
stringobject.c
tupleobject.o
:
tupleobject.c
typeobject.o
:
typeobject.c
...
...
Objects/sliceobject.c
0 → 100644
Dosyayı görüntüle @
f2d125bd
/*
Written by Jim Hugunin and Chris Chase.
This includes both the singular ellipses object and slice objects.
Guido, feel free to do whatever you want in the way of copyrights
for this file.
*/
/*
Py_Ellipses encodes the '...' rubber index token. It is similar to
the Py_NoneStruct in that there is no way to create other objects of
this type and there is exactly one in existence.
*/
#include "Python.h"
static
PyObject
*
ellipses_repr
(
op
)
PyObject
*
op
;
{
return
PyString_FromString
(
"..."
);
}
static
PyTypeObject
PyEllipses_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
"ellipses"
,
0
,
0
,
0
,
/*tp_dealloc*/
/*never called*/
0
,
/*tp_print*/
0
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_compare*/
(
reprfunc
)
ellipses_repr
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
0
,
/*tp_hash */
};
PyObject
_Py_EllipsesObject
=
{
PyObject_HEAD_INIT
(
&
PyEllipses_Type
)
};
/* Slice object implementation
start, stop, and step are python objects with None indicating no
index is present.
*/
PyObject
*
PySlice_New
(
start
,
stop
,
step
)
PyObject
*
start
;
PyObject
*
stop
;
PyObject
*
step
;
{
PySliceObject
*
obj
=
(
PySliceObject
*
)
PyObject_NEW
(
PySliceObject
,
&
PySlice_Type
);
if
(
step
==
NULL
)
step
=
Py_None
;
Py_INCREF
(
step
);
if
(
start
==
NULL
)
start
=
Py_None
;
Py_INCREF
(
start
);
if
(
stop
==
NULL
)
stop
=
Py_None
;
Py_INCREF
(
stop
);
obj
->
step
=
step
;
obj
->
start
=
start
;
obj
->
stop
=
stop
;
return
(
PyObject
*
)
obj
;
}
int
PySlice_GetIndices
(
r
,
length
,
start
,
stop
,
step
)
PySliceObject
*
r
;
int
length
;
int
*
start
;
int
*
stop
;
int
*
step
;
{
if
(
r
->
step
==
Py_None
)
{
*
step
=
1
;
}
else
{
if
(
!
PyInt_Check
(
r
->
step
))
return
-
1
;
*
step
=
PyInt_AsLong
(
r
->
step
);
}
if
(
r
->
start
==
Py_None
)
{
*
start
=
*
step
<
0
?
length
-
1
:
0
;
}
else
{
if
(
!
PyInt_Check
(
r
->
start
))
return
-
1
;
*
start
=
PyInt_AsLong
(
r
->
start
);
if
(
*
start
<
0
)
*
start
+=
length
;
}
if
(
r
->
stop
==
Py_None
)
{
*
stop
=
*
step
<
0
?
-
1
:
length
;
}
else
{
if
(
!
PyInt_Check
(
r
->
stop
))
return
-
1
;
*
stop
=
PyInt_AsLong
(
r
->
stop
);
if
(
*
stop
<
0
)
*
stop
+=
length
;
}
if
(
*
stop
>
length
)
return
-
1
;
if
(
*
start
>=
length
)
return
-
1
;
if
(
*
step
==
0
)
return
-
1
;
return
0
;
}
static
void
slice_dealloc
(
r
)
PySliceObject
*
r
;
{
Py_DECREF
(
r
->
step
);
Py_DECREF
(
r
->
start
);
Py_DECREF
(
r
->
stop
);
PyMem_DEL
(
r
);
}
static
PyObject
*
slice_repr
(
r
)
PySliceObject
*
r
;
{
PyObject
*
s
,
*
comma
;
s
=
PyString_FromString
(
"slice("
);
comma
=
PyString_FromString
(
", "
);
PyString_ConcatAndDel
(
&
s
,
PyObject_Repr
(
r
->
start
));
PyString_Concat
(
&
s
,
comma
);
PyString_ConcatAndDel
(
&
s
,
PyObject_Repr
(
r
->
stop
));
PyString_Concat
(
&
s
,
comma
);
PyString_ConcatAndDel
(
&
s
,
PyObject_Repr
(
r
->
step
));
PyString_ConcatAndDel
(
&
s
,
PyString_FromString
(
")"
));
Py_DECREF
(
comma
);
return
s
;
}
static
PyObject
*
slice_getattr
(
self
,
name
)
PySliceObject
*
self
;
char
*
name
;
{
PyObject
*
ret
;
ret
=
NULL
;
if
(
strcmp
(
name
,
"start"
)
==
0
)
{
ret
=
self
->
start
;
}
else
if
(
strcmp
(
name
,
"stop"
)
==
0
)
{
ret
=
self
->
stop
;
}
else
if
(
strcmp
(
name
,
"step"
)
==
0
)
{
ret
=
self
->
step
;
}
else
if
(
strcmp
(
name
,
"__members__"
)
==
0
)
{
return
Py_BuildValue
(
"[sss]"
,
"start"
,
"stop"
,
"step"
);
}
else
{
PyErr_SetString
(
PyExc_AttributeError
,
name
);
return
NULL
;
}
Py_INCREF
(
ret
);
return
ret
;
}
PyTypeObject
PySlice_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/* Number of items for varobject */
"slice"
,
/* Name of this type */
sizeof
(
PySliceObject
),
/* Basic object size */
0
,
/* Item size for varobject */
(
destructor
)
slice_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
(
getattrfunc
)
slice_getattr
,
/*tp_getattr*/
0
,
/*tp_setattr*/
0
,
/*tp_compare*/
(
reprfunc
)
slice_repr
,
/*tp_repr*/
0
,
/*tp_as_number*/
0
,
/*tp_as_sequence*/
0
,
/*tp_as_mapping*/
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment