handle null lists

This commit is contained in:
David Renshaw 2014-05-11 11:20:04 -04:00
parent 5d6556ae49
commit 7895bb8d9b
4 changed files with 15 additions and 1 deletions

View file

@ -2,4 +2,8 @@
This is an experimental pure Java implementation of Cap'n Proto. This is an experimental pure Java implementation of Cap'n Proto.
It doesn't do much yet. It doesn't do much yet.
```
make
```

View file

@ -29,6 +29,9 @@ class WireHelpers {
int nestingLimit) { int nestingLimit) {
// TODO check for null, follow fars, nestingLimit // TODO check for null, follow fars, nestingLimit
if (ref.isNull()) {
return new ListReader();
}
ListPointer listPtr = new ListPointer(ref); ListPointer listPtr = new ListPointer(ref);

View file

@ -21,6 +21,10 @@ class WirePointer {
this.buffer_offset = word.offset; this.buffer_offset = word.offset;
} }
public boolean isNull() {
return this.buffer.getLong(this.buffer_offset * 8) == 0;
}
public int offset_and_kind() { public int offset_and_kind() {
return this.buffer.getInt(this.buffer_offset * 8); return this.buffer.getInt(this.buffer_offset * 8);
} }

View file

@ -21,7 +21,10 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
// This program is a code generator plugin for `capnp compile` which generates java code. // This program is a code generator plugin for `capnp compile` which generates java code.
// It is a modified version of the C++ code generator plugin, capnpc-c++.
#include <capnp/schema.capnp.h> #include <capnp/schema.capnp.h>
#include "capnp/serialize.h" #include "capnp/serialize.h"