diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/json_schema_compiler/cc_generator.py | 17 | ||||
-rw-r--r-- | tools/json_schema_compiler/idl_schema.py | 2 |
2 files changed, 9 insertions, 10 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py index b8adaaf..3efad84 100644 --- a/tools/json_schema_compiler/cc_generator.py +++ b/tools/json_schema_compiler/cc_generator.py @@ -455,21 +455,16 @@ class CCGenerator(object): c = Code() c.Sblock('{') - if check_type and prop.type_ not in ( - PropertyType.CHOICES, PropertyType.ANY): - (c.Append('if (!%(value_var)s->IsType(%(value_type)s))') - .Append(' return %(failure_value)s;') - ) - if self._IsFundamentalOrFundamentalRef(prop): if prop.optional: (c.Append('%(ctype)s temp;') - .Append('if (%s)' % + .Append('if (!%s)' % cpp_util.GetAsFundamentalValue( self._cpp_type_generator.GetReferencedProperty(prop), value_var, '&temp')) - .Append(' %(dst)s->%(name)s.reset(new %(ctype)s(temp));') + .Append(' return %(failure_value)s;') + .Append('%(dst)s->%(name)s.reset(new %(ctype)s(temp));') ) else: (c.Append('if (!%s)' % @@ -477,7 +472,7 @@ class CCGenerator(object): self._cpp_type_generator.GetReferencedProperty(prop), value_var, '&%s->%s' % (dst, prop.unix_name))) - .Append('return %(failure_value)s;') + .Append(' return %(failure_value)s;') ) elif self._IsObjectOrObjectRef(prop): if prop.optional: @@ -551,7 +546,9 @@ class CCGenerator(object): # This is the same if the property is optional or not. We need a pointer # to the BinaryValue to be able to populate it, so a scoped_ptr is used # whether it is optional or required. - (c.Append('%(dst)s->%(name)s.reset(') + (c.Append('if (!%(value_var)s->IsType(%(value_type)s))') + .Append(' return %(failure_value)s;') + .Append('%(dst)s->%(name)s.reset(') .Append(' static_cast<BinaryValue*>(%(value_var)s)->DeepCopy());') ) else: diff --git a/tools/json_schema_compiler/idl_schema.py b/tools/json_schema_compiler/idl_schema.py index 3a7e6e4..087b2f4 100644 --- a/tools/json_schema_compiler/idl_schema.py +++ b/tools/json_schema_compiler/idl_schema.py @@ -161,6 +161,8 @@ class Typeref(object): properties['type'] = 'string' elif self.typeref == 'boolean': properties['type'] = 'boolean' + elif self.typeref == 'double': + properties['type'] = 'number' elif self.typeref == 'long': properties['type'] = 'integer' elif self.typeref == 'any': |