mirror of
https://github.com/reactos/CMake.git
synced 2025-02-24 22:12:46 +00:00
Merge topic 'libuv-raii'
3bcaa870 cmUVHandlePtr: Add uv_process_ptr dd700e9b cmUVHandlePtr: Add uv_timer_ptr 32cfa7b3 cmUVHandlePtr: Move to CMakeLib to make it available everywhere Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1541
This commit is contained in:
commit
e61c1cf64c
@ -348,6 +348,8 @@ set(SRCS
|
||||
cmTestGenerator.cxx
|
||||
cmTestGenerator.h
|
||||
cmUuid.cxx
|
||||
cmUVHandlePtr.cxx
|
||||
cmUVHandlePtr.h
|
||||
cmVariableWatch.cxx
|
||||
cmVariableWatch.h
|
||||
cmVersion.cxx
|
||||
@ -1029,7 +1031,6 @@ list(APPEND _tools cmake)
|
||||
target_link_libraries(cmake CMakeLib)
|
||||
|
||||
add_library(CMakeServerLib
|
||||
cmUVHandlePtr.h cmUVHandlePtr.cxx
|
||||
cmConnection.h cmConnection.cxx
|
||||
cmFileMonitor.cxx cmFileMonitor.h
|
||||
cmPipeConnection.cxx cmPipeConnection.h
|
||||
|
@ -82,6 +82,7 @@ uv_handle_ptr_<T>::operator T*() const
|
||||
return this->handle.get();
|
||||
}
|
||||
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
template <>
|
||||
struct uv_handle_deleter<uv_async_t>
|
||||
{
|
||||
@ -126,6 +127,7 @@ int uv_async_ptr::init(uv_loop_t& loop, uv_async_cb async_cb, void* data)
|
||||
allocate(data);
|
||||
return uv_async_init(&loop, handle.get(), async_cb);
|
||||
}
|
||||
#endif
|
||||
|
||||
template <>
|
||||
struct uv_handle_deleter<uv_signal_t>
|
||||
@ -169,6 +171,26 @@ uv_pipe_ptr::operator uv_stream_t*() const
|
||||
return reinterpret_cast<uv_stream_t*>(handle.get());
|
||||
}
|
||||
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
int uv_process_ptr::spawn(uv_loop_t& loop, uv_process_options_t const& options,
|
||||
void* data)
|
||||
{
|
||||
allocate(data);
|
||||
return uv_spawn(&loop, *this, &options);
|
||||
}
|
||||
|
||||
int uv_timer_ptr::init(uv_loop_t& loop, void* data)
|
||||
{
|
||||
allocate(data);
|
||||
return uv_timer_init(&loop, *this);
|
||||
}
|
||||
|
||||
int uv_timer_ptr::start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat)
|
||||
{
|
||||
assert(handle);
|
||||
return uv_timer_start(*this, cb, timeout, repeat);
|
||||
}
|
||||
|
||||
uv_tty_ptr::operator uv_stream_t*() const
|
||||
{
|
||||
return reinterpret_cast<uv_stream_t*>(handle.get());
|
||||
@ -179,6 +201,7 @@ int uv_tty_ptr::init(uv_loop_t& loop, int fd, int readable, void* data)
|
||||
allocate(data);
|
||||
return uv_tty_init(&loop, *this, fd, readable);
|
||||
}
|
||||
#endif
|
||||
|
||||
template class uv_handle_ptr_base_<uv_handle_t>;
|
||||
|
||||
@ -186,13 +209,19 @@ template class uv_handle_ptr_base_<uv_handle_t>;
|
||||
template class uv_handle_ptr_base_<uv_##NAME##_t>; \
|
||||
template class uv_handle_ptr_<uv_##NAME##_t>;
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(async)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(signal)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(pipe)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(stream)
|
||||
|
||||
#ifdef CMAKE_BUILD_WITH_CMAKE
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(async)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(process)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(timer)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXPLICIT(tty)
|
||||
#endif
|
||||
}
|
||||
|
@ -5,6 +5,7 @@
|
||||
|
||||
#include <algorithm>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
#include <type_traits>
|
||||
|
||||
@ -164,6 +165,23 @@ struct uv_pipe_ptr : public uv_handle_ptr_<uv_pipe_t>
|
||||
int init(uv_loop_t& loop, int ipc, void* data = nullptr);
|
||||
};
|
||||
|
||||
struct uv_process_ptr : public uv_handle_ptr_<uv_process_t>
|
||||
{
|
||||
CM_PERFECT_FWD_CTOR(uv_process_ptr, uv_handle_ptr_<uv_process_t>);
|
||||
|
||||
int spawn(uv_loop_t& loop, uv_process_options_t const& options,
|
||||
void* data = nullptr);
|
||||
};
|
||||
|
||||
struct uv_timer_ptr : public uv_handle_ptr_<uv_timer_t>
|
||||
{
|
||||
CM_PERFECT_FWD_CTOR(uv_timer_ptr, uv_handle_ptr_<uv_timer_t>);
|
||||
|
||||
int init(uv_loop_t& loop, void* data = nullptr);
|
||||
|
||||
int start(uv_timer_cb cb, uint64_t timeout, uint64_t repeat);
|
||||
};
|
||||
|
||||
struct uv_tty_ptr : public uv_handle_ptr_<uv_tty_t>
|
||||
{
|
||||
CM_PERFECT_FWD_CTOR(uv_tty_ptr, uv_handle_ptr_<uv_tty_t>);
|
||||
@ -190,8 +208,12 @@ UV_HANDLE_PTR_INSTANTIATE_EXTERN(signal)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXTERN(pipe)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXTERN(process)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXTERN(stream)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXTERN(timer)
|
||||
|
||||
UV_HANDLE_PTR_INSTANTIATE_EXTERN(tty)
|
||||
|
||||
#undef UV_HANDLE_PTR_INSTANTIATE_EXTERN
|
||||
|
@ -12,6 +12,7 @@ set(CMakeLib_TESTS
|
||||
testXMLParser
|
||||
testXMLSafe
|
||||
testFindPackageCommand
|
||||
testUVRAII
|
||||
)
|
||||
|
||||
set(testRST_ARGS ${CMAKE_CURRENT_SOURCE_DIR})
|
||||
@ -31,6 +32,9 @@ create_test_sourcelist(CMakeLib_TEST_SRCS CMakeLibTests.cxx ${CMakeLib_TESTS})
|
||||
add_executable(CMakeLibTests ${CMakeLib_TEST_SRCS})
|
||||
target_link_libraries(CMakeLibTests CMakeLib)
|
||||
|
||||
set_property(TARGET CMakeLibTests PROPERTY C_CLANG_TIDY "")
|
||||
set_property(TARGET CMakeLibTests PROPERTY CXX_CLANG_TIDY "")
|
||||
|
||||
add_executable(testEncoding testEncoding.cxx)
|
||||
target_link_libraries(testEncoding cmsys)
|
||||
|
||||
|
@ -155,7 +155,9 @@ static bool testAllMoves()
|
||||
struct allTypes
|
||||
{
|
||||
uv_stream_ptr _7;
|
||||
uv_timer_ptr _8;
|
||||
uv_tty_ptr _9;
|
||||
uv_process_ptr _11;
|
||||
uv_pipe_ptr _12;
|
||||
uv_async_ptr _13;
|
||||
uv_signal_ptr _14;
|
@ -6,7 +6,6 @@ include_directories(
|
||||
|
||||
set(CMakeServerLib_TESTS
|
||||
testServerBuffering
|
||||
testUVRAII
|
||||
)
|
||||
|
||||
create_test_sourcelist(CMakeLib_TEST_SRCS CMakeServerLibTests.cxx ${CMakeServerLib_TESTS})
|
||||
|
Loading…
x
Reference in New Issue
Block a user