summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorWouter van Oortmerssen <wvo@google.com>2015-01-16 17:48:51 -0800
committerWouter van Oortmerssen <wvo@google.com>2015-01-26 13:08:44 -0800
commit4fb5a764df4c4fa249c4a85b3f89be2a3e6deb9b (patch)
tree6eb64876451ced13a3826b77ecfe82852634c9fa /net
parent6c2dc41e0df3d6edc8cd8f452dd7a8ad7ff840c0 (diff)
downloadflatbuffers-4fb5a764df4c4fa249c4a85b3f89be2a3e6deb9b.tar.gz
flatbuffers-4fb5a764df4c4fa249c4a85b3f89be2a3e6deb9b.tar.bz2
flatbuffers-4fb5a764df4c4fa249c4a85b3f89be2a3e6deb9b.zip
Support for booleans in the Java/C# API
Change-Id: I72e92183a7b5f4145ea51fcec29257dc9553a461
Diffstat (limited to 'net')
-rw-r--r--net/FlatBuffers/FlatBufferBuilder.cs7
1 files changed, 7 insertions, 0 deletions
diff --git a/net/FlatBuffers/FlatBufferBuilder.cs b/net/FlatBuffers/FlatBufferBuilder.cs
index a91b8f27..d5e02b3f 100644
--- a/net/FlatBuffers/FlatBufferBuilder.cs
+++ b/net/FlatBuffers/FlatBufferBuilder.cs
@@ -105,6 +105,11 @@ namespace FlatBuffers
Pad(alignSize);
}
+ public void PutBool(bool x)
+ {
+ _bb.PutByte(_space -= sizeof(byte), (byte)(x ? 1 : 0));
+ }
+
public void PutSbyte(sbyte x)
{
_bb.PutSbyte(_space -= sizeof(sbyte), x);
@@ -157,6 +162,7 @@ namespace FlatBuffers
// Adds a scalar to the buffer, properly aligned, and the buffer grown
// if needed.
+ public void AddBool(bool x) { Prep(sizeof(byte), 0); PutBool(x); }
public void AddSbyte(sbyte x) { Prep(sizeof(sbyte), 0); PutSbyte(x); }
public void AddByte(byte x) { Prep(sizeof(byte), 0); PutByte(x); }
public void AddShort(short x) { Prep(sizeof(short), 0); PutShort(x); }
@@ -231,6 +237,7 @@ namespace FlatBuffers
}
// Add a scalar to a table at `o` into its vtable, with value `x` and default `d`
+ public void AddBool(int o, bool x, bool d) { if (x != d) { AddBool(x); Slot(o); } }
public void AddSbyte(int o, sbyte x, sbyte d) { if (x != d) { AddSbyte(x); Slot(o); } }
public void AddByte(int o, byte x, byte d) { if (x != d) { AddByte(x); Slot(o); } }
public void AddShort(int o, short x, int d) { if (x != d) { AddShort(x); Slot(o); } }