-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdotpython_bridge.h
More file actions
108 lines (101 loc) · 3.64 KB
/
Copy pathdotpython_bridge.h
File metadata and controls
108 lines (101 loc) · 3.64 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#ifndef DOTPYTHON_BRIDGE_H
#define DOTPYTHON_BRIDGE_H
#include "dotpython_abi3.h"
#ifdef __cplusplus
extern "C" {
#endif
#define DP_ABI3_BRIDGE_VERSION 5
typedef enum dp_abi3_object_kind {
DP_ABI3_OBJECT_INVALID = 0,
DP_ABI3_OBJECT_NONE = 1,
DP_ABI3_OBJECT_BOOL = 2,
DP_ABI3_OBJECT_INT = 3,
DP_ABI3_OBJECT_TEXT = 4,
DP_ABI3_OBJECT_BYTES = 5,
DP_ABI3_OBJECT_LIST = 6,
DP_ABI3_OBJECT_TUPLE = 7,
DP_ABI3_OBJECT_DICT = 8,
DP_ABI3_OBJECT_MODULE = 9,
DP_ABI3_OBJECT_CALLABLE = 10,
DP_ABI3_OBJECT_TYPE = 11,
DP_ABI3_OBJECT_INSTANCE = 12
} dp_abi3_object_kind;
/*
* Stateful calls, native callbacks, and object release must stay on the thread that first
* activates the bridge. Returned text points to thread-local bridge storage and remains valid
* only until the next bridge/C-API call on that thread. PyObject results follow CPython's
* documented new/borrowed/stolen reference conventions.
*/
DP_ABI3_EXPORT int dp_abi3_bridge_version(void);
DP_ABI3_EXPORT int
dp_abi3_module_initialize(PyObject *initialization_result, PyObject **module, int *multi_phase);
/*
* Generic qualified-object surface. Every PyObject output is a new reference owned by the caller
* and must be released with dp_abi3_object_release on the owner thread. Input object arrays contain
* borrowed references. Text output uses temporary owner-thread storage and an explicit byte count.
*/
DP_ABI3_EXPORT int
dp_abi3_module_attribute_names(PyObject *module, const char **result_json);
DP_ABI3_EXPORT int
dp_abi3_object_get_attr(PyObject *object, const char *name, PyObject **result);
DP_ABI3_EXPORT int dp_abi3_object_call(
PyObject *callable,
PyObject *const *arguments,
int64_t argument_count,
PyObject **result
);
DP_ABI3_EXPORT int dp_abi3_object_from_utf8(
const char *value,
int64_t value_length,
PyObject **result
);
DP_ABI3_EXPORT int dp_abi3_object_from_int64(int64_t value, PyObject **result);
DP_ABI3_EXPORT int dp_abi3_object_from_bool(int value, PyObject **result);
DP_ABI3_EXPORT int dp_abi3_object_from_none(PyObject **result);
DP_ABI3_EXPORT int dp_abi3_object_sequence(
int kind,
PyObject *const *items,
int64_t item_count,
PyObject **result
);
DP_ABI3_EXPORT int dp_abi3_object_kind_of(PyObject *object, int *kind);
DP_ABI3_EXPORT int dp_abi3_object_as_int64(PyObject *object, int64_t *result);
DP_ABI3_EXPORT int dp_abi3_object_as_bool(PyObject *object, int *result);
DP_ABI3_EXPORT int dp_abi3_object_as_utf8(
PyObject *object,
const char **result,
int64_t *result_length
);
DP_ABI3_EXPORT int dp_abi3_object_string(
PyObject *object,
const char **result,
int64_t *result_length
);
DP_ABI3_EXPORT int dp_abi3_object_repr(
PyObject *object,
const char **result,
int64_t *result_length
);
DP_ABI3_EXPORT int dp_abi3_object_rich_compare(
PyObject *left,
PyObject *right,
int operation,
PyObject **result
);
DP_ABI3_EXPORT int dp_abi3_object_size(PyObject *object, int64_t *result);
DP_ABI3_EXPORT int
dp_abi3_object_get_item(PyObject *object, PyObject *key, PyObject **result);
DP_ABI3_EXPORT void dp_abi3_object_release(PyObject *object);
/*
* Releases module when non-NULL and clears the owner thread's native error indicator. Passing
* NULL performs only the error-state cleanup, including release of all owned error references;
* it is the supported operation for discarding an error without a module handle.
*/
DP_ABI3_EXPORT void dp_abi3_module_destroy(PyObject *module);
DP_ABI3_EXPORT const char *dp_abi3_error_type(void);
DP_ABI3_EXPORT const char *dp_abi3_error_message(void);
DP_ABI3_EXPORT int64_t dp_abi3_active_object_count(void);
#ifdef __cplusplus
}
#endif
#endif