Import Upstream version 2.7.18
This commit is contained in:
1830
Mac/Modules/app/_Appmodule.c
Normal file
1830
Mac/Modules/app/_Appmodule.c
Normal file
File diff suppressed because it is too large
Load Diff
80
Mac/Modules/app/appscan.py
Normal file
80
Mac/Modules/app/appscan.py
Normal file
@@ -0,0 +1,80 @@
|
||||
# Scan an Apple header file, generating a Python file of generator calls.
|
||||
|
||||
import sys
|
||||
from bgenlocations import TOOLBOXDIR, BGENDIR
|
||||
sys.path.append(BGENDIR)
|
||||
from scantools import Scanner
|
||||
|
||||
LONG = "Appearance"
|
||||
SHORT = "app"
|
||||
OBJECT = "ThemeDrawingState"
|
||||
|
||||
def main():
|
||||
input = LONG + ".h"
|
||||
output = SHORT + "gen.py"
|
||||
defsoutput = TOOLBOXDIR + LONG + ".py"
|
||||
scanner = MyScanner(input, output, defsoutput)
|
||||
scanner.scan()
|
||||
scanner.close()
|
||||
print "=== Testing definitions output code ==="
|
||||
execfile(defsoutput, {}, {})
|
||||
print "=== Done scanning and generating, now importing the generated code... ==="
|
||||
exec "import " + SHORT + "support"
|
||||
print "=== Done. It's up to you to compile it now! ==="
|
||||
|
||||
class MyScanner(Scanner):
|
||||
|
||||
def destination(self, type, name, arglist):
|
||||
classname = "Function"
|
||||
listname = "functions"
|
||||
if arglist:
|
||||
t, n, m = arglist[0]
|
||||
# This is non-functional today
|
||||
if t == OBJECT and m == "InMode":
|
||||
classname = "Method"
|
||||
listname = "methods"
|
||||
return classname, listname
|
||||
|
||||
def writeinitialdefs(self):
|
||||
self.defsfile.write("def FOUR_CHAR_CODE(x): return x\n")
|
||||
|
||||
def makeblacklistnames(self):
|
||||
return [
|
||||
"GetThemeFont", # Funny stringbuffer in/out parameter, I think...
|
||||
# Constants with funny definitions
|
||||
"appearanceBadBrushIndexErr",
|
||||
"appearanceProcessRegisteredErr",
|
||||
"appearanceProcessNotRegisteredErr",
|
||||
"appearanceBadTextColorIndexErr",
|
||||
"appearanceThemeHasNoAccents",
|
||||
"appearanceBadCursorIndexErr",
|
||||
]
|
||||
|
||||
def makeblacklisttypes(self):
|
||||
return [
|
||||
"MenuTitleDrawingUPP",
|
||||
"MenuItemDrawingUPP",
|
||||
"ThemeIteratorUPP",
|
||||
"ThemeTabTitleDrawUPP",
|
||||
# "ThemeEraseUPP",
|
||||
# "ThemeButtonDrawUPP",
|
||||
"WindowTitleDrawingUPP",
|
||||
"ProcessSerialNumber_ptr", # Too much work for now.
|
||||
"ThemeTrackDrawInfo_ptr", # Too much work
|
||||
# "ThemeButtonDrawInfo_ptr", # ditto
|
||||
"ThemeWindowMetrics_ptr", # ditto
|
||||
# "ThemeDrawingState", # This is an opaque pointer, so it should be simple. Later.
|
||||
"Collection", # No interface to collection mgr yet.
|
||||
"BytePtr", # Not yet.
|
||||
]
|
||||
|
||||
def makerepairinstructions(self):
|
||||
return [
|
||||
([("void", 'inContext', "OutMode")],
|
||||
[("NULL", 'inContext', "InMode")]),
|
||||
([("Point", 'ioBounds', "OutMode")],
|
||||
[("Point", 'ioBounds', "InOutMode")]),
|
||||
]
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
133
Mac/Modules/app/appsupport.py
Normal file
133
Mac/Modules/app/appsupport.py
Normal file
@@ -0,0 +1,133 @@
|
||||
# This script generates a Python interface for an Apple Macintosh Manager.
|
||||
# It uses the "bgen" package to generate C code.
|
||||
# The function specifications are generated by scanning the mamager's header file,
|
||||
# using the "scantools" package (customized for this particular manager).
|
||||
|
||||
import string
|
||||
|
||||
# Declarations that change for each manager
|
||||
MACHEADERFILE = 'Appearance.h' # The Apple header file
|
||||
MODNAME = '_App' # The name of the module
|
||||
OBJECTNAME = 'ThemeDrawingState' # The basic name of the objects used here
|
||||
KIND = '' # Usually 'Ptr' or 'Handle'
|
||||
|
||||
# The following is *usually* unchanged but may still require tuning
|
||||
MODPREFIX = 'App' # The prefix for module-wide routines
|
||||
OBJECTTYPE = OBJECTNAME + KIND # The C type used to represent them
|
||||
OBJECTPREFIX = OBJECTNAME + 'Obj' # The prefix for object methods
|
||||
INPUTFILE = string.lower(MODPREFIX) + 'gen.py' # The file generated by the scanner
|
||||
OUTPUTFILE = MODNAME + "module.c" # The file generated by this program
|
||||
|
||||
from macsupport import *
|
||||
|
||||
# Create the type objects
|
||||
#MenuRef = OpaqueByValueType("MenuRef", "MenuObj")
|
||||
|
||||
|
||||
#WindowPeek = OpaqueByValueType("WindowPeek", OBJECTPREFIX)
|
||||
|
||||
RgnHandle = FakeType("(RgnHandle)0")
|
||||
NULL = FakeType("NULL")
|
||||
|
||||
# XXXX Should be next, but this will break a lot of code...
|
||||
# RgnHandle = OpaqueByValueType("RgnHandle", "OptResObj")
|
||||
|
||||
#KeyMap = ArrayOutputBufferType("KeyMap")
|
||||
#MacOSEventKind = Type("MacOSEventKind", "h") # Old-style
|
||||
#MacOSEventMask = Type("MacOSEventMask", "h") # Old-style
|
||||
#EventMask = Type("EventMask", "h")
|
||||
#EventKind = Type("EventKind", "h")
|
||||
ThemeBrush = Type("ThemeBrush", "h")
|
||||
ThemeColor = Type("ThemeColor", "h")
|
||||
ThemeTextColor = Type("ThemeTextColor", "h")
|
||||
ThemeMenuBarState = Type("ThemeMenuBarState", "H")
|
||||
ThemeMenuState = Type("ThemeMenuState", "H")
|
||||
ThemeMenuType = Type("ThemeMenuType", "H")
|
||||
ThemeMenuItemType = Type("ThemeMenuItemType", "H")
|
||||
ThemeFontID = Type("ThemeFontID", "H")
|
||||
ThemeTabStyle = Type("ThemeTabStyle", "H")
|
||||
ThemeTabDirection = Type("ThemeTabDirection", "H")
|
||||
ThemeDrawState = Type("ThemeDrawState", "l")
|
||||
ThemeCursor = Type("ThemeCursor", "l")
|
||||
ThemeCheckBoxStyle = Type("ThemeCheckBoxStyle", "H")
|
||||
ThemeScrollBarArrowStyle = Type("ThemeScrollBarArrowStyle", "H")
|
||||
ThemeScrollBarThumbStyle = Type("ThemeScrollBarThumbStyle", "H")
|
||||
CTabHandle = OpaqueByValueType("CTabHandle", "ResObj")
|
||||
ThemeTrackEnableState = Type("ThemeTrackEnableState", "b")
|
||||
ThemeTrackPressState = Type("ThemeTrackPressState", "b")
|
||||
ThemeThumbDirection = Type("ThemeThumbDirection", "b")
|
||||
ThemeTrackAttributes = Type("ThemeTrackAttributes", "H")
|
||||
ControlPartCode = Type("ControlPartCode", "h")
|
||||
ThemeWindowAttributes = Type("ThemeWindowAttributes", "l")
|
||||
ThemeWindowType = Type("ThemeWindowType", "H")
|
||||
ThemeTitleBarWidget = Type("ThemeTitleBarWidget", "H")
|
||||
ThemeArrowOrientation = Type("ThemeArrowOrientation", "H")
|
||||
ThemePopupArrowSize = Type("ThemePopupArrowSize", "H")
|
||||
ThemeGrowDirection = Type("ThemeGrowDirection", "H")
|
||||
ThemeSoundKind = OSTypeType("ThemeSoundKind")
|
||||
ThemeDragSoundKind = OSTypeType("ThemeDragSoundKind")
|
||||
ThemeBackgroundKind = Type("ThemeBackgroundKind", "l")
|
||||
ThemeMetric = Type("ThemeMetric", "l")
|
||||
RGBColor = OpaqueType("RGBColor", "QdRGB")
|
||||
TruncCode = Type("TruncCode", "h")
|
||||
|
||||
|
||||
ThemeButtonKind = UInt16
|
||||
ThemeButtonDrawInfo_ptr = OpaqueType("ThemeButtonDrawInfo", "ThemeButtonDrawInfo")
|
||||
ThemeEraseUPP = FakeType("NULL")
|
||||
ThemeButtonDrawUPP = FakeType("NULL")
|
||||
|
||||
|
||||
includestuff = includestuff + """
|
||||
#include <Carbon/Carbon.h>
|
||||
|
||||
|
||||
int ThemeButtonDrawInfo_Convert(PyObject *v, ThemeButtonDrawInfo *p_itself)
|
||||
{
|
||||
return PyArg_Parse(v, "(iHH)", &p_itself->state, &p_itself->value, &p_itself->adornment);
|
||||
}
|
||||
|
||||
"""
|
||||
|
||||
class MyObjectDefinition(PEP253Mixin, GlobalObjectDefinition):
|
||||
pass
|
||||
## def outputCheckNewArg(self):
|
||||
## Output("if (itself == NULL) return PyMac_Error(resNotFound);")
|
||||
## def outputCheckConvertArg(self):
|
||||
## OutLbrace("if (DlgObj_Check(v))")
|
||||
## Output("*p_itself = ((WindowObject *)v)->ob_itself;")
|
||||
## Output("return 1;")
|
||||
## OutRbrace()
|
||||
## Out("""
|
||||
## if (v == Py_None) { *p_itself = NULL; return 1; }
|
||||
## if (PyInt_Check(v)) { *p_itself = (WindowPtr)PyInt_AsLong(v); return 1; }
|
||||
## """)
|
||||
|
||||
# From here on it's basically all boiler plate...
|
||||
|
||||
# Create the generator groups and link them
|
||||
module = MacModule(MODNAME, MODPREFIX, includestuff, finalstuff, initstuff)
|
||||
object = MyObjectDefinition(OBJECTNAME, OBJECTPREFIX, OBJECTTYPE)
|
||||
module.addobject(object)
|
||||
|
||||
ThemeDrawingState = OpaqueByValueType("ThemeDrawingState", "ThemeDrawingStateObj")
|
||||
Method = WeakLinkMethodGenerator
|
||||
|
||||
|
||||
# Create the generator classes used to populate the lists
|
||||
Function = OSErrWeakLinkFunctionGenerator
|
||||
##Method = OSErrWeakLinkMethodGenerator
|
||||
|
||||
# Create and populate the lists
|
||||
functions = []
|
||||
methods = []
|
||||
execfile(INPUTFILE)
|
||||
|
||||
# add the populated lists to the generator groups
|
||||
# (in a different wordl the scan program would generate this)
|
||||
for f in functions: module.add(f)
|
||||
for f in methods: object.add(f)
|
||||
|
||||
# generate output (open the output file as late as possible)
|
||||
SetOutputFileName(OUTPUTFILE)
|
||||
module.generate()
|
||||
Reference in New Issue
Block a user