-
Notifications
You must be signed in to change notification settings - Fork 5
/
genpybind.h
19 lines (18 loc) · 943 Bytes
/
genpybind.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#pragma once
#ifdef __GENPYBIND__
#define GENPYBIND_PARENT_TYPE auto
#define GENPYBIND__CONCAT_(x, y) x##y
#define GENPYBIND__CONCAT(x, y) GENPYBIND__CONCAT_(x, y)
#define GENPYBIND__MAKE_UNIQUE(x) GENPYBIND__CONCAT(x, __COUNTER__)
#define GENPYBIND(...) __attribute__((annotate("◊" #__VA_ARGS__)))
// Will not be included in binary, because it is an uninstantiated template due to auto& parameter.
// Note: This needs C++17 during genpybind run, as lambda closure types are non-literal types
// before C++17 and thus cannot be constexpr.
#define GENPYBIND__MANUAL_(...) \
static constexpr auto __attribute__((unused)) GENPYBIND(manual) \
GENPYBIND__MAKE_UNIQUE(genpybind_) = [](auto& parent) __VA_ARGS__;
#define GENPYBIND_MANUAL GENPYBIND__MANUAL_
#else
#define GENPYBIND(...)
#define GENPYBIND_MANUAL(...)
#endif // __GENPYBIND__