1996-04-10 16:41:08 +02:00
|
|
|
# Scan an Apple header file, generating a Python file of generator calls.
|
|
|
|
|
1998-04-17 16:07:56 +02:00
|
|
|
import sys
|
|
|
|
import os
|
|
|
|
BGENDIR=os.path.join(sys.prefix, ':Tools:bgen:bgen')
|
|
|
|
sys.path.append(BGENDIR)
|
1996-04-10 16:41:08 +02:00
|
|
|
from scantools import Scanner
|
1996-04-12 18:29:23 +02:00
|
|
|
from bgenlocations import TOOLBOXDIR
|
1996-04-10 16:41:08 +02:00
|
|
|
|
|
|
|
LONG = "TextEdit"
|
|
|
|
SHORT = "te"
|
|
|
|
OBJECT = "TEHandle"
|
|
|
|
|
|
|
|
def main():
|
|
|
|
input = LONG + ".h"
|
|
|
|
output = SHORT + "gen.py"
|
1996-04-12 18:29:23 +02:00
|
|
|
defsoutput = TOOLBOXDIR + LONG + ".py"
|
1996-04-10 16:41:08 +02:00
|
|
|
scanner = MyScanner(input, output, defsoutput)
|
|
|
|
scanner.scan()
|
|
|
|
scanner.close()
|
|
|
|
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[-1]
|
|
|
|
# This is non-functional today
|
|
|
|
if t == OBJECT and m == "InMode":
|
|
|
|
classname = "Method"
|
|
|
|
listname = "methods"
|
|
|
|
return classname, listname
|
|
|
|
|
|
|
|
def makeblacklistnames(self):
|
|
|
|
return [
|
|
|
|
"TEDispose",
|
|
|
|
"TEInit",
|
1999-12-12 22:41:51 +01:00
|
|
|
## "TEGetHiliteRgn",
|
1996-04-10 16:41:08 +02:00
|
|
|
]
|
|
|
|
|
2000-12-12 23:10:21 +01:00
|
|
|
def makegreylist(self):
|
|
|
|
return [
|
|
|
|
('#if TARGET_API_MAC_CARBON', [
|
|
|
|
'TEGetScrapHandle',
|
|
|
|
'TESetScrapHandle',
|
|
|
|
])]
|
|
|
|
|
1996-04-10 16:41:08 +02:00
|
|
|
def makeblacklisttypes(self):
|
|
|
|
return [
|
|
|
|
"TEClickLoopUPP",
|
|
|
|
"UniversalProcPtr",
|
2000-12-12 23:10:21 +01:00
|
|
|
"WordBreakUPP",
|
|
|
|
"TEDoTextUPP",
|
|
|
|
"TERecalcUPP",
|
|
|
|
"TEFindWordUPP",
|
1996-04-10 16:41:08 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
def makerepairinstructions(self):
|
|
|
|
return [
|
|
|
|
([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
|
|
|
|
[("InBuffer", "*", "*")]),
|
|
|
|
|
|
|
|
# TEContinuousStyle
|
|
|
|
([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")],
|
|
|
|
[("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")])
|
|
|
|
]
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|