1
1
// Ignore style warnings for for byondapi-c bindings
2
- #![ allow( non_upper_case_globals) ]
3
- #![ allow( non_camel_case_types) ]
4
- #![ allow( non_snake_case) ]
5
- #![ allow( clippy:: missing_safety_doc) ]
6
- use std:: ffi:: c_char;
2
+ #![ allow(
3
+ clippy:: missing_safety_doc,
4
+ non_upper_case_globals,
5
+ non_camel_case_types,
6
+ non_snake_case
7
+ ) ]
8
+ use std:: ops:: Deref ;
7
9
8
10
#[ cfg( not( target_pointer_width = "32" ) ) ]
9
11
compile_error ! ( "BYOND API only functions with 32-bit targets" ) ;
@@ -15,12 +17,15 @@ compile_error!("BYOND API only functions on x86 targets");
15
17
compile_error ! ( "BYOND API only supports Windows and Linux" ) ;
16
18
17
19
// Include byondapi-c bindings (generated by build.rs)
18
- #[ allow( dead_code) ]
20
+ #[ allow( dead_code, rustdoc :: broken_intra_doc_links ) ]
19
21
mod byond_rawbind {
20
22
#[ cfg( feature = "byond-515-1621" ) ]
21
23
include ! ( concat!( env!( "OUT_DIR" ) , "/bindings_515_1621.rs" ) ) ;
22
24
}
23
25
26
+ #[ cfg( doc) ]
27
+ pub use byond_rawbind:: ByondApi as RawByondApi ;
28
+
24
29
/// we must simply hope this never changes
25
30
mod version {
26
31
use super :: byond_rawbind:: u4c;
@@ -66,6 +71,15 @@ impl ByondApi {
66
71
}
67
72
}
68
73
74
+ impl Deref for ByondApi {
75
+ type Target = byond_rawbind:: ByondApi ;
76
+
77
+ #[ inline]
78
+ fn deref ( & self ) -> & Self :: Target {
79
+ & self . internal
80
+ }
81
+ }
82
+
69
83
// Stabilized types
70
84
pub use byond_rawbind:: s1c;
71
85
pub use byond_rawbind:: s1cMAX;
@@ -87,255 +101,3 @@ pub use byond_rawbind::ByondValueData;
87
101
pub use byond_rawbind:: ByondValueType ;
88
102
pub use byond_rawbind:: CByondValue ;
89
103
pub use byond_rawbind:: CByondXYZ ;
90
-
91
- // Stabilized functions
92
- impl ByondApi {
93
- pub unsafe fn Byond_LastError ( & self ) -> * const c_char {
94
- self . internal . Byond_LastError ( )
95
- }
96
- pub unsafe fn Byond_GetVersion ( & self , version : * mut u4c , build : * mut u4c ) {
97
- self . internal . Byond_GetVersion ( version, build)
98
- }
99
- pub unsafe fn Byond_GetDMBVersion ( & self ) -> u4c {
100
- self . internal . Byond_GetDMBVersion ( )
101
- }
102
- pub unsafe fn ByondValue_Clear ( & self , v : * mut CByondValue ) {
103
- self . internal . ByondValue_Clear ( v)
104
- }
105
- pub unsafe fn ByondValue_Type ( & self , v : * const CByondValue ) -> ByondValueType {
106
- self . internal . ByondValue_Type ( v)
107
- }
108
- pub unsafe fn ByondValue_IsNull ( & self , v : * const CByondValue ) -> bool {
109
- self . internal . ByondValue_IsNull ( v)
110
- }
111
- pub unsafe fn ByondValue_IsNum ( & self , v : * const CByondValue ) -> bool {
112
- self . internal . ByondValue_IsNum ( v)
113
- }
114
- pub unsafe fn ByondValue_IsStr ( & self , v : * const CByondValue ) -> bool {
115
- self . internal . ByondValue_IsStr ( v)
116
- }
117
- pub unsafe fn ByondValue_IsList ( & self , v : * const CByondValue ) -> bool {
118
- self . internal . ByondValue_IsList ( v)
119
- }
120
- pub unsafe fn ByondValue_IsTrue ( & self , v : * const CByondValue ) -> bool {
121
- self . internal . ByondValue_IsTrue ( v)
122
- }
123
- pub unsafe fn ByondValue_GetNum ( & self , v : * const CByondValue ) -> f32 {
124
- self . internal . ByondValue_GetNum ( v)
125
- }
126
- pub unsafe fn ByondValue_GetRef ( & self , v : * const CByondValue ) -> u4c {
127
- self . internal . ByondValue_GetRef ( v)
128
- }
129
- pub unsafe fn ByondValue_SetNum ( & self , v : * mut CByondValue , f : f32 ) {
130
- self . internal . ByondValue_SetNum ( v, f)
131
- }
132
- pub unsafe fn ByondValue_SetStr ( & self , v : * mut CByondValue , str_ : * const c_char ) {
133
- self . internal . ByondValue_SetStr ( v, str_)
134
- }
135
- pub unsafe fn ByondValue_SetRef ( & self , v : * mut CByondValue , type_ : ByondValueType , ref_ : u4c ) {
136
- self . internal . ByondValue_SetRef ( v, type_, ref_)
137
- }
138
- pub unsafe fn ByondValue_Equals ( & self , a : * const CByondValue , b : * const CByondValue ) -> bool {
139
- self . internal . ByondValue_Equals ( a, b)
140
- }
141
- pub unsafe fn Byond_ThreadSync (
142
- & self ,
143
- callback : ByondCallback ,
144
- data : * mut std:: ffi:: c_void ,
145
- block : bool ,
146
- ) -> CByondValue {
147
- self . internal . Byond_ThreadSync ( callback, data, block)
148
- }
149
- pub unsafe fn Byond_GetStrId ( & self , str_ : * const c_char ) -> u4c {
150
- self . internal . Byond_GetStrId ( str_)
151
- }
152
- pub unsafe fn Byond_AddGetStrId ( & self , str_ : * const c_char ) -> u4c {
153
- self . internal . Byond_AddGetStrId ( str_)
154
- }
155
- pub unsafe fn Byond_ReadVar (
156
- & self ,
157
- loc : * const CByondValue ,
158
- varname : * const c_char ,
159
- result : * mut CByondValue ,
160
- ) -> bool {
161
- self . internal . Byond_ReadVar ( loc, varname, result)
162
- }
163
- pub unsafe fn Byond_ReadVarByStrId (
164
- & self ,
165
- loc : * const CByondValue ,
166
- varname : u4c ,
167
- result : * mut CByondValue ,
168
- ) -> bool {
169
- self . internal . Byond_ReadVarByStrId ( loc, varname, result)
170
- }
171
- pub unsafe fn Byond_WriteVar (
172
- & self ,
173
- loc : * const CByondValue ,
174
- varname : * const c_char ,
175
- val : * const CByondValue ,
176
- ) -> bool {
177
- self . internal . Byond_WriteVar ( loc, varname, val)
178
- }
179
- pub unsafe fn Byond_WriteVarByStrId (
180
- & self ,
181
- loc : * const CByondValue ,
182
- varname : u4c ,
183
- val : * const CByondValue ,
184
- ) -> bool {
185
- self . internal . Byond_WriteVarByStrId ( loc, varname, val)
186
- }
187
- pub unsafe fn Byond_CreateList ( & self , result : * mut CByondValue ) -> bool {
188
- self . internal . Byond_CreateList ( result)
189
- }
190
- pub unsafe fn Byond_ReadList (
191
- & self ,
192
- loc : * const CByondValue ,
193
- list : * mut CByondValue ,
194
- len : * mut u4c ,
195
- ) -> bool {
196
- self . internal . Byond_ReadList ( loc, list, len)
197
- }
198
- pub unsafe fn Byond_WriteList (
199
- & self ,
200
- loc : * const CByondValue ,
201
- list : * const CByondValue ,
202
- len : u4c ,
203
- ) -> bool {
204
- self . internal . Byond_WriteList ( loc, list, len)
205
- }
206
- pub unsafe fn Byond_ReadListIndex (
207
- & self ,
208
- loc : * const CByondValue ,
209
- idx : * const CByondValue ,
210
- result : * mut CByondValue ,
211
- ) -> bool {
212
- self . internal . Byond_ReadListIndex ( loc, idx, result)
213
- }
214
- pub unsafe fn Byond_WriteListIndex (
215
- & self ,
216
- loc : * const CByondValue ,
217
- idx : * const CByondValue ,
218
- val : * const CByondValue ,
219
- ) -> bool {
220
- self . internal . Byond_WriteListIndex ( loc, idx, val)
221
- }
222
- pub unsafe fn Byond_ReadPointer (
223
- & self ,
224
- ptr : * const CByondValue ,
225
- result : * mut CByondValue ,
226
- ) -> bool {
227
- self . internal . Byond_ReadPointer ( ptr, result)
228
- }
229
- pub unsafe fn Byond_WritePointer (
230
- & self ,
231
- ptr : * const CByondValue ,
232
- val : * const CByondValue ,
233
- ) -> bool {
234
- self . internal . Byond_WritePointer ( ptr, val)
235
- }
236
- pub unsafe fn Byond_CallProc (
237
- & self ,
238
- src : * const CByondValue ,
239
- name : * const c_char ,
240
- arg : * const CByondValue ,
241
- arg_count : u4c ,
242
- result : * mut CByondValue ,
243
- ) -> bool {
244
- self . internal
245
- . Byond_CallProc ( src, name, arg, arg_count, result)
246
- }
247
- pub unsafe fn Byond_CallProcByStrId (
248
- & self ,
249
- src : * const CByondValue ,
250
- name : u4c ,
251
- arg : * const CByondValue ,
252
- arg_count : u4c ,
253
- result : * mut CByondValue ,
254
- ) -> bool {
255
- self . internal
256
- . Byond_CallProcByStrId ( src, name, arg, arg_count, result)
257
- }
258
- pub unsafe fn Byond_CallGlobalProc (
259
- & self ,
260
- name : * const c_char ,
261
- arg : * const CByondValue ,
262
- arg_count : u4c ,
263
- result : * mut CByondValue ,
264
- ) -> bool {
265
- self . internal
266
- . Byond_CallGlobalProc ( name, arg, arg_count, result)
267
- }
268
- pub unsafe fn Byond_CallGlobalProcByStrId (
269
- & self ,
270
- name : u4c ,
271
- arg : * const CByondValue ,
272
- arg_count : u4c ,
273
- result : * mut CByondValue ,
274
- ) -> bool {
275
- self . internal
276
- . Byond_CallGlobalProcByStrId ( name, arg, arg_count, result)
277
- }
278
- pub unsafe fn Byond_ToString (
279
- & self ,
280
- src : * const CByondValue ,
281
- result : * mut c_char ,
282
- len : * mut u4c ,
283
- ) -> bool {
284
- self . internal . Byond_ToString ( src, result, len)
285
- }
286
- pub unsafe fn Byond_Block (
287
- & self ,
288
- corner1 : * const CByondXYZ ,
289
- corner2 : * const CByondXYZ ,
290
- result : * mut CByondValue ,
291
- len : * mut u4c ,
292
- ) -> bool {
293
- self . internal . Byond_Block ( corner1, corner2, result, len)
294
- }
295
- pub unsafe fn Byond_Length ( & self , src : * const CByondValue , result : * mut CByondValue ) -> bool {
296
- self . internal . Byond_Length ( src, result)
297
- }
298
- pub unsafe fn Byond_LocateIn (
299
- & self ,
300
- type_ : * const CByondValue ,
301
- list : * const CByondValue ,
302
- result : * mut CByondValue ,
303
- ) -> bool {
304
- self . internal . Byond_LocateIn ( type_, list, result)
305
- }
306
- pub unsafe fn Byond_LocateXYZ ( & self , xyz : * const CByondXYZ , result : * mut CByondValue ) -> bool {
307
- self . internal . Byond_LocateXYZ ( xyz, result)
308
- }
309
- pub unsafe fn Byond_New (
310
- & self ,
311
- type_ : * const CByondValue ,
312
- argA : * const CByondValue ,
313
- argS : u4c ,
314
- result : * mut CByondValue ,
315
- ) -> bool {
316
- self . internal . Byond_New ( type_, argA, argS, result)
317
- }
318
- pub unsafe fn Byond_NewArglist (
319
- & self ,
320
- type_ : * const CByondValue ,
321
- arglist : * const CByondValue ,
322
- result : * mut CByondValue ,
323
- ) -> bool {
324
- self . internal . Byond_NewArglist ( type_, arglist, result)
325
- }
326
- pub unsafe fn Byond_Refcount ( & self , type_ : * const CByondValue , result : * mut u4c ) -> bool {
327
- self . internal . Byond_Refcount ( type_, result)
328
- }
329
- pub unsafe fn Byond_XYZ ( & self , src : * const CByondValue , xyz : * mut CByondXYZ ) -> bool {
330
- self . internal . Byond_XYZ ( src, xyz)
331
- }
332
- pub unsafe fn ByondValue_IncRef ( & self , src : * const CByondValue ) {
333
- self . internal . ByondValue_IncRef ( src)
334
- }
335
- pub unsafe fn ByondValue_DecRef ( & self , src : * const CByondValue ) {
336
- self . internal . ByondValue_DecRef ( src)
337
- }
338
- pub unsafe fn Byond_TestRef ( & self , src : * mut CByondValue ) -> bool {
339
- self . internal . Byond_TestRef ( src)
340
- }
341
- }
0 commit comments