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

Side by Side Diff: tools/servicec/lib/src/resources/java/dartino/Segment.java

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
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 package dartino;
6
7 import java.nio.ByteBuffer;
8 import java.nio.ByteOrder;
9
10 class Segment {
11 public Segment(byte[] memory) {
12 buffer = ByteBuffer.wrap(memory);
13 buffer.order(ByteOrder.LITTLE_ENDIAN);
14 }
15
16 public Segment(MessageReader reader, byte[] memory) {
17 buffer = ByteBuffer.wrap(memory);
18 buffer.order(ByteOrder.LITTLE_ENDIAN);
19 this.reader = reader;
20 }
21
22 public ByteBuffer buffer() { return buffer; }
23 public MessageReader reader() { return reader; }
24
25 public boolean getBoolean(int offset) {
26 return buffer.get(offset) != 0;
27 }
28
29 public short getUnsigned(int offset) {
30 short result = (short)buffer.get(offset);
31 return (short)Math.abs(result);
32 }
33
34 public int getUnsignedChar(int offset) {
35 int result = (int)buffer.getChar(offset);
36 return (int)Math.abs(result);
37 }
38
39 public long getUnsignedInt(int offset) {
40 long result = (long)buffer.getInt(offset);
41 return (long)Math.abs(result);
42 }
43
44 private ByteBuffer buffer;
45 private MessageReader reader;
46 }
OLDNEW
« no previous file with comments | « tools/servicec/lib/src/resources/java/dartino/Reader.java ('k') | tools/servicec/lib/src/struct_layout.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698