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
15c62a50
Commit
15c62a50
authored
Jan 09, 1995
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Used new getargs interface; added {Get,Set}FileInfo.
parent
0a90cfe2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
77 additions
and
44 deletions
+77
-44
Mac/Modules/macosmodule.c
Mac/Modules/macosmodule.c
+77
-44
No files found.
Mac/Modules/macosmodule.c
View file @
15c62a50
...
@@ -111,7 +111,7 @@ Rsrc_GetResInfo(RsrcObject *r, PyObject *args)
...
@@ -111,7 +111,7 @@ Rsrc_GetResInfo(RsrcObject *r, PyObject *args)
short
id
;
short
id
;
ResType
type
;
ResType
type
;
Str255
name
;
Str255
name
;
if
(
!
PyArg_Parse
(
args
,
"()
"
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"
"
))
return
NULL
;
return
NULL
;
GetResInfo
(
r
->
h
,
&
id
,
&
type
,
name
);
GetResInfo
(
r
->
h
,
&
id
,
&
type
,
name
);
return
Py_BuildValue
(
"(is#s#)"
,
return
Py_BuildValue
(
"(is#s#)"
,
...
@@ -125,7 +125,7 @@ Rsrc_AsBytes(RsrcObject *r, PyObject *args)
...
@@ -125,7 +125,7 @@ Rsrc_AsBytes(RsrcObject *r, PyObject *args)
PyObject
*
rv
;
PyObject
*
rv
;
char
*
cp
;
char
*
cp
;
if
(
!
PyArg_Parse
(
args
,
"(l)
"
,
&
len
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"l
"
,
&
len
))
return
NULL
;
return
NULL
;
HLock
(
r
->
h
);
HLock
(
r
->
h
);
cp
=
(
char
*
)
*
r
->
h
;
cp
=
(
char
*
)
*
r
->
h
;
...
@@ -140,7 +140,7 @@ Rsrc_AsString(RsrcObject *r, PyObject *args)
...
@@ -140,7 +140,7 @@ Rsrc_AsString(RsrcObject *r, PyObject *args)
PyObject
*
rv
;
PyObject
*
rv
;
unsigned
char
*
cp
;
unsigned
char
*
cp
;
if
(
!
PyArg_Parse
(
args
,
"()
"
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"
"
))
return
NULL
;
return
NULL
;
HLock
(
r
->
h
);
HLock
(
r
->
h
);
cp
=
(
unsigned
char
*
)
*
r
->
h
;
cp
=
(
unsigned
char
*
)
*
r
->
h
;
...
@@ -187,7 +187,7 @@ MacOS_GetResource(PyObject *self, PyObject *args)
...
@@ -187,7 +187,7 @@ MacOS_GetResource(PyObject *self, PyObject *args)
ResType
rt
;
ResType
rt
;
int
id
;
int
id
;
Handle
h
;
Handle
h
;
if
(
!
PyArg_Parse
(
args
,
"(O&i)
"
,
GetOSType
,
&
rt
,
&
id
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"O&i
"
,
GetOSType
,
&
rt
,
&
id
))
return
NULL
;
return
NULL
;
h
=
GetResource
(
rt
,
id
);
h
=
GetResource
(
rt
,
id
);
return
(
PyObject
*
)
Rsrc_FromHandle
(
h
);
return
(
PyObject
*
)
Rsrc_FromHandle
(
h
);
...
@@ -199,12 +199,65 @@ MacOS_GetNamedResource(PyObject *self, PyObject *args)
...
@@ -199,12 +199,65 @@ MacOS_GetNamedResource(PyObject *self, PyObject *args)
ResType
rt
;
ResType
rt
;
Str255
name
;
Str255
name
;
Handle
h
;
Handle
h
;
if
(
!
PyArg_Parse
(
args
,
"(O&O&)
"
,
GetOSType
,
&
rt
,
GetStr255
,
&
name
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"O&O&
"
,
GetOSType
,
&
rt
,
GetStr255
,
&
name
))
return
NULL
;
return
NULL
;
h
=
GetNamedResource
(
rt
,
name
);
h
=
GetNamedResource
(
rt
,
name
);
return
(
PyObject
*
)
Rsrc_FromHandle
(
h
);
return
(
PyObject
*
)
Rsrc_FromHandle
(
h
);
}
}
/*----------------------------------------------------------------------*/
/* Miscellaneous File System Operations */
static
PyObject
*
MacOS_GetFileType
(
PyObject
*
self
,
PyObject
*
args
)
{
Str255
name
;
FInfo
info
;
PyObject
*
type
,
*
creator
,
*
res
;
OSErr
err
;
if
(
!
PyArg_ParseTuple
(
args
,
"O&"
,
GetStr255
,
&
name
))
return
NULL
;
if
((
err
=
GetFInfo
(
name
,
0
,
&
info
))
!=
noErr
)
{
errno
=
err
;
PyErr_SetFromErrno
(
MacOS_Error
);
return
NULL
;
}
type
=
PyString_FromStringAndSize
((
char
*
)
&
info
.
fdType
,
4
);
creator
=
PyString_FromStringAndSize
((
char
*
)
&
info
.
fdCreator
,
4
);
res
=
Py_BuildValue
(
"OO"
,
type
,
creator
);
DECREF
(
type
);
DECREF
(
creator
);
return
res
;
}
static
PyObject
*
MacOS_SetFileType
(
PyObject
*
self
,
PyObject
*
args
)
{
Str255
name
;
ResType
type
,
creator
;
FInfo
info
;
OSErr
err
;
if
(
!
PyArg_ParseTuple
(
args
,
"O&O&O&"
,
GetStr255
,
&
name
,
GetOSType
,
&
type
,
GetOSType
,
&
creator
))
return
NULL
;
if
((
err
=
GetFInfo
(
name
,
0
,
&
info
))
!=
noErr
)
{
errno
=
err
;
PyErr_SetFromErrno
(
MacOS_Error
);
return
NULL
;
}
info
.
fdType
=
type
;
info
.
fdCreator
=
creator
;
if
((
err
=
SetFInfo
(
name
,
0
,
&
info
))
!=
noErr
)
{
errno
=
err
;
err_errno
(
MacOS_Error
);
return
NULL
;
}
Py_INCREF
(
Py_None
);
return
Py_None
;
}
/*----------------------------------------------------------------------*/
/*----------------------------------------------------------------------*/
/* SoundChannel objects */
/* SoundChannel objects */
...
@@ -215,23 +268,13 @@ GetSndCommand(PyObject *v, SndCommand *pc)
...
@@ -215,23 +268,13 @@ GetSndCommand(PyObject *v, SndCommand *pc)
int
len
;
int
len
;
pc
->
param1
=
0
;
pc
->
param1
=
0
;
pc
->
param2
=
0
;
pc
->
param2
=
0
;
if
(
PyArg_Parse
(
v
,
"h"
,
&
pc
->
cmd
))
if
(
PyTuple_Check
(
v
))
{
return
1
;
if
(
PyArg_ParseTuple
(
v
,
"h|hl"
,
&
pc
->
cmd
,
&
pc
->
param1
,
&
pc
->
param2
))
PyErr_Clear
();
return
1
;
if
(
PyArg_Parse
(
v
,
"(h)"
,
&
pc
->
cmd
))
PyErr_Clear
();
return
1
;
return
PyArg_ParseTuple
(
v
,
"hhs#"
,
&
pc
->
cmd
,
&
pc
->
param1
,
&
pc
->
param2
,
&
len
);
PyErr_Clear
();
}
if
(
PyArg_Parse
(
v
,
"(hh)"
,
&
pc
->
cmd
,
&
pc
->
param1
))
return
PyArg_Parse
(
v
,
"h"
,
&
pc
->
cmd
);
return
1
;
PyErr_Clear
();
if
(
PyArg_Parse
(
v
,
"(hhl)"
,
&
pc
->
cmd
,
&
pc
->
param1
,
&
pc
->
param2
))
return
1
;
PyErr_Clear
();
if
(
PyArg_Parse
(
v
,
"(hhs#);SndCommand arg must be 1-3 ints or 2 ints + string"
,
&
pc
->
cmd
,
&
pc
->
param1
,
&
pc
->
param2
,
&
len
))
return
1
;
return
0
;
}
}
typedef
struct
{
typedef
struct
{
...
@@ -277,7 +320,7 @@ SndCh_DisposeChannel(SndChObject *s, PyObject *args)
...
@@ -277,7 +320,7 @@ SndCh_DisposeChannel(SndChObject *s, PyObject *args)
{
{
int
quitNow
=
1
;
int
quitNow
=
1
;
if
(
PyTuple_Size
(
args
)
>
0
)
{
if
(
PyTuple_Size
(
args
)
>
0
)
{
if
(
!
PyArg_Parse
(
args
,
"(i)
"
,
&
quitNow
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"i
"
,
&
quitNow
))
return
NULL
;
return
NULL
;
}
}
SndCh_Cleanup
(
s
,
quitNow
);
SndCh_Cleanup
(
s
,
quitNow
);
...
@@ -300,11 +343,8 @@ SndCh_SndPlay(SndChObject *s, PyObject *args)
...
@@ -300,11 +343,8 @@ SndCh_SndPlay(SndChObject *s, PyObject *args)
{
{
RsrcObject
*
r
;
RsrcObject
*
r
;
int
async
=
0
;
int
async
=
0
;
if
(
!
PyArg_Parse
(
args
,
"(O!)"
,
RsrcType
,
&
r
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"O!|i"
,
RsrcType
,
&
r
,
&
async
))
PyErr_Clear
();
return
NULL
;
if
(
!
PyArg_Parse
(
args
,
"(O&i)"
,
RsrcType
,
&
r
,
&
async
))
return
NULL
;
}
if
(
!
SndCh_OK
(
s
))
if
(
!
SndCh_OK
(
s
))
return
NULL
;
return
NULL
;
SndPlay
(
s
->
chan
,
r
->
h
,
async
);
SndPlay
(
s
->
chan
,
r
->
h
,
async
);
...
@@ -318,11 +358,8 @@ SndCh_SndDoCommand(SndChObject *s, PyObject *args)
...
@@ -318,11 +358,8 @@ SndCh_SndDoCommand(SndChObject *s, PyObject *args)
SndCommand
c
;
SndCommand
c
;
int
noWait
=
0
;
int
noWait
=
0
;
OSErr
err
;
OSErr
err
;
if
(
!
PyArg_Parse
(
args
,
"(O&)"
,
GetSndCommand
,
&
c
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"O&|i"
,
GetSndCommand
,
&
c
,
&
noWait
))
PyErr_Clear
();
return
NULL
;
if
(
!
PyArg_Parse
(
args
,
"(O&i)"
,
GetSndCommand
,
&
c
,
&
noWait
))
return
NULL
;
}
if
(
!
SndCh_OK
(
s
))
if
(
!
SndCh_OK
(
s
))
return
NULL
;
return
NULL
;
err
=
SndDoCommand
(
s
->
chan
,
&
c
,
noWait
);
err
=
SndDoCommand
(
s
->
chan
,
&
c
,
noWait
);
...
@@ -334,7 +371,7 @@ SndCh_SndDoImmediate(SndChObject *s, PyObject *args)
...
@@ -334,7 +371,7 @@ SndCh_SndDoImmediate(SndChObject *s, PyObject *args)
{
{
SndCommand
c
;
SndCommand
c
;
OSErr
err
;
OSErr
err
;
if
(
!
PyArg_Parse
(
args
,
"(O&)
"
,
GetSndCommand
,
&
c
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"O&
"
,
GetSndCommand
,
&
c
))
return
0
;
return
0
;
if
(
!
SndCh_OK
(
s
))
if
(
!
SndCh_OK
(
s
))
return
NULL
;
return
NULL
;
...
@@ -432,14 +469,8 @@ MacOS_SndNewChannel(PyObject *self, PyObject *args)
...
@@ -432,14 +469,8 @@ MacOS_SndNewChannel(PyObject *self, PyObject *args)
SndCallBackUPP
userroutine
=
0
;
SndCallBackUPP
userroutine
=
0
;
OSErr
err
;
OSErr
err
;
PyObject
*
res
;
PyObject
*
res
;
if
(
!
PyArg_Parse
(
args
,
"(h)"
,
&
synth
))
{
if
(
!
PyArg_ParseTuple
(
args
,
"h|lO"
,
&
synth
,
&
init
,
&
callback
))
PyErr_Clear
();
return
NULL
;
if
(
!
PyArg_Parse
(
args
,
"(hl)"
,
&
synth
,
&
init
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
args
,
"(hlO)"
,
&
synth
,
&
init
,
&
callback
))
return
NULL
;
}
}
if
(
callback
!=
NULL
)
{
if
(
callback
!=
NULL
)
{
p
=
NEW
(
cbinfo
,
1
);
p
=
NEW
(
cbinfo
,
1
);
if
(
p
==
NULL
)
if
(
p
==
NULL
)
...
@@ -472,7 +503,7 @@ MacOS_SndPlay(PyObject *self, PyObject *args)
...
@@ -472,7 +503,7 @@ MacOS_SndPlay(PyObject *self, PyObject *args)
{
{
RsrcObject
*
r
;
RsrcObject
*
r
;
OSErr
err
;
OSErr
err
;
if
(
!
PyArg_Parse
(
args
,
"(O!)
"
,
&
RsrcType
,
&
r
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"O!
"
,
&
RsrcType
,
&
r
))
return
NULL
;
return
NULL
;
err
=
SndPlay
((
SndChannelPtr
)
NULL
,
r
->
h
,
0
);
err
=
SndPlay
((
SndChannelPtr
)
NULL
,
r
->
h
,
0
);
return
PyErr_Mac
(
MacOS_Error
,
(
int
)
err
);
return
PyErr_Mac
(
MacOS_Error
,
(
int
)
err
);
...
@@ -484,7 +515,7 @@ MacOS_SndControl(PyObject *self, PyObject *args)
...
@@ -484,7 +515,7 @@ MacOS_SndControl(PyObject *self, PyObject *args)
int
id
;
int
id
;
SndCommand
c
;
SndCommand
c
;
OSErr
err
;
OSErr
err
;
if
(
!
PyArg_Parse
(
args
,
"(iO&)
"
,
&
id
,
GetSndCommand
,
&
c
))
if
(
!
PyArg_Parse
Tuple
(
args
,
"iO&
"
,
&
id
,
GetSndCommand
,
&
c
))
return
NULL
;
return
NULL
;
err
=
SndControl
(
id
,
&
c
);
err
=
SndControl
(
id
,
&
c
);
if
(
err
)
if
(
err
)
...
@@ -495,6 +526,8 @@ MacOS_SndControl(PyObject *self, PyObject *args)
...
@@ -495,6 +526,8 @@ MacOS_SndControl(PyObject *self, PyObject *args)
static
PyMethodDef
MacOS_Methods
[]
=
{
static
PyMethodDef
MacOS_Methods
[]
=
{
{
"GetResource"
,
MacOS_GetResource
,
1
},
{
"GetResource"
,
MacOS_GetResource
,
1
},
{
"GetNamedResource"
,
MacOS_GetNamedResource
,
1
},
{
"GetNamedResource"
,
MacOS_GetNamedResource
,
1
},
{
"GetFileType"
,
MacOS_GetFileType
,
1
},
{
"SetFileType"
,
MacOS_SetFileType
,
1
},
{
"SndNewChannel"
,
MacOS_SndNewChannel
,
1
},
{
"SndNewChannel"
,
MacOS_SndNewChannel
,
1
},
{
"SndPlay"
,
MacOS_SndPlay
,
1
},
{
"SndPlay"
,
MacOS_SndPlay
,
1
},
{
"SndControl"
,
MacOS_SndControl
,
1
},
{
"SndControl"
,
MacOS_SndControl
,
1
},
...
...
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