-
Notifications
You must be signed in to change notification settings - Fork 9
/
utils.h
132 lines (114 loc) · 3.16 KB
/
utils.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
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
// Copyright 2011 Julian Phillips. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
#ifndef _GO_PYTHON_UTILS_H_
#define _GO_PYTHON_UTILS_H_
#include <Python.h>
#if PY_MAJOR_VERSION < 3
#error "PY_MAJOR_VERSION < 3: Please make sure your cgo.go is configured properly."
#endif
typedef struct {
// Protective NULL pointer
void *zero;
// Standard Methods
void *call;
void *compare;
void *dealloc;
void *getattr;
void *getattro;
void *hash;
void *init;
void *iter;
void *iternext;
void *repr;
void *richcmp;
void *setattr;
void *setattro;
void *str;
// Mapping Protocol
int has_mp;
void *mp_len;
void *mp_get;
void *mp_set;
// Number Protocol
int has_nb;
void *nb_add;
void *nb_subtract;
void *nb_multiply;
void *nb_divide;
void *nb_remainder;
void *nb_divmod;
void *nb_power;
void *nb_negative;
void *nb_positive;
void *nb_absolute;
void *nb_nonzero;
void *nb_invert;
void *nb_lshift;
void *nb_rshift;
void *nb_and;
void *nb_xor;
void *nb_or;
void *nb_int;
void *nb_long;
void *nb_float;
void *nb_oct;
void *nb_hex;
void *nb_ip_add;
void *nb_ip_subtract;
void *nb_ip_multiply;
void *nb_ip_divide;
void *nb_ip_remainder;
void *nb_ip_power;
void *nb_ip_lshift;
void *nb_ip_rshift;
void *nb_ip_and;
void *nb_ip_xor;
void *nb_ip_or;
void *nb_floordiv;
void *nb_truediv;
void *nb_ip_floordiv;
void *nb_ip_truediv;
void *nb_index;
// Sequence Protocol
int has_sq;
void *sq_length;
void *sq_concat;
void *sq_repeat;
void *sq_get;
void *sq_set;
void *sq_contains;
void *sq_ip_concat;
void *sq_ip_repeat;
// The concrete Methods structs for the protocols (PyTypeObjects only store
// a pointer).
PyMappingMethods mp_meth;
PyNumberMethods nb_meth;
PySequenceMethods sq_meth;
} ClassContext;
extern size_t var_size(PyObject *obj, Py_ssize_t n);
extern void GoPyObject_INIT(PyObject *obj, PyObject *typ);
extern void GoPyObject_INIT_VAR(PyObject *obj, PyObject *typ, Py_ssize_t n);
extern void GoPyObject_GC_Track(PyObject *obj);
extern void setGcRefs(PyGC_Head *g, Py_ssize_t refs);
extern PyMethodDef *newMethodDef(void);
extern void set_call_noargs(PyCFunction *f);
extern void set_call_args(PyCFunction *f);
extern void set_call_keywords(PyCFunction *f);
extern PyObject *newMethod(char *name, void *func, int flags);
extern PyObject *newObjMember(int idx, char *doc);
extern PyObject *newNatMember(int idx, char *doc);
extern PyObject *newProperty(PyTypeObject *type, char *name, void *get, void *set);
extern void enableClassGc(PyTypeObject *type);
extern void overrideGenericAlloc(PyTypeObject *type);
extern void setClassContext(PyTypeObject *type, ClassContext *ctxt);
extern PyTypeObject *getBasePyType(int);
extern int getBaseGoPyType(PyObject *o);
extern PyObject *compileFile(char *name);
struct _en {
char *m;
char *c;
};
extern struct _en excName(PyObject *o);
#include "gopy_types.h"
#endif /* _GO_PYTHON_UTILS_H */