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
e433c974
Kaydet (Commit)
e433c974
authored
Eyl 29, 1994
tarafından
Guido van Rossum
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
config.c: add MacOS module
macosmodule.c: lots of updates (though playing sound can still hang :-( )
üst
14ed0b2c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
38 deletions
+52
-38
config.c
Mac/Modules/config.c
+2
-0
macosmodule.c
Mac/Modules/macosmodule.c
+50
-38
No files found.
Mac/Modules/config.c
Dosyayı görüntüle @
e433c974
...
...
@@ -165,6 +165,7 @@ extern void initarray();
extern
void
initmath
();
extern
void
initparser
();
extern
void
initmac
();
extern
void
MacOS_Init
();
extern
void
initregex
();
extern
void
initstrop
();
extern
void
initstruct
();
...
...
@@ -215,6 +216,7 @@ struct {
{
"math"
,
initmath
},
{
"parser"
,
initparser
},
{
"mac"
,
initmac
},
{
"MacOS"
,
MacOS_Init
},
{
"regex"
,
initregex
},
{
"strop"
,
initstrop
},
{
"struct"
,
initstruct
},
...
...
Mac/Modules/macosmodule.c
Dosyayı görüntüle @
e433c974
...
...
@@ -56,7 +56,7 @@ Err(OSErr err)
return
NULL
;
}
/* C
heck for
a ResType argument */
/* C
onvert
a ResType argument */
static
int
GetOSType
(
PyObject
*
v
,
ResType
*
pr
)
{
...
...
@@ -69,14 +69,14 @@ GetOSType(PyObject *v, ResType *pr)
return
1
;
}
/* C
heck for
a Str255 argument */
/* C
onvert
a Str255 argument */
static
int
GetStr255
(
PyObject
*
v
,
Str255
pbuf
)
{
int
len
;
if
(
!
PyString_Check
(
v
)
||
(
len
=
PyString_Size
(
v
))
>
255
)
{
PyErr_SetString
(
MacOS_Error
,
"Str255 arg must be string
<=
255 chars"
);
"Str255 arg must be string
of at most
255 chars"
);
return
0
;
}
pbuf
[
0
]
=
len
;
...
...
@@ -94,7 +94,7 @@ typedef struct {
staticforward
PyTypeObject
RsrcType
;
#define Rsrc
Object
_Check(r) ((r)->ob_type == &RsrcType)
#define Rsrc_Check(r) ((r)->ob_type == &RsrcType)
static
RsrcObject
*
Rsrc_FromHandle
(
Handle
h
)
...
...
@@ -184,7 +184,7 @@ MacOS_GetNamedResource(PyObject *self, PyObject *args)
/*----------------------------------------------------------------------*/
/* SoundChannel objects */
/* C
heck for
a SndCommand argument */
/* C
onvert
a SndCommand argument */
static
int
GetSndCommand
(
PyObject
*
v
,
SndCommand
*
pc
)
{
...
...
@@ -217,7 +217,7 @@ typedef struct {
staticforward
PyTypeObject
SndChType
;
#define SndCh
Object
_Check(s) ((s)->ob_type == &SndChType)
#define SndCh_Check(s) ((s)->ob_type == &SndChType)
static
SndChObject
*
SndCh_FromSndChannelPtr
(
SndChannelPtr
chan
)
...
...
@@ -229,50 +229,60 @@ SndCh_FromSndChannelPtr(SndChannelPtr chan)
}
static
void
SndCh_
Dealloc
(
SndChObject
*
s
)
SndCh_
Cleanup
(
SndChObject
*
s
,
int
quitNow
)
{
if
(
s
->
chan
!=
NULL
)
{
SndDisposeChannel
(
s
->
chan
,
1
);
if
(
s
->
chan
->
userInfo
!=
0
)
DEL
((
void
*
)
s
->
chan
->
userInfo
);
SndChannelPtr
chan
=
s
->
chan
;
if
(
chan
!=
NULL
)
{
void
*
userInfo
=
(
void
*
)
chan
->
userInfo
;
s
->
chan
=
NULL
;
SndDisposeChannel
(
chan
,
quitNow
);
if
(
userInfo
!=
0
)
DEL
(
userInfo
);
}
}
static
void
SndCh_Dealloc
(
SndChObject
*
s
)
{
SndCh_Cleanup
(
s
,
1
);
PyMem_DEL
(
s
);
}
static
PyObject
*
SndCh_
Close
(
SndChObject
*
s
,
PyObject
*
args
)
SndCh_
DisposeChannel
(
SndChObject
*
s
,
PyObject
*
args
)
{
int
qui
e
tNow
=
1
;
if
(
args
!=
NULL
)
{
if
(
!
PyArg_Parse
(
args
,
"
i"
,
&
quie
tNow
))
int
quitNow
=
1
;
if
(
PyTuple_Size
(
args
)
>
0
)
{
if
(
!
PyArg_Parse
(
args
,
"
(i)"
,
&
qui
tNow
))
return
NULL
;
}
if
(
s
->
chan
!=
NULL
)
{
SndDisposeChannel
(
s
->
chan
,
quietNow
);
if
(
s
->
chan
->
userInfo
!=
0
)
DEL
((
void
*
)
s
->
chan
->
userInfo
);
s
->
chan
=
NULL
;
}
SndCh_Cleanup
(
s
,
quitNow
);
Py_INCREF
(
Py_None
);
return
Py_None
;
}
static
int
SndCh_OK
(
SndChObject
*
s
)
{
if
(
s
->
chan
==
NULL
)
{
PyErr_SetString
(
MacOS_Error
,
"channel is closed"
);
return
0
;
}
return
1
;
}
static
PyObject
*
SndCh_SndPlay
(
SndChObject
*
s
,
PyObject
*
args
)
{
RsrcObject
*
r
;
int
async
=
0
;
if
(
!
PyArg_Parse
(
args
,
"(O
)"
,
&
r
))
{
if
(
!
PyArg_Parse
(
args
,
"(O
!)"
,
RsrcType
,
&
r
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
args
,
"(O
i)"
,
&
r
,
&
async
))
if
(
!
PyArg_Parse
(
args
,
"(O
&i)"
,
RsrcType
,
&
r
,
&
async
))
return
NULL
;
}
if
(
!
RsrcObject_Check
(
r
))
{
PyErr_SetString
(
MacOS_Error
,
"SndPlay argument must be resource"
);
if
(
!
SndCh_OK
(
s
))
return
NULL
;
}
SndPlay
(
s
->
chan
,
r
->
h
,
async
);
Py_INCREF
(
Py_None
);
return
Py_None
;
...
...
@@ -287,8 +297,10 @@ SndCh_SndDoCommand(SndChObject *s, PyObject *args)
if
(
!
PyArg_Parse
(
args
,
"(O&)"
,
GetSndCommand
,
&
c
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
args
,
"(O&i)"
,
GetSndCommand
,
&
c
,
&
noWait
))
return
0
;
return
NULL
;
}
if
(
!
SndCh_OK
(
s
))
return
NULL
;
err
=
SndDoCommand
(
s
->
chan
,
&
c
,
noWait
);
return
Err
(
err
);
}
...
...
@@ -300,13 +312,15 @@ SndCh_SndDoImmediate(SndChObject *s, PyObject *args)
OSErr
err
;
if
(
!
PyArg_Parse
(
args
,
"(O&)"
,
GetSndCommand
,
&
c
))
return
0
;
if
(
!
SndCh_OK
(
s
))
return
NULL
;
err
=
SndDoImmediate
(
s
->
chan
,
&
c
);
return
Err
(
err
);
}
static
PyMethodDef
SndCh_Methods
[]
=
{
{
"close"
,
(
PyCFunction
)
SndCh_
Close
},
{
"SndDisposeChannel"
,
(
PyCFunction
)
SndCh_
Close
},
{
"close"
,
(
PyCFunction
)
SndCh_
DisposeChannel
,
1
},
{
"SndDisposeChannel"
,
(
PyCFunction
)
SndCh_
DisposeChannel
,
1
},
{
"SndPlay"
,
(
PyCFunction
)
SndCh_SndPlay
,
1
},
{
"SndDoCommand"
,
(
PyCFunction
)
SndCh_SndDoCommand
,
1
},
{
"SndDoImmediate"
,
(
PyCFunction
)
SndCh_SndDoImmediate
,
1
},
...
...
@@ -356,8 +370,7 @@ MySafeCallback(arg)
PyObject
*
args
;
PyObject
*
res
;
args
=
Py_BuildValue
(
"(O(hhl))"
,
p
->
channel
,
p
->
cmd
.
cmd
,
p
->
cmd
.
param1
,
p
->
cmd
.
param2
);
p
->
channel
,
p
->
cmd
.
cmd
,
p
->
cmd
.
param1
,
p
->
cmd
.
param2
);
res
=
PyEval_CallObject
(
p
->
callback
,
args
);
Py_DECREF
(
args
);
if
(
res
==
NULL
)
...
...
@@ -391,8 +404,7 @@ MacOS_SndNewChannel(PyObject *self, PyObject *args)
PyErr_Clear
();
if
(
!
PyArg_Parse
(
args
,
"(hl)"
,
&
synth
,
&
init
))
{
PyErr_Clear
();
if
(
!
PyArg_Parse
(
args
,
"(hlO)"
,
&
synth
,
&
init
,
&
callback
))
if
(
!
PyArg_Parse
(
args
,
"(hlO)"
,
&
synth
,
&
init
,
&
callback
))
return
NULL
;
}
}
...
...
@@ -411,14 +423,15 @@ MacOS_SndNewChannel(PyObject *self, PyObject *args)
DEL
(
p
);
return
Err
(
err
);
}
chan
->
userInfo
=
(
long
)
p
;
res
=
(
PyObject
*
)
SndCh_FromSndChannelPtr
(
chan
);
if
(
res
==
NULL
)
{
SndDisposeChannel
(
chan
,
1
);
DEL
(
p
);
}
else
else
{
chan
->
userInfo
=
(
long
)
p
;
p
->
channel
=
res
;
}
return
res
;
}
...
...
@@ -467,7 +480,6 @@ MacOS_Init()
/* Initialize MacOS.Error exception */
MacOS_Error
=
PyString_FromString
(
"MacOS.Error"
);
if
(
MacOS_Error
==
NULL
||
PyDict_SetItemString
(
d
,
"Error"
,
MacOS_Error
)
!=
0
)
if
(
MacOS_Error
==
NULL
||
PyDict_SetItemString
(
d
,
"Error"
,
MacOS_Error
)
!=
0
)
Py_FatalError
(
"can't define MacOS.Error"
);
}
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