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
01a74b2f
Kaydet (Commit)
01a74b2f
authored
Eki 19, 2003
tarafından
Martin v. Löwis
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Make CObjects mutable. Fixes #477441.
üst
95cf84a4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
5 deletions
+30
-5
concrete.tex
Doc/api/concrete.tex
+11
-5
cobject.h
Include/cobject.h
+3
-0
NEWS
Misc/NEWS
+2
-0
cobject.c
Objects/cobject.c
+14
-0
No files found.
Doc/api/concrete.tex
Dosyayı görüntüle @
01a74b2f
...
...
@@ -2479,34 +2479,40 @@ information on using these objects.
\end{ctypedesc}
\begin{cfuncdesc}
{
int
}{
PyCObject
_
Check
}{
PyObject *p
}
Return
s
true if its argument is a
\ctype
{
PyCObject
}
.
Return true if its argument is a
\ctype
{
PyCObject
}
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyCObject
_
FromVoidPtr
}{
void* cobj,
void (*destr)(void *)
}
Create
s
a
\ctype
{
PyCObject
}
from the
\code
{
void *
}
\var
{
cobj
}
. The
Create a
\ctype
{
PyCObject
}
from the
\code
{
void *
}
\var
{
cobj
}
. The
\var
{
destr
}
function will be called when the object is reclaimed,
unless it is
\NULL
.
\end{cfuncdesc}
\begin{cfuncdesc}
{
PyObject*
}{
PyCObject
_
FromVoidPtrAndDesc
}{
void* cobj,
void* desc, void (*destr)(void *, void *)
}
Create
s
a
\ctype
{
PyCObject
}
from the
\ctype
{
void *
}
\var
{
cobj
}
. The
Create a
\ctype
{
PyCObject
}
from the
\ctype
{
void *
}
\var
{
cobj
}
. The
\var
{
destr
}
function will be called when the object is reclaimed.
The
\var
{
desc
}
argument can be used to pass extra callback data for
the destructor function.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void*
}{
PyCObject
_
AsVoidPtr
}{
PyObject* self
}
Return
s
the object
\ctype
{
void *
}
that the
\ctype
{
PyCObject
}
Return the object
\ctype
{
void *
}
that the
\ctype
{
PyCObject
}
\var
{
self
}
was created with.
\end{cfuncdesc}
\begin{cfuncdesc}
{
void*
}{
PyCObject
_
GetDesc
}{
PyObject* self
}
Return
s
the description
\ctype
{
void *
}
that the
\ctype
{
PyCObject
}
Return the description
\ctype
{
void *
}
that the
\ctype
{
PyCObject
}
\var
{
self
}
was created with.
\end{cfuncdesc}
\begin{cfuncdesc}
{
int
}{
PyCObject
_
SetVoidPtr
}{
PyObject* self, void* cobj
}
Set the void pointer inside
\var
{
self
}
to
\var
{
cobj
}
.
The
\ctype
{
PyCObject
}
must not have an associated destructor.
Return true on success, false on failure.
\end{cfuncdesc}
\subsection
{
Cell Objects
\label
{
cell-objects
}}
...
...
Include/cobject.h
Dosyayı görüntüle @
01a74b2f
...
...
@@ -45,6 +45,9 @@ PyAPI_FUNC(void *) PyCObject_GetDesc(PyObject *);
/* Import a pointer to a C object from a module using a PyCObject. */
PyAPI_FUNC
(
void
*
)
PyCObject_Import
(
char
*
module_name
,
char
*
cobject_name
);
/* Modify a C object. Fails (==0) if object has a destructor. */
PyAPI_FUNC
(
int
)
PyCObject_SetVoidPtr
(
PyObject
*
self
,
void
*
cobj
);
#ifdef __cplusplus
}
#endif
...
...
Misc/NEWS
Dosyayı görüntüle @
01a74b2f
...
...
@@ -12,6 +12,8 @@ What's New in Python 2.4 alpha 1?
Core and builtins
-----------------
- CObjects are now mutable (on the C level) through PyCObject_SetVoidPtr.
- list.sort() now supports three keyword arguments: cmp, key, and reverse.
The key argument can be a function of one argument that extracts a
comparison key from the original record: mylist.sort(key=str.lower).
...
...
Objects/cobject.c
Dosyayı görüntüle @
01a74b2f
...
...
@@ -99,6 +99,20 @@ PyCObject_Import(char *module_name, char *name)
return
r
;
}
int
PyCObject_SetVoidPtr
(
PyObject
*
_self
,
void
*
cobj
)
{
PyCObject
*
self
=
(
PyCObject
*
)
_self
;
if
(
self
==
NULL
||
!
PyCObject_Check
(
self
)
||
self
->
destructor
!=
NULL
)
{
PyErr_SetString
(
PyExc_TypeError
,
"Invalid call to PyCObject_SetVoidPtr"
);
return
0
;
}
self
->
cobject
=
cobj
;
return
1
;
}
static
void
PyCObject_dealloc
(
PyCObject
*
self
)
{
...
...
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