Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(232)

Unified Diff: mojo/public/cpp/bindings/lib/array_internal.h

Issue 611633002: mojom: Add associative arrays to the mojom language. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Suppress pylint warnings instead of making MapKind public. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/cpp/bindings/lib/array_internal.h
diff --git a/mojo/public/cpp/bindings/lib/array_internal.h b/mojo/public/cpp/bindings/lib/array_internal.h
index ded07b9e1c3939a3a36574a9f75abd77c48a7a8e..d3722afbb46fd4304a9f92af1b0af81afbce3f6e 100644
--- a/mojo/public/cpp/bindings/lib/array_internal.h
+++ b/mojo/public/cpp/bindings/lib/array_internal.h
@@ -13,7 +13,9 @@
#include "mojo/public/cpp/bindings/lib/bindings_serialization.h"
#include "mojo/public/cpp/bindings/lib/bounds_checker.h"
#include "mojo/public/cpp/bindings/lib/buffer.h"
+#include "mojo/public/cpp/bindings/lib/map_data_internal.h"
#include "mojo/public/cpp/bindings/lib/template_util.h"
+#include "mojo/public/cpp/bindings/lib/validate_params.h"
#include "mojo/public/cpp/bindings/lib/validation_errors.h"
#include "mojo/public/cpp/environment/logging.h"
@@ -141,26 +143,6 @@ struct ArrayDataTraits<bool> {
}
};
-// Array type information needed for valdiation.
-template <uint32_t in_expected_num_elements,
- bool in_element_is_nullable,
- typename InElementValidateParams>
-class ArrayValidateParams {
- public:
- // Validation information for elements. It is either another specialization of
- // ArrayValidateParams (if elements are arrays) or NoValidateParams.
- typedef InElementValidateParams ElementValidateParams;
-
- // If |expected_num_elements| is not 0, the array is expected to have exactly
- // that number of elements.
- static const uint32_t expected_num_elements = in_expected_num_elements;
- // Whether the elements are nullable.
- static const bool element_is_nullable = in_element_is_nullable;
-};
-
-// NoValidateParams is used to indicate the end of an ArrayValidateParams chain.
-class NoValidateParams {};
-
// What follows is code to support the serialization of Array_Data<T>. There
// are two interesting cases: arrays of primitives and arrays of objects.
// Arrays of objects are represented as arrays of pointers to objects.
@@ -313,6 +295,14 @@ struct ArraySerializationHelper<P*, false> {
}
};
+ template <typename Key, typename Value, typename Params>
+ struct ValidateCaller<Map_Data<Key, Value>, Params> {
+ static bool Run(const void* data, BoundsChecker* bounds_checker) {
+ return Map_Data<Key, Value>::template Validate<Params>(data,
+ bounds_checker);
+ }
+ };
+
template <typename T, typename Params>
struct ValidateCaller<Array_Data<T>, Params> {
static bool Run(const void* data, BoundsChecker* bounds_checker) {
@@ -383,6 +373,8 @@ class Array_Data {
size_t size() const { return header_.num_elements; }
+ const internal::ArrayHeader& header() { return header_; }
+
Ref at(size_t offset) {
MOJO_DCHECK(offset < static_cast<size_t>(header_.num_elements));
return Traits::ToRef(storage(), offset);

Powered by Google App Engine
This is Rietveld 408576698