forked from soblin/matplotlibcpp17
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcommon.h
More file actions
58 lines (45 loc) · 1.97 KB
/
Copy pathcommon.h
File metadata and controls
58 lines (45 loc) · 1.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef MATPLOTLIBCPP17_COMMON_H
#define MATPLOTLIBCPP17_COMMON_H
#define LOAD_FUNC_ATTR(obj, mod) \
do { \
obj##_attr = mod.attr(#obj); \
} while (0)
#define DECL_STRUCT_ATTR __attribute__((visibility("hidden")))
#include <iostream>
#include <utility>
#define INFO_MSG(msg) \
do { \
std::cout << "Info [" __FILE__ << "@" << __LINE__ << "]: "; \
std::cout << #msg << std::endl; \
} while (0)
#define WARN_MSG(msg) \
do { \
std::cout << "Warn [" __FILE__ << "@" << __LINE__ << "]: "; \
std::cout << #msg << std::endl; \
} while (0)
#define ERROR_MSG(msg) \
do { \
std::cerr << "Error [" __FILE__ << "@" << __LINE__ << "]: "; \
std::cerr << #msg << std::endl; \
} while (0)
#include <pybind11/pybind11.h>
namespace matplotlibcpp17 {
/**
* @brief A base class for python wrapper classes
**/
struct DECL_STRUCT_ATTR BaseWrapper {
public:
pybind11::object unwrap() const { return self; }
protected:
pybind11::object self;
};
/**
* @brief A proxy class for pybind object
**/
struct ObjectWrapper : public BaseWrapper {
public:
ObjectWrapper(const pybind11::object &object) { self = object; }
ObjectWrapper(pybind11::object &&object) { self = std::move(object); }
};
} // namespace matplotlibcpp17
#endif /* MATPLOTLIBCPP17_COMMON_H */