| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 define("mojo/public/js/bindings/validator", [ | 5 define("mojo/public/js/bindings/validator", [ |
| 6 "mojo/public/js/bindings/codec", | 6 "mojo/public/js/bindings/codec", |
| 7 ], function(codec) { | 7 ], function(codec) { |
| 8 | 8 |
| 9 var validationError = { | 9 var validationError = { |
| 10 NONE: 'VALIDATION_ERROR_NONE', | 10 NONE: 'VALIDATION_ERROR_NONE', |
| (...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 if (structOffset === null) | 181 if (structOffset === null) |
| 182 return validationError.ILLEGAL_POINTER; | 182 return validationError.ILLEGAL_POINTER; |
| 183 | 183 |
| 184 if (structOffset === NULL_MOJO_POINTER) | 184 if (structOffset === NULL_MOJO_POINTER) |
| 185 return nullable ? | 185 return nullable ? |
| 186 validationError.NONE : validationError.UNEXPECTED_NULL_POINTER; | 186 validationError.NONE : validationError.UNEXPECTED_NULL_POINTER; |
| 187 | 187 |
| 188 return structClass.validate(this, structOffset); | 188 return structClass.validate(this, structOffset); |
| 189 } | 189 } |
| 190 | 190 |
| 191 Validator.prototype.validateStringPointer = function(offset) { | 191 Validator.prototype.validateStringPointer = function(offset, nullable) { |
| 192 return this.validateArrayPointer( | 192 return this.validateArrayPointer( |
| 193 offset, codec.Uint8.encodedSize, 0, codec.Uint8); | 193 offset, codec.Uint8.encodedSize, 0, codec.Uint8, nullable); |
| 194 } | 194 } |
| 195 | 195 |
| 196 // Similar to Array_Data<T>::Validate() | 196 // Similar to Array_Data<T>::Validate() |
| 197 // mojo/public/cpp/bindings/lib/array_internal.h | 197 // mojo/public/cpp/bindings/lib/array_internal.h |
| 198 | 198 |
| 199 Validator.prototype.validateArray = | 199 Validator.prototype.validateArray = |
| 200 function (offset, elementSize, expectedElementCount, elementType) { | 200 function (offset, elementSize, expectedElementCount, elementType) { |
| 201 if (!codec.isAligned(offset)) | 201 if (!codec.isAligned(offset)) |
| 202 return validationError.MISALIGNED_OBJECT; | 202 return validationError.MISALIGNED_OBJECT; |
| 203 | 203 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 return err; | 282 return err; |
| 283 } | 283 } |
| 284 return validationError.NONE; | 284 return validationError.NONE; |
| 285 } | 285 } |
| 286 | 286 |
| 287 var exports = {}; | 287 var exports = {}; |
| 288 exports.validationError = validationError; | 288 exports.validationError = validationError; |
| 289 exports.Validator = Validator; | 289 exports.Validator = Validator; |
| 290 return exports; | 290 return exports; |
| 291 }); | 291 }); |
| OLD | NEW |