diff options
author | Colin Cross <ccross@android.com> | 2017-06-06 03:02:36 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2017-06-06 03:02:36 +0000 |
commit | 31db13c42a58810f66cc87c6f100465c99b8365c (patch) | |
tree | a3030d07d2ff89294ce4b6394afc5cbe4f67dbda /cpp/src/sfntly/port | |
parent | ccb3219886cbefb53c7e4160388123658200df94 (diff) | |
parent | ad302cbfd89396891e23d8902cea1b8189ac7d58 (diff) | |
download | sfntly-31db13c42a58810f66cc87c6f100465c99b8365c.tar.gz |
Merge remote-tracking branch 'aosp/upstream-master' into master am: d7c3ad1d95 am: fd76129cde am: 3d3aab44bf
am: ad302cbfd8
Change-Id: Ib2862c4330034e2bfa4a65e6d3f4dfd61e0e4f44
Diffstat (limited to 'cpp/src/sfntly/port')
-rw-r--r-- | cpp/src/sfntly/port/file_input_stream.cc | 2 | ||||
-rw-r--r-- | cpp/src/sfntly/port/logging.h | 31 | ||||
-rwxr-xr-x | cpp/src/sfntly/port/memory_input_stream.cc | 2 | ||||
-rw-r--r-- | cpp/src/sfntly/port/refcount.h | 21 | ||||
-rw-r--r-- | cpp/src/sfntly/port/type.h | 2 |
5 files changed, 45 insertions, 13 deletions
diff --git a/cpp/src/sfntly/port/file_input_stream.cc b/cpp/src/sfntly/port/file_input_stream.cc index 5bcb434..dfe9a7b 100644 --- a/cpp/src/sfntly/port/file_input_stream.cc +++ b/cpp/src/sfntly/port/file_input_stream.cc @@ -18,6 +18,8 @@ #include <windows.h> #endif +#include <algorithm> + #include "sfntly/port/file_input_stream.h" #include "sfntly/port/exception_type.h" diff --git a/cpp/src/sfntly/port/logging.h b/cpp/src/sfntly/port/logging.h new file mode 100644 index 0000000..1d9e319 --- /dev/null +++ b/cpp/src/sfntly/port/logging.h @@ -0,0 +1,31 @@ +/* + * Copyright 2015 Google Inc. All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef SFNTLY_CPP_SRC_SFNTLY_PORT_LOGGING_H_ +#define SFNTLY_CPP_SRC_SFNTLY_PORT_LOGGING_H_ + +#include <stdio.h> +#include <stdlib.h> + +// Cheap base/logging.h knock off. + +#define CHECK(expr) \ + if (!(expr)) { \ + printf("CHECK failed\n"); \ + abort(); \ + } + +#endif // SFNTLY_CPP_SRC_SFNTLY_PORT_LOGGING_H_ diff --git a/cpp/src/sfntly/port/memory_input_stream.cc b/cpp/src/sfntly/port/memory_input_stream.cc index 56ee81e..f6f2b9b 100755 --- a/cpp/src/sfntly/port/memory_input_stream.cc +++ b/cpp/src/sfntly/port/memory_input_stream.cc @@ -20,6 +20,8 @@ #include <string.h> +#include <algorithm> + #include "sfntly/port/memory_input_stream.h" #include "sfntly/port/exception_type.h" diff --git a/cpp/src/sfntly/port/refcount.h b/cpp/src/sfntly/port/refcount.h index eed5162..6353b08 100644 --- a/cpp/src/sfntly/port/refcount.h +++ b/cpp/src/sfntly/port/refcount.h @@ -99,22 +99,18 @@ namespace sfntly { +template <typename T> +class Ptr; + class RefCount { public: // Make gcc -Wnon-virtual-dtor happy. virtual ~RefCount() {} - virtual size_t AddRef() const = 0; - virtual size_t Release() const = 0; -}; - -template <typename T> -class NoAddRefRelease : public T { - public: - NoAddRefRelease(); - ~NoAddRefRelease(); - private: + template <typename T> + friend class Ptr; + virtual size_t AddRef() const = 0; virtual size_t Release() const = 0; }; @@ -142,6 +138,7 @@ class RefCounted : virtual public RefCount { return *this; } + private: virtual size_t AddRef() const { size_t new_count = AtomicIncrement(&ref_count_); DEBUG_OUTPUT("A "); @@ -224,8 +221,8 @@ class Ptr { return *p_; // It can throw! } - NoAddRefRelease<T>* operator->() const { - return (NoAddRefRelease<T>*)p_; // It can throw! + T* operator->() const { + return p_; // It can throw! } bool operator!() const { diff --git a/cpp/src/sfntly/port/type.h b/cpp/src/sfntly/port/type.h index 20a5ba8..9f82a5a 100644 --- a/cpp/src/sfntly/port/type.h +++ b/cpp/src/sfntly/port/type.h @@ -41,7 +41,7 @@ #include <stdint.h> #endif -#include <cstddef> +#include <stddef.h> #include <vector> #include <set> |