Skip to content

Commit

Permalink
Several improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
sadko4u committed Sep 20, 2024
1 parent 720c8c4 commit 2568219
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
32 changes: 13 additions & 19 deletions include/lsp-plug.in/common/finally.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2022 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2022 Vladimir Sadovnikov <[email protected]>
* Copyright (C) 2024 Linux Studio Plugins Project <https://lsp-plug.in/>
* (C) 2024 Vladimir Sadovnikov <[email protected]>
*
* This file is part of lsp-common-lib
* Created on: 29 июн. 2022 г.
Expand All @@ -23,6 +23,7 @@
#define LSP_PLUG_IN_COMMON_FINALLY_H_

#include <lsp-plug.in/common/version.h>
#include <lsp-plug.in/common/variadic.h>

namespace lsp
{
Expand All @@ -33,23 +34,24 @@ namespace lsp
T sActor;

public:
inline FinallyExecutor(T && actor): sActor(actor) {}
inline FinallyExecutor(T && actor): sActor(lsp::move(actor)) {}
inline FinallyExecutor(T & actor) : sActor(actor) {}
~FinallyExecutor() { sActor(); }
};

struct FinallyExecutorInit
{
template <class T>
inline FinallyExecutor<T> operator + (T & actor)
{
return FinallyExecutor<T>(actor);
}
inline FinallyExecutor<T> operator + (T & actor)
{
return FinallyExecutor<T>(actor);
}

template <class T>
inline FinallyExecutor<T> operator + (T && actor)
{
return FinallyExecutor<T>(actor);
}
inline FinallyExecutor<T> operator + (T && actor)
{
return FinallyExecutor<T>(lsp::move(actor));
}
};

#define lsp_impl_finally2(id, prefix) prefix ## id ## __
Expand All @@ -59,14 +61,6 @@ namespace lsp

#define lsp_finally lsp_impl_finally0(__COUNTER__)

template <class T>
inline T * release_ptr(T * & value)
{
T *res = value;
value = nullptr;
return res;
}

} /* namespace lsp */

#endif /* LSP_PLUG_IN_COMMON_FINALLY_H_ */
8 changes: 8 additions & 0 deletions include/lsp-plug.in/common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -977,6 +977,14 @@ namespace lsp
return (value) ? bits | flag : bits & (~flag);
}

template <class T>
inline T * release_ptr(T * & value)
{
T *res = value;
value = nullptr;
return res;
}

LSP_COMMON_LIB_PUBLIC
int version_cmp(const version_t *a, const version_t *b);

Expand Down
4 changes: 4 additions & 0 deletions include/lsp-plug.in/stdlib/locale.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
#include <locale.h>
#include <string.h>

#ifdef PLATFORM_MACOSX
#include <xlocale.h>
#endif /* PLATFORM_MACOSX */

#define SET_LOCALE_MANGLE2(prefix, postfix) prefix ## _ ## postfix
#define SET_LOCALE_MANGLE1(prefix, postfix) SET_LOCALE_MANGLE2(prefix, postfix)
#define SET_LOCALE_MANGLE(var) SET_LOCALE_MANGLE1(var, __COUNTER__)
Expand Down

0 comments on commit 2568219

Please sign in to comment.