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

Unified Diff: mojo/public/bindings/generated/sample_service_internal.h

Issue 23913008: C++ bindings (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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/generated/sample_service_internal.h
diff --git a/mojo/public/bindings/generated/sample_service_internal.h b/mojo/public/bindings/generated/sample_service_internal.h
new file mode 100644
index 0000000000000000000000000000000000000000..9ba4131d5189637d55b7c91ebaf7ca9dc2a455b7
--- /dev/null
+++ b/mojo/public/bindings/generated/sample_service_internal.h
@@ -0,0 +1,124 @@
+#ifndef MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_INTERNAL_H_
+#define MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_INTERNAL_H_
+
+#include <string.h>
+
+#include "mojo/public/bindings/bindings_internal.h"
+#include "mojo/public/bindings/generated/sample_service.h"
+
+namespace sample {
+namespace internal {
+
+const uint32_t kService_Frobinate_Name = 1;
+
+class Service_Frobinate_Params {
+ public:
+ Service_Frobinate_Params() {
+ header_.num_bytes = sizeof(*this);
+ header_.num_fields = 2;
+ }
+
+ void set_foo(Foo* foo) { d_.foo.ptr = foo; }
+ void set_baz(bool baz) { d_.baz = baz; }
+
+ const Foo* foo() const { return d_.foo.ptr; }
+ bool baz() const { return d_.baz; }
+
+ private:
+ friend class mojo::internal::Traits<Service_Frobinate_Params>;
+
+ mojo::StructHeader header_;
+ struct {
+ mojo::StructPointer<Foo> foo;
+ uint32_t baz : 1;
+ } d_;
+
+ ~Service_Frobinate_Params(); // NOT IMPLEMENTED
+};
+
+} // namespace internal
+} // namespace sample
+
+namespace mojo {
+namespace internal {
+
+template <>
+class Traits<sample::Bar> {
+ public:
+ static sample::Bar* Clone(const sample::Bar* bar, mojo::MessageBuffer* buf) {
+ sample::Bar* clone = buf->Alloc<sample::Bar>();
+ memcpy(clone, bar, sizeof(*bar));
+ return clone;
+ }
+
+ static void EncodePointersAndHandles(sample::Bar* bar,
+ std::vector<mojo::Handle>* handles) {
+ }
+
+ static bool DecodePointersAndHandles(sample::Bar* bar,
+ const mojo::Message& message) {
+ return true;
+ }
+};
+
+template <>
+class Traits<sample::Foo> {
+ public:
+ static sample::Foo* Clone(const sample::Foo* foo, mojo::MessageBuffer* buf) {
+ sample::Foo* clone = buf->Alloc<sample::Foo>();
+ memcpy(clone, foo, sizeof(*foo));
+
+ clone->set_bar(mojo::internal::Clone(foo->bar(), buf));
+ clone->set_data(mojo::internal::Clone(foo->data(), buf));
+ clone->set_extra_bars(mojo::internal::Clone(foo->extra_bars(), buf));
+
+ return clone;
+ }
+
+ static void EncodePointersAndHandles(sample::Foo* foo,
+ std::vector<mojo::Handle>* handles) {
+ Encode(&foo->d_.bar, handles);
+ Encode(&foo->d_.data, handles);
+ Encode(&foo->d_.extra_bars, handles);
+ }
+
+ static bool DecodePointersAndHandles(sample::Foo* foo,
+ const mojo::Message& message) {
+ if (!Decode(&foo->d_.bar, message))
+ return false;
+ if (!Decode(&foo->d_.data, message))
+ return false;
+ if (foo->header_.num_fields >= 8) {
+ if (!Decode(&foo->d_.extra_bars, message))
+ return false;
+ }
+
+ // TODO: validate
+ return true;
+ }
+};
+
+template <>
+class Traits<sample::internal::Service_Frobinate_Params> {
+ public:
+ static void EncodePointersAndHandles(
+ sample::internal::Service_Frobinate_Params* params,
+ std::vector<mojo::Handle>* handles) {
+ Encode(&params->d_.foo, handles);
+ }
+
+ static bool DecodePointersAndHandles(
+ sample::internal::Service_Frobinate_Params* params,
+ const mojo::Message& message) {
+ if (!Decode(&params->d_.foo, message))
+ return false;
+
+ // TODO: validate
+ return true;
+ }
+};
+
+} // namespace internal
+} // namespace mojo
+
+#endif // MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_INTERNAL_H_

Powered by Google App Engine
This is Rietveld 408576698