6
6
import enum
7
7
from typing import Dict , List , Tuple , Optional
8
8
9
- from pydantic import BaseModel , validator
10
-
11
-
12
- class Model (BaseModel ):
13
- class Config :
14
- extra = "forbid"
9
+ from pydantic import validator
10
+ from .util import Model , _generating_documentation
15
11
16
12
17
13
class ParamData (Model ):
18
14
"""Various ways to modify parameters"""
19
15
20
- # Rename parameter
16
+ #: Set parameter name to this
21
17
name : Optional [str ] = None
22
18
23
- # C++ type emitted
19
+ #: Change C++ type emitted
24
20
x_type : Optional [str ] = None
25
21
26
- # Default value for parameter
22
+ #: Default value for parameter
27
23
default : Optional [str ] = None
28
24
25
+ #: Force this to be an 'out' parameter
26
+ #:
27
+ #: .. seealso:: :ref:`autowrap_out_params`
28
+ #:
29
29
force_out : bool = False
30
30
31
+ #: Force an array size
31
32
array_size : Optional [int ] = None
32
33
34
+ #: Ignore this parameter
33
35
ignore : bool = False
34
36
35
37
36
38
class BufferType (str , enum .Enum ):
39
+
40
+ #: The buffer must indicate that it is readable (such as bytes, or bytearray)
37
41
IN = "in"
42
+
43
+ #: The buffer must indicate that it is writeable (such as a bytearray)
38
44
OUT = "out"
45
+
46
+ #: The buffer must indicate that it readable or writeable (such as a bytearray)
39
47
INOUT = "inout"
40
48
41
49
42
50
class BufferData (Model ):
43
- """Describes buffers"""
44
51
45
- # Indicates what type of buffer is required: out/inout buffers require
46
- # a writeable buffer such as a bytearray, but in only needs a readonly
47
- # buffer (such as bytes)
52
+ #: Indicates what type of python buffer is required
48
53
type : BufferType
49
54
50
- # Name of source parameter -- user must pass in something that implements
51
- # the buffer protocol (eg bytes, bytearray)
55
+ #: Name of C++ parameter that the buffer will use
52
56
src : str
53
57
54
- # Name of length parameter. An out-only parameter, it will be set to the size
55
- # of the src buffer, and will be returned so the caller can determine how
56
- # many bytes were written
58
+ #: Name of the C++ length parameter. An out-only parameter, it will be set
59
+ #: to the size of the python buffer, and will be returned so the caller can
60
+ #: determine how many bytes were written
57
61
len : str
58
62
59
- # If specified, the minimum size of the passed in buffer
63
+ #: If specified, the minimum size of the python buffer
60
64
minsz : Optional [int ] = None
61
65
62
66
63
67
class ReturnValuePolicy (enum .Enum ):
64
68
"""
65
- see pybind11 documentation for this
69
+ See `pybind11 documentation <https://pybind11.readthedocs.io/en/stable/advanced/functions.html#return-value-policies>`_
70
+ for what each of these values mean.
66
71
"""
67
72
68
73
TAKE_OWNERSHIP = "take_ownership"
@@ -75,37 +80,42 @@ class ReturnValuePolicy(enum.Enum):
75
80
76
81
77
82
class FunctionData (Model ):
78
- # If True, don't wrap this
83
+ """
84
+
85
+
86
+ """
87
+
88
+ #: If True, don't wrap this
79
89
ignore : bool = False
80
90
81
- # If True, don't wrap this, but provide a pure virtual implementation
82
- # -> in theory we could autodetect this, but sometimes ignore
83
- # is used for when CppHeaderParser totally blows it
91
+ #: If True, don't wrap this, but provide a pure virtual implementation
84
92
ignore_pure : bool = False
85
93
86
- # Generate this in an `#ifdef`
94
+ #: Generate this in an `#ifdef`
87
95
ifdef : Optional [str ] = None
88
- # Generate this in an `#ifndef`
96
+ #: Generate this in an `#ifndef`
89
97
ifndef : Optional [str ] = None
90
98
91
- # Use this code instead of the generated code
99
+ #: Use this code instead of the generated code
92
100
cpp_code : Optional [str ] = None
93
101
94
- # Docstring for the function
102
+ #: Docstring for the function
95
103
doc : Optional [str ] = None
96
104
97
- # If True, prepends an underscore to the python name
105
+ #: If True, prepends an underscore to the python name
98
106
internal : bool = False
99
107
100
- # Set this to rename the function
108
+ #: Use this to set the name of the function as exposed to python
101
109
rename : Optional [str ] = None
102
110
103
- # Mechanism to override individual parameters
111
+ #: Mechanism to override individual parameters
104
112
param_override : Dict [str , ParamData ] = {}
105
113
106
114
#: If specified, put the function in a sub.pack.age
107
115
subpackage : Optional [str ] = None
108
116
117
+ #: By default, robotpy-build will release the GIL whenever a wrapped
118
+ #: function is called.
109
119
no_release_gil : Optional [bool ] = None
110
120
111
121
buffers : List [BufferData ] = []
@@ -133,7 +143,8 @@ def validate_overloads(cls, value):
133
143
return value
134
144
135
145
136
- FunctionData .update_forward_refs ()
146
+ if not _generating_documentation :
147
+ FunctionData .update_forward_refs ()
137
148
138
149
139
150
class PropAccess (enum .Enum ):
@@ -154,9 +165,11 @@ class PropAccess(enum.Enum):
154
165
155
166
156
167
class PropData (Model ):
168
+
169
+ #: If set to True, this property is not made available to python
157
170
ignore : bool = False
158
171
159
- #: Set the name of this property to the specified value
172
+ #: Set the python name of this property to the specified string
160
173
rename : Optional [str ]
161
174
162
175
#: Python code access to this property
@@ -167,7 +180,11 @@ class PropData(Model):
167
180
168
181
169
182
class EnumValue (Model ):
183
+
184
+ #: If set to True, this property is not made available to python
170
185
ignore : bool = False
186
+
187
+ #: Set the python name of this enum value to the specified string
171
188
rename : Optional [str ] = None
172
189
173
190
#: Docstring for the enum value
@@ -176,11 +193,15 @@ class EnumValue(Model):
176
193
177
194
class EnumData (Model ):
178
195
179
- # Docstring for the enum
196
+ #: Set your own docstring for the enum
180
197
doc : Optional [str ] = None
181
198
199
+ #: If set to True, this property is not made available to python
182
200
ignore : bool = False
201
+
202
+ #: Set the python name of this enum to the specified string
183
203
rename : Optional [str ] = None
204
+
184
205
value_prefix : Optional [str ] = None
185
206
186
207
#: If specified, put the enum in a sub.pack.age (ignored for
@@ -198,7 +219,7 @@ class ClassData(Model):
198
219
ignore : bool = False
199
220
ignored_bases : List [str ] = []
200
221
201
- # Specify fully qualified names for the bases
222
+ #: Specify fully qualified names for the bases
202
223
base_qualnames : Dict [str , str ] = {}
203
224
204
225
attributes : Dict [str , PropData ] = {}
@@ -281,14 +302,12 @@ def validate_methods(cls, value):
281
302
282
303
class TemplateData (Model ):
283
304
284
- # Fully qualified name of template
305
+ #: Fully qualified name of template
285
306
qualname : str
286
307
287
- # Template parameters to use
308
+ #: Template parameters to use
288
309
params : List [str ]
289
310
290
- # TODO: other parameters useful for concrete types
291
-
292
311
293
312
class HooksDataYaml (Model ):
294
313
"""
0 commit comments