forked from kljohann/genpybind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkeep-alive.h
50 lines (37 loc) · 1.03 KB
/
keep-alive.h
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
// SPDX-FileCopyrightText: 2024 Johann Klähn <[email protected]>
//
// SPDX-License-Identifier: MIT
#pragma once
#include "genpybind.h"
struct GENPYBIND(visible) Resource final {
Resource();
~Resource();
GENPYBIND(readonly)
static int created;
GENPYBIND(readonly)
static int destroyed;
GENPYBIND(readonly)
static int alive;
};
struct GENPYBIND(visible) Container final {
Container();
~Container();
GENPYBIND(keep_alive(this, resource))
Container(Resource *resource);
void unannotated_sink(Resource *resource);
GENPYBIND(keep_alive(this, resource))
void keep_alive_sink(Resource *resource);
Resource *unannotated_source();
GENPYBIND(keep_alive(this, "return"))
Resource *keep_alive_source();
GENPYBIND(keep_alive(return, this))
Resource *reverse_keep_alive_source();
GENPYBIND(readonly)
static int created;
GENPYBIND(readonly)
static int destroyed;
GENPYBIND(readonly)
static int alive;
};
void link(Container *container, Resource *resource)
GENPYBIND(keep_alive(container, resource));