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

Side by Side Diff: samples/myapi/generated/myapi.h

Issue 1209033003: Work in progres, please take a look and give early feedback if this is the way we want to structure… (Closed) Base URL: git@github.com:dart-lang/fletch.git@master
Patch Set: address comments Created 5 years, 5 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 | « samples/myapi/generated/dart/struct.dart ('k') | samples/myapi/generated/myapi_service.idl » ('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 (c) 2015, the Fletch project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE.md file.
4
5 #ifndef MYAPI_H_
6 #define MYAPI_H_
7
8 #include "cc/myapi_service.h"
9
10 class MyObject;
11
12 class MyApi {
13 public:
14 static MyApi create() {
15 MyApiService::setup();
16 int api = MyApiService::create();
17 return MyApi(api);
18 }
19
20 void destroy() {
21 MyApiService::destroy(api_);
22 MyApiService::tearDown();
23 }
24
25 inline MyObject foo();
26
27 private:
28 int api_;
29
30 explicit MyApi(int api) : api_(api) { }
31 };
32
33 class MyObject {
34 public:
35 void funk(MyObject o) {
36 // TODO(kasperl): Assert that o is from same api as 'this'.
37 MyApiService::MyObject_funk(api_, id_, o.id_);
38 }
39
40 private:
41 int api_;
42 int id_;
43
44 MyObject(int api, int id) : api_(api), id_(id) { }
45
46 friend class MyApi;
47 };
48
49 inline MyObject MyApi::foo() {
50 int id = MyApiService::foo(api_);
51 return MyObject(api_, id);
52 }
53
54 #endif // MYAPI_H_
OLDNEW
« no previous file with comments | « samples/myapi/generated/dart/struct.dart ('k') | samples/myapi/generated/myapi_service.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698