Commit 0b5ae24b authored by Hokein.Wu@gmail.com's avatar Hokein.Wu@gmail.com

Add "implemented_in" key in IDL schema compiler

The "implemented_in" key format like this:
  [implemented_in="path/to/implemented_file"]
  namespace Foo {...};

BUG=313579
TEST=pass idl_schema_test

Review URL: https://codereview.chromium.org/56543003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@233442 0039d316-1c4b-4281-b951-d872f2087c98
parent 9b07c98d
......@@ -324,11 +324,13 @@ class Namespace(object):
description,
nodoc=False,
internal=False,
platforms=None):
platforms=None,
compiler_options=None):
self.namespace = namespace_node
self.nodoc = nodoc
self.internal = internal
self.platforms = platforms
self.compiler_options = compiler_options
self.events = []
self.functions = []
self.types = []
......@@ -350,6 +352,10 @@ class Namespace(object):
self.types.append(Enum(node).process(self.callbacks))
else:
sys.exit('Did not process %s %s' % (node.cls, node))
if self.compiler_options is not None:
compiler_options = self.compiler_options
else:
compiler_options = {}
return {'namespace': self.namespace.GetName(),
'description': self.description,
'nodoc': self.nodoc,
......@@ -357,7 +363,8 @@ class Namespace(object):
'functions': self.functions,
'internal': self.internal,
'events': self.events,
'platforms': self.platforms}
'platforms': self.platforms,
'compiler_options': compiler_options}
def process_interface(self, node):
members = []
......@@ -383,6 +390,7 @@ class IDLSchema(object):
internal = False
description = None
platforms = None
compiler_options = None
for node in self.idl:
if node.cls == 'Namespace':
if not description:
......@@ -390,11 +398,14 @@ class IDLSchema(object):
print('%s must have a namespace-level comment. This will '
'appear on the API summary page.' % node.GetName())
description = ''
namespace = Namespace(node, description, nodoc, internal, platforms)
namespace = Namespace(node, description, nodoc, internal,
platforms=platforms,
compiler_options=compiler_options)
namespaces.append(namespace.process())
nodoc = False
internal = False
platforms = None
compiler_options = None
elif node.cls == 'Copyright':
continue
elif node.cls == 'Comment':
......@@ -406,6 +417,8 @@ class IDLSchema(object):
internal = bool(node.value)
elif node.name == 'platforms':
platforms = list(node.value)
elif node.name == 'implemented_in':
compiler_options = {'implemented_in': node.value}
else:
continue
else:
......
......@@ -129,6 +129,24 @@ class IdlSchemaTest(unittest.TestCase):
expected = None
self.assertEquals(expected, schema['platforms'])
def testSpecificImplementNamespace(self):
schema = idl_schema.Load('test/idl_namespace_specific_implement.idl')[0]
self.assertEquals('idl_namespace_specific_implement',
schema['namespace'])
expected = 'idl_namespace_specific_implement.idl'
self.assertEquals(expected, schema['compiler_options']['implemented_in'])
def testSpecificImplementOnChromeOSNamespace(self):
schema = idl_schema.Load(
'test/idl_namespace_specific_implement_chromeos.idl')[0]
self.assertEquals('idl_namespace_specific_implement_chromeos',
schema['namespace'])
expected_implemented_path = 'idl_namespace_specific_implement_chromeos.idl'
expected_platform = ['chromeos']
self.assertEquals(expected_implemented_path,
schema['compiler_options']['implemented_in'])
self.assertEquals(expected_platform, schema['platforms'])
def testCallbackComment(self):
schema = self.idl_basics
self.assertEquals('A comment on a callback.',
......
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests the case of a namespace with specific implemented file.
[implemented_in="idl_namespace_specific_implement.idl"]
namespace idl_namespace_specific_implement {
};
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Tests the case of a namespace with specific implemented file on chromeos.
[platforms=("chromeos"),
implemented_in="idl_namespace_specific_implement_chromeos.idl"]
namespace idl_namespace_specific_implement_chromeos {
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment