symbian-qemu-0.9.1-12/python-2.6.1/Mac/Modules/te/tescan.py
changeset 1 2fb8b9db1c86
equal deleted inserted replaced
0:ffa851df0825 1:2fb8b9db1c86
       
     1 # Scan an Apple header file, generating a Python file of generator calls.
       
     2 
       
     3 import sys
       
     4 from bgenlocations import TOOLBOXDIR, BGENDIR
       
     5 sys.path.append(BGENDIR)
       
     6 from scantools import Scanner
       
     7 
       
     8 LONG = "TextEdit"
       
     9 SHORT = "te"
       
    10 OBJECT = "TEHandle"
       
    11 
       
    12 def main():
       
    13     input = LONG + ".h"
       
    14     output = SHORT + "gen.py"
       
    15     defsoutput = TOOLBOXDIR + LONG + ".py"
       
    16     scanner = MyScanner(input, output, defsoutput)
       
    17     scanner.scan()
       
    18     scanner.close()
       
    19     print "=== Testing definitions output code ==="
       
    20     execfile(defsoutput, {}, {})
       
    21     print "=== Done scanning and generating, now importing the generated code... ==="
       
    22     exec "import " + SHORT + "support"
       
    23     print "=== Done.  It's up to you to compile it now! ==="
       
    24 
       
    25 class MyScanner(Scanner):
       
    26 
       
    27     def destination(self, type, name, arglist):
       
    28         classname = "Function"
       
    29         listname = "functions"
       
    30         if arglist:
       
    31             t, n, m = arglist[-1]
       
    32             # This is non-functional today
       
    33             if t == OBJECT and m == "InMode":
       
    34                 classname = "Method"
       
    35                 listname = "methods"
       
    36         return classname, listname
       
    37 
       
    38     def makeblacklistnames(self):
       
    39         return [
       
    40                 "TEDispose",
       
    41                 "TEInit",
       
    42 ##                      "TEGetHiliteRgn",
       
    43                 ]
       
    44 
       
    45     def makeblacklisttypes(self):
       
    46         return [
       
    47                 "TEClickLoopUPP",
       
    48                 "UniversalProcPtr",
       
    49                 "WordBreakUPP",
       
    50                 "TEDoTextUPP",
       
    51                 "TERecalcUPP",
       
    52                 "TEFindWordUPP",
       
    53                 ]
       
    54 
       
    55     def makerepairinstructions(self):
       
    56         return [
       
    57                 ([("void_ptr", "*", "InMode"), ("long", "*", "InMode")],
       
    58                  [("InBuffer", "*", "*")]),
       
    59 
       
    60                 # TEContinuousStyle
       
    61                 ([("short", "mode", "OutMode"), ("TextStyle", "aStyle", "OutMode")],
       
    62                  [("short", "mode", "InOutMode"), ("TextStyle", "aStyle", "InOutMode")])
       
    63                 ]
       
    64 
       
    65 if __name__ == "__main__":
       
    66     main()