matplotlibcpp17
common.h
1#pragma once
2
3
4#define LOAD_FUNC_ATTR(obj, mod) \
5 do { \
6 obj##_attr = mod.attr(#obj); \
7 } while (0)
8
9#define DECL_STRUCT_ATTR __attribute__((visibility("hidden")))
10
11#include <iostream>
12#include <utility>
13
14#define INFO_MSG(msg) \
15 do { \
16 std::cout << "Info [" __FILE__ << "@" << __LINE__ << "]: "; \
17 std::cout << #msg << std::endl; \
18 } while (0)
19
20#define WARN_MSG(msg) \
21 do { \
22 std::cout << "Warn [" __FILE__ << "@" << __LINE__ << "]: "; \
23 std::cout << #msg << std::endl; \
24 } while (0)
25
26#define ERROR_MSG(msg) \
27 do { \
28 std::cerr << "Error [" __FILE__ << "@" << __LINE__ << "]: "; \
29 std::cerr << #msg << std::endl; \
30 } while (0)
31
32#include <pybind11/pybind11.h>
33
34namespace matplotlibcpp17 {
35
39struct DECL_STRUCT_ATTR BaseWrapper {
40public:
41 pybind11::object unwrap() const { return self; }
42
43protected:
44 pybind11::object self;
45};
46
50struct ObjectWrapper : public BaseWrapper {
51public:
52 ObjectWrapper(const pybind11::object &object) { self = object; }
53 ObjectWrapper(pybind11::object &&object) { self = std::move(object); }
54};
55
56} // namespace matplotlibcpp17
A base class for python wrapper classes.
Definition: common.h:39
A proxy class for pybind object.
Definition: common.h:50