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

Side by Side Diff: samples/todomvc/cc/todomvc_presenter.cc

Issue 2035023003: Remove service-compiler related code. (Closed) Base URL: git@github.com:dartino/sdk.git@master
Patch Set: Created 4 years, 6 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/todomvc/cc/todomvc_presenter.h ('k') | samples/todomvc/dart/presentation_graph.dart » ('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 Dartino 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 #include "todomvc_presenter.h"
6
7 void VoidCallback(void*) {}
8
9 void TodoMVCPresenter::createItem(char* title) {
10 int length = 0;
11 while (title[length] != '\0') ++length;
12 int size = 56 + BoxedStringBuilder::kSize + length;
13 MessageBuilder builder(size);
14 BoxedStringBuilder box = builder.initRoot<BoxedStringBuilder>();
15 box.setStr(title);
16 TodoMVCService::createItemAsync(box, VoidCallback, NULL);
17 }
18
19 void TodoMVCPresenter::clearItems() {
20 TodoMVCService::clearItemsAsync(VoidCallback, NULL);
21 }
22
23 void TodoMVCPresenter::dispatch(event id) {
24 TodoMVCService::dispatchAsync(id, VoidCallback, NULL);
25 }
26
27 void TodoMVCPresenter::sync() {
28 // Assuming a synchronous call will flush outstanding asynchronous calls.
29 applyPatches(TodoMVCService::sync());
30 }
31
32 void TodoMVCPresenter::applyPatches(const PatchSet& patch_set) {
33 List<Patch> patches = patch_set.getPatches();
34 for (int i = 0; i < patches.length(); ++i) {
35 applyPatch(patches[i]);
36 }
37 }
38
39 void TodoMVCPresenter::applyPatch(const Patch& patch) {
40 enterPatch();
41 List<uint8_t> path = patch.getPath();
42 for (int i = 0; i < path.length(); ++i) {
43 switch (path[i]) {
44 case TAG_CONS_FST: enterConsFst(); break;
45 case TAG_CONS_SND: enterConsSnd(); break;
46 case TAG_CONS_DELETE_EVENT: enterConsDeleteEvent(); break;
47 case TAG_CONS_COMPLETE_EVENT: enterConsCompleteEvent(); break;
48 case TAG_CONS_UNCOMPLETE_EVENT: enterConsUncompleteEvent(); break;
49 default: abort();
50 }
51 }
52 updateNode(patch.getContent());
53 }
OLDNEW
« no previous file with comments | « samples/todomvc/cc/todomvc_presenter.h ('k') | samples/todomvc/dart/presentation_graph.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698