diff options
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> |