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

Unified Diff: mojo/public/cpp/bindings/array_traits_carray.h

Issue 2379993003: Mojo C++ bindings: make String16 and gfx::Size available in Blink (Closed)
Patch Set: mapping back to WebSize :( Created 4 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
« no previous file with comments | « mojo/common/test_common_custom_types.mojom ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: mojo/public/cpp/bindings/array_traits_carray.h
diff --git a/mojo/public/cpp/bindings/array_traits_carray.h b/mojo/public/cpp/bindings/array_traits_carray.h
index ffcf9d585568c7808bb5fb12c01c1f4865106b81..3ff694b88217532cf21e25cc36523148059589ac 100644
--- a/mojo/public/cpp/bindings/array_traits_carray.h
+++ b/mojo/public/cpp/bindings/array_traits_carray.h
@@ -20,6 +20,14 @@ struct CArray {
};
template <typename T>
+struct ConstCArray {
+ ConstCArray() : size(0), data(nullptr) {}
+ ConstCArray(size_t size, const T* data) : size(size), data(data) {}
+ size_t size;
+ const T* data;
+};
+
+template <typename T>
struct ArrayTraits<CArray<T>> {
using Element = T;
@@ -48,6 +56,21 @@ struct ArrayTraits<CArray<T>> {
}
};
+template <typename T>
+struct ArrayTraits<ConstCArray<T>> {
+ using Element = T;
+
+ static bool IsNull(const ConstCArray<T>& input) { return !input.data; }
+
+ static size_t GetSize(const ConstCArray<T>& input) { return input.size; }
+
+ static const T* GetData(const ConstCArray<T>& input) { return input.data; }
+
+ static const T& GetAt(const ConstCArray<T>& input, size_t index) {
+ return input.data[index];
+ }
+};
+
} // namespace mojo
#endif // MOJO_PUBLIC_CPP_BINDINGS_ARRAY_TRAITS_CARRAY_H_
« no previous file with comments | « mojo/common/test_common_custom_types.mojom ('k') | third_party/WebKit/Source/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698