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
1f84449f
Kaydet (Commit)
1f84449f
authored
Eki 21, 1997
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
New CObject from Jim Fulton, adds PyCObject_FromVoidPtrAndDesc() and
PyCObject_GetDesc().
üst
16cb6f46
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
2 deletions
+66
-2
cobject.h
Include/cobject.h
+14
-1
cobject.c
Objects/cobject.c
+52
-1
No files found.
Include/cobject.h
Dosyayı görüntüle @
1f84449f
...
...
@@ -54,14 +54,27 @@ extern DL_IMPORT(PyTypeObject) PyCObject_Type;
destroyed.
*/
extern
PyObject
*
PyCObject_FromVoidPtr
Py_PROTO
((
void
*
cobj
,
void
(
*
destruct
)(
void
*
)));
/* Create a PyCObject from a pointer to a C object, a description object,
and an optional destrutor function. If the third argument is non-null,
then it will be called with the first and second arguments if and when
the PyCObject is destroyed.
*/
extern
PyObject
*
PyCObject_FromVoidPtrAndDesc
Py_PROTO
((
void
*
cobj
,
void
*
desc
,
void
(
*
destruct
)(
void
*
,
void
*
)));
/* Retrieve a pointer to a C object from a PyCObject. */
extern
void
*
PyCObject_AsVoidPtr
Py_PROTO
((
PyObject
*
));
/* Retrieve a pointer to a description object from a PyCObject. */
extern
void
*
PyCObject_GetDesc
Py_PROTO
((
PyObject
*
));
/* Import a pointer to a C object from a module using a PyCObject. */
extern
void
*
PyCObject_Import
Py_PROTO
((
char
*
module_name
,
char
*
cobject_name
));
...
...
Objects/cobject.c
Dosyayı görüntüle @
1f84449f
...
...
@@ -36,9 +36,13 @@ PERFORMANCE OF THIS SOFTWARE.
/* Declarations for objects of type PyCObject */
typedef
void
(
*
destructor1
)
Py_PROTO
((
void
*
));
typedef
void
(
*
destructor2
)
Py_PROTO
((
void
*
,
void
*
));
typedef
struct
{
PyObject_HEAD
void
*
cobject
;
void
*
desc
;
void
(
*
destructor
)
Py_PROTO
((
void
*
));
}
PyCObject
;
...
...
@@ -54,6 +58,30 @@ PyCObject_FromVoidPtr(cobj, destr)
return
NULL
;
self
->
cobject
=
cobj
;
self
->
destructor
=
destr
;
self
->
desc
=
NULL
;
return
(
PyObject
*
)
self
;
}
PyObject
*
PyCObject_FromVoidPtrAndDesc
(
cobj
,
desc
,
destr
)
void
*
cobj
;
void
*
desc
;
void
(
*
destr
)
Py_PROTO
((
void
*
,
void
*
));
{
PyCObject
*
self
;
if
(
!
desc
)
{
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_FromVoidPtrAndDesc called with null description"
);
return
NULL
;
}
self
=
PyObject_NEW
(
PyCObject
,
&
PyCObject_Type
);
if
(
self
==
NULL
)
return
NULL
;
self
->
cobject
=
cobj
;
self
->
destructor
=
(
destructor1
)
destr
;
self
->
desc
=
desc
;
return
(
PyObject
*
)
self
;
}
...
...
@@ -74,6 +102,23 @@ PyCObject_AsVoidPtr(self)
return
NULL
;
}
void
*
PyCObject_GetDesc
(
self
)
PyObject
*
self
;
{
if
(
self
)
{
if
(
self
->
ob_type
==
&
PyCObject_Type
)
return
((
PyCObject
*
)
self
)
->
desc
;
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_GetDesc with non-C-object"
);
}
if
(
!
PyErr_Occurred
())
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_GetDesc called with null pointer"
);
return
NULL
;
}
void
*
PyCObject_Import
(
module_name
,
name
)
char
*
module_name
;
...
...
@@ -99,7 +144,13 @@ static void
PyCObject_dealloc
(
self
)
PyCObject
*
self
;
{
if
(
self
->
destructor
)
(
self
->
destructor
)(
self
->
cobject
);
if
(
self
->
destructor
)
{
if
(
self
->
desc
)
((
destructor2
)(
self
->
destructor
))(
self
->
cobject
,
self
->
desc
);
else
(
self
->
destructor
)(
self
->
cobject
);
}
PyMem_DEL
(
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