Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(37)

Side by Side Diff: experimental/PdfViewer/generate_code.py

Issue 20328002: pdfviewer: gyp does not run in a consistent way on various palt forms, and it generates some files … (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gyp/pdfviewer.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 2
3 import os 3 import os
4 import sys 4 import sys
5 5
6 import datatypes 6 import datatypes
7 from autogen.pdfspec_autogen import * 7 from pdfspec_autogen import *
8 8
9 # TODO(edisonn): date and some other types are in fact strings, with a custom fo rmat!!! 9 # TODO(edisonn): date and some other types are in fact strings, with a custom fo rmat!!!
10 # TODO(edisonn): refer to page 99 (PDF data types) 10 # TODO(edisonn): refer to page 99 (PDF data types)
11 knowTypes = { 11 knowTypes = {
12 '(any)': ['SkPdfObject*', 'ret', datatypes.CppNull(), 'true', 'use a mapper'], 12 '(any)': ['SkPdfObject*', 'ret', datatypes.CppNull(), 'true', 'use a mapper'],
13 # TODO(edisonn): return constant for undefined 13 # TODO(edisonn): return constant for undefined
14 '(undefined)': ['SkPdfObject*', 'ret', datatypes.CppNull(), 'true', 'use a mappe r'], 14 '(undefined)': ['SkPdfObject*', 'ret', datatypes.CppNull(), 'true', 'use a mappe r'],
15 '(various)': ['SkPdfObject*', 'ret', datatypes.CppNull(), 'true', 'use a mapper' ], 15 '(various)': ['SkPdfObject*', 'ret', datatypes.CppNull(), 'true', 'use a mapper' ],
16 'array': ['SkPdfArray*', '(SkPdfArray*)ret', datatypes.CppNull(), 'ret->isArray( )'], 16 'array': ['SkPdfArray*', '(SkPdfArray*)ret', datatypes.CppNull(), 'ret->isArray( )'],
17 'boolean': ['bool', 'ret->boolValue()', datatypes.PdfBoolean('false'), 'ret->isB oolean()'], 17 'boolean': ['bool', 'ret->boolValue()', datatypes.PdfBoolean('false'), 'ret->isB oolean()'],
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 enumToCls[cls.fEnum] = cls 269 enumToCls[cls.fEnum] = cls
270 270
271 enumsRoot.sort() 271 enumsRoot.sort()
272 272
273 273
274 # TODO(edisonn): move each .h in it's own file 274 # TODO(edisonn): move each .h in it's own file
275 # write imports 275 # write imports
276 276
277 # write enums 277 # write enums
278 fileEnums = open(os.path.join(sys.argv[1], 'autogen', 'SkPdfEnums_autogen.h' ), 'w') 278 fileEnums = open(os.path.join(sys.argv[1], 'native', 'autogen', 'SkPdfEnums_ autogen.h'), 'w')
279 fileEnums.write('#ifndef __DEFINED__SkPdfEnums\n') 279 fileEnums.write('#ifndef __DEFINED__SkPdfEnums\n')
280 fileEnums.write('#define __DEFINED__SkPdfEnums\n') 280 fileEnums.write('#define __DEFINED__SkPdfEnums\n')
281 fileEnums.write('\n') 281 fileEnums.write('\n')
282 282
283 fileEnums.write('enum SkPdfObjectType {\n') 283 fileEnums.write('enum SkPdfObjectType {\n')
284 fileEnums.write(' kNone_SkPdfObjectType = 0,\n') 284 fileEnums.write(' kNone_SkPdfObjectType = 0,\n')
285 for enum in enumsRoot: 285 for enum in enumsRoot:
286 self.writeEnum(fileEnums, enum, enumToCls) 286 self.writeEnum(fileEnums, enum, enumToCls)
287 fileEnums.write('};\n') 287 fileEnums.write('};\n')
288 fileEnums.write('\n') 288 fileEnums.write('\n')
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 567
568 fileMapperNative.close() 568 fileMapperNative.close()
569 fileMapperNativeCpp.close() 569 fileMapperNativeCpp.close()
570 570
571 return 571 return
572 572
573 def generateCode(): 573 def generateCode():
574 global fileHeadersNative 574 global fileHeadersNative
575 global fileHeadersNativeCpp 575 global fileHeadersNativeCpp
576 global knowTypes 576 global knowTypes
577
578 nativeAutogenPath = os.path.join(sys.argv[1], 'native', 'autogen')
579 if not os.path.exists(nativeAutogenPath):
580 os.makedirs(nativeAutogenPath)
577 581
578 fileHeadersNative = open(os.path.join(sys.argv[1], 'native', 'autogen', 'SkPdf Headers_autogen.h'), 'w') 582 fileHeadersNative = open(os.path.join(sys.argv[1], 'native', 'autogen', 'SkPdf Headers_autogen.h'), 'w')
579 fileHeadersNativeCpp = open(os.path.join(sys.argv[1], 'native', 'autogen', 'Sk PdfHeaders_autogen.cpp'), 'w') 583 fileHeadersNativeCpp = open(os.path.join(sys.argv[1], 'native', 'autogen', 'Sk PdfHeaders_autogen.cpp'), 'w')
580 584
581 fileHeadersNative.write('#ifndef __DEFINED__SkPdfHeaders\n') 585 fileHeadersNative.write('#ifndef __DEFINED__SkPdfHeaders\n')
582 fileHeadersNative.write('#define __DEFINED__SkPdfHeaders\n') 586 fileHeadersNative.write('#define __DEFINED__SkPdfHeaders\n')
583 fileHeadersNative.write('\n') 587 fileHeadersNative.write('\n')
584 588
585 fileHeadersNativeCpp.write('#include "SkPdfHeaders_autogen.h"\n') 589 fileHeadersNativeCpp.write('#include "SkPdfHeaders_autogen.h"\n')
586 590
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 622
619 fileHeadersNative.write('#endif // __DEFINED__SkPdfHeaders\n') 623 fileHeadersNative.write('#endif // __DEFINED__SkPdfHeaders\n')
620 624
621 fileHeadersNative.close() 625 fileHeadersNative.close()
622 fileHeadersNativeCpp.close() 626 fileHeadersNativeCpp.close()
623 627
624 if '__main__' == __name__: 628 if '__main__' == __name__:
625 #print sys.argv 629 #print sys.argv
626 sys.exit(generateCode()) 630 sys.exit(generateCode())
627 631
OLDNEW
« no previous file with comments | « no previous file | gyp/pdfviewer.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698