Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
330381cb
Kaydet (Commit)
330381cb
authored
Kas 15, 1995
tarafından
Jack Jansen
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Added (minimal) support for a GrafPort type
üst
7830ab8f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
139 additions
and
94 deletions
+139
-94
Qdmodule.c
Mac/Modules/qd/Qdmodule.c
+93
-57
qdgen.py
Mac/Modules/qd/qdgen.py
+0
-15
qdscan.py
Mac/Modules/qd/qdscan.py
+12
-5
qdsupport.py
Mac/Modules/qd/qdsupport.py
+34
-17
No files found.
Mac/Modules/qd/Qdmodule.c
Dosyayı görüntüle @
330381cb
...
...
@@ -19,6 +19,8 @@ extern int ResObj_Convert(PyObject *, Handle *);
extern
PyObject
*
WinObj_New
(
WindowPtr
);
extern
int
WinObj_Convert
(
PyObject
*
,
WindowPtr
*
);
extern
PyTypeObject
Window_Type
;
#define WinObj_Check(x) ((x)->ob_type == &Window_Type)
extern
PyObject
*
DlgObj_New
(
DialogPtr
);
extern
int
DlgObj_Convert
(
PyObject
*
,
DialogPtr
*
);
...
...
@@ -31,6 +33,9 @@ extern int MenuObj_Convert(PyObject *, MenuHandle *);
extern
PyObject
*
CtlObj_New
(
ControlHandle
);
extern
int
CtlObj_Convert
(
PyObject
*
,
ControlHandle
*
);
extern
PyObject
*
GrafObj_New
(
GrafPtr
);
extern
int
GrafObj_Convert
(
PyObject
*
,
GrafPtr
*
);
extern
PyObject
*
WinObj_WhichWindow
(
WindowPtr
);
#include <QuickDraw.h>
...
...
@@ -40,59 +45,96 @@ extern PyObject *WinObj_WhichWindow(WindowPtr);
static
PyObject
*
Qd_Error
;
static
PyObject
*
Qd_OpenPort
(
_self
,
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
/* ---------------------- Object type GrafPort ---------------------- */
PyTypeObject
GrafPort_Type
;
#define GrafObj_Check(x) ((x)->ob_type == &GrafPort_Type)
typedef
struct
GrafPortObject
{
PyObject_HEAD
GrafPtr
ob_itself
;
}
GrafPortObject
;
PyObject
*
GrafObj_New
(
itself
)
GrafPtr
itself
;
{
PyObject
*
_res
=
NULL
;
WindowPtr
port
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
port
))
return
NULL
;
OpenPort
(
port
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
GrafPortObject
*
it
;
if
(
itself
==
NULL
)
return
PyMac_Error
(
resNotFound
);
it
=
PyObject_NEW
(
GrafPortObject
,
&
GrafPort_Type
);
if
(
it
==
NULL
)
return
NULL
;
it
->
ob_itself
=
itself
;
return
(
PyObject
*
)
it
;
}
static
PyObject
*
Qd_InitPort
(
_self
,
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
GrafObj_Convert
(
v
,
p_itself
)
PyObject
*
v
;
GrafPtr
*
p_itself
;
{
PyObject
*
_res
=
NULL
;
WindowPtr
port
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
port
))
return
NULL
;
InitPort
(
port
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
if
(
DlgObj_Check
(
v
)
||
WinObj_Check
(
v
))
{
*
p_itself
=
((
GrafPortObject
*
)
v
)
->
ob_itself
;
return
1
;
}
if
(
!
GrafObj_Check
(
v
))
{
PyErr_SetString
(
PyExc_TypeError
,
"GrafPort required"
);
return
0
;
}
*
p_itself
=
((
GrafPortObject
*
)
v
)
->
ob_itself
;
return
1
;
}
static
PyObject
*
Qd_ClosePort
(
_self
,
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
static
void
GrafObj_dealloc
(
self
)
GrafPortObject
*
self
;
{
PyObject
*
_res
=
NULL
;
WindowPtr
port
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
port
))
return
NULL
;
ClosePort
(
port
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
/* Cleanup of self->ob_itself goes here */
PyMem_DEL
(
self
);
}
static
PyMethodDef
GrafObj_methods
[]
=
{
{
NULL
,
NULL
,
0
}
};
PyMethodChain
GrafObj_chain
=
{
GrafObj_methods
,
NULL
};
static
PyObject
*
GrafObj_getattr
(
self
,
name
)
GrafPortObject
*
self
;
char
*
name
;
{
if
(
strcmp
(
name
,
"device"
)
==
0
)
return
PyInt_FromLong
((
long
)
self
->
ob_itself
->
device
);
if
(
strcmp
(
name
,
"portRect"
)
==
0
)
return
Py_BuildValue
(
"O&"
,
PyMac_BuildRect
,
&
self
->
ob_itself
->
portRect
);
/* XXXX Add more, as needed */
return
Py_FindMethodInChain
(
&
GrafObj_chain
,
(
PyObject
*
)
self
,
name
);
}
#define GrafObj_setattr NULL
PyTypeObject
GrafPort_Type
=
{
PyObject_HEAD_INIT
(
&
PyType_Type
)
0
,
/*ob_size*/
"GrafPort"
,
/*tp_name*/
sizeof
(
GrafPortObject
),
/*tp_basicsize*/
0
,
/*tp_itemsize*/
/* methods */
(
destructor
)
GrafObj_dealloc
,
/*tp_dealloc*/
0
,
/*tp_print*/
(
getattrfunc
)
GrafObj_getattr
,
/*tp_getattr*/
(
setattrfunc
)
GrafObj_setattr
,
/*tp_setattr*/
};
/* -------------------- End object type GrafPort -------------------- */
static
PyObject
*
Qd_SetPort
(
_self
,
_args
)
PyObject
*
_self
;
PyObject
*
_args
;
{
PyObject
*
_res
=
NULL
;
Window
Ptr
port
;
Graf
Ptr
port
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
Win
Obj_Convert
,
&
port
))
Graf
Obj_Convert
,
&
port
))
return
NULL
;
SetPort
(
port
);
Py_INCREF
(
Py_None
);
...
...
@@ -105,12 +147,12 @@ static PyObject *Qd_GetPort(_self, _args)
PyObject
*
_args
;
{
PyObject
*
_res
=
NULL
;
Window
Ptr
port
;
Graf
Ptr
port
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
GetPort
(
&
port
);
_res
=
Py_BuildValue
(
"O&"
,
Win
Obj_New
,
port
);
Graf
Obj_New
,
port
);
return
_res
;
}
...
...
@@ -2378,9 +2420,9 @@ static PyObject *Qd_SpaceExtra(_self, _args)
PyObject
*
_args
;
{
PyObject
*
_res
=
NULL
;
long
extra
;
if
(
!
PyArg_ParseTuple
(
_args
,
"
l
"
,
&
extra
))
Fixed
extra
;
if
(
!
PyArg_ParseTuple
(
_args
,
"
O&
"
,
PyMac_GetFixed
,
&
extra
))
return
NULL
;
SpaceExtra
(
extra
);
Py_INCREF
(
Py_None
);
...
...
@@ -2504,9 +2546,9 @@ static PyObject *Qd_CharExtra(_self, _args)
PyObject
*
_args
;
{
PyObject
*
_res
=
NULL
;
long
extra
;
if
(
!
PyArg_ParseTuple
(
_args
,
"
l
"
,
&
extra
))
Fixed
extra
;
if
(
!
PyArg_ParseTuple
(
_args
,
"
O&
"
,
PyMac_GetFixed
,
&
extra
))
return
NULL
;
CharExtra
(
extra
);
Py_INCREF
(
Py_None
);
...
...
@@ -2515,16 +2557,10 @@ static PyObject *Qd_CharExtra(_self, _args)
}
static
PyMethodDef
Qd_methods
[]
=
{
{
"OpenPort"
,
(
PyCFunction
)
Qd_OpenPort
,
1
,
"(WindowPtr port) -> None"
},
{
"InitPort"
,
(
PyCFunction
)
Qd_InitPort
,
1
,
"(WindowPtr port) -> None"
},
{
"ClosePort"
,
(
PyCFunction
)
Qd_ClosePort
,
1
,
"(WindowPtr port) -> None"
},
{
"SetPort"
,
(
PyCFunction
)
Qd_SetPort
,
1
,
"(
Window
Ptr port) -> None"
},
"(
Graf
Ptr port) -> None"
},
{
"GetPort"
,
(
PyCFunction
)
Qd_GetPort
,
1
,
"() -> (
Window
Ptr port)"
},
"() -> (
Graf
Ptr port)"
},
{
"GrafDevice"
,
(
PyCFunction
)
Qd_GrafDevice
,
1
,
"(short device) -> None"
},
{
"PortSize"
,
(
PyCFunction
)
Qd_PortSize
,
1
,
...
...
@@ -2788,7 +2824,7 @@ static PyMethodDef Qd_methods[] = {
{
"TextSize"
,
(
PyCFunction
)
Qd_TextSize
,
1
,
"(short size) -> None"
},
{
"SpaceExtra"
,
(
PyCFunction
)
Qd_SpaceExtra
,
1
,
"(
long
extra) -> None"
},
"(
Fixed
extra) -> None"
},
{
"DrawChar"
,
(
PyCFunction
)
Qd_DrawChar
,
1
,
"(short ch) -> None"
},
{
"DrawString"
,
(
PyCFunction
)
Qd_DrawString
,
1
,
...
...
@@ -2802,7 +2838,7 @@ static PyMethodDef Qd_methods[] = {
{
"TextWidth"
,
(
PyCFunction
)
Qd_TextWidth
,
1
,
"(Buffer textBuf, short firstByte, short byteCount) -> (short _rv)"
},
{
"CharExtra"
,
(
PyCFunction
)
Qd_CharExtra
,
1
,
"(
long
extra) -> None"
},
"(
Fixed
extra) -> None"
},
{
NULL
,
NULL
,
0
}
};
...
...
Mac/Modules/qd/qdgen.py
Dosyayı görüntüle @
330381cb
# Generated from 'Sap:CodeWarrior7:Metrowerks CodeWarrior:MacOS Support:Headers:Universal Headers:QuickDraw.h'
f
=
Function
(
void
,
'OpenPort'
,
(
GrafPtr
,
'port'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'InitPort'
,
(
GrafPtr
,
'port'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'ClosePort'
,
(
GrafPtr
,
'port'
,
InMode
),
)
functions
.
append
(
f
)
f
=
Function
(
void
,
'SetPort'
,
(
GrafPtr
,
'port'
,
InMode
),
)
...
...
Mac/Modules/qd/qdscan.py
Dosyayı görüntüle @
330381cb
...
...
@@ -49,9 +49,12 @@ class MyScanner(Scanner):
listname
=
"functions"
if
arglist
:
t
,
n
,
m
=
arglist
[
0
]
if
t
in
(
"WindowPtr"
,
"WindowPeek"
,
"WindowRef"
)
and
m
==
"InMode"
:
classname
=
"Method"
listname
=
"methods"
## elif t == "PolyHandle" and m == "InMode":
## classname = "Method"
## listname = "p_methods"
## elif t == "RgnHandle" and m == "InMode":
## classname = "Method"
## listname = "r_methods"
return
classname
,
listname
def
makeblacklistnames
(
self
):
...
...
@@ -61,14 +64,18 @@ class MyScanner(Scanner):
'StdLine'
,
'StdComment'
,
'StdGetPic'
,
'StdLine'
,
'OpenPort'
,
'InitPort'
,
'ClosePort'
,
'OpenCPort'
,
'InitCPort'
,
'CloseCPort'
,
]
def
makeblacklisttypes
(
self
):
return
[
'BitMap_ptr'
,
'CCrsrHandle'
,
'CGrafPtr'
,
'CIconHandle'
,
'CQDProcs'
,
'CSpecArray'
,
...
...
Mac/Modules/qd/qdsupport.py
Dosyayı görüntüle @
330381cb
...
...
@@ -25,8 +25,6 @@ from macsupport import *
# Create the type objects
GrafPtr
=
WindowPtr
class
TextThingieClass
(
FixedInputBufferType
):
def
getargsCheck
(
self
,
name
):
pass
...
...
@@ -34,7 +32,6 @@ class TextThingieClass(FixedInputBufferType):
TextThingie
=
TextThingieClass
(
None
)
# These are temporary!
Fixed
=
long
RgnHandle
=
OpaqueByValueType
(
"RgnHandle"
,
"ResObj"
)
PicHandle
=
OpaqueByValueType
(
"PicHandle"
,
"ResObj"
)
PolyHandle
=
OpaqueByValueType
(
"PolyHandle"
,
"ResObj"
)
...
...
@@ -42,6 +39,8 @@ PixMapHandle = OpaqueByValueType("PixMapHandle", "ResObj")
PixPatHandle
=
OpaqueByValueType
(
"PixPatHandle"
,
"ResObj"
)
PatHandle
=
OpaqueByValueType
(
"PatHandle"
,
"ResObj"
)
CursHandle
=
OpaqueByValueType
(
"CursHandle"
,
"ResObj"
)
CGrafPtr
=
OpaqueByValueType
(
"CGrafPtr"
,
"GrafObj"
)
GrafPtr
=
OpaqueByValueType
(
"GrafPtr"
,
"GrafObj"
)
includestuff
=
includestuff
+
"""
#include <
%
s>"""
%
MACHEADERFILE
+
"""
...
...
@@ -49,28 +48,45 @@ includestuff = includestuff + """
#define resNotFound -192 /* Can't include <Errors.h> because of Python's "errors.h" */
"""
class
MyObjectDefinition
(
GlobalObjectDefinition
):
## not yet...
##
##class Region_ObjectDefinition(GlobalObjectDefinition):
## def outputCheckNewArg(self):
## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
## def outputFreeIt(self, itselfname):
## Output("DisposeRegion(%s);", itselfname)
##
##class Polygon_ObjectDefinition(GlobalObjectDefinition):
## def outputCheckNewArg(self):
## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
## def outputFreeIt(self, itselfname):
## Output("KillPoly(%s);", itselfname)
class
MyGRObjectDefinition
(
GlobalObjectDefinition
):
def
outputCheckNewArg
(
self
):
Output
(
"if (itself == NULL) return PyMac_Error(resNotFound);"
)
def
outputCheckConvertArg
(
self
):
OutLbrace
(
"if (DlgObj_Check(v))"
)
Output
(
"*p_itself = ((
Window
Object *)v)->ob_itself;"
)
OutLbrace
(
"if (DlgObj_Check(v)
|| WinObj_Check(v)
)"
)
Output
(
"*p_itself = ((
GrafPort
Object *)v)->ob_itself;"
)
Output
(
"return 1;"
)
OutRbrace
()
Out
(
"""
if (v == Py_None) { *p_itself = NULL; return 1; }
if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
def
outputGetattrHook
(
self
):
Output
(
"""if ( strcmp(name, "device") == 0 )
return PyInt_FromLong((long)self->ob_itself->device);
if ( strcmp(name, "portRect") == 0 )
return Py_BuildValue("O&", PyMac_BuildRect, &self->ob_itself->portRect);
/* XXXX Add more, as needed */
"""
)
def
outputFreeIt
(
self
,
itselfname
):
Output
(
"DisposeWindow(
%
s);"
,
itselfname
)
# From here on it's basically all boiler plate...
# Create the generator groups and link them
module
=
MacModule
(
MODNAME
,
MODPREFIX
,
includestuff
,
finalstuff
,
initstuff
)
##object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
##module.addobject(object)
##r_object = Region_ObjectDefinition('Region', 'QdRgn', 'RgnHandle')
##po_object = Polygon_ObjectDefinition('Polygon', 'QdPgn', 'PolyHandle')
##module.addobject(r_object)
##module.addobject(po_object)
gr_object
=
MyGRObjectDefinition
(
"GrafPort"
,
"GrafObj"
,
"GrafPtr"
)
module
.
addobject
(
gr_object
)
# Create the generator classes used to populate the lists
Function
=
OSErrFunctionGenerator
...
...
@@ -85,7 +101,8 @@ execfile(INPUTFILE)
# add the populated lists to the generator groups
# (in a different wordl the scan program would generate this)
for
f
in
functions
:
module
.
add
(
f
)
for
f
in
methods
:
object
.
add
(
f
)
##for f in r_methods: r_object.add(f)
##for f in po_methods: po_object.add(f)
# generate output (open the output file as late as possible)
SetOutputFileName
(
OUTPUTFILE
)
...
...
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