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

Side by Side Diff: mojo/public/sky/convert_amd_modules_to_sky.py

Issue 703273002: Update mojo sdk to rev 04a510fb37db10642e156957f9b2c11c2f6442ac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix content/child -> mojo/common linking Created 6 years, 1 month 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
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2014 The Chromium Authors. All rights reserved. 2 # Copyright 2014 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import argparse 6 import argparse
7 import sys 7 import sys
8 import re 8 import re
9 9
10 IMPORT_TEMPLATE = '<import src="/%s.sky" as="%s" />' 10 IMPORT_TEMPLATE = '<import src="/%s.sky" as="%s" />'
(...skipping 24 matching lines...) Expand all
35 import_regex = re.compile(r' +"([^"]+)",') 35 import_regex = re.compile(r' +"([^"]+)",')
36 begin_body_regexp = re.compile(r', function\(([^)]*)\)') 36 begin_body_regexp = re.compile(r', function\(([^)]*)\)')
37 end_body_regexp = re.compile(r'return exports') 37 end_body_regexp = re.compile(r'return exports')
38 38
39 def AddImportNames(module, unparsed_names): 39 def AddImportNames(module, unparsed_names):
40 names = [n.strip() for n in unparsed_names.split(',')] 40 names = [n.strip() for n in unparsed_names.split(',')]
41 for i in range(len(module.imports)): 41 for i in range(len(module.imports)):
42 module.imports[i].name = names[i] 42 module.imports[i].name = names[i]
43 43
44 def RewritePathNames(path): 44 def RewritePathNames(path):
45 return path.replace("mojo/public/js/bindings", "mojo/public/sky") 45 return path.replace("mojo/public/js", "mojo/public/sky")
46 46
47 def Parse(amd_module): 47 def Parse(amd_module):
48 module = Module() 48 module = Module()
49 body_lines = [] 49 body_lines = []
50 state = "name" 50 state = "name"
51 for line in amd_module.splitlines(): 51 for line in amd_module.splitlines():
52 if state == "name": 52 if state == "name":
53 m = name_regex.search(line) 53 m = name_regex.search(line)
54 if m: 54 if m:
55 module.name = m.group(1) 55 module.name = m.group(1)
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 with open(args.input, "r") as input_file: 90 with open(args.input, "r") as input_file:
91 module = Parse(input_file.read()) 91 module = Parse(input_file.read())
92 92
93 with open(args.output, "w+") as output_file: 93 with open(args.output, "w+") as output_file:
94 output_file.write(Serialize(module)) 94 output_file.write(Serialize(module))
95 95
96 return 0 96 return 0
97 97
98 if __name__ == "__main__": 98 if __name__ == "__main__":
99 sys.exit(main()) 99 sys.exit(main())
OLDNEW
« no previous file with comments | « mojo/public/sky/BUILD.gn ('k') | mojo/public/tools/bindings/generators/cpp_templates/interface_definition.tmpl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698