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

Unified Diff: mojo/public/bindings/lib/bindings_internal.h

Issue 27034003: Mojo C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compilation issue on Official Linux builder Created 7 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/bindings/lib/bindings_internal.h
diff --git a/mojo/public/bindings/lib/bindings_internal.h b/mojo/public/bindings/lib/bindings_internal.h
new file mode 100644
index 0000000000000000000000000000000000000000..f6e7eb272657d35ecee0f0602948b5a5000784d8
--- /dev/null
+++ b/mojo/public/bindings/lib/bindings_internal.h
@@ -0,0 +1,63 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_
+#define MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_
+
+#include <stdint.h>
+
+namespace mojo {
+template <typename T> class Array;
+
+namespace internal {
+
+struct StructHeader {
+ uint32_t num_bytes;
+ uint32_t num_fields;
+};
+
+struct ArrayHeader {
+ uint32_t num_bytes;
+ uint32_t num_elements;
+};
+
+template <typename T>
+union StructPointer {
+ uint64_t offset;
+ T* ptr;
+};
+
+template <typename T>
+union ArrayPointer {
+ uint64_t offset;
+ Array<T>* ptr;
+};
+
+union StringPointer {
+ uint64_t offset;
+ Array<char>* ptr;
+};
+
+template <typename T>
+struct ArrayTraits {
+ typedef T StorageType;
+
+ static T& ToRef(StorageType& e) { return e; }
+ static T const& ToConstRef(const StorageType& e) { return e; }
+};
+
+template <typename P>
+struct ArrayTraits<P*> {
+ typedef StructPointer<P> StorageType;
+
+ static P*& ToRef(StorageType& e) { return e.ptr; }
+ static P* const& ToConstRef(const StorageType& e) { return e.ptr; }
+};
+
+template <typename T> class ObjectTraits {};
+
+} // namespace internal
+} // namespace mojo
+
+#endif // MOJO_PUBLIC_BINDINGS_LIB_BINDINGS_INTERNAL_H_

Powered by Google App Engine
This is Rietveld 408576698