Update Boost.WinAPI usage to the new location and namespace.

This commit is contained in:
Andrey Semashev
2017-10-24 21:25:23 +03:00
committed by Vinnie Falco
parent 645fdb6581
commit ab2a225a9a
5 changed files with 108 additions and 107 deletions

View File

@ -9,6 +9,7 @@ Version 126:
* Fix shadowing in session_alloc
* Fix executor type compilation
* Add Travis tests with the default compilers
* Update Boost.WinAPI usage to the new location and namespace.
--------------------------------------------------------------------------------

View File

@ -24,8 +24,8 @@
#include <boost/beast/core/error.hpp>
#include <boost/beast/core/file_base.hpp>
#include <boost/detail/winapi/basic_types.hpp>
#include <boost/detail/winapi/handles.hpp>
#include <boost/winapi/basic_types.hpp>
#include <boost/winapi/handles.hpp>
#include <cstdio>
#include <cstdint>
@ -38,8 +38,8 @@ namespace beast {
*/
class file_win32
{
boost::detail::winapi::HANDLE_ h_ =
boost::detail::winapi::INVALID_HANDLE_VALUE_;
boost::winapi::HANDLE_ h_ =
boost::winapi::INVALID_HANDLE_VALUE_;
public:
/** The type of the underlying file handle.
@ -49,7 +49,7 @@ public:
#if BOOST_BEAST_DOXYGEN
using native_handle_type = HANDLE;
#else
using native_handle_type = boost::detail::winapi::HANDLE_;
using native_handle_type = boost::winapi::HANDLE_;
#endif
/** Destructor
@ -96,7 +96,7 @@ public:
bool
is_open() const
{
return h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_;
return h_ != boost::winapi::INVALID_HANDLE_VALUE_;
}
/** Close the file if open

View File

@ -10,10 +10,10 @@
#ifndef BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
#define BOOST_BEAST_CORE_IMPL_FILE_WIN32_IPP
#include <boost/detail/winapi/access_rights.hpp>
#include <boost/detail/winapi/error_codes.hpp>
#include <boost/detail/winapi/file_management.hpp>
#include <boost/detail/winapi/get_last_error.hpp>
#include <boost/winapi/access_rights.hpp>
#include <boost/winapi/error_codes.hpp>
#include <boost/winapi/file_management.hpp>
#include <boost/winapi/get_last_error.hpp>
#include <limits>
#include <utility>
@ -25,20 +25,20 @@ namespace detail {
// VFALCO Can't seem to get boost/detail/winapi to work with
// this so use the non-Ex version for now.
inline
boost::detail::winapi::BOOL_
boost::winapi::BOOL_
set_file_pointer_ex(
boost::detail::winapi::HANDLE_ hFile,
boost::detail::winapi::LARGE_INTEGER_ lpDistanceToMove,
boost::detail::winapi::PLARGE_INTEGER_ lpNewFilePointer,
boost::detail::winapi::DWORD_ dwMoveMethod)
boost::winapi::HANDLE_ hFile,
boost::winapi::LARGE_INTEGER_ lpDistanceToMove,
boost::winapi::PLARGE_INTEGER_ lpNewFilePointer,
boost::winapi::DWORD_ dwMoveMethod)
{
auto dwHighPart = lpDistanceToMove.u.HighPart;
auto dwLowPart = boost::detail::winapi::SetFilePointer(
auto dwLowPart = boost::winapi::SetFilePointer(
hFile,
lpDistanceToMove.u.LowPart,
&dwHighPart,
dwMoveMethod);
if(dwLowPart == boost::detail::winapi::INVALID_SET_FILE_POINTER_)
if(dwLowPart == boost::winapi::INVALID_SET_FILE_POINTER_)
return 0;
if(lpNewFilePointer)
{
@ -54,8 +54,8 @@ inline
file_win32::
~file_win32()
{
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
boost::detail::winapi::CloseHandle(h_);
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
boost::winapi::CloseHandle(h_);
}
inline
@ -63,7 +63,7 @@ file_win32::
file_win32(file_win32&& other)
: h_(other.h_)
{
other.h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
other.h_ = boost::winapi::INVALID_HANDLE_VALUE_;
}
inline
@ -74,9 +74,9 @@ operator=(file_win32&& other)
if(&other == this)
return *this;
if(h_)
boost::detail::winapi::CloseHandle(h_);
boost::winapi::CloseHandle(h_);
h_ = other.h_;
other.h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
other.h_ = boost::winapi::INVALID_HANDLE_VALUE_;
return *this;
}
@ -85,8 +85,8 @@ void
file_win32::
native_handle(native_handle_type h)
{
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
boost::detail::winapi::CloseHandle(h_);
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
boost::winapi::CloseHandle(h_);
h_ = h;
}
@ -95,14 +95,14 @@ void
file_win32::
close(error_code& ec)
{
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
{
if(! boost::detail::winapi::CloseHandle(h_))
ec.assign(boost::detail::winapi::GetLastError(),
if(! boost::winapi::CloseHandle(h_))
ec.assign(boost::winapi::GetLastError(),
system_category());
else
ec.assign(0, ec.category());
h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
h_ = boost::winapi::INVALID_HANDLE_VALUE_;
}
else
{
@ -115,15 +115,15 @@ void
file_win32::
open(char const* path, file_mode mode, error_code& ec)
{
if(h_ != boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ != boost::winapi::INVALID_HANDLE_VALUE_)
{
boost::detail::winapi::CloseHandle(h_);
h_ = boost::detail::winapi::INVALID_HANDLE_VALUE_;
boost::winapi::CloseHandle(h_);
h_ = boost::winapi::INVALID_HANDLE_VALUE_;
}
boost::detail::winapi::DWORD_ share_mode = 0;
boost::detail::winapi::DWORD_ desired_access = 0;
boost::detail::winapi::DWORD_ creation_disposition = 0;
boost::detail::winapi::DWORD_ flags_and_attributes = 0;
boost::winapi::DWORD_ share_mode = 0;
boost::winapi::DWORD_ desired_access = 0;
boost::winapi::DWORD_ creation_disposition = 0;
boost::winapi::DWORD_ flags_and_attributes = 0;
/*
| When the file...
This argument: | Exists Does not exist
@ -138,59 +138,59 @@ open(char const* path, file_mode mode, error_code& ec)
{
default:
case file_mode::read:
desired_access = boost::detail::winapi::GENERIC_READ_;
share_mode = boost::detail::winapi::FILE_SHARE_READ_;
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
desired_access = boost::winapi::GENERIC_READ_;
share_mode = boost::winapi::FILE_SHARE_READ_;
creation_disposition = boost::winapi::OPEN_EXISTING_;
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
break;
case file_mode::scan:
desired_access = boost::detail::winapi::GENERIC_READ_;
share_mode = boost::detail::winapi::FILE_SHARE_READ_;
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
desired_access = boost::winapi::GENERIC_READ_;
share_mode = boost::winapi::FILE_SHARE_READ_;
creation_disposition = boost::winapi::OPEN_EXISTING_;
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
break;
case file_mode::write:
desired_access = boost::detail::winapi::GENERIC_READ_ |
boost::detail::winapi::GENERIC_WRITE_;
creation_disposition = boost::detail::winapi::CREATE_ALWAYS_;
desired_access = boost::winapi::GENERIC_READ_ |
boost::winapi::GENERIC_WRITE_;
creation_disposition = boost::winapi::CREATE_ALWAYS_;
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
break;
case file_mode::write_new:
desired_access = boost::detail::winapi::GENERIC_READ_ |
boost::detail::winapi::GENERIC_WRITE_;
creation_disposition = boost::detail::winapi::CREATE_NEW_;
desired_access = boost::winapi::GENERIC_READ_ |
boost::winapi::GENERIC_WRITE_;
creation_disposition = boost::winapi::CREATE_NEW_;
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
break;
case file_mode::write_existing:
desired_access = boost::detail::winapi::GENERIC_READ_ |
boost::detail::winapi::GENERIC_WRITE_;
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
desired_access = boost::winapi::GENERIC_READ_ |
boost::winapi::GENERIC_WRITE_;
creation_disposition = boost::winapi::OPEN_EXISTING_;
flags_and_attributes = 0x10000000; // FILE_FLAG_RANDOM_ACCESS
break;
case file_mode::append:
desired_access = boost::detail::winapi::GENERIC_READ_ |
boost::detail::winapi::GENERIC_WRITE_;
desired_access = boost::winapi::GENERIC_READ_ |
boost::winapi::GENERIC_WRITE_;
creation_disposition = boost::detail::winapi::CREATE_ALWAYS_;
creation_disposition = boost::winapi::CREATE_ALWAYS_;
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
break;
case file_mode::append_new:
desired_access = boost::detail::winapi::GENERIC_READ_ |
boost::detail::winapi::GENERIC_WRITE_;
creation_disposition = boost::detail::winapi::CREATE_NEW_;
desired_access = boost::winapi::GENERIC_READ_ |
boost::winapi::GENERIC_WRITE_;
creation_disposition = boost::winapi::CREATE_NEW_;
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
break;
case file_mode::append_existing:
desired_access = boost::detail::winapi::GENERIC_READ_ |
boost::detail::winapi::GENERIC_WRITE_;
creation_disposition = boost::detail::winapi::OPEN_EXISTING_;
desired_access = boost::winapi::GENERIC_READ_ |
boost::winapi::GENERIC_WRITE_;
creation_disposition = boost::winapi::OPEN_EXISTING_;
flags_and_attributes = 0x08000000; // FILE_FLAG_SEQUENTIAL_SCAN
break;
}
@ -202,8 +202,8 @@ open(char const* path, file_mode mode, error_code& ec)
creation_disposition,
flags_and_attributes,
NULL);
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
ec.assign(boost::detail::winapi::GetLastError(),
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
ec.assign(boost::winapi::GetLastError(),
system_category());
else
ec.assign(0, ec.category());
@ -214,15 +214,15 @@ std::uint64_t
file_win32::
size(error_code& ec) const
{
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
{
ec.assign(errc::invalid_argument, generic_category());
return 0;
}
boost::detail::winapi::LARGE_INTEGER_ fileSize;
if(! boost::detail::winapi::GetFileSizeEx(h_, &fileSize))
boost::winapi::LARGE_INTEGER_ fileSize;
if(! boost::winapi::GetFileSizeEx(h_, &fileSize))
{
ec.assign(boost::detail::winapi::GetLastError(),
ec.assign(boost::winapi::GetLastError(),
system_category());
return 0;
}
@ -235,18 +235,18 @@ std::uint64_t
file_win32::
pos(error_code& ec)
{
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
{
ec.assign(errc::invalid_argument, generic_category());
return 0;
}
boost::detail::winapi::LARGE_INTEGER_ in;
boost::detail::winapi::LARGE_INTEGER_ out;
boost::winapi::LARGE_INTEGER_ in;
boost::winapi::LARGE_INTEGER_ out;
in.QuadPart = 0;
if(! detail::set_file_pointer_ex(h_, in, &out,
boost::detail::winapi::FILE_CURRENT_))
boost::winapi::FILE_CURRENT_))
{
ec.assign(boost::detail::winapi::GetLastError(),
ec.assign(boost::winapi::GetLastError(),
system_category());
return 0;
}
@ -259,17 +259,17 @@ void
file_win32::
seek(std::uint64_t offset, error_code& ec)
{
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
{
ec.assign(errc::invalid_argument, generic_category());
return;
}
boost::detail::winapi::LARGE_INTEGER_ in;
boost::winapi::LARGE_INTEGER_ in;
in.QuadPart = offset;
if(! detail::set_file_pointer_ex(h_, in, 0,
boost::detail::winapi::FILE_BEGIN_))
boost::winapi::FILE_BEGIN_))
{
ec.assign(boost::detail::winapi::GetLastError(),
ec.assign(boost::winapi::GetLastError(),
system_category());
return;
}
@ -281,7 +281,7 @@ std::size_t
file_win32::
read(void* buffer, std::size_t n, error_code& ec)
{
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
{
ec.assign(errc::invalid_argument, generic_category());
return 0;
@ -289,19 +289,19 @@ read(void* buffer, std::size_t n, error_code& ec)
std::size_t nread = 0;
while(n > 0)
{
boost::detail::winapi::DWORD_ amount;
boost::winapi::DWORD_ amount;
if(n > (std::numeric_limits<
boost::detail::winapi::DWORD_>::max)())
boost::winapi::DWORD_>::max)())
amount = (std::numeric_limits<
boost::detail::winapi::DWORD_>::max)();
boost::winapi::DWORD_>::max)();
else
amount = static_cast<
boost::detail::winapi::DWORD_>(n);
boost::detail::winapi::DWORD_ bytesRead;
boost::winapi::DWORD_>(n);
boost::winapi::DWORD_ bytesRead;
if(! ::ReadFile(h_, buffer, amount, &bytesRead, 0))
{
auto const dwError = ::GetLastError();
if(dwError != boost::detail::winapi::ERROR_HANDLE_EOF_)
if(dwError != boost::winapi::ERROR_HANDLE_EOF_)
ec.assign(::GetLastError(), system_category());
else
ec.assign(0, ec.category());
@ -322,7 +322,7 @@ std::size_t
file_win32::
write(void const* buffer, std::size_t n, error_code& ec)
{
if(h_ == boost::detail::winapi::INVALID_HANDLE_VALUE_)
if(h_ == boost::winapi::INVALID_HANDLE_VALUE_)
{
ec.assign(errc::invalid_argument, generic_category());
return 0;
@ -330,19 +330,19 @@ write(void const* buffer, std::size_t n, error_code& ec)
std::size_t nwritten = 0;
while(n > 0)
{
boost::detail::winapi::DWORD_ amount;
boost::winapi::DWORD_ amount;
if(n > (std::numeric_limits<
boost::detail::winapi::DWORD_>::max)())
boost::winapi::DWORD_>::max)())
amount = (std::numeric_limits<
boost::detail::winapi::DWORD_>::max)();
boost::winapi::DWORD_>::max)();
else
amount = static_cast<
boost::detail::winapi::DWORD_>(n);
boost::detail::winapi::DWORD_ bytesWritten;
boost::winapi::DWORD_>(n);
boost::winapi::DWORD_ bytesWritten;
if(! ::WriteFile(h_, buffer, amount, &bytesWritten, 0))
{
auto const dwError = ::GetLastError();
if(dwError != boost::detail::winapi::ERROR_HANDLE_EOF_)
if(dwError != boost::winapi::ERROR_HANDLE_EOF_)
ec.assign(::GetLastError(), system_category());
else
ec.assign(0, ec.category());

View File

@ -24,7 +24,7 @@
#include <boost/asio/windows/overlapped_ptr.hpp>
#include <boost/make_unique.hpp>
#include <boost/smart_ptr/make_shared_array.hpp>
#include <boost/detail/winapi/basic_types.hpp>
#include <boost/winapi/basic_types.hpp>
#include <algorithm>
#include <cstring>
@ -279,27 +279,27 @@ namespace detail {
template<class Unsigned>
inline
boost::detail::winapi::DWORD_
boost::winapi::DWORD_
lowPart(Unsigned n)
{
return static_cast<
boost::detail::winapi::DWORD_>(
boost::winapi::DWORD_>(
n & 0xffffffff);
}
template<class Unsigned>
inline
boost::detail::winapi::DWORD_
boost::winapi::DWORD_
highPart(Unsigned n, std::true_type)
{
return static_cast<
boost::detail::winapi::DWORD_>(
boost::winapi::DWORD_>(
(n>>32)&0xffffffff);
}
template<class Unsigned>
inline
boost::detail::winapi::DWORD_
boost::winapi::DWORD_
highPart(Unsigned, std::false_type)
{
return 0;
@ -307,7 +307,7 @@ highPart(Unsigned, std::false_type)
template<class Unsigned>
inline
boost::detail::winapi::DWORD_
boost::winapi::DWORD_
highPart(Unsigned n)
{
return highPart(n, std::integral_constant<
@ -416,8 +416,8 @@ operator()()
sock_, sr_, std::move(*this));
}
auto& r = sr_.reader_impl();
boost::detail::winapi::DWORD_ const nNumberOfBytesToWrite =
std::min<boost::detail::winapi::DWORD_>(
boost::winapi::DWORD_ const nNumberOfBytesToWrite =
std::min<boost::winapi::DWORD_>(
beast::detail::clamp(std::min<std::uint64_t>(
r.body_.last_ - r.pos_, sr_.limit())),
2147483646);
@ -436,12 +436,12 @@ operator()()
0);
auto const dwError = ::GetLastError();
if(! bSuccess && dwError !=
boost::detail::winapi::ERROR_IO_PENDING_)
boost::winapi::ERROR_IO_PENDING_)
{
// VFALCO This needs review, is 0 the right number?
// completed immediately (with error?)
overlapped.complete(error_code{static_cast<int>(
boost::detail::winapi::GetLastError()),
boost::winapi::GetLastError()),
system_category()}, 0);
return;
}
@ -513,8 +513,8 @@ write_some(
r.body_.file_.seek(r.pos_, ec);
if(ec)
return 0;
boost::detail::winapi::DWORD_ const nNumberOfBytesToWrite =
std::min<boost::detail::winapi::DWORD_>(
boost::winapi::DWORD_ const nNumberOfBytesToWrite =
std::min<boost::winapi::DWORD_>(
beast::detail::clamp(std::min<std::uint64_t>(
r.body_.last_ - r.pos_, sr.limit())),
2147483646);
@ -529,7 +529,7 @@ write_some(
if(! bSuccess)
{
ec.assign(static_cast<int>(
boost::detail::winapi::GetLastError()),
boost::winapi::GetLastError()),
system_category());
return 0;
}

View File

@ -18,8 +18,8 @@
#include <string>
#ifdef BOOST_WINDOWS
#include <boost/detail/winapi/basic_types.hpp>
#include <boost/detail/winapi/debugapi.hpp>
#include <boost/winapi/basic_types.hpp>
#include <boost/winapi/debugapi.hpp>
#endif
namespace boost {
@ -45,14 +45,14 @@ class dstream_buf
void write(char const* s)
{
if(dbg_)
boost::detail::winapi::OutputDebugStringA(s);
boost::winapi::OutputDebugStringA(s);
os_ << s;
}
void write(wchar_t const* s)
{
if(dbg_)
boost::detail::winapi::OutputDebugStringW(s);
boost::winapi::OutputDebugStringW(s);
os_ << s;
}
@ -60,7 +60,7 @@ public:
explicit
dstream_buf(ostream& os)
: os_(os)
, dbg_(boost::detail::winapi::IsDebuggerPresent() != 0)
, dbg_(boost::winapi::IsDebuggerPresent() != 0)
{
}