OLD | NEW |
1 #!/usr/local/bin/python | 1 #!/usr/local/bin/python |
2 # coding: utf-8 | 2 # coding: utf-8 |
3 | 3 |
4 import sys | 4 import sys |
5 import re | 5 import re |
| 6 from sets import Set |
6 | 7 |
7 # TODO(edisonn): put processed part of file in a new file | 8 # TODO(edisonn): put processed part of file in a new file |
8 # put unprocessed part, in a new file, so we see what we miss | 9 # put unprocessed part, in a new file, so we see what we miss |
9 # keep blank lines, and generate a version without the blank lines | 10 # keep blank lines, and generate a version without the blank lines |
10 | 11 |
11 #TODO (edisonn): deal manually with tables that don't have "KEY TYPE VALUE' head
er, e.g. | 12 #TODO (edisonn): deal manually with tables that don't have "KEY TYPE VALUE' head
er, e.g. |
12 # TABLE 7.11 Restrictions on the entries in a soft-mask image dictionary | 13 # TABLE 7.11 Restrictions on the entries in a soft-mask image dictionary |
13 #KEY RESTRICTION | 14 #KEY RESTRICTION |
14 | 15 |
15 | 16 |
16 | 17 |
17 lines = 0 | 18 lines = 0 |
18 table = '' | 19 table = '' |
19 tableHeaderFound = False | 20 tableHeaderFound = False |
20 tableLine = 0 | 21 tableLine = 0 |
21 tableRow = 0 | 22 tableRow = 0 |
22 columnWidth = [] | 23 columnWidth = [] |
23 columnValues = None | 24 columnValues = None |
24 mustFollowTableHeader = False | 25 mustFollowTableHeader = False |
25 emitedDitionaryName = '' | 26 emitedDitionaryName = '' |
26 | 27 |
27 knownTypes = { | 28 knownTypes = Set([ |
28 '(any)', | 29 '(any)', |
29 unicode('undefined', 'utf8'), | 30 unicode('undefined', 'utf8'), |
30 '(undefined)', | 31 '(undefined)', |
31 '(various)', | 32 '(various)', |
32 'array', | 33 'array', |
33 'or', | 34 'or', |
34 'boolean', | 35 'boolean', |
35 'date', | 36 'date', |
36 'dictionary', | 37 'dictionary', |
37 'function', | 38 'function', |
38 'integer', | 39 'integer', |
39 unicode('file', 'utf8'), | 40 unicode('file', 'utf8'), |
40 'file', | 41 'file', |
41 unicode('specification', 'utf8'), | 42 unicode('specification', 'utf8'), |
42 'specification', | 43 'specification', |
43 'name', | 44 'name', |
44 'tree', | 45 'tree', |
45 'number', | 46 'number', |
46 'rectangle', | 47 'rectangle', |
47 'stream', | 48 'stream', |
48 'string', | 49 'string', |
49 'text', | 50 'text', |
50 ',', | 51 ',', |
51 ' ' | 52 ' ' |
52 } | 53 ]) |
53 | 54 |
54 # TODO(edisonn): add a third element in the vector, the base class, by default i
t is Dictionary | 55 # TODO(edisonn): add a third element in the vector, the base class, by default i
t is Dictionary |
55 # TODO(edisonn): add overrides for types map<field_name, type_name> | 56 # TODO(edisonn): add overrides for types map<field_name, type_name> |
56 # e.g. ,{'Resources', 'ResourceDictionary'} | 57 # e.g. ,{'Resources', 'ResourceDictionary'} |
57 # TODO(edisonn): can be added one by one, or extracted from documentation | 58 # TODO(edisonn): can be added one by one, or extracted from documentation |
58 | 59 |
59 tableToClassName = { | 60 tableToClassName = { |
60 'TABLE 3.4': ['StreamCommonDictionary', 'Entries common to all stream dictionari
es'], | 61 'TABLE 3.4': ['StreamCommonDictionary', 'Entries common to all stream dictionari
es'], |
61 'TABLE 3.7': ['LzwdecodeAndFlatedecodeFiltersDictionary', 'Optional parameters f
or LZWDecode and FlateDecode filters'], | 62 'TABLE 3.7': ['LzwdecodeAndFlatedecodeFiltersDictionary', 'Optional parameters f
or LZWDecode and FlateDecode filters'], |
62 'TABLE 3.9': ['CcittfaxdecodeFilterDictionary', 'Optional parameters for the CCI
TTFaxDecode filter'], | 63 'TABLE 3.9': ['CcittfaxdecodeFilterDictionary', 'Optional parameters for the CCI
TTFaxDecode filter'], |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
630 #TODO(edisonn): build this map | 631 #TODO(edisonn): build this map |
631 | 632 |
632 fspecPy.write(' knowTypes[\'' + tableToClassName[e][0] + '\'] = [\'SkPdf' +
tableToClassName[e][0] + '*\', \'(SkPdf' + tableToClassName[e][0] + '*)ret\', d
atatypes.CppNull(), \'ret->isDictionary() && ((SkPdf' + tableToClassName[e][0] +
'*)ret)->valid()\', \'A_DICTIONARY\']\n') | 633 fspecPy.write(' knowTypes[\'' + tableToClassName[e][0] + '\'] = [\'SkPdf' +
tableToClassName[e][0] + '*\', \'(SkPdf' + tableToClassName[e][0] + '*)ret\', d
atatypes.CppNull(), \'ret->isDictionary() && ((SkPdf' + tableToClassName[e][0] +
'*)ret)->valid()\', \'A_DICTIONARY\']\n') |
633 fspecPy.write('\n') | 634 fspecPy.write('\n') |
634 | 635 |
635 #print lines | 636 #print lines |
636 #fnewspec.close() | 637 #fnewspec.close() |
637 | 638 |
638 if '__main__' == __name__: | 639 if '__main__' == __name__: |
639 sys.exit(generateDef()) | 640 sys.exit(generateDef()) |
OLD | NEW |