Fixed broken newlines and changed module name. Still untested.

This commit is contained in:
Jack Jansen 2001-11-05 16:15:45 +00:00
parent e8cbb9f1e6
commit 34cbe718d4
2 changed files with 18 additions and 23 deletions

View File

@ -4,8 +4,9 @@ import sys
import os import os
import string import string
import MacOS import MacOS
import sys
BGENDIR= '/Users/dsp/Documents/python/dist/src/Tools/bgen/bgen' BGENDIR= os.path.join(sys.prefix, ':Tools:bgen:bgen:')
sys.path.append(BGENDIR) sys.path.append(BGENDIR)
from bgenlocations import TOOLBOXDIR from bgenlocations import TOOLBOXDIR
@ -21,7 +22,7 @@ def main():
scanner.scan() scanner.scan()
scanner.close() scanner.close()
print "--done scanning, importing--" print "--done scanning, importing--"
import CarbonEventssupport import CarbonEvtsupport
print "done" print "done"
RefObjectTypes = ["EventRef", RefObjectTypes = ["EventRef",
@ -87,5 +88,9 @@ class CarbonEvents_Scanner(Scanner):
# "EventLoopTimerProcPtr", # "EventLoopTimerProcPtr",
# "EventHandlerProcPtr", # "EventHandlerProcPtr",
# ] # ]
def makerepairinstructions(self):
return []
if __name__ == "__main__": if __name__ == "__main__":
main() main()

View File

@ -126,8 +126,7 @@ EventHotKeyID_Convert(PyObject *v, EventHotKeyID *out)
/******** handlecommand ***********/ /******** handlecommand ***********/
pascal OSStatus CarbonEvents_HandleCommand(EventHandlerCallRef handlerRef, Even pascal OSStatus CarbonEvents_HandleCommand(EventHandlerCallRef handlerRef, EventRef event, void *outPyObject) {
tRef event, void *outPyObject) {
PyObject *retValue; PyObject *retValue;
int status; int status;
@ -136,8 +135,7 @@ tRef event, void *outPyObject) {
PyEval_RestoreThread(_save); PyEval_RestoreThread(_save);
#endif /* USE_MAC_MP_MULTITHREADING */ #endif /* USE_MAC_MP_MULTITHREADING */
retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHand retValue = PyObject_CallFunction((PyObject *)outPyObject, "O&O&", EventHandlerCallRef_New, handlerRef, EventRef_New, event);
lerCallRef_New, handlerRef, EventRef_New, event);
status = PyInt_AsLong(retValue); status = PyInt_AsLong(retValue);
#if USE_MAC_MP_MULTITHREADING #if USE_MAC_MP_MULTITHREADING
@ -152,8 +150,7 @@ lerCallRef_New, handlerRef, EventRef_New, event);
""" """
module = MacModule('CarbonEvents', 'CarbonEvents', includestuff, finalstuff, in module = MacModule('CarbonEvents', 'CarbonEvents', includestuff, finalstuff, initstuff)
itstuff)
#class CFReleaserObj(GlobalObjectDefinition): #class CFReleaserObj(GlobalObjectDefinition):
# def outputFreeIt(self, name): # def outputFreeIt(self, name):
@ -165,25 +162,20 @@ for typ in RefObjectTypes:
module.addobject(eval(typ + 'object')) module.addobject(eval(typ + 'object'))
functions = [] functions = []
for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEvent for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py
sscan.py
# initialize the lists for carbongen to fill # initialize the lists for carbongen to fill
execstr = typ + 'methods = []' execstr = typ + 'methods = []'
exec execstr exec execstr
execfile('CarbonEventsgen.py') execfile('CarbonEventsgen.py')
for f in functions: module.add(f) # add all the functions carboneventsgen for f in functions: module.add(f) # add all the functions carboneventsgen put in the list
put in the list
for typ in RefObjectTypes: ## go thru all ObjectT for typ in RefObjectTypes: ## go thru all ObjectTypes as defined in CarbonEventsscan.py
ypes as defined in CarbonEventsscan.py
methods = eval(typ + 'methods') ## get a reference to the method list methods = eval(typ + 'methods') ## get a reference to the method list
from the main namespace from the main namespace
obj = eval(typ + 'object') ## get a reference to the obj obj = eval(typ + 'object') ## get a reference to the object
ect for m in methods: obj.add(m) ## add each method in the list to the object
for m in methods: obj.add(m) ## add each method in the list to the o
bject
installeventhandler = """ installeventhandler = """
EventTypeSpec inSpec; EventTypeSpec inSpec;
@ -196,16 +188,14 @@ if (!PyArg_ParseTuple(_args, "O&O", EventTypeSpec_Convert, &inSpec, &callback))
return NULL; return NULL;
event = NewEventHandlerUPP(CarbonEvents_HandleCommand); event = NewEventHandlerUPP(CarbonEvents_HandleCommand);
_err = InstallEventHandler(_self->ob_itself, event, 1, &inSpec, (void *)callbac _err = InstallEventHandler(_self->ob_itself, event, 1, &inSpec, (void *)callback, &outRef);
k, &outRef);
if (_err != noErr) return PyMac_Error(_err); if (_err != noErr) return PyMac_Error(_err);
return Py_BuildValue("l", outRef); return Py_BuildValue("l", outRef);
""" """
f = ManualGenerator("InstallEventHandler", installeventhandler); f = ManualGenerator("InstallEventHandler", installeventhandler);
f.docstring = lambda: "(EventTargetRef inTarget, EventTypeSpec inSpec, Method c f.docstring = lambda: "(EventTargetRef inTarget, EventTypeSpec inSpec, Method callback) -> (EventHandlerRef outRef)"
allback) -> (EventHandlerRef outRef)"
EventTargetRefobject.add(f) EventTargetRefobject.add(f)
runappeventloop = """ runappeventloop = """
@ -234,7 +224,7 @@ f = ManualGenerator("RunApplicationEventLoop", runappeventloop);
f.docstring = lambda: "() -> ()" f.docstring = lambda: "() -> ()"
module.add(f) module.add(f)
SetOutputFileName('_CarbonEvents.c') SetOutputFileName('_CarbonEvt.c')
module.generate() module.generate()
import os import os