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
bdd07471
Commit
bdd07471
authored
Jan 29, 1996
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed access to Quickdraw globals. Unfortunately, they now have to be
accessed as Qd.qd.xxxx
parent
05a6d8f4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
125 additions
and
40 deletions
+125
-40
Mac/Modules/qd/Qdmodule.c
Mac/Modules/qd/Qdmodule.c
+79
-20
Mac/Modules/qd/qdsupport.py
Mac/Modules/qd/qdsupport.py
+46
-20
No files found.
Mac/Modules/qd/Qdmodule.c
View file @
bdd07471
...
...
@@ -329,6 +329,81 @@ PyTypeObject BitMap_Type = {
/* --------------------- End object type BitMap --------------------- */
/* ------------------ Object type QDGlobalsAccess ------------------- */
staticforward
PyTypeObject
QDGlobalsAccess_Type
;
#define QDGA_Check(x) ((x)->ob_type == &QDGlobalsAccess_Type)
typedef
struct
QDGlobalsAccessObject
{
PyObject_HEAD
}
QDGlobalsAccessObject
;
static
PyObject
*
QDGA_New
()
{
QDGlobalsAccessObject
*
it
;
it
=
PyObject_NEW
(
QDGlobalsAccessObject
,
&
QDGlobalsAccess_Type
);
if
(
it
==
NULL
)
return
NULL
;
return
(
PyObject
*
)
it
;
}
static
void
QDGA_dealloc
(
self
)
QDGlobalsAccessObject
*
self
;
{
PyMem_DEL
(
self
);
}
static
PyMethodDef
QDGA_methods
[]
=
{
{
NULL
,
NULL
,
0
}
};
static
PyMethodChain
QDGA_chain
=
{
QDGA_methods
,
NULL
};
static
PyObject
*
QDGA_getattr
(
self
,
name
)
QDGlobalsAccessObject
*
self
;
char
*
name
;
{
if
(
strcmp
(
name
,
"arrow"
)
==
0
)
return
PyString_FromStringAndSize
((
char
*
)
&
qd
.
arrow
,
sizeof
(
qd
.
arrow
));
if
(
strcmp
(
name
,
"black"
)
==
0
)
return
PyString_FromStringAndSize
((
char
*
)
&
qd
.
black
,
sizeof
(
qd
.
black
));
if
(
strcmp
(
name
,
"white"
)
==
0
)
return
PyString_FromStringAndSize
((
char
*
)
&
qd
.
white
,
sizeof
(
qd
.
white
));
if
(
strcmp
(
name
,
"gray"
)
==
0
)
return
PyString_FromStringAndSize
((
char
*
)
&
qd
.
gray
,
sizeof
(
qd
.
gray
));
if
(
strcmp
(
name
,
"ltGray"
)
==
0
)
return
PyString_FromStringAndSize
((
char
*
)
&
qd
.
ltGray
,
sizeof
(
qd
.
ltGray
));
if
(
strcmp
(
name
,
"dkGray"
)
==
0
)
return
PyString_FromStringAndSize
((
char
*
)
&
qd
.
dkGray
,
sizeof
(
qd
.
dkGray
));
if
(
strcmp
(
name
,
"screenBits"
)
==
0
)
return
BMObj_New
(
&
qd
.
screenBits
);
if
(
strcmp
(
name
,
"thePort"
)
==
0
)
return
GrafObj_New
(
qd
.
thePort
);
if
(
strcmp
(
name
,
"randSeed"
)
==
0
)
return
Py_BuildValue
(
"l"
,
&
qd
.
randSeed
);
return
Py_FindMethodInChain
(
&
QDGA_chain
,
(
PyObject
*
)
self
,
name
);
}
#define QDGA_setattr NULL
staticforward
PyTypeObject
QDGlobalsAccess_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/*ob_size*/
"QDGlobalsAccess"
,
/*tp_name*/
sizeof
(
QDGlobalsAccessObject
),
/*tp_basicsize*/
0
,
/*tp_itemsize*/
/* methods */
(
destructor
)
QDGA_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
(
getattrfunc
)
QDGA_getattr
,
/*tp_getattr*/
(
setattrfunc
)
QDGA_setattr
,
/*tp_setattr*/
};
/* ---------------- End object type QDGlobalsAccess ----------------- */
static
PyObject
*
Qd_SetPort
(
_self
,
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
...
...
@@ -3855,26 +3930,10 @@ void initQd()
{
PyObject
*
o
;
o
=
PyString_FromStringAndSize
((
char
*
)
&
qd
.
arrow
,
sizeof
(
qd
.
arrow
));
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"arrow"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.arrow"
);
o
=
PyString_FromStringAndSize
((
char
*
)
&
qd
.
black
,
sizeof
(
qd
.
black
));
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"black"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.black"
);
o
=
PyString_FromStringAndSize
((
char
*
)
&
qd
.
white
,
sizeof
(
qd
.
white
));
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"white"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.white"
);
o
=
PyString_FromStringAndSize
((
char
*
)
&
qd
.
gray
,
sizeof
(
qd
.
gray
));
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"gray"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.gray"
);
o
=
PyString_FromStringAndSize
((
char
*
)
&
qd
.
ltGray
,
sizeof
(
qd
.
ltGray
));
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"ltGray"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.ltGray"
);
o
=
PyString_FromStringAndSize
((
char
*
)
&
qd
.
dkGray
,
sizeof
(
qd
.
dkGray
));
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"dkGray"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.dkGray"
);
/* thePort, screenBits and randSeed still missing... */
o
=
QDGA_New
();
if
(
o
==
NULL
||
PyDict_SetItemString
(
d
,
"qd"
,
o
)
!=
0
)
Py_FatalError
(
"can't initialize Qd.qd"
);
}
...
...
Mac/Modules/qd/qdsupport.py
View file @
bdd07471
...
...
@@ -101,26 +101,10 @@ PyObject *QdFI_New(itself)
variablestuff
=
"""
{
PyObject *o;
o = PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
if (o == NULL || PyDict_SetItemString(d, "arrow", o) != 0)
Py_FatalError("can't initialize Qd.arrow");
o = PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
if (o == NULL || PyDict_SetItemString(d, "black", o) != 0)
Py_FatalError("can't initialize Qd.black");
o = PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
if (o == NULL || PyDict_SetItemString(d, "white", o) != 0)
Py_FatalError("can't initialize Qd.white");
o = PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
if (o == NULL || PyDict_SetItemString(d, "gray", o) != 0)
Py_FatalError("can't initialize Qd.gray");
o = PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
if (o == NULL || PyDict_SetItemString(d, "ltGray", o) != 0)
Py_FatalError("can't initialize Qd.ltGray");
o = PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
if (o == NULL || PyDict_SetItemString(d, "dkGray", o) != 0)
Py_FatalError("can't initialize Qd.dkGray");
/* thePort, screenBits and randSeed still missing... */
o = QDGA_New();
if (o == NULL || PyDict_SetItemString(d, "qd", o) != 0)
Py_FatalError("can't initialize Qd.qd");
}
"""
...
...
@@ -251,6 +235,46 @@ class MyBMObjectDefinition(GlobalObjectDefinition):
if ( strcmp(name, "pixmap_data") == 0 )
return PyString_FromStringAndSize((char *)self->ob_itself, sizeof(PixMap));
"""
)
# This object is instanciated once, and will access qd globals.
class
QDGlobalsAccessObjectDefinition
(
ObjectDefinition
):
def
outputStructMembers
(
self
):
pass
def
outputNew
(
self
):
Output
()
Output
(
"%sPyObject *%s_New()"
,
self
.
static
,
self
.
prefix
)
OutLbrace
()
Output
(
"%s *it;"
,
self
.
objecttype
)
Output
(
"it = PyObject_NEW(%s, &%s);"
,
self
.
objecttype
,
self
.
typename
)
Output
(
"if (it == NULL) return NULL;"
)
Output
(
"return (PyObject *)it;"
)
OutRbrace
()
def
outputConvert
(
self
):
pass
def
outputCleanupStructMembers
(
self
):
pass
def
outputGetattrHook
(
self
):
Output
(
"""
if ( strcmp(name, "arrow") == 0 )
return PyString_FromStringAndSize((char *)&qd.arrow, sizeof(qd.arrow));
if ( strcmp(name, "black") == 0 )
return PyString_FromStringAndSize((char *)&qd.black, sizeof(qd.black));
if ( strcmp(name, "white") == 0 )
return PyString_FromStringAndSize((char *)&qd.white, sizeof(qd.white));
if ( strcmp(name, "gray") == 0 )
return PyString_FromStringAndSize((char *)&qd.gray, sizeof(qd.gray));
if ( strcmp(name, "ltGray") == 0 )
return PyString_FromStringAndSize((char *)&qd.ltGray, sizeof(qd.ltGray));
if ( strcmp(name, "dkGray") == 0 )
return PyString_FromStringAndSize((char *)&qd.dkGray, sizeof(qd.dkGray));
if ( strcmp(name, "screenBits") == 0 )
return BMObj_New(&qd.screenBits);
if ( strcmp(name, "thePort") == 0 )
return GrafObj_New(qd.thePort);
if ( strcmp(name, "randSeed") == 0 )
return Py_BuildValue("l", &qd.randSeed);
"""
)
# Create the generator groups and link them
module
=
MacModule
(
MODNAME
,
MODPREFIX
,
includestuff
,
finalstuff
,
initstuff
,
variablestuff
)
...
...
@@ -262,6 +286,8 @@ gr_object = MyGRObjectDefinition("GrafPort", "GrafObj", "GrafPtr")
module
.
addobject
(
gr_object
)
bm_object
=
MyBMObjectDefinition
(
"BitMap"
,
"BMObj"
,
"BitMapPtr"
)
module
.
addobject
(
bm_object
)
qd_object
=
QDGlobalsAccessObjectDefinition
(
"QDGlobalsAccess"
,
"QDGA"
,
"XXXX"
)
module
.
addobject
(
qd_object
)
# Create the generator classes used to populate the lists
...
...
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