diff options
author | Michael Bien <[email protected]> | 2010-01-12 18:02:50 +0100 |
---|---|---|
committer | Michael Bien <[email protected]> | 2010-01-12 18:02:50 +0100 |
commit | f65d7a7987ae4b30ef38069b3dffefa4441403f8 (patch) | |
tree | 428fc0913759e5e37ab63d2f6d73098a88600d78 /src/java/com/sun | |
parent | b138169c1f85a7914304ae793efb9cabfbfd5da2 (diff) |
fixed off-by-one bug in put and get.
implemented method chaining pattern.
added position(int pos) method.
Diffstat (limited to 'src/java/com/sun')
-rwxr-xr-x | src/java/com/sun/gluegen/runtime/PointerBuffer.java.javame_cdc_fp | 15 | ||||
-rwxr-xr-x | src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase | 15 |
2 files changed, 24 insertions, 6 deletions
diff --git a/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javame_cdc_fp b/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javame_cdc_fp index 4ab666c..0ec54d0 100755 --- a/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javame_cdc_fp +++ b/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javame_cdc_fp @@ -63,6 +63,14 @@ public class PointerBuffer { return position; } + public final PointerBuffer position(int newPos) { + if(0>newPos || newPos>=capacity) { + throw new IndexOutOfBoundsException(); + } + position = newPos; + return this; + } + public final int remaining() { return capacity - position; } @@ -71,8 +79,9 @@ public class PointerBuffer { return position < capacity; } - public final void rewind() { + public final PointerBuffer rewind() { position=0; + return this; } int arrayOffset() { return 0; } @@ -139,7 +148,7 @@ public class PointerBuffer { } public long get() { - long r = get(position+1); + long r = get(position); position++; return r; } @@ -163,7 +172,7 @@ public class PointerBuffer { } public PointerBuffer put(long v) { - put(position+1, v); + put(position, v); position++; return this; } diff --git a/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase b/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase index 4957b17..6d0029e 100755 --- a/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase +++ b/src/java/com/sun/gluegen/runtime/PointerBuffer.java.javase @@ -63,6 +63,14 @@ public class PointerBuffer { return position; } + public final PointerBuffer position(int newPos) { + if(0>newPos || newPos>=capacity) { + throw new IndexOutOfBoundsException(); + } + position = newPos; + return this; + } + public final int remaining() { return capacity - position; } @@ -71,8 +79,9 @@ public class PointerBuffer { return position < capacity; } - public final void rewind() { + public final PointerBuffer rewind() { position=0; + return this; } int arrayOffset() { return 0; } @@ -133,7 +142,7 @@ public class PointerBuffer { } public long get() { - long r = get(position+1); + long r = get(position); position++; return r; } @@ -148,7 +157,7 @@ public class PointerBuffer { } public PointerBuffer put(long v) { - put(position+1, v); + put(position, v); position++; return this; } |