Remove Abseil use from platfrom/api and platform/base.
Replaces Abseil library calls with STL equivalents, or re-implemented
equivalents. In particular, std::variant in ErrorOr<> was replaced with
a raw union (plus ctor/dtor voodoo). Also, cleaned up IPAddress ctors
and parsing routines.
Bug: openscreen:88
Change-Id: Idba4080a7b8e179067313fbcc04758a5463e621a
Reviewed-on: https://chromium-review.googlesource.com/c/openscreen/+/1947904
Reviewed-by: Yuri Wiitala <miu@chromium.org>
Reviewed-by: Jordan Bayles <jophba@chromium.org>
Commit-Queue: Yuri Wiitala <miu@chromium.org>
diff --git a/platform/api/DEPS b/platform/api/DEPS
index f0fc67f..f833653 100644
--- a/platform/api/DEPS
+++ b/platform/api/DEPS
@@ -3,7 +3,20 @@
# found in the LICENSE file.
include_rules = [
+ # Platform API code should depend on no outside code/libraries, other than
+ # the standard toolchain libraries (C, STL) and platform/base.
+ '-absl',
+ '-platform',
+ '+platform/api',
'+platform/base',
'-util',
'-third_party',
]
+
+specific_include_rules = {
+ ".*_unittest\.cc": [
+ '+platform/test',
+ '+util',
+ '+third_party',
+ ],
+}
diff --git a/platform/api/logging.h b/platform/api/logging.h
index 9ff79d1..0dea6d4 100644
--- a/platform/api/logging.h
+++ b/platform/api/logging.h
@@ -5,7 +5,7 @@
#ifndef PLATFORM_API_LOGGING_H_
#define PLATFORM_API_LOGGING_H_
-#include "absl/strings/string_view.h"
+#include <sstream>
namespace openscreen {
namespace platform {
@@ -36,17 +36,20 @@
// Returns true if |level| is at or above the level where the embedder will
// record/emit log entries from the code in |file|.
-bool IsLoggingOn(LogLevel level, absl::string_view file);
+bool IsLoggingOn(LogLevel level, const char* file);
// Record a log entry, consisting of its logging level, location and message.
// The embedder may filter-out entries according to its own policy, but this
// function will not be called if IsLoggingOn(level, file) returns false.
// Whenever |level| is kFatal, Open Screen will call Break() immediately after
// this returns.
+//
+// |message| is passed as a string stream to avoid unnecessary string copies.
+// Embedders can call its rdbuf() or str() methods to access the log message.
void LogWithLevel(LogLevel level,
- absl::string_view file,
+ const char* file,
int line,
- absl::string_view msg);
+ std::stringstream message);
// Breaks into the debugger, if one is present. Otherwise, aborts the current
// process (i.e., this function should not return). In production builds, an
diff --git a/platform/api/socket_integration_unittest.cc b/platform/api/socket_integration_unittest.cc
index fe15377..3014507 100644
--- a/platform/api/socket_integration_unittest.cc
+++ b/platform/api/socket_integration_unittest.cc
@@ -35,7 +35,7 @@
// successfully Bind(), and that the operating system will return the
// auto-assigned socket name (i.e., the local endpoint's port will not be zero).
TEST(SocketIntegrationTest, ResolvesLocalEndpoint_IPv6) {
- const uint8_t kIpV6AddrAny[16] = {};
+ const uint16_t kIpV6AddrAny[8] = {};
FakeClock clock(Clock::now());
FakeTaskRunner task_runner(&clock);
FakeUdpSocket::MockClient client;
diff --git a/platform/api/task_runner.h b/platform/api/task_runner.h
index c94777f..4f3526d 100644
--- a/platform/api/task_runner.h
+++ b/platform/api/task_runner.h
@@ -5,9 +5,9 @@
#ifndef PLATFORM_API_TASK_RUNNER_H_
#define PLATFORM_API_TASK_RUNNER_H_
-#include <future>
+#include <future> // NOLINT
+#include <utility>
-#include "absl/types/optional.h"
#include "platform/api/time.h"
namespace openscreen {