forked from mceSystems/nbind
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSmart.cc
51 lines (34 loc) · 789 Bytes
/
Smart.cc
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
// This file is part of nbind, copyright (C) 2014-2016 BusFaster Ltd.
// Released under the MIT license, see LICENSE.
#include <memory>
#include <cstdio>
class Smart {
public:
Smart(int num) : num(num) {}
~Smart() {
fprintf(stderr, "Destroy %d!!!\n", num);
}
static std::shared_ptr<Smart> make(int num) {
return(std::make_shared<Smart>(num));
}
void test() {
fprintf(stderr, "test %d!!!\n", num);
}
static void testStatic(Smart *ptr) {
fprintf(stderr, "static %d!!!\n", ptr->num);
}
static void testShared(std::shared_ptr<Smart> ptr) {
fprintf(stderr, "shared %d!!!\n", ptr->num);
}
private:
int num;
};
#include "nbind/nbind.h"
#ifdef NBIND_CLASS
NBIND_CLASS(Smart) {
method(make);
method(test);
method(testStatic);
method(testShared);
}
#endif