From 06c0e291182f20f207e4c914ae78d3f9ec16e074 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Tue, 29 Jan 2019 21:31:59 -0500 Subject: [PATCH] Fix cpplint --- libdeno/api.cc | 2 +- libdeno/binding.cc | 4 +--- libdeno/deno.h | 12 ------------ libdeno/exceptions.cc | 3 +++ libdeno/exceptions.h | 1 + libdeno/internal.h | 3 ++- libdeno/test.cc | 1 + libdeno/test.h | 6 +++--- tools/lint.py | 4 ++-- 9 files changed, 14 insertions(+), 22 deletions(-) diff --git a/libdeno/api.cc b/libdeno/api.cc index ebdbea6439..1c62cdd5ac 100644 --- a/libdeno/api.cc +++ b/libdeno/api.cc @@ -15,7 +15,7 @@ extern "C" { Deno* deno_new_snapshotter(deno_config config) { CHECK(config.will_snapshot); - // TODO Support loading snapshots before snapshotting. + // TODO(ry) Support loading snapshots before snapshotting. CHECK_NULL(config.load_snapshot.data_ptr); auto* creator = new v8::SnapshotCreator(deno::external_references); auto* isolate = creator->GetIsolate(); diff --git a/libdeno/binding.cc b/libdeno/binding.cc index effb2a979e..39007405fa 100644 --- a/libdeno/binding.cc +++ b/libdeno/binding.cc @@ -357,14 +357,12 @@ v8::MaybeLocal ResolveCallback(v8::Local context, // In order to export obj as a module, we must iterate over its properties // and export them each individually. - // TODO Find a better way to do this. std::string src = "let globalEval = eval\nlet g = globalEval('this');\n"; auto names = obj->GetOwnPropertyNames(context).ToLocalChecked(); for (uint32_t i = 0; i < names->Length(); i++) { auto name = names->Get(context, i).ToLocalChecked(); v8::String::Utf8Value name_utf8val(isolate, name); const char* name_cstr = ToCString(name_utf8val); - // TODO use format string. src.append("export const "); src.append(name_cstr); src.append(" = g.libdeno.builtinModules."); @@ -396,7 +394,7 @@ v8::MaybeLocal ResolveCallback(v8::Local context, break; } } - CHECK(referrer_filename.size() != 0); + CHECK_NE(referrer_filename.size(), 0); v8::String::Utf8Value specifier_(isolate, specifier); const char* specifier_c = ToCString(specifier_); diff --git a/libdeno/deno.h b/libdeno/deno.h index 7c8e94244a..7568002ae5 100644 --- a/libdeno/deno.h +++ b/libdeno/deno.h @@ -62,12 +62,6 @@ void deno_delete(Deno* d); // module import statements. // Return value: 0 = fail, 1 = success // Get error text with deno_last_exception(). -// -// TODO change return value to be const char*. On success the return -// value is nullptr, on failure it is the JSON exception text that -// is returned by deno_last_exception(). Remove deno_last_exception(). -// The return string is valid until the next execution of deno_execute or -// deno_respond (as deno_last_exception is now). int deno_execute(Deno* d, void* user_data, const char* js_filename, const char* js_source); @@ -99,12 +93,6 @@ int deno_execute_mod(Deno* d, void* user_data, const char* js_filename, // // A non-zero return value, means a JS exception was encountered during the // libdeno.recv() callback. Check deno_last_exception() for exception text. -// -// TODO change return value to be const char*. On success the return -// value is nullptr, on failure it is the JSON exception text that -// is returned by deno_last_exception(). Remove deno_last_exception(). -// The return string is valid until the next execution of deno_execute or -// deno_respond (as deno_last_exception is now). int deno_respond(Deno* d, void* user_data, int32_t req_id, deno_buf buf); void deno_check_promise_errors(Deno* d); diff --git a/libdeno/exceptions.cc b/libdeno/exceptions.cc index 5b1e67b930..081e61060f 100644 --- a/libdeno/exceptions.cc +++ b/libdeno/exceptions.cc @@ -1,3 +1,6 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. +#include "exceptions.h" +#include namespace deno { diff --git a/libdeno/exceptions.h b/libdeno/exceptions.h index fce70e3f31..362bbc0e6f 100644 --- a/libdeno/exceptions.h +++ b/libdeno/exceptions.h @@ -1,3 +1,4 @@ +// Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. #ifndef EXCEPTIONS_H_ #define EXCEPTIONS_H_ diff --git a/libdeno/internal.h b/libdeno/internal.h index d1b9f1d96f..58dae013c9 100644 --- a/libdeno/internal.h +++ b/libdeno/internal.h @@ -4,6 +4,7 @@ #include #include +#include #include "deno.h" #include "third_party/v8/include/v8.h" #include "third_party/v8/src/base/logging.h" @@ -13,7 +14,7 @@ namespace deno { // deno_s = Wrapped Isolate. class DenoIsolate { public: - DenoIsolate(deno_config config) + explicit DenoIsolate(deno_config config) : isolate_(nullptr), shared_(config.shared), current_args_(nullptr), diff --git a/libdeno/test.cc b/libdeno/test.cc index 4901ba6727..a8fcbc63b6 100644 --- a/libdeno/test.cc +++ b/libdeno/test.cc @@ -1,5 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. #include "test.h" +#include #include "file_util.h" deno_buf snapshot = {nullptr, 0, nullptr, 0}; diff --git a/libdeno/test.h b/libdeno/test.h index 91e7119e83..25ca939887 100644 --- a/libdeno/test.h +++ b/libdeno/test.h @@ -1,6 +1,6 @@ // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -#ifndef TEST_H -#define TEST_H +#ifndef TEST_H_ +#define TEST_H_ #include "deno.h" #include "testing/gtest/include/gtest/gtest.h" @@ -8,4 +8,4 @@ extern deno_buf snapshot; // Loaded in libdeno/test.cc const deno_buf empty = {nullptr, 0, nullptr, 0}; -#endif // TEST_H +#endif // TEST_H_ diff --git a/tools/lint.py b/tools/lint.py index 4c38d3c69e..1e22703b5a 100755 --- a/tools/lint.py +++ b/tools/lint.py @@ -15,8 +15,8 @@ tslint = os.path.join(third_party_path, "node_modules", "tslint", "bin", os.chdir(root_path) run([ - "python", cpplint, "--filter=-build/include_subdir", "--repository=src", - "--extensions=cc,h", "--recursive", "src/." + "python", cpplint, "--filter=-build/include_subdir", "--repository=libdeno", + "--extensions=cc,h", "--recursive", "libdeno" ]) run(["node", tslint, "-p", ".", "--exclude", "**/gen/**/*.ts"])