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
e4192abc
Commit
e4192abc
authored
Dec 12, 2001
by
Just van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Exposed quite a few more calls.
parent
55f4a1af
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
191 additions
and
28 deletions
+191
-28
Mac/Modules/carbonevt/CarbonEvtscan.py
Mac/Modules/carbonevt/CarbonEvtscan.py
+16
-1
Mac/Modules/carbonevt/CarbonEvtsupport.py
Mac/Modules/carbonevt/CarbonEvtsupport.py
+30
-19
Mac/Modules/carbonevt/_CarbonEvtmodule.c
Mac/Modules/carbonevt/_CarbonEvtmodule.c
+145
-8
No files found.
Mac/Modules/carbonevt/CarbonEvtscan.py
View file @
e4192abc
...
...
@@ -35,7 +35,7 @@ RefObjectTypes = ["EventRef",
"EventHotKeyRef"
,
]
class
CarbonEvents_Scanner
(
Scanner
):
class
CarbonEvents_Scanner
(
Scanner
_OSX
):
def
destination
(
self
,
type
,
name
,
arglist
):
classname
=
"CarbonEventsFunction"
listname
=
"functions"
...
...
@@ -50,8 +50,17 @@ class CarbonEvents_Scanner(Scanner):
print
"not method"
return
classname
,
listname
def
writeinitialdefs
(
self
):
self
.
defsfile
.
write
(
"def FOUR_CHAR_CODE(x): return x
\
n
"
)
self
.
defsfile
.
write
(
"def FOUR_CHAR_CODE(x): return x
\
n
"
)
self
.
defsfile
.
write
(
"false = 0
\
n
"
)
self
.
defsfile
.
write
(
"true = 1
\
n
"
)
self
.
defsfile
.
write
(
"keyAEEventClass = FOUR_CHAR_CODE('evcl')
\
n
"
)
self
.
defsfile
.
write
(
"keyAEEventID = FOUR_CHAR_CODE('evti')
\
n
"
)
def
makeblacklistnames
(
self
):
return
[
"sHandler"
,
"MacCreateEvent"
,
"TrackMouseLocationWithOptions"
,
"TrackMouseLocation"
,
...
...
@@ -64,6 +73,12 @@ class CarbonEvents_Scanner(Scanner):
"InvokeEventHandlerUPP"
,
"InvokeEventComparatorUPP"
,
"InvokeEventLoopTimerUPP"
,
"NewEventComparatorUPP"
,
"NewEventLoopTimerUPP"
,
"NewEventHandlerUPP"
,
"DisposeEventComparatorUPP"
,
"DisposeEventLoopTimerUPP"
,
"DisposeEventHandlerUPP"
,
# Wrote by hand
"InstallEventHandler"
,
...
...
Mac/Modules/carbonevt/CarbonEvtsupport.py
View file @
e4192abc
...
...
@@ -11,19 +11,21 @@ for typ in RefObjectTypes:
execstr
=
"%(name)s = OpaqueByValueType('%(name)s')"
%
{
"name"
:
typ
}
exec
execstr
# these types will have no methods and will merely be opaque blobs
# should write getattr and setattr for them?
if
0
:
# these types will have no methods and will merely be opaque blobs
# should write getattr and setattr for them?
StructObjectTypes
=
[
"EventTypeSpec"
,
StructObjectTypes
=
[
"EventTypeSpec"
,
"HIPoint"
,
"HICommand"
,
"EventHotKeyID"
,
]
for
typ
in
StructObjectTypes
:
for
typ
in
StructObjectTypes
:
execstr
=
"%(name)s = OpaqueType('%(name)s')"
%
{
"name"
:
typ
}
exec
execstr
EventHotKeyID
=
OpaqueByValueType
(
"EventHotKeyID"
,
"EventHotKeyID"
)
EventTypeSpec_ptr
=
OpaqueType
(
"EventTypeSpec"
,
"EventTypeSpec"
)
# is this the right type for the void * in GetEventParameter
...
...
@@ -51,7 +53,7 @@ EventHandlerProcPtr = FakeType("(EventHandlerProcPtr)0")
CarbonEventsFunction
=
OSErrFunctionGenerator
CarbonEventsMethod
=
OSErrMethodGenerator
includestuff
=
"""
includestuff
=
r
"""
#ifdef WITHOUT_FRAMEWORKS
#include <CarbonEvents.h>
#else
...
...
@@ -60,7 +62,15 @@ includestuff = """
#include "macglue.h"
#define USE_MAC_MP_MULTITHREADING 1
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return; \
}} while(0)
#define USE_MAC_MP_MULTITHREADING 0
#if USE_MAC_MP_MULTITHREADING
static PyThreadState *_save;
...
...
@@ -131,11 +141,11 @@ EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out)
/********** end EventHotKeyID *******/
/********
handlecommand
***********/
/********
myEventHandler
***********/
static EventHandlerUPP
g
EventHandlerUPP;
static EventHandlerUPP
my
EventHandlerUPP;
pascal OSStatus
CarbonEvents_HandleEvent
(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
pascal OSStatus
myEventHandler
(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
PyObject *retValue;
int status;
...
...
@@ -155,12 +165,13 @@ pascal OSStatus CarbonEvents_HandleEvent(EventHandlerCallRef handlerRef, EventRe
return status;
}
/******** end
handlecommand
***********/
/******** end
myEventHandler
***********/
"""
initstuff
=
initstuff
+
"""
gEventHandlerUPP = NewEventHandlerUPP(CarbonEvents_HandleEvent);
PyMac_PRECHECK(NewEventHandlerUPP); /* This can fail if CarbonLib is too old */
myEventHandlerUPP = NewEventHandlerUPP(myEventHandler);
"""
module
=
MacModule
(
'_CarbonEvt'
,
'CarbonEvents'
,
includestuff
,
finalstuff
,
initstuff
)
...
...
@@ -197,7 +208,7 @@ OSStatus _err;
if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback))
return NULL;
_err = InstallEventHandler(_self->ob_itself,
g
EventHandlerUPP, 1, &inSpec, (void *)callback, &outRef);
_err = InstallEventHandler(_self->ob_itself,
my
EventHandlerUPP, 1, &inSpec, (void *)callback, &outRef);
if (_err != noErr) return PyMac_Error(_err);
return Py_BuildValue("O&", EventHandlerRef_New, outRef);"""
...
...
@@ -209,7 +220,7 @@ EventTargetRefobject.add(f)
runappeventloop
=
"""
#if USE_MAC_MP_MULTITHREADING
if (MPCreateCriticalRegion(&reentrantLock) != noErr) {
printf
("lock failure
\
\
n");
PySys_WriteStderr
("lock failure
\
\
n");
return NULL;
}
_save = PyEval_SaveThread();
...
...
Mac/Modules/carbonevt/_CarbonEvtmodule.c
View file @
e4192abc
...
...
@@ -13,7 +13,15 @@
#include "macglue.h"
#define USE_MAC_MP_MULTITHREADING 1
/* Macro to test whether a weak-loaded CFM function exists */
#define PyMac_PRECHECK(rtn) do { if ( &rtn == NULL ) {\
PyErr_SetString(PyExc_NotImplementedError, \
"Not available in this shared library/OS version"); \
return; \
}} while(0)
#define USE_MAC_MP_MULTITHREADING 0
#if USE_MAC_MP_MULTITHREADING
static
PyThreadState
*
_save
;
...
...
@@ -84,11 +92,11 @@ EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out)
/********** end EventHotKeyID *******/
/********
handlecommand
***********/
/********
myEventHandler
***********/
static
EventHandlerUPP
g
EventHandlerUPP
;
static
EventHandlerUPP
my
EventHandlerUPP
;
pascal
OSStatus
CarbonEvents_HandleEvent
(
EventHandlerCallRef
handlerRef
,
EventRef
event
,
void
*
outPyObject
)
{
pascal
OSStatus
myEventHandler
(
EventHandlerCallRef
handlerRef
,
EventRef
event
,
void
*
outPyObject
)
{
PyObject
*
retValue
;
int
status
;
...
...
@@ -108,7 +116,7 @@ pascal OSStatus CarbonEvents_HandleEvent(EventHandlerCallRef handlerRef, EventRe
return
status
;
}
/******** end
handlecommand
***********/
/******** end
myEventHandler
***********/
static
PyObject
*
CarbonEvents_Error
;
...
...
@@ -1059,7 +1067,7 @@ static PyObject *EventTargetRef_InstallEventHandler(EventTargetRefObject *_self,
if
(
!
PyArg_ParseTuple
(
_args
,
"O&O"
,
EventTypeSpec_Convert
,
&
inSpec
,
&
callback
))
return
NULL
;
_err
=
InstallEventHandler
(
_self
->
ob_itself
,
g
EventHandlerUPP
,
1
,
&
inSpec
,
(
void
*
)
callback
,
&
outRef
);
_err
=
InstallEventHandler
(
_self
->
ob_itself
,
my
EventHandlerUPP
,
1
,
&
inSpec
,
(
void
*
)
callback
,
&
outRef
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
return
Py_BuildValue
(
"O&"
,
EventHandlerRef_New
,
outRef
);
...
...
@@ -1146,7 +1154,22 @@ static void EventHotKeyRef_dealloc(EventHotKeyRefObject *self)
PyMem_DEL
(
self
);
}
static
PyObject
*
EventHotKeyRef_UnregisterEventHotKey
(
EventHotKeyRefObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
_err
=
UnregisterEventHotKey
(
_self
->
ob_itself
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyMethodDef
EventHotKeyRef_methods
[]
=
{
{
"UnregisterEventHotKey"
,
(
PyCFunction
)
EventHotKeyRef_UnregisterEventHotKey
,
1
,
"() -> None"
},
{
NULL
,
NULL
,
0
}
};
...
...
@@ -1366,6 +1389,18 @@ static PyObject *CarbonEvents_GetUserFocusEventTarget(PyObject *_self, PyObject
return
_res
;
}
static
PyObject
*
CarbonEvents_GetEventDispatcherTarget
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
EventTargetRef
_rv
;
if
(
!
PyArg_ParseTuple
(
_args
,
""
))
return
NULL
;
_rv
=
GetEventDispatcherTarget
();
_res
=
Py_BuildValue
(
"O&"
,
EventTargetRef_New
,
_rv
);
return
_res
;
}
static
PyObject
*
CarbonEvents_QuitApplicationEventLoop
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
...
...
@@ -1377,6 +1412,66 @@ static PyObject *CarbonEvents_QuitApplicationEventLoop(PyObject *_self, PyObject
return
_res
;
}
static
PyObject
*
CarbonEvents_RunAppModalLoopForWindow
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
WindowPtr
inWindow
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
inWindow
))
return
NULL
;
_err
=
RunAppModalLoopForWindow
(
inWindow
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
CarbonEvents_QuitAppModalLoopForWindow
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
WindowPtr
inWindow
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
inWindow
))
return
NULL
;
_err
=
QuitAppModalLoopForWindow
(
inWindow
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
CarbonEvents_BeginAppModalStateForWindow
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
WindowPtr
inWindow
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
inWindow
))
return
NULL
;
_err
=
BeginAppModalStateForWindow
(
inWindow
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
CarbonEvents_EndAppModalStateForWindow
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
WindowPtr
inWindow
;
if
(
!
PyArg_ParseTuple
(
_args
,
"O&"
,
WinObj_Convert
,
&
inWindow
))
return
NULL
;
_err
=
EndAppModalStateForWindow
(
inWindow
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
Py_INCREF
(
Py_None
);
_res
=
Py_None
;
return
_res
;
}
static
PyObject
*
CarbonEvents_SetUserFocusWindow
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
...
...
@@ -1474,13 +1569,42 @@ static PyObject *CarbonEvents_GetWindowCancelButton(PyObject *_self, PyObject *_
return
_res
;
}
static
PyObject
*
CarbonEvents_RegisterEventHotKey
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
OSStatus
_err
;
UInt32
inHotKeyCode
;
UInt32
inHotKeyModifiers
;
EventHotKeyID
inHotKeyID
;
EventTargetRef
inTarget
;
OptionBits
inOptions
;
EventHotKeyRef
outRef
;
if
(
!
PyArg_ParseTuple
(
_args
,
"llO&O&l"
,
&
inHotKeyCode
,
&
inHotKeyModifiers
,
EventHotKeyID_Convert
,
&
inHotKeyID
,
EventTargetRef_Convert
,
&
inTarget
,
&
inOptions
))
return
NULL
;
_err
=
RegisterEventHotKey
(
inHotKeyCode
,
inHotKeyModifiers
,
inHotKeyID
,
inTarget
,
inOptions
,
&
outRef
);
if
(
_err
!=
noErr
)
return
PyMac_Error
(
_err
);
_res
=
Py_BuildValue
(
"O&"
,
EventHotKeyRef_New
,
outRef
);
return
_res
;
}
static
PyObject
*
CarbonEvents_RunApplicationEventLoop
(
PyObject
*
_self
,
PyObject
*
_args
)
{
PyObject
*
_res
=
NULL
;
#if USE_MAC_MP_MULTITHREADING
if
(
MPCreateCriticalRegion
(
&
reentrantLock
)
!=
noErr
)
{
printf
(
"lock failure
\n
"
);
PySys_WriteStderr
(
"lock failure
\n
"
);
return
NULL
;
}
_save
=
PyEval_SaveThread
();
...
...
@@ -1527,8 +1651,18 @@ static PyMethodDef CarbonEvents_methods[] = {
"() -> (EventTargetRef _rv)"
},
{
"GetUserFocusEventTarget"
,
(
PyCFunction
)
CarbonEvents_GetUserFocusEventTarget
,
1
,
"() -> (EventTargetRef _rv)"
},
{
"GetEventDispatcherTarget"
,
(
PyCFunction
)
CarbonEvents_GetEventDispatcherTarget
,
1
,
"() -> (EventTargetRef _rv)"
},
{
"QuitApplicationEventLoop"
,
(
PyCFunction
)
CarbonEvents_QuitApplicationEventLoop
,
1
,
"() -> None"
},
{
"RunAppModalLoopForWindow"
,
(
PyCFunction
)
CarbonEvents_RunAppModalLoopForWindow
,
1
,
"(WindowPtr inWindow) -> None"
},
{
"QuitAppModalLoopForWindow"
,
(
PyCFunction
)
CarbonEvents_QuitAppModalLoopForWindow
,
1
,
"(WindowPtr inWindow) -> None"
},
{
"BeginAppModalStateForWindow"
,
(
PyCFunction
)
CarbonEvents_BeginAppModalStateForWindow
,
1
,
"(WindowPtr inWindow) -> None"
},
{
"EndAppModalStateForWindow"
,
(
PyCFunction
)
CarbonEvents_EndAppModalStateForWindow
,
1
,
"(WindowPtr inWindow) -> None"
},
{
"SetUserFocusWindow"
,
(
PyCFunction
)
CarbonEvents_SetUserFocusWindow
,
1
,
"(WindowPtr inWindow) -> None"
},
{
"GetUserFocusWindow"
,
(
PyCFunction
)
CarbonEvents_GetUserFocusWindow
,
1
,
...
...
@@ -1541,6 +1675,8 @@ static PyMethodDef CarbonEvents_methods[] = {
"(WindowPtr inWindow) -> (ControlHandle outControl)"
},
{
"GetWindowCancelButton"
,
(
PyCFunction
)
CarbonEvents_GetWindowCancelButton
,
1
,
"(WindowPtr inWindow) -> (ControlHandle outControl)"
},
{
"RegisterEventHotKey"
,
(
PyCFunction
)
CarbonEvents_RegisterEventHotKey
,
1
,
"(UInt32 inHotKeyCode, UInt32 inHotKeyModifiers, EventHotKeyID inHotKeyID, EventTargetRef inTarget, OptionBits inOptions) -> (EventHotKeyRef outRef)"
},
{
"RunApplicationEventLoop"
,
(
PyCFunction
)
CarbonEvents_RunApplicationEventLoop
,
1
,
"() -> ()"
},
{
NULL
,
NULL
,
0
}
...
...
@@ -1556,7 +1692,8 @@ void init_CarbonEvt(void)
gEventHandlerUPP
=
NewEventHandlerUPP
(
CarbonEvents_HandleEvent
);
PyMac_PRECHECK
(
NewEventHandlerUPP
);
/* This can fail if CarbonLib is too old */
myEventHandlerUPP
=
NewEventHandlerUPP
(
myEventHandler
);
m
=
Py_InitModule
(
"_CarbonEvt"
,
CarbonEvents_methods
);
...
...
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