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

Side by Side Diff: mojo/public/tools/bindings/pylib/mojom/generate/generator.py

Issue 265793015: Mojo: Replace RemotePtr with InterfacePtr and InterfaceImpl (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 7 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
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Code shared by the various language-specific code generators.""" 5 """Code shared by the various language-specific code generators."""
6 6
7 from functools import partial 7 from functools import partial
8 import os.path 8 import os.path
9 9
10 import module as mojom 10 import module as mojom
(...skipping 28 matching lines...) Expand all
39 39
40 def IsEnumKind(kind): 40 def IsEnumKind(kind):
41 return isinstance(kind, mojom.Enum) 41 return isinstance(kind, mojom.Enum)
42 42
43 def IsObjectKind(kind): 43 def IsObjectKind(kind):
44 return isinstance(kind, (mojom.Struct, mojom.Array)) or IsStringKind(kind) 44 return isinstance(kind, (mojom.Struct, mojom.Array)) or IsStringKind(kind)
45 45
46 def IsHandleKind(kind): 46 def IsHandleKind(kind):
47 return kind.spec.startswith('h') or isinstance(kind, mojom.Interface) 47 return kind.spec.startswith('h') or isinstance(kind, mojom.Interface)
48 48
49 def IsInterfaceKind(kind):
50 return isinstance(kind, mojom.Interface)
51
49 def StudlyCapsToCamel(studly): 52 def StudlyCapsToCamel(studly):
50 return studly[0].lower() + studly[1:] 53 return studly[0].lower() + studly[1:]
51 54
52 def VerifyTokenType(token, expected): 55 def VerifyTokenType(token, expected):
53 """Used to check that arrays and objects are used correctly as default 56 """Used to check that arrays and objects are used correctly as default
54 values. Arrays are tokens that look like ('ARRAY', element0, element1...). 57 values. Arrays are tokens that look like ('ARRAY', element0, element1...).
55 See mojom_parser.py for their representation. 58 See mojom_parser.py for their representation.
56 """ 59 """
57 if not isinstance(token, tuple): 60 if not isinstance(token, tuple):
58 raise Exception("Expected token type '%s'. Invalid token '%s'." % 61 raise Exception("Expected token type '%s'. Invalid token '%s'." %
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 93
91 def Write(self, contents, filename): 94 def Write(self, contents, filename):
92 if self.output_dir is None: 95 if self.output_dir is None:
93 print contents 96 print contents
94 return 97 return
95 with open(os.path.join(self.output_dir, filename), "w+") as f: 98 with open(os.path.join(self.output_dir, filename), "w+") as f:
96 f.write(contents) 99 f.write(contents)
97 100
98 def GenerateFiles(self): 101 def GenerateFiles(self):
99 raise NotImplementedError("Subclasses must override/implement this method") 102 raise NotImplementedError("Subclasses must override/implement this method")
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698