Chromium Code Reviews| Index: mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl |
| diff --git a/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl b/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl |
| index ad30fb72f4ddfa5633df7ccefb07ffa570c53898..464daf45029708fb89c0c30b18f2b909dcf837db 100644 |
| --- a/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl |
| +++ b/mojo/public/tools/bindings/generators/cpp_templates/union_definition.tmpl |
| @@ -7,9 +7,11 @@ |
| return new (buf->Allocate(sizeof({{class_name}}))) {{class_name}}(); |
| } |
| + |
|
yzshen1
2015/02/17 19:34:35
unnecessary empty line.
azani
2015/02/18 00:27:58
Done.
|
| // static |
| bool {{class_name}}::Validate(const void* data, |
| - mojo::internal::BoundsChecker* bounds_checker) { |
| + mojo::internal::BoundsChecker* bounds_checker, |
| + bool claim_memory) { |
| if (!data) { |
| return true; |
| } |
| @@ -19,7 +21,9 @@ bool {{class_name}}::Validate(const void* data, |
| return false; |
| } |
| - if (!bounds_checker->ClaimMemory(data, sizeof({{class_name}}))) { |
| + // If the union is inlined in another structure its memory was already claimed. |
|
yzshen1
2015/02/17 19:34:35
nit: I understand 80-char limit is not honored in
azani
2015/02/18 00:27:57
Done.
|
| + // This ONLY applies to the union itself, NOT anything which the union points to. |
| + if (claim_memory && !bounds_checker->ClaimMemory(data, sizeof({{class_name}}))) { |
|
yzshen1
2015/02/17 19:34:35
For non-inlined case, we need to check that the fi
|
| ReportValidationError( |
| mojo::internal::VALIDATION_ERROR_ILLEGAL_MEMORY_RANGE); |
| return false; |