1pub const s1cMAX: u32 = 127;
5pub const s1cMIN: i32 = -127;
6pub const s2cMAX: u32 = 32767;
7pub const s2cMIN: i32 = -32767;
8pub const s4cMAX: u32 = 2147483647;
9pub const s4cMIN: i32 = -2147483647;
10pub type u1c = ::std::os::raw::c_uchar;
11pub type s1c = ::std::os::raw::c_schar;
12pub type u2c = ::std::os::raw::c_ushort;
13pub type s2c = ::std::os::raw::c_short;
14pub type u4c = ::std::os::raw::c_ulong;
15pub type s4c = ::std::os::raw::c_long;
16pub type s8c = ::std::os::raw::c_longlong;
17pub type u8c = ::std::os::raw::c_ulonglong;
18#[repr(C)]
19#[derive(Copy, Clone)]
20pub union u4cOrPointer {
21 pub num: u4c,
22 pub ptr: *mut ::std::os::raw::c_void,
23}
24impl Default for u4cOrPointer {
25 fn default() -> Self {
26 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
27 unsafe {
28 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
29 s.assume_init()
30 }
31 }
32}
33pub type ByondValueType = u1c;
34#[repr(C)]
35#[derive(Copy, Clone)]
36pub union ByondValueData {
37 #[doc = "!< 4-byte reference ID"]
38 pub ref_: u4c,
39 #[doc = "!< floating-point number"]
40 pub num: f32,
41}
42impl Default for ByondValueData {
43 fn default() -> Self {
44 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
45 unsafe {
46 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
47 s.assume_init()
48 }
49 }
50}
51#[repr(C)]
52#[derive(Copy, Clone)]
53pub struct CByondValue {
54 #[doc = "!< 1-byte intrinsic data type"]
55 pub type_: ByondValueType,
56 #[doc = "!< padding"]
57 pub junk1: u1c,
58 #[doc = "!< padding"]
59 pub junk2: u1c,
60 #[doc = "!< padding"]
61 pub junk3: u1c,
62 #[doc = "!< 4-byte reference ID or floating point number"]
63 pub data: ByondValueData,
64}
65impl Default for CByondValue {
66 fn default() -> Self {
67 let mut s = ::std::mem::MaybeUninit::<Self>::uninit();
68 unsafe {
69 ::std::ptr::write_bytes(s.as_mut_ptr(), 0, 1);
70 s.assume_init()
71 }
72 }
73}
74#[repr(C)]
75#[derive(Debug, Default, Copy, Clone)]
76pub struct CByondXYZ {
77 #[doc = "!< signed 2-byte integer coordinates"]
78 pub x: s2c,
79 #[doc = "!< signed 2-byte integer coordinates"]
80 pub y: s2c,
81 #[doc = "!< signed 2-byte integer coordinates"]
82 pub z: s2c,
83 #[doc = "!< padding"]
84 pub junk: s2c,
85}
86#[repr(C)]
87#[derive(Debug, Default, Copy, Clone)]
88pub struct CByondPixLoc {
89 #[doc = "!< pixel coordinates as floats"]
90 pub x: f32,
91 #[doc = "!< pixel coordinates as floats"]
92 pub y: f32,
93 #[doc = "!< signed 2-byte integer coordinates"]
94 pub z: s2c,
95 #[doc = "!< padding"]
96 pub junk: s2c,
97}
98pub type ByondCallback = ::std::option::Option<
99 unsafe extern "C-unwind" fn(arg1: *mut ::std::os::raw::c_void) -> CByondValue,
100>;
101pub struct ByondApi {
102 __library: ::libloading::Library,
103 pub Byond_LastError: unsafe extern "C-unwind" fn() -> *const ::std::os::raw::c_char,
104 pub Byond_GetVersion: unsafe extern "C-unwind" fn(version: *mut u4c, build: *mut u4c),
105 pub Byond_GetDMBVersion: unsafe extern "C-unwind" fn() -> u4c,
106 pub ByondValue_Clear: unsafe extern "C-unwind" fn(v: *mut CByondValue),
107 pub ByondValue_Type: unsafe extern "C-unwind" fn(v: *const CByondValue) -> ByondValueType,
108 pub ByondValue_IsNull: unsafe extern "C-unwind" fn(v: *const CByondValue) -> bool,
109 pub ByondValue_IsNum: unsafe extern "C-unwind" fn(v: *const CByondValue) -> bool,
110 pub ByondValue_IsStr: unsafe extern "C-unwind" fn(v: *const CByondValue) -> bool,
111 pub ByondValue_IsList: unsafe extern "C-unwind" fn(v: *const CByondValue) -> bool,
112 pub ByondValue_IsTrue: unsafe extern "C-unwind" fn(v: *const CByondValue) -> bool,
113 pub ByondValue_GetNum: unsafe extern "C-unwind" fn(v: *const CByondValue) -> f32,
114 pub ByondValue_GetRef: unsafe extern "C-unwind" fn(v: *const CByondValue) -> u4c,
115 pub ByondValue_SetNum: unsafe extern "C-unwind" fn(v: *mut CByondValue, f: f32),
116 pub ByondValue_SetStr:
117 unsafe extern "C-unwind" fn(v: *mut CByondValue, str_: *const ::std::os::raw::c_char),
118 pub ByondValue_SetStrId: unsafe extern "C-unwind" fn(v: *mut CByondValue, strid: u4c),
119 pub ByondValue_SetRef:
120 unsafe extern "C-unwind" fn(v: *mut CByondValue, type_: ByondValueType, ref_: u4c),
121 pub ByondValue_Equals:
122 unsafe extern "C-unwind" fn(a: *const CByondValue, b: *const CByondValue) -> bool,
123 pub Byond_ThreadSync: unsafe extern "C-unwind" fn(
124 callback: ByondCallback,
125 data: *mut ::std::os::raw::c_void,
126 block: bool,
127 ) -> CByondValue,
128 pub Byond_GetStrId: unsafe extern "C-unwind" fn(str_: *const ::std::os::raw::c_char) -> u4c,
129 pub Byond_AddGetStrId: unsafe extern "C-unwind" fn(str_: *const ::std::os::raw::c_char) -> u4c,
130 pub Byond_ReadVar: unsafe extern "C-unwind" fn(
131 loc: *const CByondValue,
132 varname: *const ::std::os::raw::c_char,
133 result: *mut CByondValue,
134 ) -> bool,
135 pub Byond_ReadVarByStrId: unsafe extern "C-unwind" fn(
136 loc: *const CByondValue,
137 varname: u4c,
138 result: *mut CByondValue,
139 ) -> bool,
140 pub Byond_WriteVar: unsafe extern "C-unwind" fn(
141 loc: *const CByondValue,
142 varname: *const ::std::os::raw::c_char,
143 val: *const CByondValue,
144 ) -> bool,
145 pub Byond_WriteVarByStrId: unsafe extern "C-unwind" fn(
146 loc: *const CByondValue,
147 varname: u4c,
148 val: *const CByondValue,
149 ) -> bool,
150 pub Byond_CreateList: unsafe extern "C-unwind" fn(result: *mut CByondValue) -> bool,
151 pub Byond_ReadList: unsafe extern "C-unwind" fn(
152 loc: *const CByondValue,
153 list: *mut CByondValue,
154 len: *mut u4c,
155 ) -> bool,
156 pub Byond_WriteList: unsafe extern "C-unwind" fn(
157 loc: *const CByondValue,
158 list: *const CByondValue,
159 len: u4c,
160 ) -> bool,
161 pub Byond_ReadListAssoc: unsafe extern "C-unwind" fn(
162 loc: *const CByondValue,
163 list: *mut CByondValue,
164 len: *mut u4c,
165 ) -> bool,
166 pub Byond_ReadListIndex: unsafe extern "C-unwind" fn(
167 loc: *const CByondValue,
168 idx: *const CByondValue,
169 result: *mut CByondValue,
170 ) -> bool,
171 pub Byond_WriteListIndex: unsafe extern "C-unwind" fn(
172 loc: *const CByondValue,
173 idx: *const CByondValue,
174 val: *const CByondValue,
175 ) -> bool,
176 pub Byond_ReadPointer:
177 unsafe extern "C-unwind" fn(ptr: *const CByondValue, result: *mut CByondValue) -> bool,
178 pub Byond_WritePointer:
179 unsafe extern "C-unwind" fn(ptr: *const CByondValue, val: *const CByondValue) -> bool,
180 pub Byond_CallProc: unsafe extern "C-unwind" fn(
181 src: *const CByondValue,
182 name: *const ::std::os::raw::c_char,
183 arg: *const CByondValue,
184 arg_count: u4c,
185 result: *mut CByondValue,
186 ) -> bool,
187 pub Byond_CallProcByStrId: unsafe extern "C-unwind" fn(
188 src: *const CByondValue,
189 name: u4c,
190 arg: *const CByondValue,
191 arg_count: u4c,
192 result: *mut CByondValue,
193 ) -> bool,
194 pub Byond_CallGlobalProc: unsafe extern "C-unwind" fn(
195 name: *const ::std::os::raw::c_char,
196 arg: *const CByondValue,
197 arg_count: u4c,
198 result: *mut CByondValue,
199 ) -> bool,
200 pub Byond_CallGlobalProcByStrId: unsafe extern "C-unwind" fn(
201 name: u4c,
202 arg: *const CByondValue,
203 arg_count: u4c,
204 result: *mut CByondValue,
205 ) -> bool,
206 pub Byond_ToString: unsafe extern "C-unwind" fn(
207 src: *const CByondValue,
208 buf: *mut ::std::os::raw::c_char,
209 buflen: *mut u4c,
210 ) -> bool,
211 #[cfg(feature = "byond-1664")]
212 pub Byond_Return: unsafe extern "C-unwind" fn(
213 waiting_proc: *const CByondValue,
214 retval: *const CByondValue,
215 ) -> bool,
216 pub Byond_Block: unsafe extern "C-unwind" fn(
217 corner1: *const CByondXYZ,
218 corner2: *const CByondXYZ,
219 list: *mut CByondValue,
220 len: *mut u4c,
221 ) -> bool,
222 #[cfg(feature = "byond-1664")]
223 pub ByondValue_IsType: unsafe extern "C-unwind" fn(
224 src: *const CByondValue,
225 typestr: *const ::std::os::raw::c_char,
226 ) -> bool,
227 pub Byond_Length:
228 unsafe extern "C-unwind" fn(src: *const CByondValue, result: *mut CByondValue) -> bool,
229 pub Byond_LocateIn: unsafe extern "C-unwind" fn(
230 type_: *const CByondValue,
231 list: *const CByondValue,
232 result: *mut CByondValue,
233 ) -> bool,
234 pub Byond_LocateXYZ:
235 unsafe extern "C-unwind" fn(xyz: *const CByondXYZ, result: *mut CByondValue) -> bool,
236 pub Byond_New: unsafe extern "C-unwind" fn(
237 type_: *const CByondValue,
238 arg: *const CByondValue,
239 arg_count: u4c,
240 result: *mut CByondValue,
241 ) -> bool,
242 pub Byond_NewArglist: unsafe extern "C-unwind" fn(
243 type_: *const CByondValue,
244 arglist: *const CByondValue,
245 result: *mut CByondValue,
246 ) -> bool,
247 pub Byond_Refcount:
248 unsafe extern "C-unwind" fn(src: *const CByondValue, result: *mut u4c) -> bool,
249 pub Byond_XYZ:
250 unsafe extern "C-unwind" fn(src: *const CByondValue, xyz: *mut CByondXYZ) -> bool,
251 pub Byond_PixLoc:
252 unsafe extern "C-unwind" fn(src: *const CByondValue, pixloc: *mut CByondPixLoc) -> bool,
253 pub Byond_BoundPixLoc: unsafe extern "C-unwind" fn(
254 src: *const CByondValue,
255 dir: u1c,
256 pixloc: *mut CByondPixLoc,
257 ) -> bool,
258 pub ByondValue_IncRef: unsafe extern "C-unwind" fn(src: *const CByondValue),
259 pub ByondValue_DecRef: unsafe extern "C-unwind" fn(src: *const CByondValue),
260 pub ByondValue_DecTempRef: unsafe extern "C-unwind" fn(src: *const CByondValue),
261 pub Byond_TestRef: unsafe extern "C-unwind" fn(src: *mut CByondValue) -> bool,
262 pub Byond_CRASH: unsafe extern "C-unwind" fn(message: *const ::std::os::raw::c_char),
263}
264impl ByondApi {
265 pub unsafe fn new<P>(path: P) -> Result<Self, ::libloading::Error>
266 where
267 P: AsRef<::std::ffi::OsStr>,
268 {
269 let library = ::libloading::Library::new(path)?;
270 Self::from_library(library)
271 }
272 pub unsafe fn from_library<L>(library: L) -> Result<Self, ::libloading::Error>
273 where
274 L: Into<::libloading::Library>,
275 {
276 let __library = library.into();
277 let Byond_LastError = __library.get(b"Byond_LastError\0").map(|sym| *sym)?;
278 let Byond_GetVersion = __library.get(b"Byond_GetVersion\0").map(|sym| *sym)?;
279 let Byond_GetDMBVersion = __library.get(b"Byond_GetDMBVersion\0").map(|sym| *sym)?;
280 let ByondValue_Clear = __library.get(b"ByondValue_Clear\0").map(|sym| *sym)?;
281 let ByondValue_Type = __library.get(b"ByondValue_Type\0").map(|sym| *sym)?;
282 let ByondValue_IsNull = __library.get(b"ByondValue_IsNull\0").map(|sym| *sym)?;
283 let ByondValue_IsNum = __library.get(b"ByondValue_IsNum\0").map(|sym| *sym)?;
284 let ByondValue_IsStr = __library.get(b"ByondValue_IsStr\0").map(|sym| *sym)?;
285 let ByondValue_IsList = __library.get(b"ByondValue_IsList\0").map(|sym| *sym)?;
286 let ByondValue_IsTrue = __library.get(b"ByondValue_IsTrue\0").map(|sym| *sym)?;
287 let ByondValue_GetNum = __library.get(b"ByondValue_GetNum\0").map(|sym| *sym)?;
288 let ByondValue_GetRef = __library.get(b"ByondValue_GetRef\0").map(|sym| *sym)?;
289 let ByondValue_SetNum = __library.get(b"ByondValue_SetNum\0").map(|sym| *sym)?;
290 let ByondValue_SetStr = __library.get(b"ByondValue_SetStr\0").map(|sym| *sym)?;
291 let ByondValue_SetStrId = __library.get(b"ByondValue_SetStrId\0").map(|sym| *sym)?;
292 let ByondValue_SetRef = __library.get(b"ByondValue_SetRef\0").map(|sym| *sym)?;
293 let ByondValue_Equals = __library.get(b"ByondValue_Equals\0").map(|sym| *sym)?;
294 let Byond_ThreadSync = __library.get(b"Byond_ThreadSync\0").map(|sym| *sym)?;
295 let Byond_GetStrId = __library.get(b"Byond_GetStrId\0").map(|sym| *sym)?;
296 let Byond_AddGetStrId = __library.get(b"Byond_AddGetStrId\0").map(|sym| *sym)?;
297 let Byond_ReadVar = __library.get(b"Byond_ReadVar\0").map(|sym| *sym)?;
298 let Byond_ReadVarByStrId = __library.get(b"Byond_ReadVarByStrId\0").map(|sym| *sym)?;
299 let Byond_WriteVar = __library.get(b"Byond_WriteVar\0").map(|sym| *sym)?;
300 let Byond_WriteVarByStrId = __library.get(b"Byond_WriteVarByStrId\0").map(|sym| *sym)?;
301 let Byond_CreateList = __library.get(b"Byond_CreateList\0").map(|sym| *sym)?;
302 let Byond_ReadList = __library.get(b"Byond_ReadList\0").map(|sym| *sym)?;
303 let Byond_WriteList = __library.get(b"Byond_WriteList\0").map(|sym| *sym)?;
304 let Byond_ReadListAssoc = __library.get(b"Byond_ReadListAssoc\0").map(|sym| *sym)?;
305 let Byond_ReadListIndex = __library.get(b"Byond_ReadListIndex\0").map(|sym| *sym)?;
306 let Byond_WriteListIndex = __library.get(b"Byond_WriteListIndex\0").map(|sym| *sym)?;
307 let Byond_ReadPointer = __library.get(b"Byond_ReadPointer\0").map(|sym| *sym)?;
308 let Byond_WritePointer = __library.get(b"Byond_WritePointer\0").map(|sym| *sym)?;
309 let Byond_CallProc = __library.get(b"Byond_CallProc\0").map(|sym| *sym)?;
310 let Byond_CallProcByStrId = __library.get(b"Byond_CallProcByStrId\0").map(|sym| *sym)?;
311 let Byond_CallGlobalProc = __library.get(b"Byond_CallGlobalProc\0").map(|sym| *sym)?;
312 let Byond_CallGlobalProcByStrId = __library
313 .get(b"Byond_CallGlobalProcByStrId\0")
314 .map(|sym| *sym)?;
315 let Byond_ToString = __library.get(b"Byond_ToString\0").map(|sym| *sym)?;
316 #[cfg(feature = "byond-1664")]
317 let Byond_Return = __library.get(b"Byond_Return\0").map(|sym| *sym)?;
318 let Byond_Block = __library.get(b"Byond_Block\0").map(|sym| *sym)?;
319 #[cfg(feature = "byond-1664")]
320 let ByondValue_IsType = __library.get(b"ByondValue_IsType\0").map(|sym| *sym)?;
321 let Byond_Length = __library.get(b"Byond_Length\0").map(|sym| *sym)?;
322 let Byond_LocateIn = __library.get(b"Byond_LocateIn\0").map(|sym| *sym)?;
323 let Byond_LocateXYZ = __library.get(b"Byond_LocateXYZ\0").map(|sym| *sym)?;
324 let Byond_New = __library.get(b"Byond_New\0").map(|sym| *sym)?;
325 let Byond_NewArglist = __library.get(b"Byond_NewArglist\0").map(|sym| *sym)?;
326 let Byond_Refcount = __library.get(b"Byond_Refcount\0").map(|sym| *sym)?;
327 let Byond_XYZ = __library.get(b"Byond_XYZ\0").map(|sym| *sym)?;
328 let Byond_PixLoc = __library.get(b"Byond_PixLoc\0").map(|sym| *sym)?;
329 let Byond_BoundPixLoc = __library.get(b"Byond_BoundPixLoc\0").map(|sym| *sym)?;
330 let ByondValue_IncRef = __library.get(b"ByondValue_IncRef\0").map(|sym| *sym)?;
331 let ByondValue_DecRef = __library.get(b"ByondValue_DecRef\0").map(|sym| *sym)?;
332 let ByondValue_DecTempRef = __library.get(b"ByondValue_DecTempRef\0").map(|sym| *sym)?;
333 let Byond_TestRef = __library.get(b"Byond_TestRef\0").map(|sym| *sym)?;
334 let Byond_CRASH = __library.get(b"Byond_CRASH\0").map(|sym| *sym)?;
335 Ok(ByondApi {
336 __library,
337 Byond_LastError,
338 Byond_GetVersion,
339 Byond_GetDMBVersion,
340 ByondValue_Clear,
341 ByondValue_Type,
342 ByondValue_IsNull,
343 ByondValue_IsNum,
344 ByondValue_IsStr,
345 ByondValue_IsList,
346 ByondValue_IsTrue,
347 ByondValue_GetNum,
348 ByondValue_GetRef,
349 ByondValue_SetNum,
350 ByondValue_SetStr,
351 ByondValue_SetStrId,
352 ByondValue_SetRef,
353 ByondValue_Equals,
354 Byond_ThreadSync,
355 Byond_GetStrId,
356 Byond_AddGetStrId,
357 Byond_ReadVar,
358 Byond_ReadVarByStrId,
359 Byond_WriteVar,
360 Byond_WriteVarByStrId,
361 Byond_CreateList,
362 Byond_ReadList,
363 Byond_WriteList,
364 Byond_ReadListAssoc,
365 Byond_ReadListIndex,
366 Byond_WriteListIndex,
367 Byond_ReadPointer,
368 Byond_WritePointer,
369 Byond_CallProc,
370 Byond_CallProcByStrId,
371 Byond_CallGlobalProc,
372 Byond_CallGlobalProcByStrId,
373 Byond_ToString,
374 #[cfg(feature = "byond-1664")]
375 Byond_Return,
376 Byond_Block,
377 #[cfg(feature = "byond-1664")]
378 ByondValue_IsType,
379 Byond_Length,
380 Byond_LocateIn,
381 Byond_LocateXYZ,
382 Byond_New,
383 Byond_NewArglist,
384 Byond_Refcount,
385 Byond_XYZ,
386 Byond_PixLoc,
387 Byond_BoundPixLoc,
388 ByondValue_IncRef,
389 ByondValue_DecRef,
390 ByondValue_DecTempRef,
391 Byond_TestRef,
392 Byond_CRASH,
393 })
394 }
395 #[doc = "Gets the last error from a failed call\n The result is a static string that does not \
396 need to be freed.\n # Returns\n\nError message"]
397 pub unsafe fn Byond_LastError(&self) -> *const ::std::os::raw::c_char {
398 (self.Byond_LastError)()
399 }
400 #[doc = "Gets the current BYOND version\n # Arguments\n\n* `version` - Pointer to the major \
401 version number\n * `build` - Pointer to the build number"]
402 pub unsafe fn Byond_GetVersion(&self, version: *mut u4c, build: *mut u4c) {
403 (self.Byond_GetVersion)(version, build)
404 }
405 #[doc = "Gets the DMB version\n # Returns\n\nVersion number the .dmb was built with"]
406 pub unsafe fn Byond_GetDMBVersion(&self) -> u4c {
407 (self.Byond_GetDMBVersion)()
408 }
409 #[doc = "Fills a CByondValue struct with a null value.\n # Arguments\n\n* `v` - Pointer to \
410 CByondValue"]
411 pub unsafe fn ByondValue_Clear(&self, v: *mut CByondValue) {
412 (self.ByondValue_Clear)(v)
413 }
414 #[doc = "Reads CByondVale's 1-byte data type\n # Arguments\n\n* `v` - Pointer to CByondValue\n \
415 # Returns\n\nType of value"]
416 pub unsafe fn ByondValue_Type(&self, v: *const CByondValue) -> ByondValueType {
417 (self.ByondValue_Type)(v)
418 }
419 #[doc = "# Arguments\n\n* `v` - Pointer to CByondValue\n # Returns\n\nTrue if value is null"]
420 pub unsafe fn ByondValue_IsNull(&self, v: *const CByondValue) -> bool {
421 (self.ByondValue_IsNull)(v)
422 }
423 #[doc = "# Arguments\n\n* `v` - Pointer to CByondValue\n # Returns\n\nTrue if value is a \
424 numeric type"]
425 pub unsafe fn ByondValue_IsNum(&self, v: *const CByondValue) -> bool {
426 (self.ByondValue_IsNum)(v)
427 }
428 #[doc = "# Arguments\n\n* `v` - Pointer to CByondValue\n # Returns\n\nTrue if value is a string"]
429 pub unsafe fn ByondValue_IsStr(&self, v: *const CByondValue) -> bool {
430 (self.ByondValue_IsStr)(v)
431 }
432 #[doc = "# Arguments\n\n* `v` - Pointer to CByondValue\n # Returns\n\nTrue if value is a list \
433 (any list type, not just user-defined)"]
434 pub unsafe fn ByondValue_IsList(&self, v: *const CByondValue) -> bool {
435 (self.ByondValue_IsList)(v)
436 }
437 #[doc = "Determines if a value is logically true or false\n\n # Arguments\n\n* `v` - Pointer \
438 to CByondValue\n # Returns\n\nTruthiness of value"]
439 pub unsafe fn ByondValue_IsTrue(&self, v: *const CByondValue) -> bool {
440 (self.ByondValue_IsTrue)(v)
441 }
442 #[doc = "# Arguments\n\n* `v` - Pointer to CByondValue\n # Returns\n\nFloating point number \
443 for v, or 0 if not numeric"]
444 pub unsafe fn ByondValue_GetNum(&self, v: *const CByondValue) -> f32 {
445 (self.ByondValue_GetNum)(v)
446 }
447 #[doc = "# Arguments\n\n* `v` - Pointer to CByondValue\n # Returns\n\nReference ID if value is \
448 a reference type, or 0 otherwise"]
449 pub unsafe fn ByondValue_GetRef(&self, v: *const CByondValue) -> u4c {
450 (self.ByondValue_GetRef)(v)
451 }
452 #[doc = "Fills a CByondValue struct with a floating point number.\n # Arguments\n\n* `v` - \
453 Pointer to CByondValue\n * `f` - Floating point number"]
454 pub unsafe fn ByondValue_SetNum(&self, v: *mut CByondValue, f: f32) {
455 (self.ByondValue_SetNum)(v, f)
456 }
457 #[doc = "Creates a string and sets CByondValue to a reference to that string, and increases \
458 the reference count. See REFERENCE COUNTING in byondapi.h.\n Blocks if not on the \
459 main thread. If string creation fails, the struct is set to null.\n # Arguments\n\n* \
460 `v` - Pointer to CByondValue\n * `str` - Null-terminated UTF-8 string\n \
461 [`Byond_AddGetStrId()`]"]
462 pub unsafe fn ByondValue_SetStr(
463 &self,
464 v: *mut CByondValue,
465 str_: *const ::std::os::raw::c_char,
466 ) {
467 (self.ByondValue_SetStr)(v, str_)
468 }
469 #[doc = "Fills a CByondValue struct with a reference to a string with a given ID. Does not \
470 validate, and does not increase the reference count.\n If the strid is NONE, it will \
471 be changed to 0.\n # Arguments\n\n* `v` - Pointer to CByondValue\n * `strid` - 4-byte \
472 string ID\n [`Byond_TestRef()`]"]
473 pub unsafe fn ByondValue_SetStrId(&self, v: *mut CByondValue, strid: u4c) {
474 (self.ByondValue_SetStrId)(v, strid)
475 }
476 #[doc = "Fills a CByondValue struct with a reference (object) type. Does not validate.\n # \
477 Arguments\n\n* `v` - Pointer to CByondValue\n * `type` - 1-byte teference type\n * \
478 `ref` - 4-byte reference ID; for most types, an ID of NONE is invalid\n \
479 [`Byond_TestRef()`]"]
480 pub unsafe fn ByondValue_SetRef(&self, v: *mut CByondValue, type_: ByondValueType, ref_: u4c) {
481 (self.ByondValue_SetRef)(v, type_, ref_)
482 }
483 #[doc = "Compares two values for equality\n # Arguments\n\n* `a` - Pointer to CByondValue\n * \
484 `b` - Pointer to CByondValue\n # Returns\n\nTrue if values are equal"]
485 pub unsafe fn ByondValue_Equals(&self, a: *const CByondValue, b: *const CByondValue) -> bool {
486 (self.ByondValue_Equals)(a, b)
487 }
488 #[doc = "Runs a function as a callback on the main thread (or right away if already there)\n \
489 All references created from Byondapi calls within your callback are persistent, not \
490 temporary, even though your callback runs on the main thread.\n Blocking is optional. \
491 If already on the main thread, the block parameter is meaningless.\n # Arguments\n\n* \
492 `callback` - Function pointer to CByondValue function(void*)\n * `data` - Void \
493 pointer (argument to function)\n * `block` - True if this call should block while \
494 waiting for the callback to finish; false if not\n # Returns\n\nCByondValue returned \
495 by the function (if it blocked; null if not)"]
496 pub unsafe fn Byond_ThreadSync(
497 &self,
498 callback: ByondCallback,
499 data: *mut ::std::os::raw::c_void,
500 block: bool,
501 ) -> CByondValue {
502 (self.Byond_ThreadSync)(callback, data, block)
503 }
504 #[doc = "Returns a reference to an existing string ID, but does not create a new string ID.\n \
505 Blocks if not on the main thread.\n # Arguments\n\n* `str` - Null-terminated string\n \
506 # Returns\n\nID of string; NONE if string does not exist"]
507 pub unsafe fn Byond_GetStrId(&self, str_: *const ::std::os::raw::c_char) -> u4c {
508 (self.Byond_GetStrId)(str_)
509 }
510 #[doc = "Returns a reference to an existing string ID or creates a new string ID reference.\n \
511 The new string is reference-counted. See REFERENCE COUNTING in byondapi.h for \
512 details.\n Call ByondValue_SeStrId() to use the returned ID in a CByondValue.\n \
513 Blocks if not on the main thread.\n # Arguments\n\n* `str` - Null-terminated string\n \
514 # Returns\n\nID of string; NONE if string creation failed"]
515 pub unsafe fn Byond_AddGetStrId(&self, str_: *const ::std::os::raw::c_char) -> u4c {
516 (self.Byond_AddGetStrId)(str_)
517 }
518 #[doc = "Reads an object variable by name.\n Blocks if not on the main thread.\n # \
519 Arguments\n\n* `loc` - Object that owns the var\n * `varname` - Var name as \
520 null-terminated string\n * `result` - Pointer to accept result (referenced)\n # \
521 Returns\n\nTrue on success"]
522 pub unsafe fn Byond_ReadVar(
523 &self,
524 loc: *const CByondValue,
525 varname: *const ::std::os::raw::c_char,
526 result: *mut CByondValue,
527 ) -> bool {
528 (self.Byond_ReadVar)(loc, varname, result)
529 }
530 #[doc = "Reads an object variable by the string ID of its var name.\n ID can be cached ahead \
531 of time for performance.\n Blocks if not on the main thread.\n # Arguments\n\n* `loc` \
532 - Object that owns the var\n * `varname` - Var name as string ID\n * `result` - \
533 Pointer to accept result (referenced)\n # Returns\n\nTrue on success\n \
534 [`Byond_GetStrId()`]"]
535 pub unsafe fn Byond_ReadVarByStrId(
536 &self,
537 loc: *const CByondValue,
538 varname: u4c,
539 result: *mut CByondValue,
540 ) -> bool {
541 (self.Byond_ReadVarByStrId)(loc, varname, result)
542 }
543 #[doc = "Writes an object variable by name.\n Blocks if not on the main thread.\n # \
544 Arguments\n\n* `loc` - Object that owns the var\n * `varname` - Var name as \
545 null-terminated string\n * `val` - New value\n # Returns\n\nTrue on success"]
546 pub unsafe fn Byond_WriteVar(
547 &self,
548 loc: *const CByondValue,
549 varname: *const ::std::os::raw::c_char,
550 val: *const CByondValue,
551 ) -> bool {
552 (self.Byond_WriteVar)(loc, varname, val)
553 }
554 #[doc = "Writes an object variable by the string ID of its var name.\n ID can be cached ahead \
555 of time for performance.\n Blocks if not on the main thread.\n # Arguments\n\n* `loc` \
556 - Object that owns the var\n * `varname` - Var name as string ID\n * `val` - New \
557 value\n # Returns\n\nTrue on success"]
558 pub unsafe fn Byond_WriteVarByStrId(
559 &self,
560 loc: *const CByondValue,
561 varname: u4c,
562 val: *const CByondValue,
563 ) -> bool {
564 (self.Byond_WriteVarByStrId)(loc, varname, val)
565 }
566 #[doc = "Creates an empty list (referenced). Equivalent to list().\n Blocks if not on the main \
567 thread.\n # Arguments\n\n* `result` - Result\n # Returns\n\nTrue on success"]
568 pub unsafe fn Byond_CreateList(&self, result: *mut CByondValue) -> bool {
569 (self.Byond_CreateList)(result)
570 }
571 #[doc = "Reads items (referenced) from a list.\n Blocks if not on the main thread.\n # \
572 Arguments\n\n* `loc` - The list to read\n * `list` - CByondValue array, allocated by \
573 caller (can be null if querying length)\n * `len` - Pointer to length of array (in \
574 items); receives the number of items read on success, or required length of array if \
575 not big enough\n # Returns\n\nTrue on success; false with *len=0 for failure; false \
576 with *len=required size if array is not big enough"]
577 pub unsafe fn Byond_ReadList(
578 &self,
579 loc: *const CByondValue,
580 list: *mut CByondValue,
581 len: *mut u4c,
582 ) -> bool {
583 (self.Byond_ReadList)(loc, list, len)
584 }
585 #[doc = "Writes items to a list, in place of old contents.\n Blocks if not on the main \
586 thread.\n # Arguments\n\n* `loc` - The list to fill\n * `list` - CByondValue array of \
587 items to write\n * `len` - Number of items to write\n # Returns\n\nTrue on success"]
588 pub unsafe fn Byond_WriteList(
589 &self,
590 loc: *const CByondValue,
591 list: *const CByondValue,
592 len: u4c,
593 ) -> bool {
594 (self.Byond_WriteList)(loc, list, len)
595 }
596 #[doc = "Reads items as key,value pairs from an associative list, storing them sequentially as \
597 key1, value1, key2, value2, etc.\n Blocks if not on the main thread.\n # \
598 Arguments\n\n* `loc` - The list to read\n * `list` - CByondValue array, allocated by \
599 caller (can be null if querying length)\n * `len` - Pointer to length of array (in \
600 items); receives the number of items read on success, or required length of array if \
601 not big enough\n # Returns\n\nTrue on success; false with *len=0 for failure; false \
602 with *len=required size if array is not big enough"]
603 pub unsafe fn Byond_ReadListAssoc(
604 &self,
605 loc: *const CByondValue,
606 list: *mut CByondValue,
607 len: *mut u4c,
608 ) -> bool {
609 (self.Byond_ReadListAssoc)(loc, list, len)
610 }
611 #[doc = "Reads an item (referenced) from a list.\n Blocks if not on the main thread.\n # \
612 Arguments\n\n* `loc` - The list\n * `idx` - The index in the list (may be a number, \
613 or a non-number if using associative lists)\n * `result` - Pointer to accept result\n \
614 # Returns\n\nTrue on success"]
615 pub unsafe fn Byond_ReadListIndex(
616 &self,
617 loc: *const CByondValue,
618 idx: *const CByondValue,
619 result: *mut CByondValue,
620 ) -> bool {
621 (self.Byond_ReadListIndex)(loc, idx, result)
622 }
623 #[doc = "Writes an item to a list.\n Blocks if not on the main thread.\n # Arguments\n\n* \
624 `loc` - The list\n * `idx` - The index in the list (may be a number, or a non-number \
625 if using associative lists)\n * `val` - New value\n # Returns\n\nTrue on success"]
626 pub unsafe fn Byond_WriteListIndex(
627 &self,
628 loc: *const CByondValue,
629 idx: *const CByondValue,
630 val: *const CByondValue,
631 ) -> bool {
632 (self.Byond_WriteListIndex)(loc, idx, val)
633 }
634 #[doc = "Reads from a BYOND pointer\n Blocks if not on the main thread.\n # Arguments\n\n* \
635 `ptr` - The BYOND pointer\n * `result` - Pointer to accept result (referenced)\n # \
636 Returns\n\nTrue on success"]
637 pub unsafe fn Byond_ReadPointer(
638 &self,
639 ptr: *const CByondValue,
640 result: *mut CByondValue,
641 ) -> bool {
642 (self.Byond_ReadPointer)(ptr, result)
643 }
644 #[doc = "Writes to a BYOND pointer\n Blocks if not on the main thread.\n # Arguments\n\n* \
645 `ptr` - The BYOND pointer\n * `val` - New value\n # Returns\n\nTrue on success"]
646 pub unsafe fn Byond_WritePointer(
647 &self,
648 ptr: *const CByondValue,
649 val: *const CByondValue,
650 ) -> bool {
651 (self.Byond_WritePointer)(ptr, val)
652 }
653 #[doc = "Calls an object proc by name.\n The proc call is treated as waitfor=0 and will return \
654 immediately on sleep.\n Blocks if not on the main thread.\n # Arguments\n\n* `src` - \
655 The object that owns the proc\n * `name` - Proc name as null-terminated string\n * \
656 `arg` - Array of arguments\n * `arg_count` - Number of arguments\n * `result` - \
657 Pointer to accept result (referenced)\n # Returns\n\nTrue on success"]
658 pub unsafe fn Byond_CallProc(
659 &self,
660 src: *const CByondValue,
661 name: *const ::std::os::raw::c_char,
662 arg: *const CByondValue,
663 arg_count: u4c,
664 result: *mut CByondValue,
665 ) -> bool {
666 (self.Byond_CallProc)(src, name, arg, arg_count, result)
667 }
668 #[doc = "Calls an object proc by name, where the name is a string ID.\n The proc call is \
669 treated as waitfor=0 and will return immediately on sleep.\n Blocks if not on the \
670 main thread.\n # Arguments\n\n* `src` - The object that owns the proc\n * `name` - \
671 Proc name as string ID\n * `arg` - Array of arguments\n * `arg_count` - Number of \
672 arguments\n * `result` - Pointer to accept result (referenced)\n # Returns\n\nTrue on \
673 success\n [`Byond_GetStrId()`]"]
674 pub unsafe fn Byond_CallProcByStrId(
675 &self,
676 src: *const CByondValue,
677 name: u4c,
678 arg: *const CByondValue,
679 arg_count: u4c,
680 result: *mut CByondValue,
681 ) -> bool {
682 (self.Byond_CallProcByStrId)(src, name, arg, arg_count, result)
683 }
684 #[doc = "Calls a global proc by name.\n The proc call is treated as waitfor=0 and will return \
685 immediately on sleep.\n Blocks if not on the main thread.\n # Arguments\n\n* `name` - \
686 Proc name as null-terminated string\n * `arg` - Array of arguments\n * `arg_count` - \
687 Number of arguments\n * `result` - Pointer to accept result (referenced)\n # \
688 Returns\n\nTrue on success"]
689 pub unsafe fn Byond_CallGlobalProc(
690 &self,
691 name: *const ::std::os::raw::c_char,
692 arg: *const CByondValue,
693 arg_count: u4c,
694 result: *mut CByondValue,
695 ) -> bool {
696 (self.Byond_CallGlobalProc)(name, arg, arg_count, result)
697 }
698 #[doc = "Calls a global proc by name, where the name is a string ID.\n The proc call is \
699 treated as waitfor=0 and will return immediately on sleep.\n Blocks if not on the \
700 main thread.\n # Arguments\n\n* `name` - Proc name as string ID\n * `arg` - Array of \
701 arguments\n * `arg_count` - Number of arguments\n * `result` - Pointer to accept \
702 result\n # Returns\n\nTrue on success\n [`Byond_GetStrId()`]"]
703 pub unsafe fn Byond_CallGlobalProcByStrId(
704 &self,
705 name: u4c,
706 arg: *const CByondValue,
707 arg_count: u4c,
708 result: *mut CByondValue,
709 ) -> bool {
710 (self.Byond_CallGlobalProcByStrId)(name, arg, arg_count, result)
711 }
712 #[doc = "Uses BYOND's internals to represent a value as text\n Blocks if not on the main \
713 thread.\n # Arguments\n\n* `src` - The value to convert to text\n * `buf` - char \
714 array, allocated by caller (can be null if querying length)\n * `buflen` - Pointer to \
715 length of array in bytes; receives the string length (including trailing null) on \
716 success, or required length of array if not big enough\n # Returns\n\nTrue on \
717 success; false with *buflen=0 for failure; false with *buflen=required size if array \
718 is not big enough"]
719 pub unsafe fn Byond_ToString(
720 &self,
721 src: *const CByondValue,
722 buf: *mut ::std::os::raw::c_char,
723 buflen: *mut u4c,
724 ) -> bool {
725 (self.Byond_ToString)(src, buf, buflen)
726 }
727 #[cfg(feature = "byond-1664")]
728 #[doc = "Returns from a byond,await: call\n Blocks if not on the main thread.\n # \
729 Arguments\n\n* `waiting_proc` - The /callee waiting on a response\n * `retval` - The \
730 return value to pass back to the waiting proc\n # Returns\n\nTrue on success; false \
731 if the waiting proc doesn't exist"]
732 pub unsafe fn Byond_Return(
733 &self,
734 waiting_proc: *const CByondValue,
735 retval: *const CByondValue,
736 ) -> bool {
737 (self.Byond_Return)(waiting_proc, retval)
738 }
739 #[doc = "Equivalent to calling block(x1,y1,z1, x2,y2,z2).\n Blocks if not on the main \
740 thread.\n # Arguments\n\n* `corner1` - One corner of the block\n * `corner2` - \
741 Another corner of the block\n * `list` - CByondValue array, allocated by caller (can \
742 be null if querying length)\n * `len` - Pointer to length of array (in items); \
743 receives the number of items read on success, or required length of array if not big \
744 enough\n # Returns\n\nTrue on success; false with *len=0 for failure; false with \
745 *len=required size if array is not big enough"]
746 pub unsafe fn Byond_Block(
747 &self,
748 corner1: *const CByondXYZ,
749 corner2: *const CByondXYZ,
750 list: *mut CByondValue,
751 len: *mut u4c,
752 ) -> bool {
753 (self.Byond_Block)(corner1, corner2, list, len)
754 }
755 #[cfg(feature = "byond-1664")]
756 #[doc = "Equivalent to calling istype(src, text2path(typestr)).\n Blocks if not on the main \
757 thread.\n # Arguments\n\n* `src` - The value\n * `typestr` - The type path to check\n \
758 # Returns\n\nTrue if src is of the given type, false if not"]
759 pub unsafe fn ByondValue_IsType(
760 &self,
761 src: *const CByondValue,
762 typestr: *const ::std::os::raw::c_char,
763 ) -> bool {
764 (self.ByondValue_IsType)(src, typestr)
765 }
766 #[doc = "Equivalent to calling length(src).\n Blocks if not on the main thread.\n # \
767 Arguments\n\n* `src` - The value\n * `result` - Pointer to accept result as a \
768 CByondValue (intended for future possible override of length)\n # Returns\n\nTrue on \
769 success"]
770 pub unsafe fn Byond_Length(&self, src: *const CByondValue, result: *mut CByondValue) -> bool {
771 (self.Byond_Length)(src, result)
772 }
773 #[doc = "Equivalent to calling locate(type), or locate(type) in list.\n Blocks if not on the \
774 main thread.\n # Arguments\n\n* `type` - The type to locate\n * `list` - The list to \
775 locate in; can be a null pointer instead of a CByondValue to locate(type) without a \
776 list\n * `result` - Pointer to accept result (referenced); can be null if nothing is \
777 found\n # Returns\n\nTrue on success (including if nothing is found); false on error"]
778 pub unsafe fn Byond_LocateIn(
779 &self,
780 type_: *const CByondValue,
781 list: *const CByondValue,
782 result: *mut CByondValue,
783 ) -> bool {
784 (self.Byond_LocateIn)(type_, list, result)
785 }
786 #[doc = "Equivalent to calling locate(x,y,z)\n Blocks if not on the main thread.\n Result is \
787 null if coords are invalid.\n # Arguments\n\n* `xyz` - The x,y,z coords\n * `result` \
788 - Pointer to accept result (NOT referenced; is a turf or null)\n # Returns\n\nTrue \
789 (always)"]
790 pub unsafe fn Byond_LocateXYZ(&self, xyz: *const CByondXYZ, result: *mut CByondValue) -> bool {
791 (self.Byond_LocateXYZ)(xyz, result)
792 }
793 #[doc = "Equivalent to calling new type(...)\n Blocks if not on the main thread.\n # \
794 Arguments\n\n* `type` - The type to create (type path or string)\n * `arg` - Array of \
795 arguments\n * `arg_count` - Number of arguments\n * `result` - Pointer to accept \
796 result (referenced)\n # Returns\n\nTrue on success"]
797 pub unsafe fn Byond_New(
798 &self,
799 type_: *const CByondValue,
800 arg: *const CByondValue,
801 arg_count: u4c,
802 result: *mut CByondValue,
803 ) -> bool {
804 (self.Byond_New)(type_, arg, arg_count, result)
805 }
806 #[doc = "Equivalent to calling new type(arglist)\n Blocks if not on the main thread.\n # \
807 Arguments\n\n* `type` - The type to create (type path or string)\n * `arglist` - \
808 Arguments, as a reference to an arglist\n * `result` - Pointer to accept result \
809 (referenced)\n # Returns\n\nTrue on success"]
810 pub unsafe fn Byond_NewArglist(
811 &self,
812 type_: *const CByondValue,
813 arglist: *const CByondValue,
814 result: *mut CByondValue,
815 ) -> bool {
816 (self.Byond_NewArglist)(type_, arglist, result)
817 }
818 #[doc = "Equivalent to calling refcount(value)\n Blocks if not on the main thread.\n # \
819 Arguments\n\n* `src` - The object to refcount\n * `result` - Pointer to accept \
820 result\n # Returns\n\nTrue on success"]
821 pub unsafe fn Byond_Refcount(&self, src: *const CByondValue, result: *mut u4c) -> bool {
822 (self.Byond_Refcount)(src, result)
823 }
824 #[doc = "Get x,y,z coords of an atom\n Blocks if not on the main thread.\n # Arguments\n\n* \
825 `src` - The object to read\n * `xyz` - Pointer to accept CByondXYZ result\n # \
826 Returns\n\nTrue on success"]
827 pub unsafe fn Byond_XYZ(&self, src: *const CByondValue, xyz: *mut CByondXYZ) -> bool {
828 (self.Byond_XYZ)(src, xyz)
829 }
830 #[doc = "Get pixloc coords of an atom\n Blocks if not on the main thread.\n # Arguments\n\n* \
831 `src` - The object to read\n * `pixloc` - Pointer to accept CByondPixLoc result\n # \
832 Returns\n\nTrue on success"]
833 pub unsafe fn Byond_PixLoc(&self, src: *const CByondValue, pixloc: *mut CByondPixLoc) -> bool {
834 (self.Byond_PixLoc)(src, pixloc)
835 }
836 #[doc = "Get pixloc coords of an atom based on its bounding box\n Blocks if not on the main \
837 thread.\n # Arguments\n\n* `src` - The object to read\n * `dir` - The direction\n * \
838 `pixloc` - Pointer to accept CByondPixLoc result\n # Returns\n\nTrue on success"]
839 pub unsafe fn Byond_BoundPixLoc(
840 &self,
841 src: *const CByondValue,
842 dir: u1c,
843 pixloc: *mut CByondPixLoc,
844 ) -> bool {
845 (self.Byond_BoundPixLoc)(src, dir, pixloc)
846 }
847 #[doc = "Increase the persistent reference count of an object used in Byondapi\n Reminder: \
848 Calls only create temporary references when made on the main thread. On other \
849 threads, the references are already persistent.\n Blocks if not on the main thread.\n \
850 # Arguments\n\n* `src` - The object to incref"]
851 pub unsafe fn ByondValue_IncRef(&self, src: *const CByondValue) {
852 (self.ByondValue_IncRef)(src)
853 }
854 #[doc = "Mark a persistent reference as no longer in use by Byondapi\n This is IMPORTANT to \
855 call when you make Byondapi calls on another thread, since all the references they \
856 create are persistent.\n This cannot be used for temporary references. See \
857 ByondValue_DecTempRef() for those.\n Blocks if not on the main thread.\n # \
858 Arguments\n\n* `src` - The object to decref"]
859 pub unsafe fn ByondValue_DecRef(&self, src: *const CByondValue) {
860 (self.ByondValue_DecRef)(src)
861 }
862 #[doc = "Mark a temporary reference as no longer in use by Byondapi\n Temporary references \
863 will be deleted automatically at the end of a tick, so this only gets rid of the \
864 reference a little faster.\n Only works on the main thread. Does nothing on other \
865 threads.\n # Arguments\n\n* `src` - The object to decref"]
866 pub unsafe fn ByondValue_DecTempRef(&self, src: *const CByondValue) {
867 (self.ByondValue_DecTempRef)(src)
868 }
869 #[doc = "Test if a reference-type CByondValue is valid\n Blocks if not on the main thread.\n # \
870 Arguments\n\n* `src` - Pointer to the reference to test; will be filled with null if \
871 the reference is invalid\n # Returns\n\nTrue if ref is valid; false if not"]
872 pub unsafe fn Byond_TestRef(&self, src: *mut CByondValue) -> bool {
873 (self.Byond_TestRef)(src)
874 }
875 #[doc = "Causes a runtime error to crash the current proc\n Blocks if not on the main \
876 thread.\n # Arguments\n\n* `message` - Message to use as the runtime error"]
877 pub unsafe fn Byond_CRASH(&self, message: *const ::std::os::raw::c_char) {
878 (self.Byond_CRASH)(message)
879 }
880}