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
ee48519b
Commit
ee48519b
authored
Apr 12, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Modernize the minimal example of an extension type.
parent
28de8d4b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
7 deletions
+15
-7
Doc/ext/noddy.c
Doc/ext/noddy.c
+15
-7
No files found.
Doc/ext/noddy.c
View file @
ee48519b
...
...
@@ -4,6 +4,7 @@ staticforward PyTypeObject noddy_NoddyType;
typedef
struct
{
PyObject_HEAD
/* Type-specific fields go here. */
}
noddy_NoddyObject
;
static
PyObject
*
...
...
@@ -11,21 +12,24 @@ noddy_new_noddy(PyObject* self, PyObject* args)
{
noddy_NoddyObject
*
noddy
;
if
(
!
PyArg_ParseTuple
(
args
,
":new_noddy"
))
return
NULL
;
noddy
=
PyObject_New
(
noddy_NoddyObject
,
&
noddy_NoddyType
);
/* Initialize type-specific fields here. */
return
(
PyObject
*
)
noddy
;
}
static
void
noddy_noddy_dealloc
(
PyObject
*
self
)
{
/* Free any external resources here;
* if the instance owns references to any Python
* objects, call Py_DECREF() on them here.
*/
PyObject_Del
(
self
);
}
static
PyTypeObject
noddy_NoddyType
=
{
static
here
PyTypeObject
noddy_NoddyType
=
{
PyObject_HEAD_INIT
(
NULL
)
0
,
"Noddy"
,
...
...
@@ -44,15 +48,19 @@ static PyTypeObject noddy_NoddyType = {
};
static
PyMethodDef
noddy_methods
[]
=
{
{
"new_noddy"
,
noddy_new_noddy
,
METH_
VAR
ARGS
,
{
"new_noddy"
,
noddy_new_noddy
,
METH_
NO
ARGS
,
"Create a new Noddy object."
},
{
NULL
,
NULL
,
0
,
NULL
}
{
NULL
}
/* Sentinel */
};
DL_EXPORT
(
void
)
initnoddy
(
void
)
{
noddy_NoddyType
.
ob_type
=
&
PyType_Type
;
if
(
PyType_Ready
(
&
noddy_NoddyType
))
return
;
Py_InitModule
(
"noddy"
,
noddy_methods
);
Py_InitModule3
(
"noddy"
,
noddy_methods
"Example module that creates an extension type."
);
}
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