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

Side by Side Diff: examples/c/echo_client/echo_client.c

Issue 2229573002: Change the canonical way to include the C macros.h to <mojo/macros.h>. (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 | « examples/c/echo_client/BUILD.gn ('k') | mojo/edk/platform/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Here is an example of the echo client using C bindings. This example avoids 5 // Here is an example of the echo client using C bindings. This example avoids
6 // making any dynamic allocations and uses the stack entirely by wildly 6 // making any dynamic allocations and uses the stack entirely by wildly
7 // reserving a stack buffer, and foregoing any size-computation and copying. 7 // reserving a stack buffer, and foregoing any size-computation and copying.
8 // Using it this way essentially requires the programmer to know the mojom 8 // Using it this way essentially requires the programmer to know the mojom
9 // encoding order and can be error-prone, but fast. 9 // encoding order and can be error-prone, but fast.
10 10
11 #include <assert.h> 11 #include <assert.h>
12 #include <mojo/macros.h>
12 #include <stdio.h> 13 #include <stdio.h>
13 #include <string.h> 14 #include <string.h>
14 15
15 #include "examples/echo/echo.mojom-c.h" 16 #include "examples/echo/echo.mojom-c.h"
16 #include "mojo/public/c/bindings/buffer.h" 17 #include "mojo/public/c/bindings/buffer.h"
17 #include "mojo/public/c/bindings/message.h" 18 #include "mojo/public/c/bindings/message.h"
18 #include "mojo/public/c/system/macros.h"
19 #include "mojo/public/c/system/main.h" 19 #include "mojo/public/c/system/main.h"
20 #include "mojo/public/c/system/message_pipe.h" 20 #include "mojo/public/c/system/message_pipe.h"
21 #include "mojo/public/c/system/result.h" 21 #include "mojo/public/c/system/result.h"
22 #include "mojo/public/c/system/wait.h" 22 #include "mojo/public/c/system/wait.h"
23 #include "mojo/public/interfaces/application/application.mojom-c.h" 23 #include "mojo/public/interfaces/application/application.mojom-c.h"
24 #include "mojo/public/interfaces/application/application_connector.mojom-c.h" 24 #include "mojo/public/interfaces/application/application_connector.mojom-c.h"
25 #include "mojo/public/interfaces/application/shell.mojom-c.h" 25 #include "mojo/public/interfaces/application/shell.mojom-c.h"
26 26
27 // To avoid dynamic allocations, we reserve this much space as an upper-bound 27 // To avoid dynamic allocations, we reserve this much space as an upper-bound
28 // for allocating mojo messages on the stack. This space is meant to be consumed 28 // for allocating mojo messages on the stack. This space is meant to be consumed
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
373 MojoHandle echo_service_h = 373 MojoHandle echo_service_h =
374 connect_to_service(echo_sp_h, mojo_examples_Echo__ServiceName, 374 connect_to_service(echo_sp_h, mojo_examples_Echo__ServiceName,
375 strlen(mojo_examples_Echo__ServiceName)); 375 strlen(mojo_examples_Echo__ServiceName));
376 376
377 // 5) Call into the echo service. 377 // 5) Call into the echo service.
378 const char kEchoMsg[] = "Hello world!"; 378 const char kEchoMsg[] = "Hello world!";
379 call_echo(echo_service_h, kEchoMsg, strlen(kEchoMsg)); 379 call_echo(echo_service_h, kEchoMsg, strlen(kEchoMsg));
380 380
381 return MOJO_RESULT_OK; 381 return MOJO_RESULT_OK;
382 } 382 }
OLDNEW
« no previous file with comments | « examples/c/echo_client/BUILD.gn ('k') | mojo/edk/platform/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698