@bloomengine/engine 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/native/tvos/metal-patched/Cargo.toml +178 -0
  2. package/native/tvos/metal-patched/LICENSE-APACHE +201 -0
  3. package/native/tvos/metal-patched/LICENSE-MIT +25 -0
  4. package/native/tvos/metal-patched/src/acceleration_structure.rs +667 -0
  5. package/native/tvos/metal-patched/src/acceleration_structure_pass.rs +108 -0
  6. package/native/tvos/metal-patched/src/argument.rs +366 -0
  7. package/native/tvos/metal-patched/src/blitpass.rs +102 -0
  8. package/native/tvos/metal-patched/src/buffer.rs +71 -0
  9. package/native/tvos/metal-patched/src/capturedescriptor.rs +76 -0
  10. package/native/tvos/metal-patched/src/capturemanager.rs +113 -0
  11. package/native/tvos/metal-patched/src/commandbuffer.rs +192 -0
  12. package/native/tvos/metal-patched/src/commandqueue.rs +44 -0
  13. package/native/tvos/metal-patched/src/computepass.rs +107 -0
  14. package/native/tvos/metal-patched/src/constants.rs +152 -0
  15. package/native/tvos/metal-patched/src/counters.rs +119 -0
  16. package/native/tvos/metal-patched/src/depthstencil.rs +190 -0
  17. package/native/tvos/metal-patched/src/device.rs +2134 -0
  18. package/native/tvos/metal-patched/src/drawable.rs +39 -0
  19. package/native/tvos/metal-patched/src/encoder.rs +2041 -0
  20. package/native/tvos/metal-patched/src/heap.rs +281 -0
  21. package/native/tvos/metal-patched/src/indirect_encoder.rs +344 -0
  22. package/native/tvos/metal-patched/src/lib.rs +657 -0
  23. package/native/tvos/metal-patched/src/library.rs +902 -0
  24. package/native/tvos/metal-patched/src/mps.rs +575 -0
  25. package/native/tvos/metal-patched/src/pipeline/compute.rs +475 -0
  26. package/native/tvos/metal-patched/src/pipeline/mod.rs +71 -0
  27. package/native/tvos/metal-patched/src/pipeline/render.rs +762 -0
  28. package/native/tvos/metal-patched/src/renderpass.rs +443 -0
  29. package/native/tvos/metal-patched/src/resource.rs +182 -0
  30. package/native/tvos/metal-patched/src/sampler.rs +165 -0
  31. package/native/tvos/metal-patched/src/sync.rs +178 -0
  32. package/native/tvos/metal-patched/src/texture.rs +352 -0
  33. package/native/tvos/metal-patched/src/types.rs +90 -0
  34. package/native/tvos/metal-patched/src/vertexdescriptor.rs +250 -0
  35. package/package.json +5 -1
@@ -0,0 +1,657 @@
1
+ // Copyright 2023 GFX developers
2
+ //
3
+ // Licensed under the Apache License, Version 2.0, <LICENSE-APACHE or
4
+ // http://apache.org/licenses/LICENSE-2.0> or the MIT license <LICENSE-MIT or
5
+ // http://opensource.org/licenses/MIT>, at your option. This file may not be
6
+ // copied, modified, or distributed except according to those terms.
7
+
8
+ #![allow(deprecated)]
9
+ #![allow(non_snake_case)]
10
+ #![allow(non_upper_case_globals)]
11
+ // Silence clippy warnings as a stopgap to get CI working.
12
+ #![allow(clippy::enum_variant_names)]
13
+ #![allow(clippy::identity_op)]
14
+ #![allow(clippy::let_and_return)]
15
+ #![allow(clippy::missing_safety_doc)]
16
+ #![allow(clippy::missing_transmute_annotations)]
17
+ #![allow(clippy::new_ret_no_self)]
18
+ #![allow(clippy::new_without_default)]
19
+ #![allow(clippy::too_many_arguments)]
20
+ #![allow(clippy::transmute_ptr_to_ref)]
21
+ #![allow(clippy::unit_arg)]
22
+
23
+ #[macro_use]
24
+ pub extern crate objc;
25
+ #[macro_use]
26
+ pub extern crate foreign_types;
27
+ #[macro_use]
28
+ pub extern crate paste;
29
+
30
+ use std::{borrow::Borrow, marker::PhantomData, mem, ops::Deref, os::raw::c_void};
31
+
32
+ use core_graphics_types::{base::CGFloat, geometry::CGSize};
33
+ use foreign_types::ForeignType;
34
+ use objc::runtime::{Object, NO, YES};
35
+
36
+ /// See <https://developer.apple.com/documentation/objectivec/nsinteger>
37
+ #[cfg(target_pointer_width = "64")]
38
+ pub type NSInteger = i64;
39
+
40
+ /// See <https://developer.apple.com/documentation/objectivec/nsinteger>
41
+ #[cfg(not(target_pointer_width = "64"))]
42
+ pub type NSInteger = i32;
43
+
44
+ /// See <https://developer.apple.com/documentation/objectivec/nsuinteger>
45
+ #[cfg(target_pointer_width = "64")]
46
+ pub type NSUInteger = u64;
47
+
48
+ /// See <https://developer.apple.com/documentation/objectivec/nsuinteger>
49
+ #[cfg(target_pointer_width = "32")]
50
+ pub type NSUInteger = u32;
51
+
52
+ /// See <https://developer.apple.com/documentation/foundation/nsrange>
53
+ #[repr(C)]
54
+ #[derive(Copy, Clone)]
55
+ pub struct NSRange {
56
+ pub location: NSUInteger,
57
+ pub length: NSUInteger,
58
+ }
59
+
60
+ impl NSRange {
61
+ #[inline]
62
+ pub fn new(location: NSUInteger, length: NSUInteger) -> NSRange {
63
+ NSRange { location, length }
64
+ }
65
+ }
66
+
67
+ fn nsstring_as_str(nsstr: &objc::runtime::Object) -> &str {
68
+ let bytes = unsafe {
69
+ let bytes: *const std::os::raw::c_char = msg_send![nsstr, UTF8String];
70
+ bytes as *const u8
71
+ };
72
+ let len: NSUInteger = unsafe { msg_send![nsstr, length] };
73
+ unsafe {
74
+ let bytes = std::slice::from_raw_parts(bytes, len as usize);
75
+ std::str::from_utf8(bytes).unwrap()
76
+ }
77
+ }
78
+
79
+ fn nsstring_from_str(string: &str) -> *mut objc::runtime::Object {
80
+ const UTF8_ENCODING: usize = 4;
81
+
82
+ let cls = class!(NSString);
83
+ let bytes = string.as_ptr() as *const c_void;
84
+ unsafe {
85
+ let obj: *mut objc::runtime::Object = msg_send![cls, alloc];
86
+ let obj: *mut objc::runtime::Object = msg_send![
87
+ obj,
88
+ initWithBytes:bytes
89
+ length:string.len()
90
+ encoding:UTF8_ENCODING
91
+ ];
92
+ let _: *mut c_void = msg_send![obj, autorelease];
93
+ obj
94
+ }
95
+ }
96
+
97
+ /// Define a Rust wrapper for an Objective-C opaque type.
98
+ ///
99
+ /// This macro adapts the `foreign-types` crate's [`foreign_type!`]
100
+ /// macro to Objective-C, defining Rust types that represent owned and
101
+ /// borrowed forms of some underlying Objective-C type, using
102
+ /// Objective-C's reference counting to manage its lifetime.
103
+ ///
104
+ /// Given a use of the form:
105
+ ///
106
+ /// ```ignore
107
+ /// foreign_obj_type! {
108
+ /// type CType = MTLBuffer; // underlying Objective-C type
109
+ /// pub struct Buffer; // owned Rust type
110
+ /// pub struct BufferRef; // borrowed Rust type
111
+ /// type ParentType = ResourceRef; // borrowed parent class
112
+ /// }
113
+ /// ```
114
+ ///
115
+ /// This defines the types `Buffer` and `BufferRef` as owning and
116
+ /// non-owning types, analogous to `String` and `str`, that manage
117
+ /// some underlying `*mut MTLBuffer`:
118
+ ///
119
+ /// - Both `Buffer` and `BufferRef` implement [`obj::Message`], indicating
120
+ /// that they can be sent Objective-C messages.
121
+ ///
122
+ /// - Dropping a `Buffer` sends the underlying `MTLBuffer` a `release`
123
+ /// message, and cloning a `BufferRef` sends a `retain` message and
124
+ /// returns a new `Buffer`.
125
+ ///
126
+ /// - `Buffer` dereferences to `BufferRef`.
127
+ ///
128
+ /// - `BufferRef` dereferences to its parent type `ResourceRef`. The
129
+ /// `ParentType` component is optional; if omitted, the `Ref` type
130
+ /// doesn't implement `Deref` or `DerefMut`.
131
+ ///
132
+ /// - Both `Buffer` and `BufferRef` implement `std::fmt::Debug`,
133
+ /// sending an Objective-C `debugDescription` message to the
134
+ /// underlying `MTLBuffer`.
135
+ ///
136
+ /// Following the `foreign_types` crate's nomenclature, the `Ref`
137
+ /// suffix indicates that `BufferRef` and `ResourceRef` are non-owning
138
+ /// types, used *by reference*, like `&BufferRef` or `&ResourceRef`.
139
+ /// These types are not, themselves, references.
140
+ macro_rules! foreign_obj_type {
141
+ {
142
+ type CType = $raw_ident:ident;
143
+ pub struct $owned_ident:ident;
144
+ type ParentType = $parent_ident:ident;
145
+ } => {
146
+ foreign_obj_type! {
147
+ type CType = $raw_ident;
148
+ pub struct $owned_ident;
149
+ }
150
+
151
+ impl ::std::ops::Deref for paste!{[<$owned_ident Ref>]} {
152
+ type Target = paste!{[<$parent_ident Ref>]};
153
+
154
+ #[inline]
155
+ fn deref(&self) -> &Self::Target {
156
+ unsafe { &*(self as *const Self as *const Self::Target) }
157
+ }
158
+ }
159
+
160
+ impl ::std::convert::From<$owned_ident> for $parent_ident {
161
+ fn from(item: $owned_ident) -> Self {
162
+ unsafe { Self::from_ptr(::std::mem::transmute(item.into_ptr())) }
163
+ }
164
+ }
165
+ };
166
+ {
167
+ type CType = $raw_ident:ident;
168
+ pub struct $owned_ident:ident;
169
+ } => {
170
+ foreign_type! {
171
+ pub unsafe type $owned_ident: Sync + Send {
172
+ type CType = $raw_ident;
173
+ fn drop = crate::obj_drop;
174
+ fn clone = crate::obj_clone;
175
+ }
176
+ }
177
+
178
+ unsafe impl ::objc::Message for $raw_ident {
179
+ }
180
+ unsafe impl ::objc::Message for paste!{[<$owned_ident Ref>]} {
181
+ }
182
+
183
+ impl ::std::fmt::Debug for paste!{[<$owned_ident Ref>]} {
184
+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
185
+ unsafe {
186
+ let string: *mut ::objc::runtime::Object = msg_send![self, debugDescription];
187
+ write!(f, "{}", crate::nsstring_as_str(&*string))
188
+ }
189
+ }
190
+ }
191
+
192
+ impl ::std::fmt::Debug for $owned_ident {
193
+ fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
194
+ ::std::ops::Deref::deref(self).fmt(f)
195
+ }
196
+ }
197
+ };
198
+ }
199
+
200
+ macro_rules! try_objc {
201
+ {
202
+ $err_name: ident => $body:expr
203
+ } => {
204
+ {
205
+ let mut $err_name: *mut Object = ::std::ptr::null_mut();
206
+ let value = $body;
207
+ if !$err_name.is_null() {
208
+ let desc: *mut Object = msg_send![$err_name, localizedDescription];
209
+ let compile_error: *const std::os::raw::c_char = msg_send![desc, UTF8String];
210
+ let message = CStr::from_ptr(compile_error).to_string_lossy().into_owned();
211
+ return Err(message);
212
+ }
213
+ value
214
+ }
215
+ };
216
+ }
217
+
218
+ macro_rules! msg_send_bool {
219
+ ($obj:expr, $name:ident) => {{
220
+ match msg_send![$obj, $name] {
221
+ YES => true,
222
+ NO => false,
223
+ #[cfg(not(target_arch = "aarch64"))]
224
+ _ => unreachable!(),
225
+ }
226
+ }};
227
+ ($obj:expr, $name:ident : $arg:expr) => {{
228
+ match msg_send![$obj, $name: $arg] {
229
+ YES => true,
230
+ NO => false,
231
+ #[cfg(not(target_arch = "aarch64"))]
232
+ _ => unreachable!(),
233
+ }
234
+ }};
235
+ }
236
+
237
+ macro_rules! msg_send_bool_error_check {
238
+ ($obj:expr, $name:ident: $arg:expr) => {{
239
+ let mut err: *mut Object = ptr::null_mut();
240
+ let result: BOOL = msg_send![$obj, $name:$arg
241
+ error:&mut err];
242
+ if !err.is_null() {
243
+ let desc: *mut Object = msg_send![err, localizedDescription];
244
+ let c_msg: *const c_char = msg_send![desc, UTF8String];
245
+ let message = CStr::from_ptr(c_msg).to_string_lossy().into_owned();
246
+ Err(message)
247
+ } else {
248
+ match result {
249
+ YES => Ok(true),
250
+ NO => Ok(false),
251
+ #[cfg(not(target_arch = "aarch64"))]
252
+ _ => unreachable!(),
253
+ }
254
+ }
255
+ }};
256
+ }
257
+
258
+ /// See <https://developer.apple.com/documentation/foundation/nsarray>
259
+ pub struct NSArray<T> {
260
+ _phantom: PhantomData<T>,
261
+ }
262
+
263
+ pub struct Array<T>(*mut NSArray<T>)
264
+ where
265
+ T: ForeignType + 'static,
266
+ T::Ref: objc::Message + 'static;
267
+
268
+ pub struct ArrayRef<T>(foreign_types::Opaque, PhantomData<T>)
269
+ where
270
+ T: ForeignType + 'static,
271
+ T::Ref: objc::Message + 'static;
272
+
273
+ impl<T> Drop for Array<T>
274
+ where
275
+ T: ForeignType + 'static,
276
+ T::Ref: objc::Message + 'static,
277
+ {
278
+ fn drop(&mut self) {
279
+ unsafe {
280
+ let () = msg_send![self.0, release];
281
+ }
282
+ }
283
+ }
284
+
285
+ impl<T> Clone for Array<T>
286
+ where
287
+ T: ForeignType + 'static,
288
+ T::Ref: objc::Message + 'static,
289
+ {
290
+ fn clone(&self) -> Self {
291
+ unsafe { Array(msg_send![self.0, retain]) }
292
+ }
293
+ }
294
+
295
+ unsafe impl<T> objc::Message for NSArray<T>
296
+ where
297
+ T: ForeignType + 'static,
298
+ T::Ref: objc::Message + 'static,
299
+ {
300
+ }
301
+
302
+ unsafe impl<T> objc::Message for ArrayRef<T>
303
+ where
304
+ T: ForeignType + 'static,
305
+ T::Ref: objc::Message + 'static,
306
+ {
307
+ }
308
+
309
+ impl<T> Array<T>
310
+ where
311
+ T: ForeignType + 'static,
312
+ T::Ref: objc::Message + 'static,
313
+ {
314
+ pub fn from_slice<'a>(s: &[&T::Ref]) -> &'a ArrayRef<T> {
315
+ unsafe {
316
+ let class = class!(NSArray);
317
+ msg_send![class, arrayWithObjects: s.as_ptr() count: s.len()]
318
+ }
319
+ }
320
+
321
+ pub fn from_owned_slice<'a>(s: &[T]) -> &'a ArrayRef<T> {
322
+ unsafe {
323
+ let class = class!(NSArray);
324
+ msg_send![class, arrayWithObjects: s.as_ptr() count: s.len()]
325
+ }
326
+ }
327
+ }
328
+
329
+ unsafe impl<T> foreign_types::ForeignType for Array<T>
330
+ where
331
+ T: ForeignType + 'static,
332
+ T::Ref: objc::Message + 'static,
333
+ {
334
+ type CType = NSArray<T>;
335
+ type Ref = ArrayRef<T>;
336
+
337
+ unsafe fn from_ptr(p: *mut NSArray<T>) -> Self {
338
+ Array(p)
339
+ }
340
+
341
+ fn as_ptr(&self) -> *mut NSArray<T> {
342
+ self.0
343
+ }
344
+ }
345
+
346
+ unsafe impl<T> foreign_types::ForeignTypeRef for ArrayRef<T>
347
+ where
348
+ T: ForeignType + 'static,
349
+ T::Ref: objc::Message + 'static,
350
+ {
351
+ type CType = NSArray<T>;
352
+ }
353
+
354
+ impl<T> Deref for Array<T>
355
+ where
356
+ T: ForeignType + 'static,
357
+ T::Ref: objc::Message + 'static,
358
+ {
359
+ type Target = ArrayRef<T>;
360
+
361
+ #[inline]
362
+ fn deref(&self) -> &ArrayRef<T> {
363
+ unsafe { mem::transmute(self.as_ptr()) }
364
+ }
365
+ }
366
+
367
+ impl<T> Borrow<ArrayRef<T>> for Array<T>
368
+ where
369
+ T: ForeignType + 'static,
370
+ T::Ref: objc::Message + 'static,
371
+ {
372
+ fn borrow(&self) -> &ArrayRef<T> {
373
+ unsafe { mem::transmute(self.as_ptr()) }
374
+ }
375
+ }
376
+
377
+ impl<T> ToOwned for ArrayRef<T>
378
+ where
379
+ T: ForeignType + 'static,
380
+ T::Ref: objc::Message + 'static,
381
+ {
382
+ type Owned = Array<T>;
383
+
384
+ fn to_owned(&self) -> Array<T> {
385
+ unsafe { Array::from_ptr(msg_send![self, retain]) }
386
+ }
387
+ }
388
+
389
+ /// See <https://developer.apple.com/documentation/quartzcore/cametaldrawable>
390
+ pub enum CAMetalDrawable {}
391
+
392
+ foreign_obj_type! {
393
+ type CType = CAMetalDrawable;
394
+ pub struct MetalDrawable;
395
+ type ParentType = Drawable;
396
+ }
397
+
398
+ impl MetalDrawableRef {
399
+ pub fn texture(&self) -> &TextureRef {
400
+ unsafe { msg_send![self, texture] }
401
+ }
402
+ }
403
+
404
+ pub enum NSObject {}
405
+
406
+ foreign_obj_type! {
407
+ type CType = NSObject;
408
+ pub struct NsObject;
409
+ }
410
+
411
+ impl NsObjectRef {
412
+ pub fn conforms_to_protocol<T>(&self) -> Result<bool, String> {
413
+ let name = ::std::any::type_name::<T>();
414
+ if let Some(name) = name.split("::").last() {
415
+ if let Some(protocol) = objc::runtime::Protocol::get(name) {
416
+ Ok(unsafe { msg_send![self, conformsToProtocol: protocol] })
417
+ } else {
418
+ Err(format!("Can not find the protocol for type: {}.", name))
419
+ }
420
+ } else {
421
+ Err(format!("Unexpected type name: {}.", name))
422
+ }
423
+ }
424
+ }
425
+
426
+ // See <https://developer.apple.com/documentation/quartzcore/cametallayer>
427
+ pub enum CAMetalLayer {}
428
+
429
+ foreign_obj_type! {
430
+ type CType = CAMetalLayer;
431
+ pub struct MetalLayer;
432
+ }
433
+
434
+ impl MetalLayer {
435
+ pub fn new() -> Self {
436
+ unsafe {
437
+ let class = class!(CAMetalLayer);
438
+ msg_send![class, new]
439
+ }
440
+ }
441
+ }
442
+
443
+ impl MetalLayerRef {
444
+ pub fn device(&self) -> &DeviceRef {
445
+ unsafe { msg_send![self, device] }
446
+ }
447
+
448
+ pub fn set_device(&self, device: &DeviceRef) {
449
+ unsafe { msg_send![self, setDevice: device] }
450
+ }
451
+
452
+ pub fn pixel_format(&self) -> MTLPixelFormat {
453
+ unsafe { msg_send![self, pixelFormat] }
454
+ }
455
+
456
+ pub fn set_pixel_format(&self, pixel_format: MTLPixelFormat) {
457
+ unsafe { msg_send![self, setPixelFormat: pixel_format] }
458
+ }
459
+
460
+ pub fn drawable_size(&self) -> CGSize {
461
+ unsafe { msg_send![self, drawableSize] }
462
+ }
463
+
464
+ pub fn set_drawable_size(&self, size: CGSize) {
465
+ unsafe { msg_send![self, setDrawableSize: size] }
466
+ }
467
+
468
+ pub fn presents_with_transaction(&self) -> bool {
469
+ unsafe { msg_send_bool![self, presentsWithTransaction] }
470
+ }
471
+
472
+ pub fn set_presents_with_transaction(&self, transaction: bool) {
473
+ unsafe { msg_send![self, setPresentsWithTransaction: transaction] }
474
+ }
475
+
476
+ pub fn display_sync_enabled(&self) -> bool {
477
+ unsafe { msg_send_bool![self, displaySyncEnabled] }
478
+ }
479
+
480
+ pub fn set_display_sync_enabled(&self, enabled: bool) {
481
+ unsafe { msg_send![self, setDisplaySyncEnabled: enabled] }
482
+ }
483
+
484
+ pub fn maximum_drawable_count(&self) -> NSUInteger {
485
+ unsafe { msg_send![self, maximumDrawableCount] }
486
+ }
487
+
488
+ pub fn set_maximum_drawable_count(&self, count: NSUInteger) {
489
+ unsafe { msg_send![self, setMaximumDrawableCount: count] }
490
+ }
491
+
492
+ pub fn set_edge_antialiasing_mask(&self, mask: u64) {
493
+ unsafe { msg_send![self, setEdgeAntialiasingMask: mask] }
494
+ }
495
+
496
+ pub fn set_masks_to_bounds(&self, masks: bool) {
497
+ unsafe { msg_send![self, setMasksToBounds: masks] }
498
+ }
499
+
500
+ pub fn remove_all_animations(&self) {
501
+ unsafe { msg_send![self, removeAllAnimations] }
502
+ }
503
+
504
+ pub fn next_drawable(&self) -> Option<&MetalDrawableRef> {
505
+ unsafe { msg_send![self, nextDrawable] }
506
+ }
507
+
508
+ pub fn contents_scale(&self) -> CGFloat {
509
+ unsafe { msg_send![self, contentsScale] }
510
+ }
511
+
512
+ pub fn set_contents_scale(&self, scale: CGFloat) {
513
+ unsafe { msg_send![self, setContentsScale: scale] }
514
+ }
515
+
516
+ /// [framebufferOnly Apple Docs](https://developer.apple.com/documentation/metal/mtltexture/1515749-framebufferonly?language=objc)
517
+ pub fn framebuffer_only(&self) -> bool {
518
+ unsafe { msg_send_bool!(self, framebufferOnly) }
519
+ }
520
+
521
+ pub fn set_framebuffer_only(&self, framebuffer_only: bool) {
522
+ unsafe { msg_send![self, setFramebufferOnly: framebuffer_only] }
523
+ }
524
+
525
+ pub fn is_opaque(&self) -> bool {
526
+ unsafe { msg_send_bool!(self, isOpaque) }
527
+ }
528
+
529
+ pub fn set_opaque(&self, opaque: bool) {
530
+ unsafe { msg_send![self, setOpaque: opaque] }
531
+ }
532
+
533
+ pub fn wants_extended_dynamic_range_content(&self) -> bool {
534
+ unsafe { msg_send_bool![self, wantsExtendedDynamicRangeContent] }
535
+ }
536
+
537
+ pub fn set_wants_extended_dynamic_range_content(
538
+ &self,
539
+ wants_extended_dynamic_range_content: bool,
540
+ ) {
541
+ unsafe {
542
+ msg_send![
543
+ self,
544
+ setWantsExtendedDynamicRangeContent: wants_extended_dynamic_range_content
545
+ ]
546
+ }
547
+ }
548
+ }
549
+
550
+ mod acceleration_structure;
551
+ mod acceleration_structure_pass;
552
+ mod argument;
553
+ mod blitpass;
554
+ mod buffer;
555
+ mod capturedescriptor;
556
+ mod capturemanager;
557
+ mod commandbuffer;
558
+ mod commandqueue;
559
+ mod computepass;
560
+ mod constants;
561
+ mod counters;
562
+ mod depthstencil;
563
+ mod device;
564
+ mod drawable;
565
+ mod encoder;
566
+ mod heap;
567
+ mod indirect_encoder;
568
+ mod library;
569
+ #[cfg(feature = "mps")]
570
+ pub mod mps;
571
+ mod pipeline;
572
+ mod renderpass;
573
+ mod resource;
574
+ mod sampler;
575
+ mod sync;
576
+ mod texture;
577
+ mod types;
578
+ mod vertexdescriptor;
579
+
580
+ #[rustfmt::skip]
581
+ pub use {
582
+ acceleration_structure::*,
583
+ acceleration_structure_pass::*,
584
+ argument::*,
585
+ blitpass::*,
586
+ buffer::*,
587
+ counters::*,
588
+ computepass::*,
589
+ capturedescriptor::*,
590
+ capturemanager::*,
591
+ commandbuffer::*,
592
+ commandqueue::*,
593
+ constants::*,
594
+ depthstencil::*,
595
+ device::*,
596
+ drawable::*,
597
+ encoder::*,
598
+ heap::*,
599
+ indirect_encoder::*,
600
+ library::*,
601
+ pipeline::*,
602
+ renderpass::*,
603
+ resource::*,
604
+ sampler::*,
605
+ texture::*,
606
+ types::*,
607
+ vertexdescriptor::*,
608
+ sync::*,
609
+ };
610
+
611
+ #[inline]
612
+ unsafe fn obj_drop<T>(p: *mut T) {
613
+ msg_send![(p as *mut Object), release]
614
+ }
615
+
616
+ #[inline]
617
+ unsafe fn obj_clone<T: 'static>(p: *mut T) -> *mut T {
618
+ msg_send![(p as *mut Object), retain]
619
+ }
620
+
621
+ #[allow(non_camel_case_types)]
622
+ type c_size_t = usize;
623
+
624
+ // TODO: expand supported interface
625
+ /// See <https://developer.apple.com/documentation/foundation/nsurl>
626
+ pub enum NSURL {}
627
+
628
+ foreign_obj_type! {
629
+ type CType = NSURL;
630
+ pub struct URL;
631
+ }
632
+
633
+ impl URL {
634
+ pub fn new_with_string(string: &str) -> Self {
635
+ unsafe {
636
+ let ns_str = crate::nsstring_from_str(string);
637
+ let class = class!(NSURL);
638
+ msg_send![class, URLWithString: ns_str]
639
+ }
640
+ }
641
+ }
642
+
643
+ impl URLRef {
644
+ pub fn absolute_string(&self) -> &str {
645
+ unsafe {
646
+ let absolute_string = msg_send![self, absoluteString];
647
+ crate::nsstring_as_str(absolute_string)
648
+ }
649
+ }
650
+
651
+ pub fn path(&self) -> &str {
652
+ unsafe {
653
+ let path = msg_send![self, path];
654
+ crate::nsstring_as_str(path)
655
+ }
656
+ }
657
+ }