parent
c764b70b3a
commit
8f981845dc
2
NEWS
2
NEWS
|
@ -12,6 +12,8 @@ ver 0.22 (not yet released)
|
|||
- ffmpeg: new plugin based on FFmpeg's libavfilter library
|
||||
- hdcd: new plugin based on FFmpeg's "af_hdcd" for HDCD playback
|
||||
- volume: convert S16 to S24 to preserve quality and reduce dithering noise
|
||||
* switch to C++17
|
||||
- GCC 7 or clang 4 (or newer) recommended
|
||||
|
||||
ver 0.21.12 (2019/08/03)
|
||||
* decoder
|
||||
|
|
|
@ -12,7 +12,7 @@ Code Style
|
|||
* indent with tabs (width 8)
|
||||
* don't write CPP when you can write C++: use inline functions and constexpr instead of macros
|
||||
* comment your code, document your APIs
|
||||
* the code should be C++14 compliant, and must compile with :program:`GCC` 6.0 and :program:`clang` 3.4
|
||||
* the code should be C++17 compliant, and must compile with :program:`GCC` 7 and :program:`clang` 4
|
||||
* report error conditions with C++ exceptions, preferable derived from :envvar:`std::runtime_error`
|
||||
* all code must be exception-safe
|
||||
* classes and functions names use CamelCase; variables are lower-case with words separated by underscore
|
||||
|
|
10
meson.build
10
meson.build
|
@ -5,7 +5,7 @@ project(
|
|||
meson_version: '>= 0.49.0',
|
||||
default_options: [
|
||||
'c_std=c99',
|
||||
'cpp_std=c++14'
|
||||
'cpp_std=c++17'
|
||||
],
|
||||
license: 'GPLv2+',
|
||||
)
|
||||
|
@ -15,10 +15,10 @@ version_cxx = vcs_tag(input: 'src/GitVersion.cxx', output: 'GitVersion.cxx')
|
|||
compiler = meson.get_compiler('cpp')
|
||||
c_compiler = meson.get_compiler('c')
|
||||
|
||||
if compiler.get_id() == 'gcc' and compiler.version().version_compare('<6')
|
||||
warning('Your GCC version is too old. You need at least version 6.')
|
||||
elif compiler.get_id() == 'clang' and compiler.version().version_compare('<3')
|
||||
warning('Your clang version is too old. You need at least version 3.')
|
||||
if compiler.get_id() == 'gcc' and compiler.version().version_compare('<7')
|
||||
warning('Your GCC version is too old. You need at least version 7.')
|
||||
elif compiler.get_id() == 'clang' and compiler.version().version_compare('<4')
|
||||
warning('Your clang version is too old. You need at least version 4.')
|
||||
endif
|
||||
|
||||
conf = configuration_data()
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
class MaskMonitor final {
|
||||
DeferEvent defer;
|
||||
|
||||
typedef BoundMethod<void(unsigned)> Callback;
|
||||
typedef BoundMethod<void(unsigned) noexcept> Callback;
|
||||
const Callback callback;
|
||||
|
||||
std::atomic_uint pending_mask;
|
||||
|
|
|
@ -44,7 +44,7 @@ class TimerEvent final {
|
|||
|
||||
EventLoop &loop;
|
||||
|
||||
typedef BoundMethod<void()> Callback;
|
||||
typedef BoundMethod<void() noexcept> Callback;
|
||||
const Callback callback;
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace ODBus {
|
|||
class AsyncRequest {
|
||||
PendingCall pending_call;
|
||||
|
||||
std::function<void(Message) noexcept> callback;
|
||||
std::function<void(Message)> callback;
|
||||
|
||||
public:
|
||||
operator bool() const noexcept {
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
#include <assert.h>
|
||||
|
||||
class Thread {
|
||||
typedef BoundMethod<void()> Function;
|
||||
typedef BoundMethod<void() noexcept> Function;
|
||||
const Function f;
|
||||
|
||||
#ifdef _WIN32
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2016 Max Kellermann <max.kellermann@gmail.com>
|
||||
* Copyright 2016-2018 Max Kellermann <max.kellermann@gmail.com>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
|
@ -30,6 +30,8 @@
|
|||
#ifndef BIND_METHOD_HXX
|
||||
#define BIND_METHOD_HXX
|
||||
|
||||
#include "Compiler.h"
|
||||
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
|
||||
|
@ -43,9 +45,21 @@
|
|||
template<typename S=void()>
|
||||
class BoundMethod;
|
||||
|
||||
template<typename R, typename... Args>
|
||||
class BoundMethod<R(Args...)> {
|
||||
typedef R (*function_pointer)(void *instance, Args... args);
|
||||
#if GCC_OLDER_THAN(7,0)
|
||||
static constexpr bool NoExcept = false;
|
||||
#endif
|
||||
|
||||
template<typename R,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename... Args>
|
||||
class BoundMethod<R(Args...) noexcept(NoExcept)> {
|
||||
typedef R (*function_pointer)(void *instance, Args... args)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
;
|
||||
|
||||
void *instance_;
|
||||
function_pointer function;
|
||||
|
@ -91,9 +105,21 @@ namespace BindMethodDetail {
|
|||
template<typename T, typename S>
|
||||
struct MethodWithSignature;
|
||||
|
||||
template<typename T, typename R, typename... Args>
|
||||
struct MethodWithSignature<T, R(Args...)> {
|
||||
typedef R (T::*method_pointer)(Args...);
|
||||
template<typename T,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename R, typename... Args>
|
||||
struct MethodWithSignature<T, R(Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
> {
|
||||
typedef R (T::*method_pointer)(Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -104,8 +130,12 @@ struct MethodWithSignature<T, R(Args...)> {
|
|||
template<typename M>
|
||||
struct MethodSignatureHelper;
|
||||
|
||||
template<typename R, typename T, typename... Args>
|
||||
struct MethodSignatureHelper<R (T::*)(Args...)> {
|
||||
template<typename R,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename T, typename... Args>
|
||||
struct MethodSignatureHelper<R (T::*)(Args...) noexcept(NoExcept)> {
|
||||
/**
|
||||
* The class which contains the given method (signature).
|
||||
*/
|
||||
|
@ -115,7 +145,11 @@ struct MethodSignatureHelper<R (T::*)(Args...)> {
|
|||
* A function type which describes the "plain" function
|
||||
* signature.
|
||||
*/
|
||||
typedef R plain_signature(Args...);
|
||||
typedef R plain_signature(Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -125,9 +159,17 @@ struct MethodSignatureHelper<R (T::*)(Args...)> {
|
|||
template<typename S>
|
||||
struct MethodWrapperWithSignature;
|
||||
|
||||
template<typename R, typename... Args>
|
||||
struct MethodWrapperWithSignature<R(Args...)> {
|
||||
typedef R (*function_pointer)(void *instance, Args...);
|
||||
template<typename R,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename... Args>
|
||||
struct MethodWrapperWithSignature<R(Args...) noexcept(NoExcept)> {
|
||||
typedef R (*function_pointer)(void *instance, Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -140,9 +182,9 @@ struct MethodWrapperWithSignature<R(Args...)> {
|
|||
* @param R the return type
|
||||
* @param Args the method arguments
|
||||
*/
|
||||
template<typename T, typename M, M method, typename R, typename... Args>
|
||||
template<typename T, bool NoExcept, typename M, M method, typename R, typename... Args>
|
||||
struct BindMethodWrapperGenerator2 {
|
||||
static R Invoke(void *_instance, Args... args) {
|
||||
static R Invoke(void *_instance, Args... args) noexcept(NoExcept) {
|
||||
auto &t = *(T *)_instance;
|
||||
return (t.*method)(std::forward<Args>(args)...);
|
||||
}
|
||||
|
@ -159,9 +201,13 @@ struct BindMethodWrapperGenerator2 {
|
|||
template<typename T, typename M, M method, typename S>
|
||||
struct BindMethodWrapperGenerator;
|
||||
|
||||
template<typename T, typename M, M method, typename R, typename... Args>
|
||||
struct BindMethodWrapperGenerator<T, M, method, R(Args...)>
|
||||
: BindMethodWrapperGenerator2<T, M, method, R, Args...> {
|
||||
template<typename T,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename M, M method, typename R, typename... Args>
|
||||
struct BindMethodWrapperGenerator<T, M, method, R(Args...) noexcept(NoExcept)>
|
||||
: BindMethodWrapperGenerator2<T, NoExcept, M, method, R, Args...> {
|
||||
};
|
||||
|
||||
template<typename T, typename S,
|
||||
|
@ -180,19 +226,31 @@ MakeBindMethodWrapper() noexcept
|
|||
template<typename S>
|
||||
struct FunctionTraits;
|
||||
|
||||
template<typename R, typename... Args>
|
||||
struct FunctionTraits<R(Args...)> {
|
||||
template<typename R,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename... Args>
|
||||
struct FunctionTraits<R(Args...) noexcept(NoExcept)> {
|
||||
/**
|
||||
* A function type which describes the "plain" function
|
||||
* signature.
|
||||
*/
|
||||
typedef R function_type(Args...);
|
||||
typedef R function_type(Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
;
|
||||
|
||||
/**
|
||||
* A function pointer type which describes the "plain"
|
||||
* function signature.
|
||||
*/
|
||||
typedef R (*pointer_type)(Args...);
|
||||
typedef R (*pointer_type)(Args...)
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
noexcept(NoExcept)
|
||||
#endif
|
||||
;
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -205,9 +263,9 @@ struct FunctionTraits<R(Args...)> {
|
|||
* @param R the return type
|
||||
* @param Args the function arguments
|
||||
*/
|
||||
template<typename F, F function, typename R, typename... Args>
|
||||
template<bool NoExcept, typename F, F function, typename R, typename... Args>
|
||||
struct BindFunctionWrapperGenerator2 {
|
||||
static R Invoke(void *, Args... args) {
|
||||
static R Invoke(void *, Args... args) noexcept(NoExcept) {
|
||||
return function(std::forward<Args>(args)...);
|
||||
}
|
||||
};
|
||||
|
@ -222,9 +280,13 @@ struct BindFunctionWrapperGenerator2 {
|
|||
template<typename S, typename P, P function>
|
||||
struct BindFunctionWrapperGenerator;
|
||||
|
||||
template<typename P, P function, typename R, typename... Args>
|
||||
struct BindFunctionWrapperGenerator<R(Args...), P, function>
|
||||
: BindFunctionWrapperGenerator2<P, function, R, Args...> {
|
||||
template<typename P, P function,
|
||||
#if !GCC_OLDER_THAN(7,0)
|
||||
bool NoExcept,
|
||||
#endif
|
||||
typename R, typename... Args>
|
||||
struct BindFunctionWrapperGenerator<R(Args...) noexcept(NoExcept), P, function>
|
||||
: BindFunctionWrapperGenerator2<NoExcept, P, function, R, Args...> {
|
||||
};
|
||||
|
||||
template<typename T, typename T::pointer_type function>
|
||||
|
|
|
@ -49,6 +49,8 @@ test('TestUtil', executable(
|
|||
test('TestRewindInputStream', executable(
|
||||
'TestRewindInputStream',
|
||||
'TestRewindInputStream.cxx',
|
||||
'../src/Log.cxx',
|
||||
'../src/LogBackend.cxx',
|
||||
include_directories: inc,
|
||||
dependencies: [
|
||||
input_glue_dep,
|
||||
|
|
Loading…
Reference in New Issue