Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
component_export.h
Go to the documentation of this file.
1// Copyright 2024 The PDFium Authors
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CORE_FXCRT_COMPONENT_EXPORT_H_
6#define CORE_FXCRT_COMPONENT_EXPORT_H_
7
8// Used to annotate symbols which are exported by the component named
9// |component|. Note that this only does the right thing if the corresponding
10// component target's sources are compiled with |IS_$component_IMPL| defined
11// as 1. For example:
12//
13// class COMPONENT_EXPORT(FOO) Bar {};
14//
15// If IS_FOO_IMPL=1 at compile time, then Bar will be annotated using the
16// COMPONENT_EXPORT_ANNOTATION macro defined below. Otherwise it will be
17// annotated using the COMPONENT_IMPORT_ANNOTATION macro.
18#define COMPONENT_EXPORT(component)
19 COMPONENT_MACRO_CONDITIONAL_(IS_##component##_IMPL,
22
23// Indicates whether the current compilation unit is being compiled as part of
24// the implementation of the component named |component|. Expands to |1| if
25// |IS_$component_IMPL| is defined as |1|; expands to |0| otherwise.
26//
27// Note in particular that if |IS_$component_IMPL| is not defined at all, it is
28// still fine to test INSIDE_COMPONENT_IMPL(component), which expands to |0| as
29// expected.
30#define INSIDE_COMPONENT_IMPL(component)
31 COMPONENT_MACRO_CONDITIONAL_(IS_##component##_IMPL, 1, 0)
32
33// Compiler-specific macros to annotate for export or import of a symbol. No-op
34// in non-component builds. These should not see much if any direct use.
35// Instead use the COMPONENT_EXPORT macro defined above.
36#if defined(COMPONENT_BUILD)
37#if defined(WIN32)
38#define COMPONENT_EXPORT_ANNOTATION __declspec(dllexport)
39#define COMPONENT_IMPORT_ANNOTATION __declspec(dllimport)
40#else // defined(WIN32)
41#define COMPONENT_EXPORT_ANNOTATION __attribute__((visibility("default")))
42#define COMPONENT_IMPORT_ANNOTATION
43#endif // defined(WIN32)
44#else // defined(COMPONENT_BUILD)
45#define COMPONENT_EXPORT_ANNOTATION
46#define COMPONENT_IMPORT_ANNOTATION
47#endif // defined(COMPONENT_BUILD)
48
49// Below this point are several internal utility macros used for the
50// implementation of the above macros. Not intended for external use.
51
52// Helper for conditional expansion to one of two token strings. If |condition|
53// expands to |1| then this macro expands to |consequent|; otherwise it expands
54// to |alternate|.
55#define COMPONENT_MACRO_CONDITIONAL_(condition, consequent, alternate)
57 COMPONENT_MACRO_CONDITIONAL_COMMA_(condition), consequent, alternate)
58
59// Expands to a comma (,) iff its first argument expands to |1|. Used in
60// conjunction with |COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_()|, as the presence
61// or absense of an extra comma can be used to conditionally shift subsequent
62// argument positions and thus influence which argument is selected.
63#define COMPONENT_MACRO_CONDITIONAL_COMMA_(...)
65#define COMPONENT_MACRO_CONDITIONAL_COMMA_IMPL_(x, ...)
67#define COMPONENT_MACRO_CONDITIONAL_COMMA_1_ ,
68
69// Helper which simply selects its third argument. Used in conjunction with
70// |COMPONENT_MACRO_CONDITIONAL_COMMA_()| above to implement conditional macro
71// expansion.
72#define COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_(...)
74#define COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_IMPL_(a, b, c, ...) c
75
76#endif // CORE_FXCRT_COMPONENT_EXPORT_H_
#define COMPONENT_MACRO_CONDITIONAL_COMMA_IMPL_(x,...)
#define COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_IMPL_(a, b, c,...)
#define COMPONENT_MACRO_SELECT_THIRD_ARGUMENT_(...)
#define COMPONENT_MACRO_CONDITIONAL_(condition, consequent, alternate)
#define COMPONENT_EXPORT_ANNOTATION
#define COMPONENT_MACRO_CONDITIONAL_COMMA_(...)
#define COMPONENT_IMPORT_ANNOTATION