Merge commit '7c1ae250acb4120322b01a666993ed63c795ef21' into master

Update flatbuffers to latest master.

This adds an upstream flatbuffer_ts_library rule and changes the
typescript codegen, so ends up touching every typescript file we have
that uses flatbuffers. But it does clean up some of the hacks we had to
make to get that to work.

Had to hack the flatbuffer_ts_library a bit because I forgot to make
imports work nicely for cross-repo things.

And of course, the original motivation for this is that it gives us
proper handling of transitive dependencies for
flatbuffer_cc_library, if we start using the deps attribute!

Had to modify the codegen for the new declaration_file attribute in
flatbuffer schemas to make it just be the filename rather than including
the path. Modifying that to make it use a workspace-relative path was
looking obnoxious. It's definitely feasible, but since we don't actually
need that attribute, just make it be a filename for now.

Change-Id: I523a758cafa512fa2a686c9705d23337a26798ca
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
diff --git a/aos/network/www/reflection.ts b/aos/network/www/reflection.ts
index 18d4996..a765eea 100644
--- a/aos/network/www/reflection.ts
+++ b/aos/network/www/reflection.ts
@@ -6,9 +6,9 @@
 // constructed flatbuffers.
 // See reflection_test_main.ts for sample usage.
 
-import {reflection, aos} from 'org_frc971/aos/configuration_generated';
-import {ByteBuffer} from 'org_frc971/external/com_github_google_flatbuffers/ts/byte-buffer';
-import {Long} from 'org_frc971/external/com_github_google_flatbuffers/ts/long';
+import * as aos from 'org_frc971/aos/configuration_generated';
+import * as reflection from '../../../external/com_github_google_flatbuffers/reflection/reflection_generated';
+import {ByteBuffer} from 'flatbuffers';
 
 // Returns the size, in bytes, of the given type. For vectors/strings/etc.
 // returns the size of the offset.
@@ -236,7 +236,7 @@
   }
 
   // Returns the Object definition associated with the given type index.
-  getType(typeIndex: number): reflection.ObjectGenerated {
+  getType(typeIndex: number): reflection.Object_ {
     if (typeIndex === -1) {
       return this.schema.rootTable();
     }
@@ -249,7 +249,7 @@
   // Retrieves the Field schema for the given field name within a given
   // type index.
   getField(fieldName: string, typeIndex: number): reflection.Field {
-    const schema: reflection.ObjectGenerated = this.getType(typeIndex);
+    const schema: reflection.Object_ = this.getType(typeIndex);
     const numFields = schema.fieldsLength();
     for (let ii = 0; ii < numFields; ++ii) {
       const field = schema.fields(ii);
@@ -269,7 +269,7 @@
   // value for the field and return that.
   // For 64-bit fields, returns a flatbuffer Long rather than a standard number.
   readScalar(table: Table, fieldName: string, readDefaults: boolean = false):
-      number|Long|null {
+      number|BigInt|null {
     return this.readScalarLambda(
         table.typeIndex, fieldName, readDefaults)(table);
   }
@@ -279,7 +279,7 @@
   // can be obtained using table.typeIndex.
   readScalarLambda(
       typeIndex: number, fieldName: string,
-      readDefaults: boolean = false): (t: Table) => number | Long | null {
+      readDefaults: boolean = false): (t: Table) => number | BigInt | null {
     const field = this.getField(fieldName, typeIndex);
     const fieldType = field.type();
     const isStruct = this.getType(typeIndex).isStruct();
@@ -301,15 +301,7 @@
           return null;
         }
         if (isInteger(fieldType.baseType())) {
-          if (isLong(fieldType.baseType())) {
-            return field.defaultInteger();
-          } else {
-            if (field.defaultInteger().high != 0) {
-              throw new Error(
-                  '<=4 byte integer types should not use 64-bit default values.');
-            }
-            return field.defaultInteger().low;
-          }
+          return field.defaultInteger();
         } else {
           return field.defaultReal();
         }
@@ -374,14 +366,14 @@
       return new Table(table.bb, fieldType.index(), objectStart);
     };
   }
-  // Reads a vector of scalars (like readScalar, may return a vector of Long's
+  // Reads a vector of scalars (like readScalar, may return a vector of BigInt's
   // instead). Also, will return null if the vector is not set.
-  readVectorOfScalars(table: Table, fieldName: string): number[]|Long[]|null {
+  readVectorOfScalars(table: Table, fieldName: string): number[]|BigInt[]|null {
     return this.readVectorOfScalarsLambda(table.typeIndex, fieldName)(table);
   }
 
   readVectorOfScalarsLambda(typeIndex: number, fieldName: string):
-      (t: Table) => number[] | Long[] | null {
+      (t: Table) => number[] | BigInt[] | null {
     const field = this.getField(fieldName, typeIndex);
     const fieldType = field.type();
     if (fieldType.baseType() !== reflection.BaseType.Vector) {