Merge branch 'master' of github.com:dwrensha/capnproto-java

This commit is contained in:
David Renshaw 2014-05-19 15:12:24 -04:00
commit 33cd2c7851
30 changed files with 76 additions and 75 deletions

View file

@ -1,7 +1,7 @@
CXX=clang++
CXX_FLAGS=-std=c++11 -stdlib=libc++ `pkg-config capnp --cflags --libs`
CAPNPC_JAVA_SOURCES=generator/src/main/cpp/compiler/capnpc-java.c++
CAPNPC_JAVA_SOURCES=compiler/src/main/cpp/capnpc-java.c++
.PHONY: all clean addressbook
@ -16,4 +16,4 @@ capnpc-java : $(CAPNPC_JAVA_SOURCES)
addressbook : capnpc-java
PWD=pwd
mkdir -p examples/src/main/generated
capnp compile -I$(PWD)/generator/src/main/cpp/compiler --src-prefix=examples/src/main/schema -o./capnpc-java:examples/src/main/generated examples/src/main/schema/addressbook.capnp
capnp compile -I$(PWD)/compiler/src/main/cpp --src-prefix=examples/src/main/schema -o./capnpc-java:examples/src/main/generated examples/src/main/schema/addressbook.capnp

View file

@ -1,6 +0,0 @@
package org.capnproto;
public interface FromStructBuilder<T> {
public abstract T fromStructBuilder(StructBuilder builder);
public abstract StructSize structSize();
}

View file

@ -7,22 +7,27 @@ object Build extends sbt.Build {
project(
id = "capnproto-java",
base = file(".")
).aggregate(generator, examples)
).aggregate(compiler, runtime, examples)
.settings(cleanFiles <+= baseDirectory { base => base / "capnpc-java"})
lazy val generator =
lazy val compiler =
project(
id = "generator",
base = file("generator")
).settings(Defaults.itSettings: _*)
.settings(makeCppTask)
id = "compiler",
base = file("compiler")
).settings(makeCppTask)
.settings(compile <<= compile in Compile dependsOn makeCpp)
lazy val runtime =
project(
id = "runtime",
base = file("runtime")
)
lazy val examples =
project(
id = "examples",
base = file("examples")
).dependsOn(generator)
).dependsOn(runtime)
.settings(makeExamplesTask)
.settings(compile <<= compile in Compile dependsOn makeExamples)
.settings(unmanagedSourceDirectories in Compile += sourceDirectory.value / "main" / "generated")

View file

@ -1,9 +1,9 @@
package org.capnproto;
public class AnyPointer {
public final class AnyPointer {
public static class Reader {
public PointerReader reader;
public final static class Reader {
public final PointerReader reader;
public Reader(PointerReader reader) {
this.reader = reader;

View file

@ -1,6 +1,6 @@
package org.capnproto;
public class DecodeException extends RuntimeException {
public final class DecodeException extends RuntimeException {
public DecodeException(String message) {
super(message);
}

View file

@ -1,6 +1,6 @@
package org.capnproto;
public class FieldSize {
public final class FieldSize {
public static final byte VOID = 0;
public static final byte BIT = 1;
public static final byte BYTE = 2;

View file

@ -0,0 +1,6 @@
package org.capnproto;
public interface FromStructBuilder<T> {
T fromStructBuilder(StructBuilder builder);
StructSize structSize();
}

View file

@ -1,5 +1,5 @@
package org.capnproto;
public interface FromStructReader<T> {
public abstract T fromStructReader(StructReader reader);
T fromStructReader(StructReader reader);
}

View file

@ -1,13 +1,12 @@
package org.capnproto;
import java.io.InputStream;
import java.io.IOException;
import java.io.InputStream;
import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.util.Vector;
public class InputStreamMessageReader {
public final class InputStreamMessageReader {
static byte[] readExact(InputStream is, int length) throws IOException {
byte[] bytes = new byte[length];

View file

@ -1,12 +1,12 @@
package org.capnproto;
public final class ListBuilder {
SegmentBuilder segment;
int ptr; // byte offset to front of list
int elementCount;
int step; // in bits
int structDataSize; // in bits
short structPointerCount;
final SegmentBuilder segment;
final int ptr; // byte offset to front of list
final int elementCount;
final int step; // in bits
final int structDataSize; // in bits
final short structPointerCount;
public ListBuilder(SegmentBuilder segment, int ptr,
int elementCount, int step,

View file

@ -1,14 +1,13 @@
package org.capnproto;
public class ListReader {
SegmentReader segment;
int ptr; // byte offset to front of list
int elementCount;
int step; // in bits
int structDataSize; // in bits
short structPointerCount;
int nestingLimit;
public final class ListReader {
final SegmentReader segment;
final int ptr; // byte offset to front of list
final int elementCount;
final int step; // in bits
final int structDataSize; // in bits
final short structPointerCount;
final int nestingLimit;
public ListReader() {
this.segment = null;

View file

@ -2,8 +2,8 @@ package org.capnproto;
import java.nio.ByteBuffer;
public class MessageReader {
ByteBuffer[] segmentSlices;
public final class MessageReader {
final ByteBuffer[] segmentSlices;
public MessageReader(ByteBuffer[] segmentSlices) {
this.segmentSlices = segmentSlices;

View file

@ -1,8 +1,8 @@
package org.capnproto;
public final class PointerBuilder {
public SegmentBuilder segment;
public int pointer; // word offset
public final SegmentBuilder segment;
public final int pointer; // word offset
public PointerBuilder(SegmentBuilder segment, int pointer) {
this.segment = segment;

View file

@ -1,9 +1,9 @@
package org.capnproto;
public class PointerReader {
public SegmentReader segment;
public int pointer; // word offset
public int nestingLimit;
public final class PointerReader {
public final SegmentReader segment;
public final int pointer; // word offset
public final int nestingLimit;
public PointerReader() {
this.segment = null;

View file

@ -2,11 +2,11 @@ package org.capnproto;
import java.nio.ByteBuffer;
public class SegmentBuilder extends SegmentReader {
public int pos = 0; // in words
public final class SegmentBuilder extends SegmentReader {
public static final int FAILED_ALLOCATION = -1;
public int pos = 0; // in words
public SegmentBuilder(ByteBuffer buf) {
super(buf);
}

View file

@ -3,7 +3,7 @@ package org.capnproto;
import java.nio.ByteBuffer;
public class SegmentReader {
ByteBuffer buffer;
final ByteBuffer buffer;
public SegmentReader(ByteBuffer buffer) {
this.buffer = buffer;

View file

@ -1,12 +1,12 @@
package org.capnproto;
public final class StructBuilder {
public SegmentBuilder segment;
public int data; //byte offset to data section
public int pointers; // word offset of pointer section
public int dataSize; // in bits
public short pointerCount;
public byte bit0Offset;
public final SegmentBuilder segment;
public final int data; //byte offset to data section
public final int pointers; // word offset of pointer section
public final int dataSize; // in bits
public final short pointerCount;
public final byte bit0Offset;
public StructBuilder(SegmentBuilder segment, int data,
int pointers, int dataSize, short pointerCount,

View file

@ -1,6 +1,5 @@
package org.capnproto;
public final class StructList {
public static final class Reader<T> {
public ListReader reader;

View file

@ -1,14 +1,13 @@
package org.capnproto;
public final class StructReader {
public SegmentReader segment;
public int data; //byte offset to data section
public int pointers; // word offset of pointer section
public int dataSize; // in bits
public short pointerCount;
public byte bit0Offset;
public int nestingLimit;
public final SegmentReader segment;
public final int data; //byte offset to data section
public final int pointers; // word offset of pointer section
public final int dataSize; // in bits
public final short pointerCount;
public final byte bit0Offset;
public final int nestingLimit;
public StructReader(SegmentReader segment, int data,
int pointers, int dataSize, short pointerCount,

View file

@ -2,7 +2,7 @@ package org.capnproto;
import java.nio.ByteBuffer;
public class Text {
public final class Text {
public static final class Reader {
public final ByteBuffer buffer;