| OLD | NEW |
| (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 import 'dart/myapi_service.dart'; | |
| 6 import '../myapi_impl.dart' as impl; | |
| 7 | |
| 8 class ApiService { | |
| 9 final Map<int, List> objects = {}; | |
| 10 | |
| 11 int create() { | |
| 12 int api = objects.length; | |
| 13 objects[api] = new List(); | |
| 14 return api; | |
| 15 } | |
| 16 | |
| 17 void destroy(int api) { | |
| 18 objects[api].clear(); | |
| 19 } | |
| 20 | |
| 21 int register(int api, Object o) { | |
| 22 List list = objects[api]; | |
| 23 int index = list.indexOf(o); | |
| 24 if (index >= 0) return index; | |
| 25 index = list.length; | |
| 26 list.add(o); | |
| 27 return index; | |
| 28 } | |
| 29 } | |
| 30 | |
| 31 class MyApiServiceImpl extends ApiService implements MyApiService { | |
| 32 int foo(int api) { | |
| 33 impl.MyObject result = impl.foo(); | |
| 34 return register(api, result); | |
| 35 } | |
| 36 | |
| 37 void MyObject_funk(int api, int id, int o) { | |
| 38 impl.MyObject object = objects[api][id]; | |
| 39 object.funk(objects[api][o]); | |
| 40 } | |
| 41 } | |
| 42 | |
| 43 void main() { | |
| 44 var impl = new MyApiServiceImpl(); | |
| 45 MyApiService.initialize(impl); | |
| 46 while (MyApiService.hasNextEvent()) { | |
| 47 MyApiService.handleNextEvent(); | |
| 48 } | |
| 49 } | |
| OLD | NEW |