Skip to content

Commit

Permalink
#128 Mark non-template public classes and functions as UREACT_API
Browse files Browse the repository at this point in the history
UREACT_API, UREACT_EXPORT and UREACT_SHARED are ported from `{fmt}`
  • Loading branch information
YarikTH committed Aug 26, 2023
1 parent 7463e7d commit 01162d6
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
6 changes: 3 additions & 3 deletions include/ureact/context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ UREACT_BEGIN_NAMESPACE
namespace detail
{

class context_internals
class UREACT_API context_internals
{
public:
explicit context_internals( std::shared_ptr<react_graph> graph = make_react_graph() );
Expand All @@ -43,7 +43,7 @@ namespace default_context
* @brief Return default context
* Default contexts are thread_local
*/
context get();
UREACT_API context get();

} // namespace default_context

Expand All @@ -53,7 +53,7 @@ context get();
* Each signal and node belongs to a single ureact context.
* Signals from different contexts can't interact with each other.
*/
class context final : protected detail::context_internals
class UREACT_API context final : protected detail::context_internals
{
public:
/*!
Expand Down
17 changes: 17 additions & 0 deletions include/ureact/detail/defines.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,23 @@ static_assert( __cplusplus >= 201703L, "At least c++17 standard is required" );
# define UREACT_FUNC
#endif

#if !UREACT_HEADER_ONLY && defined( _WIN32 )
# ifdef UREACT_EXPORT
# define UREACT_API __declspec( dllexport )
# elif defined( UREACT_SHARED )
# define UREACT_API __declspec( dllimport )
# endif
#else
# if defined( UREACT_EXPORT ) || defined( UREACT_SHARED )
# if defined( __GNUC__ ) || defined( __clang__ )
# define UREACT_API __attribute__( ( visibility( "default" ) ) )
# endif
# endif
#endif
#ifndef UREACT_API
# define UREACT_API
#endif

#define UREACT_SETUP_COPY( ClassName, Action ) \
ClassName( const ClassName& ) = Action; \
ClassName& operator=( const ClassName& ) = Action
Expand Down
2 changes: 1 addition & 1 deletion include/ureact/detail/graph_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ struct react_graph
[[nodiscard]] virtual bool is_propagation_in_progress() const = 0;
};

std::shared_ptr<react_graph> make_react_graph();
UREACT_API std::shared_ptr<react_graph> make_react_graph();

} // namespace detail

Expand Down
2 changes: 1 addition & 1 deletion include/ureact/detail/node_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Ret create_wrapped_node( Args&&... args )
return Ret{ create_node<Node>( std::forward<Args>( args )... ) };
}

class node_base : public reactive_node_interface
class UREACT_API node_base : public reactive_node_interface
{
public:
explicit node_base( context context );
Expand Down
4 changes: 2 additions & 2 deletions include/ureact/observer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ UREACT_BEGIN_NAMESPACE
namespace detail
{

class observer_internals
class UREACT_API observer_internals
{
public:
observer_internals() = default;
Expand Down Expand Up @@ -50,7 +50,7 @@ class observer_internals
* An instance of this class provides a unique handle to an observer which can
* be used to detach it explicitly
*/
class observer final : protected detail::observer_internals
class UREACT_API observer final : protected detail::observer_internals
{
public:
UREACT_MAKE_COPYABLE( observer );
Expand Down
4 changes: 2 additions & 2 deletions include/ureact/transaction.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ UREACT_BEGIN_NAMESPACE
/*!
* @brief Guard class to perform several changes atomically
*/
class UREACT_WARN_UNUSED_RESULT transaction
class UREACT_API UREACT_WARN_UNUSED_RESULT transaction
{
public:
explicit transaction( context ctx );
Expand Down Expand Up @@ -48,7 +48,7 @@ namespace default_context
* Named differently from "transaction", so it is possible to use them both,
* where both ureact and ureact::default_context namespaces are used
*/
struct UREACT_WARN_UNUSED_RESULT default_transaction : public transaction
struct UREACT_API UREACT_WARN_UNUSED_RESULT default_transaction : public transaction
{
default_transaction();
};
Expand Down

0 comments on commit 01162d6

Please sign in to comment.