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
69785032
Kaydet (Commit)
69785032
authored
Ock 26, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
added findmethodinchain and methodchain data types
üst
5279ec68
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
60 additions
and
23 deletions
+60
-23
methodobject.h
Include/methodobject.h
+8
-0
rename2.h
Include/rename2.h
+2
-0
methodobject.c
Objects/methodobject.c
+50
-23
No files found.
Include/methodobject.h
Dosyayı görüntüle @
69785032
...
...
@@ -57,6 +57,14 @@ extern PyObject *PyCFunction_New
/* Flag passed to newmethodobject */
#define METH_VARARGS 0x0001
typedef
struct
PyMethodChain
{
PyMethodDef
*
methods
;
/* Methods of this type */
struct
PyMethodChain
*
link
;
/* NULL or base type */
}
PyMethodChain
;
extern
PyObject
*
Py_FindMethodInChain
Py_PROTO
((
PyMethodChain
*
,
PyObject
*
,
char
*
));
#ifdef __cplusplus
}
#endif
...
...
Include/rename2.h
Dosyayı görüntüle @
69785032
...
...
@@ -38,6 +38,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
/* typedef ANY *PyUnivPtr; */
#define methodlist PyMethodDef
#define methodchain PyMethodChain
#define None Py_None
#define False Py_False
...
...
@@ -290,6 +291,7 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define newrangeobject PyRange_New
#define method PyCFunction
#define findmethod Py_FindMethod
#define findmethodinchain Py_FindMethodInChain
#define getmethod PyCFunction_GetFunction
#define getself PyCFunction_GetSelf
#define getvarargs PyCFunction_IsVarArgs
...
...
Objects/methodobject.c
Dosyayı görüntüle @
69785032
...
...
@@ -188,46 +188,73 @@ typeobject Methodtype = {
(
hashfunc
)
meth_hash
,
/*tp_hash*/
};
static
object
*
listmethods
PROTO
((
struct
methodlist
*
));
/* Forward
*/
/* List all methods in a chain -- helper for findmethodinchain
*/
static
object
*
listmethod
s
(
ml
)
struct
method
list
*
ml
;
listmethod
chain
(
chain
)
struct
method
chain
*
chain
;
{
struct
methodchain
*
c
;
struct
methodlist
*
ml
;
int
i
,
n
;
object
*
v
;
for
(
n
=
0
;
ml
[
n
].
ml_name
!=
NULL
;
n
++
)
;
n
=
0
;
for
(
c
=
chain
;
c
!=
NULL
;
c
=
c
->
link
)
{
for
(
ml
=
c
->
methods
;
ml
->
ml_name
!=
NULL
;
ml
++
)
n
++
;
}
v
=
newlistobject
(
n
);
if
(
v
!=
NULL
)
{
for
(
i
=
0
;
i
<
n
;
i
++
)
setlistitem
(
v
,
i
,
newstringobject
(
ml
[
i
].
ml_name
));
if
(
err_occurred
())
{
DECREF
(
v
);
v
=
NULL
;
}
else
{
sortlist
(
v
);
if
(
v
==
NULL
)
return
NULL
;
i
=
0
;
for
(
c
=
chain
;
c
!=
NULL
;
c
=
c
->
link
)
{
for
(
ml
=
c
->
methods
;
ml
->
ml_name
!=
NULL
;
ml
++
)
{
setlistitem
(
v
,
i
,
newstringobject
(
ml
->
ml_name
));
i
++
;
}
}
if
(
err_occurred
())
{
DECREF
(
v
);
return
NULL
;
}
sortlist
(
v
);
return
v
;
}
/* Find a method in a module's method table.
Usually called from an object's getattr method. */
/* Find a method in a method chain */
object
*
findmethod
(
ml
,
op
,
name
)
struct
method
list
*
ml
;
object
*
op
;
findmethod
inchain
(
chain
,
self
,
name
)
struct
method
chain
*
chain
;
object
*
self
;
char
*
name
;
{
if
(
strcmp
(
name
,
"__methods__"
)
==
0
)
return
listmethods
(
ml
);
for
(;
ml
->
ml_name
!=
NULL
;
ml
++
)
{
if
(
strcmp
(
name
,
ml
->
ml_name
)
==
0
)
return
newmethodobject
(
ml
,
op
);
return
listmethodchain
(
chain
);
while
(
chain
!=
NULL
)
{
struct
methodlist
*
ml
=
chain
->
methods
;
for
(;
ml
->
ml_name
!=
NULL
;
ml
++
)
{
if
(
name
[
0
]
==
ml
->
ml_name
[
0
]
&&
strcmp
(
name
+
1
,
ml
->
ml_name
+
1
)
==
0
)
return
newmethodobject
(
ml
,
self
);
}
chain
=
chain
->
link
;
}
err_setstr
(
AttributeError
,
name
);
return
NULL
;
}
/* Find a method in a single method list */
object
*
findmethod
(
methods
,
self
,
name
)
struct
methodlist
*
methods
;
object
*
self
;
char
*
name
;
{
struct
methodchain
chain
;
chain
.
methods
=
methods
;
chain
.
link
=
NULL
;
return
findmethodinchain
(
&
chain
,
self
,
name
);
}
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