Chromium Code Reviews| Index: tools/json_schema_compiler/cc_generator.py |
| diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py |
| index eaf6fb3e6e48dcc9f2e4e2c4308676ab36e654bf..21a817ac0d79df5d8d7c41a94da2d0ace9df3bfb 100644 |
| --- a/tools/json_schema_compiler/cc_generator.py |
| +++ b/tools/json_schema_compiler/cc_generator.py |
| @@ -354,7 +354,7 @@ class CCGenerator(object): |
| return '%s.release()' % self._util_cc_helper.CreateValueFromArray( |
| self._cpp_type_generator.GetReferencedProperty(prop), var, |
| prop.optional) |
| - elif prop.type_.is_fundamental: |
| + elif self._IsFundamentalOrFundamentalRef(prop): |
| if prop.optional: |
| var = '*' + var |
| return { |
| @@ -461,17 +461,22 @@ class CCGenerator(object): |
| .Append(' return %(failure_value)s;') |
| ) |
| - if prop.type_.is_fundamental: |
| + if self._IsFundamentalOrFundamentalRef(prop): |
| if prop.optional: |
| (c.Append('%(ctype)s temp;') |
| .Append('if (%s)' % |
| - cpp_util.GetAsFundamentalValue(prop, value_var, '&temp')) |
| + cpp_util.GetAsFundamentalValue( |
| + self._cpp_type_generator.GetReferencedProperty(prop), |
| + value_var, |
| + '&temp')) |
| .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));') |
| ) |
| else: |
| (c.Append('if (!%s)' % |
| cpp_util.GetAsFundamentalValue( |
| - prop, value_var, '&%s->%s' % (dst, prop.unix_name))) |
| + self._cpp_type_generator.GetReferencedProperty(prop), |
| + value_var, |
| + '&%s->%s' % (dst, prop.unix_name))) |
| .Append('return %(failure_value)s;') |
| ) |
| elif self._IsObjectOrObjectRef(prop): |
| @@ -657,3 +662,10 @@ class CCGenerator(object): |
| """ |
| return (self._cpp_type_generator.GetReferencedProperty(prop).type_ == |
| PropertyType.ARRAY) |
| + |
| + def _IsFundamentalOrFundamentalRef(self, prop): |
| + """Determines if this property is a Fundamental type or is a ref to a |
| + Fundamental type. |
| + """ |
| + return (self._cpp_type_generator.GetReferencedProperty(prop).type_ |
|
Yoyo Zhou
2012/05/01 00:21:58
nit: I'd put the dot on the first line
cduvall
2012/05/01 00:31:51
Done.
|
| + .is_fundamental) |