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

Unified Diff: mojo/public/bindings/generated/sample_service.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.h
diff --git a/mojo/public/bindings/generated/sample_service.h b/mojo/public/bindings/generated/sample_service.h
new file mode 100644
index 0000000000000000000000000000000000000000..b50e27c68e1c63bf3cd279d14ffd729ce027f4c9
--- /dev/null
+++ b/mojo/public/bindings/generated/sample_service.h
@@ -0,0 +1,95 @@
+// 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_GENERATED_BINDINGS_SAMPLE_SERVICE_H_
+#define MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_H_
+
+#include "mojo/public/bindings/bindings.h"
+
+namespace sample {
Ben Goodger (Google) 2013/09/28 21:15:29 this looks much better
+
+class Bar {
+ public:
+ Bar() {
+ header_.num_bytes = sizeof(*this);
+ header_.num_fields = 3;
+ }
+
+ void set_alpha(uint8_t alpha) { d_.alpha = alpha; }
+ void set_beta(uint8_t beta) { d_.beta = beta; }
+ void set_gamma(uint8_t gamma) { d_.gamma = gamma; }
+
+ uint8_t alpha() const { return d_.alpha; }
+ uint8_t beta() const { return d_.beta; }
+ uint8_t gamma() const { return d_.gamma; }
+
+ private:
+ friend class mojo::internal::Traits<Bar>;
+
+ mojo::StructHeader header_;
+ struct {
viettrungluu 2013/10/01 00:51:04 This is nice for debugging, but apart from that ar
+ uint8_t alpha;
+ uint8_t beta;
+ uint8_t gamma;
+ } d_;
+
+ ~Bar(); // NOT IMPLEMENTED
+};
+
+class Foo {
+ public:
+ Foo() {
+ header_.num_bytes = sizeof(*this);
+ header_.num_fields = 8;
+ }
+
+ void set_x(int32_t x) { d_.x = x; }
+ void set_y(int32_t y) { d_.y = y; }
+ void set_a(bool a) { d_.a = a; }
+ void set_b(bool b) { d_.b = b; }
+ void set_c(bool c) { d_.c = c; }
+ void set_bar(Bar* bar) { d_.bar.ptr = bar; }
+ void set_data(mojo::Array<uint8_t>* data) { d_.data.ptr = data; }
+ void set_extra_bars(mojo::Array<Bar*>* extra_bars) {
+ d_.extra_bars.ptr = extra_bars;
+ }
+
+ int32_t x() const { return d_.x; }
+ int32_t y() const { return d_.y; }
+ bool a() const { return d_.a; }
+ bool b() const { return d_.b; }
+ bool c() const { return d_.c; }
+ const Bar* bar() const { return d_.bar.ptr; }
viettrungluu 2013/10/01 00:51:04 Would there be value in also have a (non-const) |B
+ const mojo::Array<uint8_t>* data() const { return d_.data.ptr; }
+ const mojo::Array<Bar*>* extra_bars() const {
+ // NOTE: extra_bars is an optional field!
+ return header_.num_fields >= 8 ? d_.extra_bars.ptr : NULL;
+ }
+
+ private:
+ friend class mojo::internal::Traits<Foo>;
+
+ mojo::StructHeader header_;
+ struct {
+ int32_t x;
+ int32_t y;
+ uint32_t a : 1;
+ uint32_t b : 1;
+ uint32_t c : 1;
+ mojo::StructPointer<Bar> bar;
+ mojo::ArrayPointer<uint8_t> data;
+ mojo::ArrayPointer<Bar*> extra_bars;
+ } d_;
+
+ ~Foo(); // NOT IMPLEMENTED
+};
+
+class Service {
+ public:
+ virtual void Frobinate(const Foo* foo, bool baz) = 0;
+};
+
+} // namespace sample
+
+#endif // MOJO_GENERATED_BINDINGS_SAMPLE_SERVICE_H_

Powered by Google App Engine
This is Rietveld 408576698