Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
e0e69628
Commit
e0e69628
authored
Jan 22, 1997
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added PyCObject_Import.
parent
43d287ad
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
44 additions
and
18 deletions
+44
-18
Include/cobject.h
Include/cobject.h
+4
-0
Objects/cobject.c
Objects/cobject.c
+39
-18
PC/python_nt.def
PC/python_nt.def
+1
-0
No files found.
Include/cobject.h
View file @
e0e69628
...
...
@@ -62,6 +62,10 @@ PyCObject_FromVoidPtr Py_PROTO((void *cobj, void (*destruct)(void*)));
extern
void
*
PyCObject_AsVoidPtr
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
));
#ifdef __cplusplus
}
#endif
...
...
Objects/cobject.c
View file @
e0e69628
...
...
@@ -57,6 +57,44 @@ PyCObject_FromVoidPtr(cobj, destr)
return
(
PyObject
*
)
self
;
}
void
*
PyCObject_AsVoidPtr
(
self
)
PyObject
*
self
;
{
if
(
self
)
{
if
(
self
->
ob_type
==
&
PyCObject_Type
)
return
((
PyCObject
*
)
self
)
->
cobject
;
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_AsVoidPtr with non-C-object"
);
}
if
(
!
PyErr_Occurred
())
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_AsVoidPtr called with null pointer"
);
return
NULL
;
}
void
*
PyCObject_Import
(
module_name
,
name
)
char
*
module_name
;
char
*
name
;
{
PyObject
*
m
,
*
c
;
void
*
r
=
NULL
;
if
(
m
=
PyImport_ImportModule
(
module_name
))
{
if
(
c
=
PyObject_GetAttrString
(
m
,
name
))
{
r
=
PyCObject_AsVoidPtr
(
c
);
Py_DECREF
(
c
);
}
Py_DECREF
(
m
);
}
return
r
;
}
static
void
PyCObject_dealloc
(
self
)
PyCObject
*
self
;
...
...
@@ -65,6 +103,7 @@ PyCObject_dealloc(self)
PyMem_DEL
(
self
);
}
static
char
PyCObject_Type__doc__
[]
=
"C objects to be exported from one extension module to another
\n
\
\n
\
...
...
@@ -98,21 +137,3 @@ PyTypeObject PyCObject_Type = {
0L
,
0L
,
0L
,
0L
,
PyCObject_Type__doc__
/* Documentation string */
};
void
*
PyCObject_AsVoidPtr
(
self
)
PyObject
*
self
;
{
if
(
self
)
{
if
(
self
->
ob_type
==
&
PyCObject_Type
)
return
((
PyCObject
*
)
self
)
->
cobject
;
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_AsVoidPtr with non-C-object"
);
}
if
(
!
PyErr_Occurred
())
PyErr_SetString
(
PyExc_TypeError
,
"PyCObject_AsVoidPtr called with null pointer"
);
return
NULL
;
}
PC/python_nt.def
View file @
e0e69628
...
...
@@ -351,4 +351,5 @@ EXPORTS
_Py_c_diff
PyCObject_FromVoidPtr
PyCObject_AsVoidPtr
PyCObject_Import
Py_GetBuildInfo
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