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

Unified Diff: mojo/public/tools/bindings/pylib/mojom/generate/data.py

Issue 1635613002: [mojo-bindings] Support reuse of native enum classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix more missing public_deps Created 4 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « mojo/public/tools/bindings/mojom.gni ('k') | mojo/public/tools/bindings/pylib/mojom/parse/ast.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/tools/bindings/pylib/mojom/generate/data.py
diff --git a/mojo/public/tools/bindings/pylib/mojom/generate/data.py b/mojo/public/tools/bindings/pylib/mojom/generate/data.py
index e8c71f33d938ae2201981ec35934eaaefda058ae..70b9d40f9f22160ee6bc7d11a6e1c4c780435e17 100644
--- a/mojo/public/tools/bindings/pylib/mojom/generate/data.py
+++ b/mojo/public/tools/bindings/pylib/mojom/generate/data.py
@@ -397,6 +397,7 @@ def ResolveNumericEnumValues(enum_fields):
def EnumFromData(module, data, parent_kind):
enum = mojom.Enum(module=module)
enum.name = data['name']
+ enum.native_only = data['native_only']
name = enum.name
if parent_kind:
name = parent_kind.name + '.' + name
@@ -404,11 +405,19 @@ def EnumFromData(module, data, parent_kind):
enum.parent_kind = parent_kind
enum.fields = map(
lambda field: EnumFieldFromData(module, enum, field, parent_kind),
- data['fields'])
+ data['fields'] if not enum.native_only else [])
enum.attributes = data.get('attributes')
ResolveNumericEnumValues(enum.fields)
module.kinds[enum.spec] = enum
+
+ # Enforce that a [Native=True] attribute is set to make native-only enum
+ # declarations more explicit.
+ if enum.native_only:
+ if not enum.attributes or not enum.attributes.get('Native', False):
+ raise Exception("Native-only enum declarations must include a " +
+ "Native=True attribute.")
+
return enum
def ConstantFromData(module, data, parent_kind):
« no previous file with comments | « mojo/public/tools/bindings/mojom.gni ('k') | mojo/public/tools/bindings/pylib/mojom/parse/ast.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698