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

Side by Side Diff: mojo/public/rust/src/lib.rs

Issue 2250183003: Make the fuchsia mojo/public repo the source of truth. (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « mojo/public/rust/src/bindings/util.rs ('k') | mojo/public/rust/src/system/core.rs » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #[macro_use]
6 mod macros {
7 /// This macro must be used at the top-level in any
8 /// Rust Mojo application. It defines and abstracts away the
9 /// hook needed by Mojo in order to set up the basic
10 /// functionality (see mojo::system::ffi). It must take the
11 /// name of a function who returns a MojoResult and takes
12 /// exactly one argument: a mojo::handle::Handle, or on in
13 /// other words, an untyped handle.
14 #[macro_export]
15 macro_rules! set_mojo_main {
16 ( $fn_main:ident ) => {
17 #[allow(bad_style)]
18 #[no_mangle]
19 pub fn MojoMain(app_request_handle: mojo::system::MojoHandle) -> moj o::MojoResult
20 {
21 use std::panic;
22 use mojo::system::CastHandle;
23 let handle = unsafe {
24 mojo::system::message_pipe::MessageEndpoint::from_untyped(
25 mojo::system::acquire(app_request_handle)
26 )
27 };
28 let result = panic::catch_unwind(|| {
29 $fn_main(handle)
30 });
31 match result {
32 Ok(value) => value,
33 Err(_) => {
34 mojo::MojoResult::Aborted
35 },
36 }
37 }
38 }
39 }
40
41 /// This macro assists in generating flags for
42 /// functions and methods found in mojo::system::message_pipe.
43 ///
44 /// See mojo::system::message_pipe for the available flags
45 /// that may be passed.
46 ///
47 /// # Examples
48 ///
49 /// # mpflags!(Create::None);
50 /// # mpflags!(Read::MayDiscard);
51 #[macro_export]
52 macro_rules! mpflags {
53 ( $( $flag:path ),* ) => {{
54 use $crate::system::message_pipe::*;
55 $(
56 ($flag as u32)
57 )|*
58 }}
59 }
60
61 /// This macro assists in generating flags for
62 /// functions and methods found in mojo::system::data_pipe.
63 ///
64 /// See mojo::system::data_pipe for the available flags
65 /// that may be passed.
66 ///
67 /// # Examples
68 ///
69 /// # dpflags!(Create::None);
70 /// # dpflags!(Read::AllOrNone, Read::Discard);
71 #[macro_export]
72 macro_rules! dpflags {
73 ( $( $flag:path ),* ) => {{
74 use $crate::system::data_pipe::*;
75 $(
76 ($flag as u32)
77 )|*
78 }}
79 }
80
81 /// This macro assists in generating flags for
82 /// functions and methods found in mojo::system::shared_buffer.
83 ///
84 /// See mojo::system::shared_buffer for the available flags
85 /// that may be passed.
86 ///
87 /// # Examples
88 ///
89 /// # sbflags!(Create::None);
90 /// # sbflags!(Map::None);
91 #[macro_export]
92 macro_rules! sbflags {
93 ( $( $flag:path ),* ) => {{
94 use $crate::system::shared_buffer::*;
95 $(
96 ($flag as u32)
97 )|*
98 }}
99 }
100
101 /// This macro assists in generating flags for
102 /// functions and methods found in mojo::system::wait_set.
103 ///
104 /// See mojo::system::wait_set for the available flags
105 /// that may be passed.
106 ///
107 /// # Examples
108 ///
109 /// # wsflags!(Create::None);
110 /// # wsflags!(Add::None);
111 #[macro_export]
112 macro_rules! wsflags {
113 ( $( $flag:path ),* ) => {{
114 use $crate::system::wait_set::*;
115 $(
116 ($flag as u32)
117 )|*
118 }}
119 }
120
121 /// This macro assists in generating MojoSignals to be
122 /// used in wait() and wait_many(), part of mojo::system::core.
123 ///
124 /// See mojo::system::handle for the available signals
125 /// that may be checked for by wait() and wait_many().
126 ///
127 /// # Examples
128 ///
129 /// # signals!(Signals::Readable, Signals::Writable);
130 /// # signals!(Signals::PeerClosed);
131 #[macro_export]
132 macro_rules! signals {
133 ( $( $flag:path ),* ) => {{
134 use $crate::system::Signals;
135 $crate::system::HandleSignals::new(
136 $(
137 ($flag as u32)
138 )|*
139 )
140 }}
141 }
142 }
143
144 #[macro_use]
145 pub mod bindings;
146 pub mod system;
147
148 pub use system::MojoResult;
OLDNEW
« no previous file with comments | « mojo/public/rust/src/bindings/util.rs ('k') | mojo/public/rust/src/system/core.rs » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698