summaryrefslogtreecommitdiffstats
path: root/ppapi/generators
diff options
context:
space:
mode:
authornoelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 21:04:26 +0000
committernoelallen@google.com <noelallen@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2011-08-25 21:04:26 +0000
commite8a83febaed38a6c891b866a7504de909cd2942b (patch)
tree805c1d4ae13c184cb038f36cb9264c3aae704a0f /ppapi/generators
parent32b885603a053196143fb27d05772df6301bf6cb (diff)
downloadchromium_src-e8a83febaed38a6c891b866a7504de909cd2942b.zip
chromium_src-e8a83febaed38a6c891b866a7504de909cd2942b.tar.gz
chromium_src-e8a83febaed38a6c891b866a7504de909cd2942b.tar.bz2
More multi-version support (part 2)
Add member to Node to return a set of unique releases for that node. Updates DefineStruct to iterate across all unique releases for the struct, generating first the most recent release as we do today and other releases without comments, and the version number appended to the structure name. NOTE: This is work in progress. This CL adds support for Interfaces that change which should be enough for M15. While this same CL creates multiple structures when the structures change, references to structures will not have mangled names which would cause errors. BUG= http://code.google.com/p/chromium/issues/detail?id=89969 TEST= python generator.py --cgen --test --diff --range=M13,M14 Review URL: http://codereview.chromium.org/7751001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@98298 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ppapi/generators')
-rw-r--r--ppapi/generators/idl_c_header.py17
-rw-r--r--ppapi/generators/idl_c_proto.py30
-rw-r--r--ppapi/generators/idl_namespace.py4
-rw-r--r--ppapi/generators/idl_node.py11
-rw-r--r--ppapi/generators/test_cgen_range/versions.h40
-rw-r--r--ppapi/generators/test_cgen_range/versions.idl22
6 files changed, 93 insertions, 31 deletions
diff --git a/ppapi/generators/idl_c_header.py b/ppapi/generators/idl_c_header.py
index edec95f..00933b5 100644
--- a/ppapi/generators/idl_c_header.py
+++ b/ppapi/generators/idl_c_header.py
@@ -167,15 +167,14 @@ class HGen(GeneratorByFile):
macro = node.GetProperty('macro')
if not macro:
macro = self.GetMacro(node)
- label = node.GetLabel()
- if label:
- for vers in label.versions:
- strver = str(vers).replace('.', '_')
- idefs += self.GetDefine('%s_%s' % (macro, strver),
- '"%s;%s"' % (name, vers))
- if label.GetRelease(vers) == releases[-1]:
- idefs += self.GetDefine(macro, '%s_%s' % (macro, strver))
- idefs += '\n'
+
+ unique = node.GetUniqueReleases(releases)
+ for rel in unique:
+ version = node.GetVersion(rel)
+ strver = str(version).replace('.', '_')
+ idefs += self.GetDefine('%s_%s' % (macro, strver),
+ '"%s;%s"' % (name, version))
+ idefs += self.GetDefine(macro, '%s_%s' % (macro, strver)) + '\n'
out.Write(idefs)
# Generate the @file comment
diff --git a/ppapi/generators/idl_c_proto.py b/ppapi/generators/idl_c_proto.py
index 05937e4..1ea8e03 100644
--- a/ppapi/generators/idl_c_proto.py
+++ b/ppapi/generators/idl_c_proto.py
@@ -398,27 +398,43 @@ class CGen(object):
self.LogExit('Exit DefineMember')
return out
- # Define a Struct.
- def DefineStruct(self, node, releases, prefix='', comment=False):
+ def DefineStructInternals(self, node, release, suffix='', comment=True):
out = ''
-
- self.LogEnter('DefineStruct %s' % node)
if node.GetProperty('union'):
- out += 'union %s%s {\n' % (prefix, node.GetName())
+ out += 'union %s%s {\n' % (node.GetName(), suffix)
else:
- out += 'struct %s%s {\n' % (prefix, node.GetName())
+ out += 'struct %s%s {\n' % (node.GetName(), suffix)
# Generate Member Functions
members = []
for child in node.GetListOf('Member'):
- member = self.Define(child, releases, tabs=1, comment=comment)
+ member = self.Define(child, [release], tabs=1, comment=comment)
if not member:
continue
members.append(member)
out += '%s\n};\n' % '\n'.join(members)
+ return out
+
+
+ def DefineStruct(self, node, releases, prefix='', comment=False):
+ self.LogEnter('DefineStruct %s' % node)
+ out = ''
+ build_list = node.GetUniqueReleases(releases)
+
+ # Build the most recent one with comments
+ out = self.DefineStructInternals(node, build_list[-1], comment=True)
+
+ # Build the rest without comments and with the version number appended
+ for rel in build_list[0:-1]:
+ ver_num = node.GetVersion(rel)
+ ver = ("_%s" % ver_num).replace('.', '_')
+ out += '\n' + self.DefineStructInternals(node, rel, suffix=ver,
+ comment=False)
+
self.LogExit('Exit DefineStruct')
return out
+
#
# Copyright and Comment
#
diff --git a/ppapi/generators/idl_namespace.py b/ppapi/generators/idl_namespace.py
index 98e86258..ee9c151 100644
--- a/ppapi/generators/idl_namespace.py
+++ b/ppapi/generators/idl_namespace.py
@@ -119,6 +119,10 @@ class IDLVersionMap(object):
return self.version_to_release[version]
def GetVersion(self, release):
+ if release > self.releases[-1]:
+ release = self.releases[-1]
+ elif release < self.releases[0]:
+ release = self.releases[0]
return self.release_to_version[release]
diff --git a/ppapi/generators/idl_node.py b/ppapi/generators/idl_node.py
index b8f71eb..b146ba3 100644
--- a/ppapi/generators/idl_node.py
+++ b/ppapi/generators/idl_node.py
@@ -273,6 +273,17 @@ class IDLNode(IDLVersion):
if not label: return None
return label.GetVersion(release)
+ def GetUniqueReleases(self, releases):
+ # Given a list of release, return a subset of releases that change.
+ last_hash = None
+ build_list = []
+ for rel in releases:
+ cur_hash = self.GetHash(rel)
+ if last_hash != cur_hash:
+ build_list.append(rel)
+ last_hash = cur_hash
+ return build_list
+
def SetProperty(self, name, val):
self.property_node.SetProperty(name, val)
diff --git a/ppapi/generators/test_cgen_range/versions.h b/ppapi/generators/test_cgen_range/versions.h
index 819ec0c..92b5324 100644
--- a/ppapi/generators/test_cgen_range/versions.h
+++ b/ppapi/generators/test_cgen_range/versions.h
@@ -3,13 +3,18 @@
* found in the LICENSE file.
*/
-/* From test_cgen_range/versions.idl modified Wed Aug 24 10:35:01 2011. */
+/* From test_cgen_range/versions.idl modified Wed Aug 24 19:49:19 2011. */
#ifndef PPAPI_C_TEST_CGEN_RANGE_VERSIONS_H_
#define PPAPI_C_TEST_CGEN_RANGE_VERSIONS_H_
#include "ppapi/c/pp_macros.h"
+#define BAR_INTERFACE_0_0 "Bar;0.0"
+#define BAR_INTERFACE_1_0 "Bar;1.0"
+#define BAR_INTERFACE_2_0 "Bar;2.0"
+#define BAR_INTERFACE BAR_INTERFACE_2_0
+
/**
* @file
* File Comment. */
@@ -19,20 +24,39 @@
* @addtogroup Structs
* @{
*/
-/* Bogus Struct */
-struct PP_Size {
+/* Bogus Struct Foo */
+struct Foo {
/**
- * Comment for function
+ * Comment for function x,y,z
*/
+ int32_t (*Foo)(int32_t x, int32_t y, int32_t z);
+};
+struct Foo_0_0 {
int32_t (*Foo)(int32_t x);
- /**
- * Comment for function
- */
+};
+struct Foo_1_0 {
int32_t (*Foo)(int32_t x, int32_t y);
+};
+/**
+ * @}
+ */
+
+/**
+ * @addtogroup Interfaces
+ * @{
+ */
+/* Inherit revisions thanks to Foo */
+struct Bar {
/**
* Comment for function
*/
- int32_t (*Foo)(int32_t x, int32_t y, int32_t z);
+ int32_t (*UseFoo)( struct Foo* val);
+};
+struct Bar_0_0 {
+ int32_t (*UseFoo)( struct Foo* val);
+};
+struct Bar_1_0 {
+ int32_t (*UseFoo)( struct Foo* val);
};
/**
* @}
diff --git a/ppapi/generators/test_cgen_range/versions.idl b/ppapi/generators/test_cgen_range/versions.idl
index f4fe232..11b4de0 100644
--- a/ppapi/generators/test_cgen_range/versions.idl
+++ b/ppapi/generators/test_cgen_range/versions.idl
@@ -11,26 +11,34 @@ label Chrome {
M15 = 2.0
};
-[version=0.0]
describe {
- /** Standard Ints. */
int32_t;
};
-/* Bogus Struct */
+/* Bogus Struct Foo */
[version=0.0]
-struct PP_Size {
+struct Foo {
/**
- * Comment for function
+ * Comment for function x
*/
[version=0.0] int32_t Foo(int32_t x);
/**
- * Comment for function
+ * Comment for function x,y
*/
[version=1.0] int32_t Foo(int32_t x, int32_t y);
/**
- * Comment for function
+ * Comment for function x,y,z
*/
[version=2.0] int32_t Foo(int32_t x, int32_t y, int32_t z);
};
+
+
+/* Inherit revisions thanks to Foo */
+[version=0.0]
+interface Bar {
+ /**
+ * Comment for function
+ */
+ int32_t UseFoo(Foo val);
+};