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
cf27c2d5
Commit
cf27c2d5
authored
Jan 25, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some layout changes; added EventRecord Get/Build functions (as a tuple).
parent
01f5a81d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
119 additions
and
20 deletions
+119
-20
Mac/Include/macglue.h
Mac/Include/macglue.h
+23
-9
Mac/Python/macglue.c
Mac/Python/macglue.c
+96
-11
No files found.
Mac/Include/macglue.h
View file @
cf27c2d5
...
@@ -24,18 +24,32 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
...
@@ -24,18 +24,32 @@ OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#include <Types.h>
#include <Types.h>
#include <Files.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 */
int
PyMac_Idle
(
void
);
/* Idle routine */
PyObject
*
PyMac_BuildOSType
Py_PROTO
((
OSType
));
/* Convert OSType to PyObject */
int
PyMac_Get
Str255
Py_PROTO
((
PyObject
*
,
Str255
));
/* argument parser for Str255
*/
int
PyMac_Get
OSType
(
PyObject
*
,
OSType
*
);
/* argument parser for OSType
*/
PyObject
*
PyMac_Build
Str255
Py_PROTO
((
Str255
));
/* Convert Str255
to PyObject */
PyObject
*
PyMac_Build
OSType
(
OSType
);
/* Convert OSType
to PyObject */
int
PyMac_GetFSSpec
Py_PROTO
((
PyObject
*
,
FSSpec
*
));
/* argument parser for FSSpec */
int
PyMac_GetStr255
(
PyObject
*
,
Str255
);
/* argument parser for Str255 */
PyObject
*
PyMac_BuildFSSpec
Py_PROTO
((
FSSpec
*
));
/* Convert FSSpec to PyObject */
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
View file @
cf27c2d5
...
@@ -71,6 +71,18 @@ char *macstrerror(int err)
...
@@ -71,6 +71,18 @@ char *macstrerror(int err)
return
buf
;
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 */
/* Set a MAC-specific error from errno, and return NULL; return None if no error */
PyObject
*
PyObject
*
PyErr_Mac
(
PyObject
*
eobj
,
int
err
)
PyErr_Mac
(
PyObject
*
eobj
,
int
err
)
...
@@ -91,6 +103,13 @@ PyErr_Mac(PyObject *eobj, int err)
...
@@ -91,6 +103,13 @@ PyErr_Mac(PyObject *eobj, int err)
return
NULL
;
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.
** Idle routine for busy-wait loops.
** This is rather tricky: if we see an event we check whether it is
** This is rather tricky: if we see an event we check whether it is
...
@@ -117,9 +136,9 @@ PyMac_Idle()
...
@@ -117,9 +136,9 @@ PyMac_Idle()
}
}
/* Convert a
ResType argument
*/
/* Convert a
4-char string object argument to an OSType value
*/
int
int
PyMac_GetOSType
(
PyObject
*
v
,
Res
Type
*
pr
)
PyMac_GetOSType
(
PyObject
*
v
,
OS
Type
*
pr
)
{
{
if
(
!
PyString_Check
(
v
)
||
PyString_Size
(
v
)
!=
4
)
{
if
(
!
PyString_Check
(
v
)
||
PyString_Size
(
v
)
!=
4
)
{
PyErr_SetString
(
PyExc_TypeError
,
PyErr_SetString
(
PyExc_TypeError
,
...
@@ -130,7 +149,15 @@ PyMac_GetOSType(PyObject *v, ResType *pr)
...
@@ -130,7 +149,15 @@ PyMac_GetOSType(PyObject *v, ResType *pr)
return
1
;
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
int
PyMac_GetStr255
(
PyObject
*
v
,
Str255
pbuf
)
PyMac_GetStr255
(
PyObject
*
v
,
Str255
pbuf
)
{
{
...
@@ -145,8 +172,18 @@ PyMac_GetStr255(PyObject *v, Str255 pbuf)
...
@@ -145,8 +172,18 @@ PyMac_GetStr255(PyObject *v, Str255 pbuf)
return
1
;
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.
** NOTE: This routine will fail on pre-sys7 machines.
** The caller is responsible for not calling this routine
** The caller is responsible for not calling this routine
** in those cases (which is fine, since everyone calling
** in those cases (which is fine, since everyone calling
...
@@ -180,23 +217,71 @@ PyMac_GetFSSpec(PyObject *v, FSSpec *fs)
...
@@ -180,23 +217,71 @@ PyMac_GetFSSpec(PyObject *v, FSSpec *fs)
return
1
;
return
1
;
}
}
/*
Return a Python object that describes an FSSpec
*/
/*
Convert an FSSpec to a Python object -- a triple (vrefnum, dirid, path)
*/
PyObject
*
PyObject
*
PyMac_BuildFSSpec
(
FSSpec
*
fs
)
PyMac_BuildFSSpec
(
FSSpec
*
fs
)
{
{
return
Py_BuildValue
(
"(iis#)"
,
fs
->
vRefNum
,
fs
->
parID
,
&
fs
->
name
[
1
],
fs
->
name
[
0
]);
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
*
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
*
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