summaryrefslogtreecommitdiffstats
path: root/ppapi/generators
diff options
context:
space:
mode:
authorteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 17:10:19 +0000
committerteravest@chromium.org <teravest@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-17 17:10:19 +0000
commit67676f21f4ed8c9ecbf76cd87233d5b12b8ebade (patch)
tree8d7e46ad060437d9880cb907329fd56eed77c0bb /ppapi/generators
parent6c620205dc1126c9678cf88ac080c9a0300f013c (diff)
downloadchromium_src-67676f21f4ed8c9ecbf76cd87233d5b12b8ebade.zip
chromium_src-67676f21f4ed8c9ecbf76cd87233d5b12b8ebade.tar.gz
chromium_src-67676f21f4ed8c9ecbf76cd87233d5b12b8ebade.tar.bz2
Pepper: Add IDL support for "channel=dev".
This adds some basic support for the "channel=dev" label annotation for pepper IDL files. Design doc is at: https://docs.google.com/a/chromium.org/document/d/1Q660kK72_230gxnqtgQavMcDT5_gLgPVh_W51MXT6nk/edit TESTED=idl_tests.py, generator.py BUG=325403 Review URL: https://codereview.chromium.org/105313002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@241305 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generators')
-rw-r--r--ppapi/generators/idl_ast.py9
-rwxr-xr-xppapi/generators/idl_c_header.py31
-rwxr-xr-xppapi/generators/idl_c_proto.py53
-rwxr-xr-xppapi/generators/idl_node.py22
-rwxr-xr-xppapi/generators/idl_release.py7
-rw-r--r--ppapi/generators/test_cgen_range/dev_channel_interface.h102
-rw-r--r--ppapi/generators/test_cgen_range/dev_channel_interface.idl67
-rw-r--r--ppapi/generators/test_cgen_range/versions.idl4
8 files changed, 275 insertions, 20 deletions
diff --git a/ppapi/generators/idl_ast.py b/ppapi/generators/idl_ast.py
index 74dce94..515dbb0 100644
--- a/ppapi/generators/idl_ast.py
+++ b/ppapi/generators/idl_ast.py
@@ -21,7 +21,10 @@ class IDLLabelResolver(IDLVisitor):
def Depart(self, node, ignore, childdata):
# Build list of Release=Version
if node.IsA('LabelItem'):
- return (node.GetName(), node.GetProperty('VALUE'))
+ channel = node.GetProperty('channel')
+ if not channel:
+ channel = 'stable'
+ return (node.GetName(), node.GetProperty('VALUE'), channel)
# On completion of the Label, apply to the parent File if the
# name of the label matches the generation label.
@@ -75,7 +78,9 @@ class IDLNamespaceVersionResolver(IDLVisitor):
if parent_namespace and node.cls in IDLNode.NamedSet:
# Set version min and max based on properties
if self.release_map:
- vmin = node.GetProperty('version')
+ vmin = node.GetProperty('dev_version')
+ if vmin == None:
+ vmin = node.GetProperty('version')
vmax = node.GetProperty('deprecate')
# If no min is available, the use the parent File's min
if vmin == None:
diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py
index d3a1b32..22932e6 100755
--- a/ppapi/generators/idl_c_header.py
+++ b/ppapi/generators/idl_c_header.py
@@ -288,12 +288,33 @@ class HGen(GeneratorByFile):
# Skip this interface if there are no matching versions
if not unique: continue
+ last_stable_ver = None
+ last_dev_rel = None
+ for rel in unique:
+ channel = node.GetProperty('FILE').release_map.GetChannel(rel)
+ if channel == 'dev':
+ last_dev_rel = rel
+
for rel in unique:
version = node.GetVersion(rel)
name = cgen.GetInterfaceString(node, version)
strver = str(version).replace('.', '_')
- idefs += cgen.GetDefine('%s_%s' % (macro, strver), '"%s"' % name)
- idefs += cgen.GetDefine(macro, '%s_%s' % (macro, strver)) + '\n'
+ channel = node.GetProperty('FILE').release_map.GetChannel(rel)
+ if channel == 'dev':
+ # Skip dev channel interface versions that are
+ # Not the newest version, and
+ # Don't have an equivalent stable version.
+ if rel != last_dev_rel and not node.DevInterfaceMatchesStable(rel):
+ continue
+ value_string = '"%s" /* dev */' % name
+ else:
+ value_string = '"%s"' % name
+ last_stable_ver = strver
+ idefs += cgen.GetDefine('%s_%s' % (macro, strver), value_string)
+ if last_stable_ver:
+ idefs += cgen.GetDefine(macro, '%s_%s' % (macro, last_stable_ver))
+ idefs += '\n'
+
out.Write(idefs)
# Generate the @file comment
@@ -337,11 +358,11 @@ def main(args):
filenames = glob.glob(idldir)
ast = ParseFiles(filenames)
- if hgen.GenerateRange(ast, ['M13', 'M14', 'M15'], {}):
- print "Golden file for M13-M15 failed."
+ if hgen.GenerateRange(ast, ['M13', 'M14', 'M15', 'M16', 'M17'], {}):
+ print "Golden file for M13-M17 failed."
failed =1
else:
- print "Golden file for M13-M15 passed."
+ print "Golden file for M13-M17 passed."
return failed
diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py
index 34d5361..d7aa0e7 100755
--- a/ppapi/generators/idl_c_proto.py
+++ b/ppapi/generators/idl_c_proto.py
@@ -538,17 +538,25 @@ class CGen(object):
def DefineStructInternals(self, node, release,
include_version=False, comment=True):
+ channel = node.GetProperty('FILE').release_map.GetChannel(release)
+ if channel == 'dev':
+ channel_comment = ' /* dev */'
+ else:
+ channel_comment = ''
out = ''
if node.GetProperty('union'):
- out += 'union %s {\n' % (
- self.GetStructName(node, release, include_version))
+ out += 'union %s {%s\n' % (
+ self.GetStructName(node, release, include_version), channel_comment)
else:
- out += 'struct %s {\n' % (
- self.GetStructName(node, release, include_version))
+ out += 'struct %s {%s\n' % (
+ self.GetStructName(node, release, include_version), channel_comment)
+ channel = node.GetProperty('FILE').release_map.GetChannel(release)
# Generate Member Functions
members = []
for child in node.GetListOf('Member'):
+ if channel == 'stable' and child.NodeIsDevOnly():
+ continue
member = self.Define(child, [release], tabs=1, comment=comment)
if not member:
continue
@@ -563,27 +571,52 @@ class CGen(object):
out = ''
build_list = node.GetUniqueReleases(releases)
+ newest_stable = None
+ newest_dev = None
+ for rel in build_list:
+ channel = node.GetProperty('FILE').release_map.GetChannel(rel)
+ if channel == 'stable':
+ newest_stable = rel
+ if channel == 'dev':
+ newest_dev = rel
+ last_rel = build_list[-1]
+
# TODO(noelallen) : Bug 157017 finish multiversion support
if node.IsA('Struct'):
if len(build_list) != 1:
node.Error('Can not support multiple versions of node.')
assert len(build_list) == 1
- out = self.DefineStructInternals(node, build_list[-1],
+ # Build the most recent one versioned, with comments
+ out = self.DefineStructInternals(node, last_rel,
include_version=False, comment=True)
if node.IsA('Interface'):
# Build the most recent one versioned, with comments
- out = self.DefineStructInternals(node, build_list[-1],
+ out = self.DefineStructInternals(node, last_rel,
include_version=True, comment=True)
- # Define an unversioned typedef for the most recent version
- out += '\ntypedef struct %s %s;\n' % (
- self.GetStructName(node, build_list[-1], include_version=True),
- self.GetStructName(node, build_list[-1], include_version=False))
+ if last_rel == newest_stable:
+ # Define an unversioned typedef for the most recent version
+ out += '\ntypedef struct %s %s;\n' % (
+ self.GetStructName(node, last_rel, include_version=True),
+ self.GetStructName(node, last_rel, include_version=False))
+
# Build the rest without comments and with the version number appended
for rel in build_list[0:-1]:
+ channel = node.GetProperty('FILE').release_map.GetChannel(rel)
+ # Skip dev channel interface versions that are
+ # Not the newest version, and
+ # Don't have an equivalent stable version.
+ if channel == 'dev' and rel != newest_dev:
+ if not node.DevInterfaceMatchesStable(rel):
+ continue
out += '\n' + self.DefineStructInternals(node, rel,
include_version=True,
comment=False)
+ if rel == newest_stable:
+ # Define an unversioned typedef for the most recent version
+ out += '\ntypedef struct %s %s;\n' % (
+ self.GetStructName(node, rel, include_version=True),
+ self.GetStructName(node, rel, include_version=False))
self.LogExit('Exit DefineStruct')
return out
diff --git a/ppapi/generators/idl_node.py b/ppapi/generators/idl_node.py
index 3c94707..55b24d1 100755
--- a/ppapi/generators/idl_node.py
+++ b/ppapi/generators/idl_node.py
@@ -276,6 +276,10 @@ class IDLNode(IDLRelease):
else:
my_releases = set([my_min])
+ r = self.GetRelease(self.GetProperty('version'))
+ if not r in my_releases:
+ my_releases |= set([r])
+
# Break cycle if we reference ourselves
if self in visited:
return [my_min]
@@ -338,6 +342,22 @@ class IDLNode(IDLRelease):
def GetPropertyLocal(self, name):
return self._property_node.GetPropertyLocal(name)
+ def NodeIsDevOnly(self):
+ """Returns true iff a node is only in dev channel."""
+ return self.GetProperty('dev_version') and not self.GetProperty('version')
+
+ def DevInterfaceMatchesStable(self, release):
+ """Returns true if an interface has an equivalent stable version."""
+ assert(self.IsA('Interface'))
+ for child in self.GetListOf('Member'):
+ unique = child.GetUniqueReleases([release])
+ if not unique or not child.InReleases([release]):
+ continue
+ if child.NodeIsDevOnly():
+ return False
+ return True
+
+
#
# IDLFile
#
@@ -352,7 +372,7 @@ class IDLFile(IDLNode):
IDLNode.__init__(self, 'File', name, 1, 0, attrs + children)
# TODO(teravest): Why do we set release map like this here? This looks
# suspicious...
- self.release_map = IDLReleaseMap([('M13', 1.0)])
+ self.release_map = IDLReleaseMap([('M13', 1.0, 'stable')])
#
diff --git a/ppapi/generators/idl_release.py b/ppapi/generators/idl_release.py
index eafc95f..ff4aa01 100755
--- a/ppapi/generators/idl_release.py
+++ b/ppapi/generators/idl_release.py
@@ -214,9 +214,11 @@ class IDLReleaseMap(object):
def __init__(self, release_info):
self.version_to_release = {}
self.release_to_version = {}
- for release, version in release_info:
+ self.release_to_channel = {}
+ for release, version, channel in release_info:
self.version_to_release[version] = release
self.release_to_version[release] = version
+ self.release_to_channel[release] = channel
self.releases = sorted(self.release_to_version.keys())
self.versions = sorted(self.version_to_release.keys())
@@ -238,6 +240,9 @@ class IDLReleaseMap(object):
def GetVersionRange(self):
return (self.versions[0], self.version[-1])
+ def GetChannel(self, release):
+ return self.release_to_channel.get(release, None)
+
#
# Test Code
#
diff --git a/ppapi/generators/test_cgen_range/dev_channel_interface.h b/ppapi/generators/test_cgen_range/dev_channel_interface.h
new file mode 100644
index 0000000..1b340ab
--- /dev/null
+++ b/ppapi/generators/test_cgen_range/dev_channel_interface.h
@@ -0,0 +1,102 @@
+/* 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.
+ */
+
+/* From test_cgen_range/dev_channel_interface.idl,
+ * modified Tue Dec 3 14:58:15 2013.
+ */
+
+#ifndef PPAPI_C_TEST_CGEN_RANGE_DEV_CHANNEL_INTERFACE_H_
+#define PPAPI_C_TEST_CGEN_RANGE_DEV_CHANNEL_INTERFACE_H_
+
+#include "ppapi/c/pp_macros.h"
+#include "ppapi/c/test_cgen_range/versions.h"
+
+#define TESTDEV_INTERFACE_1_0 "TestDev;1.0"
+#define TESTDEV_INTERFACE_1_2 "TestDev;1.2"
+#define TESTDEV_INTERFACE_1_3 "TestDev;1.3" /* dev */
+#define TESTDEV_INTERFACE TESTDEV_INTERFACE_1_2
+
+#define TESTDEVTOSTABLE_INTERFACE_1_0 "TestDevToStable;1.0"
+#define TESTDEVTOSTABLE_INTERFACE_1_1 "TestDevToStable;1.1" /* dev */
+#define TESTDEVTOSTABLE_INTERFACE_1_2 "TestDevToStable;1.2"
+#define TESTDEVTOSTABLE_INTERFACE TESTDEVTOSTABLE_INTERFACE_1_2
+
+/**
+ * @file
+ */
+
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+/**
+ * TestDev
+ */
+struct TestDev_1_3 { /* dev */
+ /**
+ * TestDev1()
+ */
+ void (*TestDev1)(void);
+ /**
+ * TestDev2()
+ */
+ void (*TestDev2)(void);
+ /**
+ * TestDev3()
+ */
+ void (*TestDev3)(void);
+ /**
+ * TestDev4()
+ */
+ void (*TestDev4)(void);
+};
+
+struct TestDev_1_0 {
+ void (*TestDev1)(void);
+};
+
+struct TestDev_1_2 {
+ void (*TestDev1)(void);
+ void (*TestDev3)(void);
+};
+
+typedef struct TestDev_1_2 TestDev;
+
+/**
+ * TestDevToStable
+ */
+struct TestDevToStable_1_2 {
+ /**
+ * Foo() comment.
+ */
+ void (*Foo)(int32_t x);
+ /**
+ * Bar() comment.
+ */
+ void (*Bar)(int32_t x);
+ /**
+ * Baz() comment.
+ */
+ void (*Baz)(int32_t x);
+};
+
+typedef struct TestDevToStable_1_2 TestDevToStable;
+
+struct TestDevToStable_1_0 {
+ void (*Foo)(int32_t x);
+};
+
+struct TestDevToStable_1_1 { /* dev */
+ void (*Foo)(int32_t x);
+ void (*Bar)(int32_t x);
+ void (*Baz)(int32_t x);
+};
+/**
+ * @}
+ */
+
+#endif /* PPAPI_C_TEST_CGEN_RANGE_DEV_CHANNEL_INTERFACE_H_ */
+
diff --git a/ppapi/generators/test_cgen_range/dev_channel_interface.idl b/ppapi/generators/test_cgen_range/dev_channel_interface.idl
new file mode 100644
index 0000000..d3ae0ec
--- /dev/null
+++ b/ppapi/generators/test_cgen_range/dev_channel_interface.idl
@@ -0,0 +1,67 @@
+/* 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.
+ */
+
+label Chrome {
+ M13 = 1.0,
+ [channel=dev] M14 = 1.1,
+ M15 = 1.2,
+ [channel=dev] M16 = 1.3,
+ M17 = 1.4
+};
+
+describe {
+ int32_t;
+ void;
+};
+
+/**
+ * TestDev
+ */
+interface TestDev {
+ /**
+ * TestDev1()
+ */
+ void TestDev1();
+
+ /**
+ * TestDev2()
+ */
+ [dev_version=1.1]
+ void TestDev2();
+
+ /**
+ * TestDev3()
+ */
+ [version=1.2]
+ void TestDev3();
+
+ /**
+ * TestDev4()
+ */
+ [dev_version=1.3]
+ void TestDev4();
+};
+
+/**
+ * TestDevToStable
+ */
+interface TestDevToStable {
+ /**
+ * Foo() comment.
+ */
+ void Foo([in] int32_t x);
+
+ /**
+ * Bar() comment.
+ */
+ [dev_version=1.1, version=1.2]
+ void Bar([in] int32_t x);
+
+ /**
+ * Baz() comment.
+ */
+ [dev_version=1.1, version=1.2]
+ void Baz([in] int32_t x);
+};
diff --git a/ppapi/generators/test_cgen_range/versions.idl b/ppapi/generators/test_cgen_range/versions.idl
index 3dcc87e..6c67aee 100644
--- a/ppapi/generators/test_cgen_range/versions.idl
+++ b/ppapi/generators/test_cgen_range/versions.idl
@@ -8,7 +8,9 @@
label Chrome {
M13 = 0.0,
M14 = 1.0,
- M15 = 2.0
+ M15 = 2.0,
+ M16 = 3.0,
+ M17 = 4.0
};
describe {