--- openexr/IlmBase/Half/half.cpp 2019-09-09 23:40:27.186426000 -0700 +++ ilmbase_half.cpp 2019-08-05 18:07:51.371334000 -0700 @@ -45,18 +45,27 @@ //--------------------------------------------------------------------------- #include -#include "half.h" + +#include "pxr/pxr.h" +#include "pxr/base/gf/ilmbase_half.h" + +#include +#include using namespace std; +PXR_NAMESPACE_OPEN_SCOPE + +namespace pxr_half { + //------------------------------------------------------------- // Lookup tables for half-to-float and float-to-half conversion //------------------------------------------------------------- -HALF_EXPORT const half::uif half::_toFloat[1 << 16] = - #include "toFloat.h" -HALF_EXPORT const unsigned short half::_eLut[1 << 9] = - #include "eLut.h" +GF_API const half::uif half::_toFloat[1 << 16] = + #include "pxr/base/gf/ilmbase_toFloat.h" +GF_API const unsigned short half::_eLut[1 << 9] = + #include "pxr/base/gf/ilmbase_eLut.h" //----------------------------------------------- // Overflow handler for float-to-half conversion; @@ -64,7 +73,7 @@ // which may be trapped by the operating system. //----------------------------------------------- -HALF_EXPORT float +GF_API float half::overflow () { volatile float f = 1e10; @@ -81,7 +90,7 @@ // zeroes, denormalized numbers and exponent overflows. //----------------------------------------------------- -HALF_EXPORT short +GF_API short half::convert (int i) { // @@ -221,7 +230,7 @@ // Stream I/O operators //--------------------- -HALF_EXPORT ostream & +GF_API ostream & operator << (ostream &os, half h) { os << float (h); @@ -229,7 +238,7 @@ } -HALF_EXPORT istream & +GF_API istream & operator >> (istream &is, half &h) { float f; @@ -244,7 +253,7 @@ // floats and halfs, mostly for debugging //--------------------------------------- -HALF_EXPORT void +GF_API void printBits (ostream &os, half h) { unsigned short b = h.bits(); @@ -259,7 +268,7 @@ } -HALF_EXPORT void +GF_API void printBits (ostream &os, float f) { half::uif x; @@ -275,7 +284,7 @@ } -HALF_EXPORT void +GF_API void printBits (char c[19], half h) { unsigned short b = h.bits(); @@ -292,7 +301,7 @@ } -HALF_EXPORT void +GF_API void printBits (char c[35], float f) { half::uif x; @@ -308,3 +317,7 @@ c[34] = 0; } + +} // namespace pxr_half + +PXR_NAMESPACE_CLOSE_SCOPE --- openexr/IlmBase/Half/half.h 2019-09-09 23:42:36.452479000 -0700 +++ ilmbase_half.h 2019-09-09 14:25:22.287651000 -0700 @@ -82,11 +82,17 @@ // //--------------------------------------------------------------------------- -#ifndef _HALF_H_ -#define _HALF_H_ +#ifndef PXR_HALF_H +#define PXR_HALF_H -#include "halfExport.h" // for definition of HALF_EXPORT -#include +#include "pxr/pxr.h" +#include "pxr/base/gf/api.h" + +#include + +PXR_NAMESPACE_OPEN_SCOPE + +namespace pxr_half { class half { @@ -96,9 +102,11 @@ // Constructors //------------- - half (); // no initialization + half () = default; // no initialization half (float f); + constexpr half (const half& h) = default; + //-------------------- // Conversion to float @@ -118,7 +126,7 @@ // Assignment //----------- - half & operator = (half h); + half & operator = (const half &) = default; half & operator = (float f); half & operator += (half h); @@ -197,8 +205,8 @@ // Access to the internal representation //-------------------------------------- - HALF_EXPORT unsigned short bits () const; - HALF_EXPORT void setBits (unsigned short bits); + GF_API unsigned short bits () const; + GF_API void setBits (unsigned short bits); public: @@ -211,13 +219,13 @@ private: - HALF_EXPORT static short convert (int i); - HALF_EXPORT static float overflow (); + GF_API static short convert (int i); + GF_API static float overflow (); unsigned short _h; - HALF_EXPORT static const uif _toFloat[1 << 16]; - HALF_EXPORT static const unsigned short _eLut[1 << 9]; + GF_API static const uif _toFloat[1 << 16]; + GF_API static const unsigned short _eLut[1 << 9]; }; @@ -226,18 +234,18 @@ // Stream I/O //----------- -HALF_EXPORT std::ostream & operator << (std::ostream &os, half h); -HALF_EXPORT std::istream & operator >> (std::istream &is, half &h); +GF_API std::ostream & operator << (std::ostream &os, half h); +GF_API std::istream & operator >> (std::istream &is, half &h); //---------- // Debugging //---------- -HALF_EXPORT void printBits (std::ostream &os, half h); -HALF_EXPORT void printBits (std::ostream &os, float f); -HALF_EXPORT void printBits (char c[19], half h); -HALF_EXPORT void printBits (char c[35], float f); +GF_API void printBits (std::ostream &os, half h); +GF_API void printBits (std::ostream &os, float f); +GF_API void printBits (char c[19], half h); +GF_API void printBits (char c[35], float f); //------------------------------------------------------------------------- @@ -414,17 +422,6 @@ //--------------------------------------------------------------------------- -//-------------------- -// Simple constructors -//-------------------- - -inline -half::half () -{ - // no initialization -} - - //---------------------------- // Half-from-float constructor //---------------------------- @@ -573,14 +570,6 @@ inline half & -half::operator = (half h) -{ - _h = h._h; - return *this; -} - - -inline half & half::operator = (float f) { *this = half (f); @@ -758,4 +747,8 @@ _h = bits; } +} // namespace pxr_half + +PXR_NAMESPACE_CLOSE_SCOPE + #endif --- openexr/IlmBase/Half/halfLimits.h 2019-09-09 23:40:27.206431000 -0700 +++ ilmbase_halfLimits.h 2019-08-05 18:07:51.394336000 -0700 @@ -38,8 +38,8 @@ // Rod Bogart -#ifndef INCLUDED_HALF_LIMITS_H -#define INCLUDED_HALF_LIMITS_H +#ifndef PXR_HALF_LIMITS_H +#define PXR_HALF_LIMITS_H //------------------------------------------------------------------------ @@ -49,13 +49,16 @@ //------------------------------------------------------------------------ #include -#include "half.h" +#include "pxr/base/gf/ilmbase_half.h" namespace std { template <> -class numeric_limits +class numeric_limits { + private: + using half = PXR_NS::pxr_half::half; + public: static const bool is_specialized = true;