Index: tools/json_schema_compiler/h_generator.py |
diff --git a/tools/json_schema_compiler/h_generator.py b/tools/json_schema_compiler/h_generator.py |
index 5f59ffbe04603f83e730b78cf7bbec8c94698bb7..ba7c5ca133a27b4a4ebc5e87089b5a77071a143c 100644 |
--- a/tools/json_schema_compiler/h_generator.py |
+++ b/tools/json_schema_compiler/h_generator.py |
@@ -35,6 +35,7 @@ class HGenerator(object): |
.Append('#include <vector>') |
.Append() |
.Append('#include "base/basictypes.h"') |
+ .Append('#include "base/logging.h"') |
.Append('#include "base/memory/linked_ptr.h"') |
.Append('#include "base/memory/scoped_ptr.h"') |
.Append('#include "base/values.h"') |
@@ -214,6 +215,9 @@ class HGenerator(object): |
(c.Eblock() |
.Sblock(' private:') |
+ .Concat(self._GeneratePrivatePropertyStructures( |
+ type_.properties.values())) |
+ .Append() |
.Append('DISALLOW_COPY_AND_ASSIGN(%(classname)s);') |
.Eblock('};') |
) |
@@ -303,6 +307,22 @@ class HGenerator(object): |
c.Append(create_enum_value) |
return c |
+ def _GeneratePrivatePropertyStructures(self, props): |
+ """Generate the private structures required by a property such as OBJECT |
+ classes and enums. |
+ """ |
+ c = Code() |
+ for prop in props: |
+ if prop.type_ == PropertyType.ARRAY: |
+ c.Concat(self._GeneratePrivatePropertyStructures([prop.item_type])) |
+ c.Append() |
+ elif prop.type_ == PropertyType.CHOICES: |
+ # We only need GetChoiceValue() if there is a ToValue() method. |
+ if prop.from_client: |
+ c.Append('scoped_ptr<base::Value> Get%sChoiceValue() const;' % ( |
+ cpp_util.Classname(prop.name))) |
+ return c |
+ |
def _GenerateCreateCallbackArguments(self, function): |
"""Generates functions for passing paramaters to a callback. |
""" |