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
cf27c2d5
Kaydet (Commit)
cf27c2d5
authored
Ock 25, 1995
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
Some layout changes; added EventRecord Get/Build functions (as a tuple).
üst
01f5a81d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
20 deletions
+119
-20
macglue.h
Mac/Include/macglue.h
+23
-9
macglue.c
Mac/Python/macglue.c
+96
-11
No files found.
Mac/Include/macglue.h
Dosyayı görüntüle @
cf27c2d5
...
...
@@ -24,18 +24,32 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <Types.h>
#include <Files.h>
#include <Events.h>
char
*
macstrerror
Py_PROTO
((
int
));
/* strerror with mac errors */
char
*
macstrerror
(
int
);
/* strerror with mac errors */
PyObject
*
PyErr_Mac
Py_PROTO
((
PyObject
*
,
int
));
/* Exception with a mac error */
extern
PyObject
*
PyMac_OSErrException
;
/* Exception for OSErr */
PyObject
*
PyMac_GetOSErrException
(
void
);
/* Initialize & return it */
int
PyMac_Idle
Py_PROTO
((
void
));
/* Idle routine */
PyObject
*
PyErr_Mac
(
PyObject
*
,
int
);
/* Exception with a mac error */
PyObject
*
PyMac_Error
(
OSErr
);
/* Uses PyMac_GetOSErrException */
int
PyMac_GetOSType
Py_PROTO
((
PyObject
*
,
OSType
*
));
/* argument parser for OSType */
PyObject
*
PyMac_BuildOSType
Py_PROTO
((
OSType
));
/* Convert OSType to PyObject */
int
PyMac_Idle
(
void
);
/* Idle routine */
int
PyMac_Get
Str255
Py_PROTO
((
PyObject
*
,
Str255
));
/* argument parser for Str255
*/
PyObject
*
PyMac_Build
Str255
Py_PROTO
((
Str255
));
/* Convert Str255
to PyObject */
int
PyMac_Get
OSType
(
PyObject
*
,
OSType
*
);
/* argument parser for OSType
*/
PyObject
*
PyMac_Build
OSType
(
OSType
);
/* Convert OSType
to PyObject */
int
PyMac_GetFSSpec
Py_PROTO
((
PyObject
*
,
FSSpec
*
));
/* argument parser for FSSpec */
PyObject
*
PyMac_BuildFSSpec
Py_PROTO
((
FSSpec
*
));
/* Convert FSSpec to PyObject */
int
PyMac_GetStr255
(
PyObject
*
,
Str255
);
/* argument parser for Str255 */
PyObject
*
PyMac_BuildStr255
(
Str255
);
/* Convert Str255 to PyObject */
int
PyMac_GetFSSpec
(
PyObject
*
,
FSSpec
*
);
/* argument parser for FSSpec */
PyObject
*
PyMac_BuildFSSpec
(
FSSpec
*
);
/* Convert FSSpec to PyObject */
int
PyMac_GetRect
(
PyObject
*
,
Rect
*
);
/* argument parser for Rect */
PyObject
*
PyMac_BuildRect
(
Rect
*
);
/* Convert Rect to PyObject */
int
PyMac_GetPoint
(
PyObject
*
,
Point
*
);
/* argument parser for Point */
PyObject
*
PyMac_BuildPoint
(
Point
);
/* Convert Point to PyObject */
int
PyMac_GetEventRecord
(
PyObject
*
,
EventRecord
*
);
/* argument parser for EventRecord */
PyObject
*
PyMac_BuildEventRecord
(
EventRecord
*
);
/* Convert EventRecord to PyObject */
Mac/Python/macglue.c
Dosyayı görüntüle @
cf27c2d5
...
...
@@ -71,6 +71,18 @@ char *macstrerror(int err)
return
buf
;
}
/* Exception object shared by all Mac specific modules for Mac OS errors */
PyObject
*
PyMac_OSErrException
;
/* Initialize and return PyMac_OSErrException */
PyObject
*
PyMac_GetOSErrException
()
{
if
(
PyMac_OSErrException
==
NULL
)
PyMac_OSErrException
=
PyString_FromString
(
"Mac OS Error"
);
return
PyMac_OSErrException
;
}
/* Set a MAC-specific error from errno, and return NULL; return None if no error */
PyObject
*
PyErr_Mac
(
PyObject
*
eobj
,
int
err
)
...
...
@@ -91,6 +103,13 @@ PyErr_Mac(PyObject *eobj, int err)
return
NULL
;
}
/* Call PyErr_Mac with PyMac_OSErrException */
PyObject
*
PyMac_Error
(
OSErr
err
)
{
return
PyErr_Mac
(
PyMac_GetOSErrException
(),
err
);
}
/*
** Idle routine for busy-wait loops.
** This is rather tricky: if we see an event we check whether it is
...
...
@@ -117,9 +136,9 @@ PyMac_Idle()
}
/* Convert a
ResType argument
*/
/* Convert a
4-char string object argument to an OSType value
*/
int
PyMac_GetOSType
(
PyObject
*
v
,
Res
Type
*
pr
)
PyMac_GetOSType
(
PyObject
*
v
,
OS
Type
*
pr
)
{
if
(
!
PyString_Check
(
v
)
||
PyString_Size
(
v
)
!=
4
)
{
PyErr_SetString
(
PyExc_TypeError
,
...
...
@@ -130,7 +149,15 @@ PyMac_GetOSType(PyObject *v, ResType *pr)
return
1
;
}
/* Convert a Python string to a Str255 */
/* Convert an OSType value to a 4-char string object */
PyObject
*
PyMac_BuildOSType
(
OSType
t
)
{
return
PyString_FromStringAndSize
((
char
*
)
&
t
,
4
);
}
/* Convert a Python string object to a Str255 */
int
PyMac_GetStr255
(
PyObject
*
v
,
Str255
pbuf
)
{
...
...
@@ -145,8 +172,18 @@ PyMac_GetStr255(PyObject *v, Str255 pbuf)
return
1
;
}
/* Convert a Str255 to a Python string object */
PyObject
*
PyMac_BuildStr255
(
Str255
s
)
{
return
PyString_FromStringAndSize
((
char
*
)
&
s
[
1
],
(
int
)
s
[
0
]);
}
/*
** Convert anything resembling an FSSpec argument
** Convert a Python object to an FSSpec.
** The object may either be a full pathname or a triple
** (vrefnum, dirid, path).
** NOTE: This routine will fail on pre-sys7 machines.
** The caller is responsible for not calling this routine
** in those cases (which is fine, since everyone calling
...
...
@@ -180,23 +217,71 @@ PyMac_GetFSSpec(PyObject *v, FSSpec *fs)
return
1
;
}
/*
Return a Python object that describes an FSSpec
*/
/*
Convert an FSSpec to a Python object -- a triple (vrefnum, dirid, path)
*/
PyObject
*
PyMac_BuildFSSpec
(
FSSpec
*
fs
)
{
return
Py_BuildValue
(
"(iis#)"
,
fs
->
vRefNum
,
fs
->
parID
,
&
fs
->
name
[
1
],
fs
->
name
[
0
]);
}
/* Convert an OSType value to a 4-char string object */
/* Convert a Python object to a Rect.
The object must be a (top, left, bottom, right) tuple.
(Unfortunately this is different from STDWIN's convention). */
int
PyMac_GetRect
(
PyObject
*
v
,
Rect
*
r
)
{
return
PyArg_Parse
(
v
,
"(hhhh)"
,
&
r
->
top
,
&
r
->
left
,
&
r
->
bottom
,
&
r
->
right
);
}
/* Convert a Rect to a Python object */
PyObject
*
PyMac_Build
OSType
(
OSType
t
)
PyMac_Build
Rect
(
Rect
*
r
)
{
return
PyString_FromStringAndSize
((
char
*
)
&
t
,
4
);
return
Py_BuildValue
(
"(hhhh)"
,
r
->
top
,
r
->
left
,
r
->
bottom
,
r
->
right
);
}
/* Convert a Python object to a Point.
The object must be a (v, h) tuple.
(Unfortunately this is different from STDWIN's convention). */
int
PyMac_GetPoint
(
PyObject
*
v
,
Point
*
p
)
{
return
PyArg_Parse
(
v
,
"(hh)"
,
&
p
->
v
,
&
p
->
h
);
}
/* Convert a
Str255 to a Python string
*/
/* Convert a
Point to a Python object
*/
PyObject
*
PyMac_Build
Str255
(
Str255
s
)
PyMac_Build
Point
(
Point
p
)
{
return
PyString_FromStringAndSize
((
char
*
)
&
s
[
1
],
(
int
)
s
[
0
]);
return
Py_BuildValue
(
"(hh)"
,
p
.
v
,
p
.
h
);
}
/* Convert a Python object to an EventRecord.
The object must be a (what, message, when, (v, h), modifiers) tuple. */
int
PyMac_GetEventRecord
(
PyObject
*
v
,
EventRecord
*
e
)
{
return
PyArg_Parse
(
v
,
"(hll(hh)h)"
,
&
e
->
what
,
&
e
->
message
,
&
e
->
when
,
&
e
->
where
.
v
,
&
e
->
where
.
h
,
&
e
->
modifiers
);
}
/* Convert a Rect to an EventRecord object */
PyObject
*
PyMac_BuildEventRecord
(
EventRecord
*
e
)
{
return
Py_BuildValue
(
"(hll(hh)h)"
,
e
->
what
,
e
->
message
,
e
->
when
,
e
->
where
.
v
,
e
->
where
.
h
,
e
->
modifiers
);
}
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