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
41058c0d
Commit
41058c0d
authored
Nov 16, 1995
by
Jack Jansen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
BitMap object support (only lightly tested)
parent
135fb714
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
411 additions
and
1 deletion
+411
-1
Mac/Modules/qd/Qdmodule.c
Mac/Modules/qd/Qdmodule.c
+294
-0
Mac/Modules/qd/qdgen.py
Mac/Modules/qd/qdgen.py
+52
-0
Mac/Modules/qd/qdscan.py
Mac/Modules/qd/qdscan.py
+1
-1
Mac/Modules/qd/qdsupport.py
Mac/Modules/qd/qdsupport.py
+64
-0
No files found.
Mac/Modules/qd/Qdmodule.c
View file @
41058c0d
This diff is collapsed.
Click to expand it.
Mac/Modules/qd/qdgen.py
View file @
41058c0d
...
...
@@ -15,6 +15,11 @@ f = Function(void, 'GrafDevice',
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'SetPortBits'
,
(
BitMap_ptr
,
'bm'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'PortSize'
,
(
short
,
'width'
,
InMode
),
(
short
,
'height'
,
InMode
),
...
...
@@ -288,6 +293,12 @@ f = Function(void, 'CloseRgn',
)
functions
.
append
(
f
)
f
=
Function
(
OSErr
,
'BitMapToRegion'
,
(
RgnHandle
,
'region'
,
InMode
),
(
BitMap_ptr
,
'bMap'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'DisposeRgn'
,
(
RgnHandle
,
'rgn'
,
InMode
),
)
...
...
@@ -406,6 +417,26 @@ f = Function(void, 'ScrollRect',
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'CopyBits'
,
(
BitMap_ptr
,
'srcBits'
,
InMode
),
(
BitMap_ptr
,
'dstBits'
,
InMode
),
(
Rect_ptr
,
'srcRect'
,
InMode
),
(
Rect_ptr
,
'dstRect'
,
InMode
),
(
short
,
'mode'
,
InMode
),
(
RgnHandle
,
'maskRgn'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'CopyMask'
,
(
BitMap_ptr
,
'srcBits'
,
InMode
),
(
BitMap_ptr
,
'maskBits'
,
InMode
),
(
BitMap_ptr
,
'dstBits'
,
InMode
),
(
Rect_ptr
,
'srcRect'
,
InMode
),
(
Rect_ptr
,
'maskRect'
,
InMode
),
(
Rect_ptr
,
'dstRect'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
PicHandle
,
'OpenPicture'
,
(
Rect_ptr
,
'picFrame'
,
InMode
),
)
...
...
@@ -535,6 +566,15 @@ f = Function(void, 'MapPoly',
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'StdBits'
,
(
BitMap_ptr
,
'srcBits'
,
InMode
),
(
Rect_ptr
,
'srcRect'
,
InMode
),
(
Rect_ptr
,
'dstRect'
,
InMode
),
(
short
,
'mode'
,
InMode
),
(
RgnHandle
,
'maskRgn'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'AddPt'
,
(
Point
,
'src'
,
InMode
),
(
Point
,
'dst'
,
InOutMode
),
...
...
@@ -698,6 +738,18 @@ f = Function(short, 'QDError',
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'CopyDeepMask'
,
(
BitMap_ptr
,
'srcBits'
,
InMode
),
(
BitMap_ptr
,
'maskBits'
,
InMode
),
(
BitMap_ptr
,
'dstBits'
,
InMode
),
(
Rect_ptr
,
'srcRect'
,
InMode
),
(
Rect_ptr
,
'maskRect'
,
InMode
),
(
Rect_ptr
,
'dstRect'
,
InMode
),
(
short
,
'mode'
,
InMode
),
(
RgnHandle
,
'maskRgn'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
PatHandle
,
'GetPattern'
,
(
short
,
'patternID'
,
InMode
),
)
...
...
Mac/Modules/qd/qdscan.py
View file @
41058c0d
...
...
@@ -70,11 +70,11 @@ class MyScanner(Scanner):
'OpenCPort'
,
'InitCPort'
,
'CloseCPort'
,
'BitMapToRegionGlue'
,
]
def
makeblacklisttypes
(
self
):
return
[
'BitMap_ptr'
,
'CCrsrHandle'
,
'CIconHandle'
,
'CQDProcs'
,
...
...
Mac/Modules/qd/qdsupport.py
View file @
41058c0d
...
...
@@ -41,6 +41,7 @@ PatHandle = OpaqueByValueType("PatHandle", "ResObj")
CursHandle
=
OpaqueByValueType
(
"CursHandle"
,
"ResObj"
)
CGrafPtr
=
OpaqueByValueType
(
"CGrafPtr"
,
"GrafObj"
)
GrafPtr
=
OpaqueByValueType
(
"GrafPtr"
,
"GrafObj"
)
BitMap_ptr
=
OpaqueByValueType
(
"BitMapPtr"
,
"BMObj"
)
includestuff
=
includestuff
+
"""
#include <%s>"""
%
MACHEADERFILE
+
"""
...
...
@@ -73,11 +74,39 @@ class MyGRObjectDefinition(GlobalObjectDefinition):
def
outputGetattrHook
(
self
):
Output
(
"""if ( strcmp(name, "device") == 0 )
return PyInt_FromLong((long)self->ob_itself->device);
if ( strcmp(name, "portBits") == 0 )
return BMObj_New(&self->ob_itself->portBits);
if ( strcmp(name, "portRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
/* XXXX Add more, as needed */
"""
)
class
MyBMObjectDefinition
(
GlobalObjectDefinition
):
def
outputCheckNewArg
(
self
):
Output
(
"if (itself == NULL) return PyMac_Error(resNotFound);"
)
def
outputStructMembers
(
self
):
# We need to more items: a pointer to privately allocated data
# and a python object we're referring to.
Output
(
"%s ob_itself;"
,
self
.
itselftype
)
Output
(
"PyObject *referred_object;"
)
Output
(
"BitMap *referred_bitmap;"
)
def
outputInitStructMembers
(
self
):
Output
(
"it->ob_itself = %sitself;"
,
self
.
argref
)
Output
(
"it->referred_object = NULL;"
)
Output
(
"it->referred_bitmap = NULL;"
)
def
outputCleanupStructMembers
(
self
):
Output
(
"Py_XDECREF(self->referred_object);"
)
Output
(
"if (self->referred_bitmap) free(self->referred_bitmap);"
)
def
outputGetattrHook
(
self
):
Output
(
"""if ( strcmp(name, "baseAddr") == 0 )
return PyInt_FromLong((long)self->ob_itself->baseAddr);
if ( strcmp(name, "rowBytes") == 0 )
return PyInt_FromLong((long)self->ob_itself->rowBytes);
if ( strcmp(name, "bounds") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->bounds);
/* XXXX Add more, as needed */
"""
)
# Create the generator groups and link them
module
=
MacModule
(
MODNAME
,
MODPREFIX
,
includestuff
,
finalstuff
,
initstuff
)
##r_object = Region_ObjectDefinition('Region', 'QdRgn', 'RgnHandle')
...
...
@@ -86,6 +115,8 @@ module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
##module.addobject(po_object)
gr_object
=
MyGRObjectDefinition
(
"GrafPort"
,
"GrafObj"
,
"GrafPtr"
)
module
.
addobject
(
gr_object
)
bm_object
=
MyBMObjectDefinition
(
"BitMap"
,
"BMObj"
,
"BitMapPtr"
)
module
.
addobject
(
bm_object
)
# Create the generator classes used to populate the lists
...
...
@@ -104,6 +135,39 @@ for f in functions: module.add(f)
##for f in r_methods: r_object.add(f)
##for f in po_methods: po_object.add(f)
#
# We manually generate a routine to create a BitMap from python data.
#
BitMap_body
=
"""
BitMap *ptr;
PyObject *source;
Rect bounds;
int rowbytes;
char *data;
if ( !PyArg_ParseTuple(_args, "O!iO&", &PyString_Type, &source, &rowbytes, PyMac_GetRect,
&bounds) )
return NULL;
data = PyString_AsString(source);
if ((ptr=(BitMap *)malloc(sizeof(BitMap))) == NULL )
return PyErr_NoMemory();
ptr->baseAddr = (Ptr)data;
ptr->rowBytes = rowbytes;
ptr->bounds = bounds;
if ( (_res = BMObj_New(ptr)) == NULL ) {
free(ptr);
return NULL;
}
((BitMapObject *)_res)->referred_object = source;
Py_INCREF(source);
((BitMapObject *)_res)->referred_bitmap = ptr;
return _res;
"""
f
=
ManualGenerator
(
"BitMap"
,
BitMap_body
)
f
.
docstring
=
lambda
:
"""Take (string, int, Rect) argument and create BitMap"""
module
.
add
(
f
)
# generate output (open the output file as late as possible)
SetOutputFileName
(
OUTPUTFILE
)
module
.
generate
()
...
...
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