summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Dahl <ry@tinyclouds.org>2019-08-26 17:02:34 -0400
committerGitHub <noreply@github.com>2019-08-26 17:02:34 -0400
commitf94900406d52a9d0a432ae9ebef65d46092afb41 (patch)
tree0a12b3201f8bdd0bbee1b6b1abf3f413d7d92e9f
parentd8ada4d3fcc5dfe7f76103399a1d765fbab2ee45 (diff)
Remove flatbuffers (#2818)
-rw-r--r--Cargo.lock10
-rw-r--r--build_extra/flatbuffers/BUILD.gn126
-rw-r--r--build_extra/flatbuffers/flatbuffer.gni239
-rw-r--r--build_extra/flatbuffers/rust/rust_flatbuffer.gni34
-rw-r--r--build_extra/rust/BUILD.gn7
-rw-r--r--cli/BUILD.gn23
-rw-r--r--cli/Cargo.toml1
-rw-r--r--cli/build.rs17
-rw-r--r--cli/msg.fbs73
-rw-r--r--cli/msg.rs85
-rw-r--r--gclient_config.py5
-rw-r--r--js/compiler.ts27
-rw-r--r--js/dispatch_json.ts6
-rw-r--r--js/errors.ts58
-rw-r--r--js/flatbuffers.ts56
-rw-r--r--package.json2
m---------third_party0
-rw-r--r--tools/ts_library_builder/build_library.ts35
18 files changed, 158 insertions, 646 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 3fbcb616c..a09152acc 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -229,7 +229,6 @@ dependencies = [
"clap 2.33.0 (registry+https://github.com/rust-lang/crates.io-index)",
"deno 0.16.0",
"dirs 2.0.2 (registry+https://github.com/rust-lang/crates.io-index)",
- "flatbuffers 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)",
"futures 0.1.28 (registry+https://github.com/rust-lang/crates.io-index)",
"fwdansi 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
"http 0.1.18 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -310,14 +309,6 @@ dependencies = [
]
[[package]]
-name = "flatbuffers"
-version = "0.6.0"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-dependencies = [
- "smallvec 0.6.10 (registry+https://github.com/rust-lang/crates.io-index)",
-]
-
-[[package]]
name = "fnv"
version = "1.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1625,7 +1616,6 @@ dependencies = [
"checksum either 1.5.2 (registry+https://github.com/rust-lang/crates.io-index)" = "5527cfe0d098f36e3f8839852688e63c8fff1c90b2b405aef730615f9a7bcf7b"
"checksum failure 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "795bd83d3abeb9220f257e597aa0080a508b27533824adf336529648f6abf7e2"
"checksum failure_derive 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)" = "ea1063915fd7ef4309e222a5a07cf9c319fb9c7836b1f89b85458672dbb127e1"
-"checksum flatbuffers 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2fc1af59fd8248b59beb048d614a869ce211315c195f5412334e47f5b7e22726"
"checksum fnv 1.0.6 (registry+https://github.com/rust-lang/crates.io-index)" = "2fad85553e09a6f881f739c29f0b00b0f01357c743266d478b68951ce23285f3"
"checksum fuchsia-cprng 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "a06f77d526c1a601b7c4cdd98f54b5eaabffc14d5f2f0296febdc7f357c6d3ba"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
diff --git a/build_extra/flatbuffers/BUILD.gn b/build_extra/flatbuffers/BUILD.gn
deleted file mode 100644
index 39db6b80d..000000000
--- a/build_extra/flatbuffers/BUILD.gn
+++ /dev/null
@@ -1,126 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("flatbuffer.gni")
-
-fb_src = flatbuffers_source_location
-
-config("flatbuffers_config") {
- include_dirs = [ "$fb_src/include" ]
-
- if (is_clang) {
- cflags = [
- "-Wno-exit-time-destructors",
- "-Wno-header-hygiene",
- "-fcolor-diagnostics",
- "-fansi-escape-codes",
- ]
- }
-}
-
-# The part of FlatBuffers that Chrome is interested in.
-source_set("flatbuffers") {
- sources = [
- "$fb_src/include/flatbuffers/flatbuffers.h",
- ]
-
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
-
- public_configs = [ ":flatbuffers_config" ]
-}
-
-# The complete FlatBuffers library, as required to build the flatc compiler and
-# some of the tests.
-source_set("compiler_files") {
- include_dirs = [ "$fb_src/grpc" ]
- sources = [
- "$fb_src/grpc/src/compiler/config.h",
- "$fb_src/grpc/src/compiler/config.h",
- "$fb_src/grpc/src/compiler/cpp_generator.cc",
- "$fb_src/grpc/src/compiler/cpp_generator.h",
- "$fb_src/grpc/src/compiler/go_generator.cc",
- "$fb_src/grpc/src/compiler/go_generator.h",
- "$fb_src/grpc/src/compiler/java_generator.cc",
- "$fb_src/grpc/src/compiler/java_generator.h",
- "$fb_src/grpc/src/compiler/schema_interface.h",
- "$fb_src/include/flatbuffers/code_generators.h",
- "$fb_src/include/flatbuffers/flatc.h",
- "$fb_src/include/flatbuffers/flexbuffers.h",
- "$fb_src/include/flatbuffers/grpc.h",
- "$fb_src/include/flatbuffers/hash.h",
- "$fb_src/include/flatbuffers/idl.h",
- "$fb_src/include/flatbuffers/reflection.h",
- "$fb_src/include/flatbuffers/reflection_generated.h",
- "$fb_src/include/flatbuffers/util.h",
- "$fb_src/src/code_generators.cpp",
- "$fb_src/src/flatc.cpp",
- "$fb_src/src/idl_gen_cpp.cpp",
- "$fb_src/src/idl_gen_dart.cpp",
- "$fb_src/src/idl_gen_fbs.cpp",
- "$fb_src/src/idl_gen_general.cpp",
- "$fb_src/src/idl_gen_go.cpp",
- "$fb_src/src/idl_gen_grpc.cpp",
- "$fb_src/src/idl_gen_js.cpp",
- "$fb_src/src/idl_gen_json_schema.cpp",
- "$fb_src/src/idl_gen_lobster.cpp",
- "$fb_src/src/idl_gen_lua.cpp",
- "$fb_src/src/idl_gen_php.cpp",
- "$fb_src/src/idl_gen_python.cpp",
- "$fb_src/src/idl_gen_rust.cpp",
- "$fb_src/src/idl_gen_text.cpp",
- "$fb_src/src/idl_parser.cpp",
- "$fb_src/src/reflection.cpp",
- "$fb_src/src/util.cpp",
- ]
- configs -= [ "//build/config/compiler:chromium_code" ]
- configs += [ "//build/config/compiler:no_chromium_code" ]
- visibility = [ ":*" ]
- deps = [
- ":flatbuffers",
- ]
-}
-
-executable("flatc") {
- sources = [
- "$fb_src/src/flatc_main.cpp",
- ]
- deps = [
- ":compiler_files",
- ":flatbuffers",
- ]
-}
-
-# The following is just for testing.
-
-flatbuffer("flatbuffers_samplebuffer") {
- testonly = true
- sources = [
- "$fb_src/tests/include_test/include_test1.fbs",
- "$fb_src/tests/include_test/sub/include_test2.fbs",
- "$fb_src/tests/monster_test.fbs",
- "$fb_src/tests/namespace_test/namespace_test1.fbs",
- "$fb_src/tests/namespace_test/namespace_test2.fbs",
- ]
- flatc_include_dirs = [ "$fb_src/tests/include_test" ]
-}
-# test("flatbuffers_unittest") {
-# sources = [
-# "src/tests/test.cpp",
-# ]
-# deps = [
-# ":compiler_files",
-# ":flatbuffers",
-# ":flatbuffers_samplebuffer",
-# ]
-# data = [
-# "src/tests/",
-# ]
-#
-# if (is_win) {
-# # Suppress "object allocated on the heap may not be aligned 16".
-# cflags = [ "/wd4316" ]
-# }
-# defines = [ "FLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE" ]
-# }
diff --git a/build_extra/flatbuffers/flatbuffer.gni b/build_extra/flatbuffers/flatbuffer.gni
deleted file mode 100644
index ff4a48dfa..000000000
--- a/build_extra/flatbuffers/flatbuffer.gni
+++ /dev/null
@@ -1,239 +0,0 @@
-# Copyright 2016 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-
-import("//build/compiled_action.gni")
-
-declare_args() {
- # Location of flatbuffers source code.
- flatbuffers_source_location = "//third_party/flatbuffers/"
-
- # Absolute location flatbuffers BUILD.gn file.
- flatbuffers_build_location = "//build_extra/flatbuffers/"
-}
-
-# Compile a flatbuffer for C++.
-#
-# flatc_out_dir (optional)
-# Specifies the path suffix that output files are generated under. This
-# path will be appended to root_gen_dir.
-#
-# Targets that depend on the flatbuffer target will be able to include
-# the resulting FlatBuffers header with an include like:
-# #include "dir/for/my_flatbuffer/buffer_generated.h"
-# If undefined, this defaults to matchign the input directory for each
-# .fbs file (you should almost always use the default mode).
-#
-# flatc_include_dirs (optional)
-# Specifies the directories which FlatBuffers compiler uses to find
-# included .fbs files in. Almost always should be empty.
-#
-# The list always has an implicit first item corresponding to the root of
-# the source tree. This enables including .fbs files by absolute path.
-#
-# The compiler will try the directories in the order given, and if all
-# fail it will try to load relative to the directory of the schema file
-# being parsed.
-#
-# deps (optional)
-# Additional dependencies.
-#
-# Parameters for compiling the generated code:
-#
-# defines (optional)
-# Defines to supply to the source set that compiles the generated source
-# code.
-#
-# extra_configs (optional)
-# A list of config labels that will be appended to the configs applying
-# to the source set.
-#
-# testonly (optional)
-# Boolean to indicate whether the generated source sets should be labeled
-# as testonly.
-#
-# Example:
-# flatbuffer("mylib") {
-# sources = [
-# "foo.fbs",
-# ]
-# }
-template("flatbuffer") {
- assert(defined(invoker.sources), "Need sources for flatbuffers_library")
-
- # Don't apply OS-specific sources filtering to the assignments later on.
- # Platform files should have gotten filtered out in the sources assignment
- # when this template was invoked. If they weren't, it was on purpose and
- # this template shouldn't re-apply the filter.
- set_sources_assignment_filter([])
-
- action_name = "${target_name}_gen"
- source_set_name = target_name
- compiled_action_foreach(action_name) {
- visibility = [ ":$source_set_name" ]
-
- tool = "$flatbuffers_build_location:flatc"
-
- sources = invoker.sources
- deps = []
-
- if (defined(invoker.flatc_out_dir)) {
- out_dir = "$root_gen_dir/" + invoker.flatc_out_dir
- } else {
- out_dir = "{{source_gen_dir}}"
- }
-
- outputs = [
- "$out_dir/{{source_name_part}}_generated.h",
- ]
-
- args = [
- "-c",
- "--keep-prefix",
- "-o",
- "$out_dir",
- "-I",
- rebase_path("//", root_build_dir),
- ]
-
- if (defined(invoker.flatc_include_dirs)) {
- foreach(include_dir, invoker.flatc_include_dirs) {
- args += [
- "-I",
- rebase_path(include_dir, root_build_dir),
- ]
- }
- }
-
- args += [ "{{source}}" ]
-
- # The deps may have steps that have to run before running flatc.
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
- }
-
- source_set(target_name) {
- forward_variables_from(invoker,
- [
- "visibility",
- "defines",
- ])
-
- sources = get_target_outputs(":$action_name")
-
- if (defined(invoker.extra_configs)) {
- configs += invoker.extra_configs
- }
-
- if (defined(invoker.testonly)) {
- testonly = invoker.testonly
- }
-
- public_configs = [ "$flatbuffers_build_location:flatbuffers_config" ]
-
- public_deps = [
- # The generated headers reference headers within FlatBuffers, so
- # dependencies must be able to find those headers too.
- flatbuffers_build_location,
- ]
- deps = [
- ":$action_name",
- ]
-
- # This will link any libraries in the deps (the use of invoker.deps in the
- # action won't link it).
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
-
- # Same for public_deps.
- if (defined(invoker.public_deps)) {
- public_deps += invoker.public_deps
- }
- }
-}
-
-# Compile a flatbuffer to typescript.
-#
-# flatc_include_dirs (optional)
-# Specifies the directories which FlatBuffers compiler uses to find
-# included .fbs files in. Almost always should be empty.
-#
-# The list always has an implicit first item corresponding to the root of
-# the source tree. This enables including .fbs files by absolute path.
-#
-# The compiler will try the directories in the order given, and if all
-# fail it will try to load relative to the directory of the schema file
-# being parsed.
-#
-# deps (optional)
-# Additional dependencies.
-#
-# Example:
-# ts_flatbuffer("foo_ts") {
-# sources = [
-# "foo.fbs",
-# ]
-# }
-template("ts_flatbuffer") {
- assert(defined(invoker.sources), "Need sources for flatbuffers_library")
-
- # Don't apply OS-specific sources filtering to the assignments later on.
- # Platform files should have gotten filtered out in the sources assignment
- # when this template was invoked. If they weren't, it was on purpose and
- # this template shouldn't re-apply the filter.
- set_sources_assignment_filter([])
-
- copy_name = target_name + "_copy"
-
- copy(copy_name) {
- sources = [
- "$flatbuffers_source_location/js/flatbuffers.js",
- ]
- outputs = [
- "$target_gen_dir/flatbuffers.js",
- ]
- }
-
- compiled_action_foreach(target_name) {
- tool = "$flatbuffers_build_location:flatc"
-
- sources = invoker.sources
- deps = [
- ":" + copy_name,
- ]
-
- out_dir = target_gen_dir
-
- outputs = [
- "$out_dir/{{source_name_part}}_generated.ts",
- ]
-
- args = [
- "--ts",
- "--no-fb-import",
- "--gen-mutable",
- "-o",
- rebase_path(out_dir, root_build_dir),
- "-I",
- rebase_path("//", root_build_dir),
- ]
-
- if (defined(invoker.flatc_include_dirs)) {
- foreach(include_dir, invoker.flatc_include_dirs) {
- args += [
- "-I",
- rebase_path(include_dir, root_build_dir),
- ]
- }
- }
-
- args += [ "{{source}}" ]
-
- # The deps may have steps that have to run before running flatc.
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
- }
-}
diff --git a/build_extra/flatbuffers/rust/rust_flatbuffer.gni b/build_extra/flatbuffers/rust/rust_flatbuffer.gni
deleted file mode 100644
index bf211c2dd..000000000
--- a/build_extra/flatbuffers/rust/rust_flatbuffer.gni
+++ /dev/null
@@ -1,34 +0,0 @@
-# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import("//build_extra/rust/rust.gni")
-
-# TODO(ry) "flatbuffer.gni" should be "flatbuffers.gni" we should be consistent
-# in our pluralization.
-import("//build_extra/flatbuffers/flatbuffer.gni")
-
-template("rust_flatbuffer") {
- compiled_action_foreach(target_name) {
- tool = "$flatbuffers_build_location:flatc"
-
- sources = invoker.sources
- deps = []
- out_dir = target_gen_dir
-
- outputs = [
- "$out_dir/{{source_name_part}}_generated.rs",
- ]
-
- args = [
- "--rust",
- "-o",
- rebase_path(out_dir, root_build_dir),
- "-I",
- rebase_path("//", root_build_dir),
- ]
- args += [ "{{source}}" ]
-
- # The deps may have steps that have to run before running flatc.
- if (defined(invoker.deps)) {
- deps += invoker.deps
- }
- }
-}
diff --git a/build_extra/rust/BUILD.gn b/build_extra/rust/BUILD.gn
index 80f2d8c85..a9d8c6161 100644
--- a/build_extra/rust/BUILD.gn
+++ b/build_extra/rust/BUILD.gn
@@ -241,13 +241,6 @@ rust_rlib("either") {
]
}
-rust_rlib("flatbuffers") {
- cap_lints = "allow"
- edition = "2015"
- source_root = "$cargo_home/registry/src/github.com-1ecc6299db9ec823/flatbuffers-0.6.0/src/lib.rs"
- extern_rlib = [ "smallvec" ]
-}
-
rust_rlib("fnv") {
cap_lints = "allow"
edition = "2015"
diff --git a/cli/BUILD.gn b/cli/BUILD.gn
index 8b8790386..cfc397d65 100644
--- a/cli/BUILD.gn
+++ b/cli/BUILD.gn
@@ -1,7 +1,5 @@
# Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
import("//build/toolchain/cc_wrapper.gni")
-import("//build_extra/flatbuffers/flatbuffer.gni")
-import("//build_extra/flatbuffers/rust/rust_flatbuffer.gni")
import("//build_extra/rust/rust.gni")
import("//third_party/v8/gni/snapshot_toolchain.gni")
import("//third_party/v8/gni/v8.gni")
@@ -24,7 +22,6 @@ main_extern_rlib = [
"atty",
"clap",
"dirs",
- "flatbuffers",
"futures",
"http",
"hyper",
@@ -94,7 +91,6 @@ ts_sources = [
"../js/fetch.ts",
"../js/file_info.ts",
"../js/files.ts",
- "../js/flatbuffers.ts",
"../js/form_data.ts",
"../js/format_error.ts",
"../js/get_random_values.ts",
@@ -151,7 +147,6 @@ ts_sources = [
# targets. Cargo handles all Rust source files and the final linking step.
group("deno_deps") {
deps = [
- ":msg_rs",
":snapshot_compiler",
":snapshot_deno",
]
@@ -164,7 +159,6 @@ group("deno_deps_cross") {
deps = [
":compiler_bundle",
":main_bundle",
- ":msg_rs",
]
}
@@ -213,9 +207,6 @@ run_node("deno_runtime_declaration") {
outputs = [
"$out_dir/lib/lib.deno_runtime.d.ts",
]
- deps = [
- ":msg_ts",
- ]
inputs = ts_sources + [
"//tools/ts_library_builder/tsconfig.json",
"//tools/ts_library_builder/main.ts",
@@ -248,7 +239,6 @@ bundle("main_bundle") {
out_name = "main"
deps = [
":deno_runtime_declaration",
- ":msg_ts",
]
}
@@ -257,19 +247,6 @@ bundle("compiler_bundle") {
out_name = "compiler"
deps = [
":deno_runtime_declaration",
- ":msg_ts",
- ]
-}
-
-ts_flatbuffer("msg_ts") {
- sources = [
- "msg.fbs",
- ]
-}
-
-rust_flatbuffer("msg_rs") {
- sources = [
- "msg.fbs",
]
}
diff --git a/cli/Cargo.toml b/cli/Cargo.toml
index cc2286af5..632c60c13 100644
--- a/cli/Cargo.toml
+++ b/cli/Cargo.toml
@@ -22,7 +22,6 @@ ansi_term = "0.12.0"
atty = "0.2.13"
clap = "2.33.0"
dirs = "2.0.2"
-flatbuffers = "0.6.0"
futures = "0.1.28"
http = "0.1.18"
hyper = "0.12.33"
diff --git a/cli/build.rs b/cli/build.rs
index 8e05b2119..55451e6b7 100644
--- a/cli/build.rs
+++ b/cli/build.rs
@@ -6,15 +6,10 @@ mod gn {
fn main() {
let build = gn::Build::setup();
-
- let gn_target = if build.check_only {
- // When RLS is running "cargo check" to analyze the source code, we're not
- // trying to build a working executable, rather we're just compiling all
- // rust code. Therefore, make ninja build only 'msg_generated.rs'.
- "cli:msg_rs"
- } else {
- "cli:deno_deps"
- };
-
- build.run(gn_target);
+ // When RLS is running "cargo check" to analyze the source code, we're not
+ // trying to build a working executable, rather we're just compiling all
+ // rust code.
+ if !build.check_only {
+ build.run("cli:deno_deps");
+ }
}
diff --git a/cli/msg.fbs b/cli/msg.fbs
deleted file mode 100644
index ad0a6274b..000000000
--- a/cli/msg.fbs
+++ /dev/null
@@ -1,73 +0,0 @@
-enum ErrorKind: byte {
- NoError = 0,
-
- // io errors
-
- NotFound,
- PermissionDenied,
- ConnectionRefused,
- ConnectionReset,
- ConnectionAborted,
- NotConnected,
- AddrInUse,
- AddrNotAvailable,
- BrokenPipe,
- AlreadyExists,
- WouldBlock,
- InvalidInput,
- InvalidData,
- TimedOut,
- Interrupted,
- WriteZero,
- Other,
- UnexpectedEof,
- BadResource,
- CommandFailed,
-
- // url errors
-
- EmptyHost,
- IdnaError,
- InvalidPort,
- InvalidIpv4Address,
- InvalidIpv6Address,
- InvalidDomainCharacter,
- RelativeUrlWithoutBase,
- RelativeUrlWithCannotBeABaseBase,
- SetHostOnCannotBeABaseUrl,
- Overflow,
-
- // hyper errors
-
- HttpUser,
- HttpClosed,
- HttpCanceled,
- HttpParse,
- HttpOther,
- TooLarge,
-
- // custom errors
- InvalidUri,
- InvalidSeekMode,
- OpNotAvailable,
- WorkerInitFailed,
- UnixError,
- NoAsyncSupport,
- NoSyncSupport,
- ImportMapError,
- InvalidPath,
- ImportPrefixMissing,
- UnsupportedFetchScheme,
- TooManyRedirects,
-
- // other kinds
- Diagnostic,
- JSError,
-}
-
-enum MediaType: byte {
- JavaScript = 0,
- TypeScript,
- Json,
- Unknown
-}
diff --git a/cli/msg.rs b/cli/msg.rs
index db4c771f8..4416c7d71 100644
--- a/cli/msg.rs
+++ b/cli/msg.rs
@@ -1,8 +1,81 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-#![allow(dead_code)]
-#![cfg_attr(feature = "cargo-clippy", allow(clippy::all, clippy::pedantic))]
-use flatbuffers;
-// GN_OUT_DIR is set either by build.rs (for the Cargo build), or by
-// build_extra/rust/run.py (for the GN+Ninja build).
-include!(concat!(env!("GN_OUT_DIR"), "/gen/cli/msg_generated.rs"));
+// Warning! The values in this enum are duplicated in js/errors.ts
+// Update carefully!
+#[allow(non_camel_case_types)]
+#[repr(i8)]
+#[derive(Clone, Copy, PartialEq, Debug)]
+pub enum ErrorKind {
+ NoError = 0,
+ NotFound = 1,
+ PermissionDenied = 2,
+ ConnectionRefused = 3,
+ ConnectionReset = 4,
+ ConnectionAborted = 5,
+ NotConnected = 6,
+ AddrInUse = 7,
+ AddrNotAvailable = 8,
+ BrokenPipe = 9,
+ AlreadyExists = 10,
+ WouldBlock = 11,
+ InvalidInput = 12,
+ InvalidData = 13,
+ TimedOut = 14,
+ Interrupted = 15,
+ WriteZero = 16,
+ Other = 17,
+ UnexpectedEof = 18,
+ BadResource = 19,
+ CommandFailed = 20,
+ EmptyHost = 21,
+ IdnaError = 22,
+ InvalidPort = 23,
+ InvalidIpv4Address = 24,
+ InvalidIpv6Address = 25,
+ InvalidDomainCharacter = 26,
+ RelativeUrlWithoutBase = 27,
+ RelativeUrlWithCannotBeABaseBase = 28,
+ SetHostOnCannotBeABaseUrl = 29,
+ Overflow = 30,
+ HttpUser = 31,
+ HttpClosed = 32,
+ HttpCanceled = 33,
+ HttpParse = 34,
+ HttpOther = 35,
+ TooLarge = 36,
+ InvalidUri = 37,
+ InvalidSeekMode = 38,
+ OpNotAvailable = 39,
+ WorkerInitFailed = 40,
+ UnixError = 41,
+ NoAsyncSupport = 42,
+ NoSyncSupport = 43,
+ ImportMapError = 44,
+ InvalidPath = 45,
+ ImportPrefixMissing = 46,
+ UnsupportedFetchScheme = 47,
+ TooManyRedirects = 48,
+ Diagnostic = 49,
+ JSError = 50,
+}
+
+// Warning! The values in this enum are duplicated in js/compiler.ts
+// Update carefully!
+#[allow(non_camel_case_types)]
+#[repr(i8)]
+#[derive(Clone, Copy, PartialEq, Debug)]
+pub enum MediaType {
+ JavaScript = 0,
+ TypeScript = 1,
+ Json = 2,
+ Unknown = 3,
+}
+
+pub fn enum_name_media_type(mt: MediaType) -> &'static str {
+ match mt {
+ MediaType::JavaScript => "JavaScript",
+ MediaType::TypeScript => "TypeScript",
+ MediaType::Json => "Json",
+ MediaType::Unknown => "Unknown",
+ }
+}
diff --git a/gclient_config.py b/gclient_config.py
index f27ff9aed..304cb6ecd 100644
--- a/gclient_config.py
+++ b/gclient_config.py
@@ -37,9 +37,4 @@ solutions = [{
'https://github.com/cpplint/cpplint.git@a33992f68f36fcaa6d0f531a25012a4c474d3542',
'name':
'cpplint'
-}, {
- 'url':
- 'https://github.com/google/flatbuffers.git@80d148b1757f0fab9305616d69d876378405843a',
- 'name':
- 'flatbuffers'
}]
diff --git a/js/compiler.ts b/js/compiler.ts
index 60fe49701..e10dc50db 100644
--- a/js/compiler.ts
+++ b/js/compiler.ts
@@ -17,8 +17,14 @@ import { window } from "./window";
import { postMessage, workerClose, workerMain } from "./workers";
import { writeFileSync } from "./write_file";
-// TODO(ry) msg_generated import will be removed soon.
-import * as msg from "gen/cli/msg_generated";
+// Warning! The values in this enum are duplicated in cli/msg.rs
+// Update carefully!
+enum MediaType {
+ JavaScript = 0,
+ TypeScript = 1,
+ Json = 2,
+ Unknown = 3
+}
// Startup boilerplate. This is necessary because the compiler has its own
// snapshot. (It would be great if we could remove these things or centralize
@@ -112,7 +118,7 @@ const ignoredCompilerOptions: ReadonlyArray<string> = [
interface SourceFile {
moduleName: string | undefined;
filename: string | undefined;
- mediaType: msg.MediaType;
+ mediaType: MediaType;
sourceCode: string | undefined;
typeDirectives?: Record<string, string>;
}
@@ -173,18 +179,15 @@ function emitBundle(fileName: string, data: string): void {
}
/** Returns the TypeScript Extension enum for a given media type. */
-function getExtension(
- fileName: string,
- mediaType: msg.MediaType
-): ts.Extension {
+function getExtension(fileName: string, mediaType: MediaType): ts.Extension {
switch (mediaType) {
- case msg.MediaType.JavaScript:
+ case MediaType.JavaScript:
return ts.Extension.Js;
- case msg.MediaType.TypeScript:
+ case MediaType.TypeScript:
return fileName.endsWith(".d.ts") ? ts.Extension.Dts : ts.Extension.Ts;
- case msg.MediaType.Json:
+ case MediaType.Json:
return ts.Extension.Json;
- case msg.MediaType.Unknown:
+ case MediaType.Unknown:
default:
throw TypeError("Cannot resolve extension.");
}
@@ -224,7 +227,7 @@ class Host implements ts.CompilerHost {
const sourceFile = {
moduleName,
filename: specifier,
- mediaType: msg.MediaType.TypeScript,
+ mediaType: MediaType.TypeScript,
sourceCode
};
this._sourceFileCache[moduleName] = sourceFile;
diff --git a/js/dispatch_json.ts b/js/dispatch_json.ts
index e8c976164..bde2b7cb1 100644
--- a/js/dispatch_json.ts
+++ b/js/dispatch_json.ts
@@ -1,12 +1,8 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-// Do not add flatbuffer dependencies to this module.
-// TODO(ry) Currently ErrorKind enum is defined in FlatBuffers. Therefore
-// we must still reference the msg_generated.ts. This should be removed!
-import { ErrorKind } from "gen/cli/msg_generated";
import * as util from "./util";
import { TextEncoder, TextDecoder } from "./text_encoding";
import { core } from "./core";
-import { DenoError } from "./errors";
+import { ErrorKind, DenoError } from "./errors";
// eslint-disable-next-line @typescript-eslint/no-explicit-any
type Ok = any;
diff --git a/js/errors.ts b/js/errors.ts
index 717015589..02ddfa2f2 100644
--- a/js/errors.ts
+++ b/js/errors.ts
@@ -1,6 +1,4 @@
// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { ErrorKind } from "gen/cli/msg_generated";
-export { ErrorKind } from "gen/cli/msg_generated";
/** A Deno specific error. The `kind` property is set to a specific error code
* which can be used to in application logic.
@@ -23,3 +21,59 @@ export class DenoError<T extends ErrorKind> extends Error {
this.name = ErrorKind[kind];
}
}
+
+// Warning! The values in this enum are duplicated in cli/msg.rs
+// Update carefully!
+export enum ErrorKind {
+ NoError = 0,
+ NotFound = 1,
+ PermissionDenied = 2,
+ ConnectionRefused = 3,
+ ConnectionReset = 4,
+ ConnectionAborted = 5,
+ NotConnected = 6,
+ AddrInUse = 7,
+ AddrNotAvailable = 8,
+ BrokenPipe = 9,
+ AlreadyExists = 10,
+ WouldBlock = 11,
+ InvalidInput = 12,
+ InvalidData = 13,
+ TimedOut = 14,
+ Interrupted = 15,
+ WriteZero = 16,
+ Other = 17,
+ UnexpectedEof = 18,
+ BadResource = 19,
+ CommandFailed = 20,
+ EmptyHost = 21,
+ IdnaError = 22,
+ InvalidPort = 23,
+ InvalidIpv4Address = 24,
+ InvalidIpv6Address = 25,
+ InvalidDomainCharacter = 26,
+ RelativeUrlWithoutBase = 27,
+ RelativeUrlWithCannotBeABaseBase = 28,
+ SetHostOnCannotBeABaseUrl = 29,
+ Overflow = 30,
+ HttpUser = 31,
+ HttpClosed = 32,
+ HttpCanceled = 33,
+ HttpParse = 34,
+ HttpOther = 35,
+ TooLarge = 36,
+ InvalidUri = 37,
+ InvalidSeekMode = 38,
+ OpNotAvailable = 39,
+ WorkerInitFailed = 40,
+ UnixError = 41,
+ NoAsyncSupport = 42,
+ NoSyncSupport = 43,
+ ImportMapError = 44,
+ InvalidPath = 45,
+ ImportPrefixMissing = 46,
+ UnsupportedFetchScheme = 47,
+ TooManyRedirects = 48,
+ Diagnostic = 49,
+ JSError = 50
+}
diff --git a/js/flatbuffers.ts b/js/flatbuffers.ts
deleted file mode 100644
index f05bd1c55..000000000
--- a/js/flatbuffers.ts
+++ /dev/null
@@ -1,56 +0,0 @@
-// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license.
-import { flatbuffers } from "flatbuffers";
-import * as util from "./util";
-
-/* eslint-disable @typescript-eslint/camelcase */
-
-// Re-export some types.
-export type Offset = flatbuffers.Offset;
-export class ByteBuffer extends flatbuffers.ByteBuffer {}
-export interface Builder extends flatbuffers.Builder {
- inUse: boolean;
-}
-
-const globalBuilder = new flatbuffers.Builder() as Builder;
-globalBuilder.inUse = false;
-
-// This is a wrapper around the real Builder .
-// The purpose is to reuse a single ArrayBuffer for every message.
-// We can do this because the "control" messages sent to the privileged
-// side are guaranteed to be used during the call to Deno.core.send().
-export function createBuilder(): Builder {
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
- const gb = globalBuilder as any;
- util.assert(!gb.inUse);
-
- let bb = globalBuilder.dataBuffer();
- // Only create a new backing ArrayBuffer if the previous one had grown very
- // large in capacity. This should only happen rarely.
- if (bb.capacity() > 1024) {
- util.log(`realloc flatbuffer ArrayBuffer because it was ${bb.capacity()}`);
- bb = ByteBuffer.allocate(1024);
- }
- gb.bb = bb;
- // Remaining space in the ByteBuffer.
- gb.space = globalBuilder.dataBuffer().capacity();
- // Minimum alignment encountered so far.
- gb.minalign = 1;
- // The vtable for the current table.
- gb.vtable = null;
- // The amount of fields we're actually using.
- gb.vtable_in_use = 0;
- // Whether we are currently serializing a table.
- gb.isNested = false;
- // Starting offset of the current struct/table.
- gb.object_start = 0;
- // List of offsets of all vtables.
- gb.vtables = [];
- // For the current vector being built.
- gb.vector_num_elems = 0;
- // False omits default values from the serialized data
- gb.force_defaults = false;
-
- gb.inUse = true;
-
- return gb as Builder;
-}
diff --git a/package.json b/package.json
index 8f87d4229..7d11915b4 100644
--- a/package.json
+++ b/package.json
@@ -3,14 +3,12 @@
"devDependencies": {
"@stardazed/streams": "3.0.0",
"@types/base64-js": "1.2.5",
- "@types/flatbuffers": "1.9.1",
"@types/prettier": "1.16.1",
"@typescript-eslint/eslint-plugin": "1.6.0",
"@typescript-eslint/parser": "1.6.0",
"base64-js": "1.3.0",
"eslint": "5.15.1",
"eslint-config-prettier": "4.1.0",
- "flatbuffers": "1.9.0",
"magic-string": "0.25.2",
"prettier": "1.17.1",
"rollup": "1.4.1",
diff --git a/third_party b/third_party
-Subproject ad1117a3448408d7c008b680c770c6ea26f0782
+Subproject a338942cea812ab197ef0abaafd312ef28a3ff1
diff --git a/tools/ts_library_builder/build_library.ts b/tools/ts_library_builder/build_library.ts
index 678a603ae..0a18abcbb 100644
--- a/tools/ts_library_builder/build_library.ts
+++ b/tools/ts_library_builder/build_library.ts
@@ -89,27 +89,6 @@ const libPreamble = `// Copyright 2018-2019 the Deno authors. All rights reserve
`;
-// The path to the msg_generated file relative to the build path
-const MSG_GENERATED_PATH = "/gen/cli/msg_generated.ts";
-
-// An array of enums we want to expose pub
-const MSG_GENERATED_ENUMS = ["ErrorKind"];
-
-/** Extracts enums from a source file */
-function extract(sourceFile: SourceFile, enumNames: string[]): string {
- // Copy specified enums from msg_generated
- let output = "";
- for (const enumName of enumNames) {
- const enumDeclaration = sourceFile.getEnumOrThrow(enumName);
- enumDeclaration.setHasDeclareKeyword(false);
- // we are not copying JSDocs or other trivia here because msg_generated only
- // contains some non-useful JSDocs and comments that are not ideal to copy
- // over
- output += enumDeclaration.getText();
- }
- return output;
-}
-
interface FlattenOptions {
basePath: string;
customSources: { [filePath: string]: string };
@@ -499,20 +478,8 @@ export function main({
// Deal with `js/deno.ts`
- // `gen/msg_generated.d.ts` contains too much exported information that is not
- // part of the public API surface of Deno, so we are going to extract just the
- // information we need.
- const msgGeneratedDts = inputProject.getSourceFileOrThrow(
- `${buildPath}${MSG_GENERATED_PATH}`
- );
- const msgGeneratedDtsText = extract(msgGeneratedDts, MSG_GENERATED_ENUMS);
-
// Generate a object hash of substitutions of modules to use when flattening
- const customSources = {
- [msgGeneratedDts.getFilePath().replace(/(\.d)?\.ts$/, "")]: `${
- debug ? getSourceComment(msgGeneratedDts, basePath) : ""
- }${msgGeneratedDtsText}\n`
- };
+ const customSources = {};
const prepareForMergeOpts: PrepareFileForMergeOptions = {
globalVarName: "window",