summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authormseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 01:37:19 +0000
committermseaborn@chromium.org <mseaborn@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-07-20 01:37:19 +0000
commit76f6334342185167a22d829990103e7361c2f8d1 (patch)
tree1a9b7d2331e7b4e44330954c6b54c1fa4d5578a4 /tools
parent7a376e31c7da59b7ac08e7d10941e74d371f6963 (diff)
downloadchromium_src-76f6334342185167a22d829990103e7361c2f8d1.zip
chromium_src-76f6334342185167a22d829990103e7361c2f8d1.tar.gz
chromium_src-76f6334342185167a22d829990103e7361c2f8d1.tar.bz2
NaCl: Remove two uses of '#include "nacl/nacl_log.h"'
We should be using the full path for nacl_log.h, because it shouldn't be installed into the NaCl SDK. BUG=http://code.google.com/p/nativeclient/issues/detail?id=2908 TEST=build Review URL: https://chromiumcodereview.appspot.com/10804034 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@147594 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'tools')
-rw-r--r--tools/json_schema_compiler/cc_generator.py26
-rw-r--r--tools/json_schema_compiler/cpp_type_generator.py9
2 files changed, 15 insertions, 20 deletions
diff --git a/tools/json_schema_compiler/cc_generator.py b/tools/json_schema_compiler/cc_generator.py
index 770ae48..d21e160 100644
--- a/tools/json_schema_compiler/cc_generator.py
+++ b/tools/json_schema_compiler/cc_generator.py
@@ -355,12 +355,7 @@ class CCGenerator(object):
elif prop.type_ == PropertyType.ENUM:
return 'CreateEnumValue(%s).release()' % var
elif prop.type_ == PropertyType.BINARY:
- if prop.optional:
- vardot = var + '->'
- else:
- vardot = var + '.'
- return ('base::BinaryValue::CreateWithCopiedBuffer(%sdata(), %ssize())' %
- (vardot, vardot))
+ return '%s->DeepCopy()' % var
elif self._IsArrayOrArrayRef(prop):
return '%s.release()' % self._util_cc_helper.CreateValueFromArray(
self._cpp_type_generator.GetReferencedProperty(prop), var,
@@ -547,20 +542,15 @@ class CCGenerator(object):
c.Append('%(dst)s->%(name)s = enum_temp;')
c.Eblock('}')
elif prop.type_ == PropertyType.BINARY:
+ # This is the same if the property is optional or not. We need a pointer
+ # to the base::BinaryValue to be able to populate it, so a scoped_ptr is
+ # used whether it is optional or required.
(c.Append('if (!%(value_var)s->IsType(%(value_type)s))')
.Append(' return %(failure_value)s;')
- .Append('base::BinaryValue* binary_value =')
- .Append(' static_cast<base::BinaryValue*>(%(value_var)s);')
- )
- if prop.optional:
- (c.Append('%(dst)s->%(name)s.reset(')
- .Append(' new std::string(binary_value->GetBuffer(),')
- .Append(' binary_value->GetSize()));')
- )
- else:
- (c.Append('%(dst)s->%(name)s.assign(binary_value->GetBuffer(),')
- .Append(' binary_value->GetSize());')
- )
+ .Append('%(dst)s->%(name)s.reset(')
+ .Append(' static_cast<base::BinaryValue*>(%(value_var)s)'
+ '->DeepCopy());')
+ )
else:
raise NotImplementedError(prop.type_)
c.Eblock('}')
diff --git a/tools/json_schema_compiler/cpp_type_generator.py b/tools/json_schema_compiler/cpp_type_generator.py
index f398c75..5b54bae 100644
--- a/tools/json_schema_compiler/cpp_type_generator.py
+++ b/tools/json_schema_compiler/cpp_type_generator.py
@@ -127,6 +127,7 @@ class CppTypeGenerator(object):
optional.
"""
cpp_type = None
+ force_wrapping = False
if prop.type_ == PropertyType.REF:
dependency_namespace = self._ResolveTypeNamespace(prop.ref_type)
if not dependency_namespace:
@@ -164,13 +165,17 @@ class CppTypeGenerator(object):
cpp_type = cpp_type % self.GetType(
prop.item_type, pad_for_generics=True)
elif prop.type_ == PropertyType.BINARY:
- cpp_type = 'std::string'
+ # Since base::BinaryValue's are immutable, we wrap them in a scoped_ptr to
+ # allow them to be modified after the fact.
+ force_wrapping = True
+ cpp_type = 'base::BinaryValue'
else:
raise NotImplementedError(prop.type_)
# Enums aren't wrapped because C++ won't allow it. Optional enums have a
# NONE value generated instead.
- if wrap_optional and prop.optional and prop.type_ != PropertyType.ENUM:
+ if force_wrapping or (wrap_optional and prop.optional and prop.type_ !=
+ PropertyType.ENUM):
cpp_type = 'scoped_ptr<%s> ' % cpp_type
if pad_for_generics:
return cpp_type