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
0f9a34da
Commit
0f9a34da
authored
Mar 28, 2002
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added comments for more entries of the type structure in the example
type implementation.
parent
2ab0a109
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
19 deletions
+19
-19
Doc/ext/newtypes.tex
Doc/ext/newtypes.tex
+19
-19
No files found.
Doc/ext/newtypes.tex
View file @
0f9a34da
...
@@ -152,20 +152,20 @@ Moving on, we come to the crunch --- the type object.
...
@@ -152,20 +152,20 @@ Moving on, we come to the crunch --- the type object.
\begin{verbatim}
\begin{verbatim}
static PyTypeObject noddy
_
NoddyType =
{
static PyTypeObject noddy
_
NoddyType =
{
PyObject
_
HEAD
_
INIT(NULL)
PyObject
_
HEAD
_
INIT(NULL)
0,
0,
/* ob
_
size */
"Noddy",
"Noddy",
/* tp
_
name */
sizeof(noddy
_
NoddyObject),
sizeof(noddy
_
NoddyObject),
/* tp
_
basicsize */
0,
0,
/* tp
_
itemsize */
noddy
_
noddy
_
dealloc,
/*tp
_
dealloc
*/
noddy
_
noddy
_
dealloc,
/* tp
_
dealloc
*/
0,
/*tp
_
print
*/
0,
/* tp
_
print
*/
0,
/*tp
_
getattr
*/
0,
/* tp
_
getattr
*/
0,
/*tp
_
setattr
*/
0,
/* tp
_
setattr
*/
0,
/*tp
_
compare
*/
0,
/* tp
_
compare
*/
0,
/*tp
_
repr
*/
0,
/* tp
_
repr
*/
0,
/*tp
_
as
_
number
*/
0,
/* tp
_
as
_
number
*/
0,
/*tp
_
as
_
sequence
*/
0,
/* tp
_
as
_
sequence
*/
0,
/*tp
_
as
_
mapping
*/
0,
/* tp
_
as
_
mapping
*/
0,
/*
tp
_
hash */
0,
/*
tp
_
hash */
}
;
}
;
\end{verbatim}
\end{verbatim}
...
@@ -194,7 +194,7 @@ conforming C and some compilers complain. So instead we fill in the
...
@@ -194,7 +194,7 @@ conforming C and some compilers complain. So instead we fill in the
oppourtunity --- in
\cfunction
{
initnoddy()
}
.
oppourtunity --- in
\cfunction
{
initnoddy()
}
.
\begin{verbatim}
\begin{verbatim}
0,
0,
/* ob
_
size */
\end{verbatim}
\end{verbatim}
The
\member
{
ob
_
size
}
field of the header is not used; it's presence in
The
\member
{
ob
_
size
}
field of the header is not used; it's presence in
...
@@ -203,7 +203,7 @@ binary compatibility with extension modules compiled for older
...
@@ -203,7 +203,7 @@ binary compatibility with extension modules compiled for older
versions of Python. Always set this field to zero.
versions of Python. Always set this field to zero.
\begin{verbatim}
\begin{verbatim}
"Noddy",
"Noddy",
/* tp
_
name */
\end{verbatim}
\end{verbatim}
The name of our type. This will appear in the default textual
The name of our type. This will appear in the default textual
...
@@ -217,14 +217,14 @@ TypeError: cannot add type "Noddy" to string
...
@@ -217,14 +217,14 @@ TypeError: cannot add type "Noddy" to string
\end{verbatim}
\end{verbatim}
\begin{verbatim}
\begin{verbatim}
sizeof(noddy
_
NoddyObject),
sizeof(noddy
_
NoddyObject),
/* tp
_
basicsize */
\end{verbatim}
\end{verbatim}
This is so that Python knows how much memory to allocate when you call
This is so that Python knows how much memory to allocate when you call
\cfunction
{
PyObject
_
New
}
.
\cfunction
{
PyObject
_
New
}
.
\begin{verbatim}
\begin{verbatim}
0,
0,
/* tp
_
itemsize */
\end{verbatim}
\end{verbatim}
This has to do with variable length objects like lists and strings.
This has to do with variable length objects like lists and strings.
...
@@ -236,7 +236,7 @@ implement many of these, but as mentioned above you have to implement
...
@@ -236,7 +236,7 @@ implement many of these, but as mentioned above you have to implement
the deallocation function.
the deallocation function.
\begin{verbatim}
\begin{verbatim}
noddy
_
noddy
_
dealloc,
/*tp
_
dealloc
*/
noddy
_
noddy
_
dealloc,
/* tp
_
dealloc
*/
\end{verbatim}
\end{verbatim}
From here, all the type methods are
\NULL
, so I won't go over them yet
From here, all the type methods are
\NULL
, so I won't go over them yet
...
...
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