objc2-model-io 0.3.2

Bindings to the ModelIO framework
Documentation
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
//! This file has been automatically generated by `objc2`'s `header-translator`.
//! DO NOT EDIT
use core::ffi::*;
use core::ptr::NonNull;
use objc2::__framework_prelude::*;
use objc2_foundation::*;

use crate::*;

extern "C" {
    /// The attribute data describes the degree to which a surface’s appearance
    /// changes in appearance when rotated about its normal vector.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributeanisotropy?language=objc)
    pub static MDLVertexAttributeAnisotropy: &'static NSString;
}

extern "C" {
    /// The normal to a curve at a vertex position
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributebinormal?language=objc)
    pub static MDLVertexAttributeBinormal: &'static NSString;
}

extern "C" {
    /// The vector completing a tangent basis at a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributebitangent?language=objc)
    pub static MDLVertexAttributeBitangent: &'static NSString;
}

extern "C" {
    /// Color of a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributecolor?language=objc)
    pub static MDLVertexAttributeColor: &'static NSString;
}

extern "C" {
    /// A crease value along an edge to be applied during subdivision.
    /// A zero value indicates an edge is smooth, one is sharply creased.
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributeedgecrease?language=objc)
    pub static MDLVertexAttributeEdgeCrease: &'static NSString;
}

extern "C" {
    /// Indices of joints in an animation rig corresponding to weighting information
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributejointindices?language=objc)
    pub static MDLVertexAttributeJointIndices: &'static NSString;
}

extern "C" {
    /// Weights corresponding to joints for the purpose of blending animation
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributejointweights?language=objc)
    pub static MDLVertexAttributeJointWeights: &'static NSString;
}

extern "C" {
    /// The direction of a normal at a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributenormal?language=objc)
    pub static MDLVertexAttributeNormal: &'static NSString;
}

extern "C" {
    /// A value indicating the degree to which a vertex is occluded by surrounding geometry
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributeocclusionvalue?language=objc)
    pub static MDLVertexAttributeOcclusionValue: &'static NSString;
}

extern "C" {
    /// The position of a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributeposition?language=objc)
    pub static MDLVertexAttributePosition: &'static NSString;
}

extern "C" {
    /// The u direction of a shading basis at a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributeshadingbasisu?language=objc)
    pub static MDLVertexAttributeShadingBasisU: &'static NSString;
}

extern "C" {
    /// The v direction of a shading basis at a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributeshadingbasisv?language=objc)
    pub static MDLVertexAttributeShadingBasisV: &'static NSString;
}

extern "C" {
    /// Stencil values for subdivision at a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributesubdivisionstencil?language=objc)
    pub static MDLVertexAttributeSubdivisionStencil: &'static NSString;
}

extern "C" {
    /// A vector tangent to a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributetangent?language=objc)
    pub static MDLVertexAttributeTangent: &'static NSString;
}

extern "C" {
    /// Texture coordinate mapping at a vertex
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattributetexturecoordinate?language=objc)
    pub static MDLVertexAttributeTextureCoordinate: &'static NSString;
}

/// Describes the format of a an attribute in a vertex buffer
///
/// Designed to be very similar to MTLVertexDescriptor to ease the
/// translation from one to the other. Values are chosen such that
/// packed types would all be less than 0x1000 and the bottom 5 bits
/// can be used to determine the number of channels/components in the
/// format.
///
/// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexformat?language=objc)
// NS_ENUM
#[repr(transparent)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct MDLVertexFormat(pub NSUInteger);
impl MDLVertexFormat {
    #[doc(alias = "MDLVertexFormatInvalid")]
    pub const Invalid: Self = Self(0);
    #[doc(alias = "MDLVertexFormatPackedBit")]
    pub const PackedBit: Self = Self(0x1000);
    #[doc(alias = "MDLVertexFormatUCharBits")]
    pub const UCharBits: Self = Self(0x10000);
    #[doc(alias = "MDLVertexFormatCharBits")]
    pub const CharBits: Self = Self(0x20000);
    #[doc(alias = "MDLVertexFormatUCharNormalizedBits")]
    pub const UCharNormalizedBits: Self = Self(0x30000);
    #[doc(alias = "MDLVertexFormatCharNormalizedBits")]
    pub const CharNormalizedBits: Self = Self(0x40000);
    #[doc(alias = "MDLVertexFormatUShortBits")]
    pub const UShortBits: Self = Self(0x50000);
    #[doc(alias = "MDLVertexFormatShortBits")]
    pub const ShortBits: Self = Self(0x60000);
    #[doc(alias = "MDLVertexFormatUShortNormalizedBits")]
    pub const UShortNormalizedBits: Self = Self(0x70000);
    #[doc(alias = "MDLVertexFormatShortNormalizedBits")]
    pub const ShortNormalizedBits: Self = Self(0x80000);
    #[doc(alias = "MDLVertexFormatUIntBits")]
    pub const UIntBits: Self = Self(0x90000);
    #[doc(alias = "MDLVertexFormatIntBits")]
    pub const IntBits: Self = Self(0xA0000);
    #[doc(alias = "MDLVertexFormatHalfBits")]
    pub const HalfBits: Self = Self(0xB0000);
    #[doc(alias = "MDLVertexFormatFloatBits")]
    pub const FloatBits: Self = Self(0xC0000);
    #[doc(alias = "MDLVertexFormatUChar")]
    pub const UChar: Self = Self(MDLVertexFormat::UCharBits.0 | 1);
    #[doc(alias = "MDLVertexFormatUChar2")]
    pub const UChar2: Self = Self(MDLVertexFormat::UCharBits.0 | 2);
    #[doc(alias = "MDLVertexFormatUChar3")]
    pub const UChar3: Self = Self(MDLVertexFormat::UCharBits.0 | 3);
    #[doc(alias = "MDLVertexFormatUChar4")]
    pub const UChar4: Self = Self(MDLVertexFormat::UCharBits.0 | 4);
    #[doc(alias = "MDLVertexFormatChar")]
    pub const Char: Self = Self(MDLVertexFormat::CharBits.0 | 1);
    #[doc(alias = "MDLVertexFormatChar2")]
    pub const Char2: Self = Self(MDLVertexFormat::CharBits.0 | 2);
    #[doc(alias = "MDLVertexFormatChar3")]
    pub const Char3: Self = Self(MDLVertexFormat::CharBits.0 | 3);
    #[doc(alias = "MDLVertexFormatChar4")]
    pub const Char4: Self = Self(MDLVertexFormat::CharBits.0 | 4);
    #[doc(alias = "MDLVertexFormatUCharNormalized")]
    pub const UCharNormalized: Self = Self(MDLVertexFormat::UCharNormalizedBits.0 | 1);
    #[doc(alias = "MDLVertexFormatUChar2Normalized")]
    pub const UChar2Normalized: Self = Self(MDLVertexFormat::UCharNormalizedBits.0 | 2);
    #[doc(alias = "MDLVertexFormatUChar3Normalized")]
    pub const UChar3Normalized: Self = Self(MDLVertexFormat::UCharNormalizedBits.0 | 3);
    #[doc(alias = "MDLVertexFormatUChar4Normalized")]
    pub const UChar4Normalized: Self = Self(MDLVertexFormat::UCharNormalizedBits.0 | 4);
    #[doc(alias = "MDLVertexFormatCharNormalized")]
    pub const CharNormalized: Self = Self(MDLVertexFormat::CharNormalizedBits.0 | 1);
    #[doc(alias = "MDLVertexFormatChar2Normalized")]
    pub const Char2Normalized: Self = Self(MDLVertexFormat::CharNormalizedBits.0 | 2);
    #[doc(alias = "MDLVertexFormatChar3Normalized")]
    pub const Char3Normalized: Self = Self(MDLVertexFormat::CharNormalizedBits.0 | 3);
    #[doc(alias = "MDLVertexFormatChar4Normalized")]
    pub const Char4Normalized: Self = Self(MDLVertexFormat::CharNormalizedBits.0 | 4);
    #[doc(alias = "MDLVertexFormatUShort")]
    pub const UShort: Self = Self(MDLVertexFormat::UShortBits.0 | 1);
    #[doc(alias = "MDLVertexFormatUShort2")]
    pub const UShort2: Self = Self(MDLVertexFormat::UShortBits.0 | 2);
    #[doc(alias = "MDLVertexFormatUShort3")]
    pub const UShort3: Self = Self(MDLVertexFormat::UShortBits.0 | 3);
    #[doc(alias = "MDLVertexFormatUShort4")]
    pub const UShort4: Self = Self(MDLVertexFormat::UShortBits.0 | 4);
    #[doc(alias = "MDLVertexFormatShort")]
    pub const Short: Self = Self(MDLVertexFormat::ShortBits.0 | 1);
    #[doc(alias = "MDLVertexFormatShort2")]
    pub const Short2: Self = Self(MDLVertexFormat::ShortBits.0 | 2);
    #[doc(alias = "MDLVertexFormatShort3")]
    pub const Short3: Self = Self(MDLVertexFormat::ShortBits.0 | 3);
    #[doc(alias = "MDLVertexFormatShort4")]
    pub const Short4: Self = Self(MDLVertexFormat::ShortBits.0 | 4);
    #[doc(alias = "MDLVertexFormatUShortNormalized")]
    pub const UShortNormalized: Self = Self(MDLVertexFormat::UShortNormalizedBits.0 | 1);
    #[doc(alias = "MDLVertexFormatUShort2Normalized")]
    pub const UShort2Normalized: Self = Self(MDLVertexFormat::UShortNormalizedBits.0 | 2);
    #[doc(alias = "MDLVertexFormatUShort3Normalized")]
    pub const UShort3Normalized: Self = Self(MDLVertexFormat::UShortNormalizedBits.0 | 3);
    #[doc(alias = "MDLVertexFormatUShort4Normalized")]
    pub const UShort4Normalized: Self = Self(MDLVertexFormat::UShortNormalizedBits.0 | 4);
    #[doc(alias = "MDLVertexFormatShortNormalized")]
    pub const ShortNormalized: Self = Self(MDLVertexFormat::ShortNormalizedBits.0 | 1);
    #[doc(alias = "MDLVertexFormatShort2Normalized")]
    pub const Short2Normalized: Self = Self(MDLVertexFormat::ShortNormalizedBits.0 | 2);
    #[doc(alias = "MDLVertexFormatShort3Normalized")]
    pub const Short3Normalized: Self = Self(MDLVertexFormat::ShortNormalizedBits.0 | 3);
    #[doc(alias = "MDLVertexFormatShort4Normalized")]
    pub const Short4Normalized: Self = Self(MDLVertexFormat::ShortNormalizedBits.0 | 4);
    #[doc(alias = "MDLVertexFormatUInt")]
    pub const UInt: Self = Self(MDLVertexFormat::UIntBits.0 | 1);
    #[doc(alias = "MDLVertexFormatUInt2")]
    pub const UInt2: Self = Self(MDLVertexFormat::UIntBits.0 | 2);
    #[doc(alias = "MDLVertexFormatUInt3")]
    pub const UInt3: Self = Self(MDLVertexFormat::UIntBits.0 | 3);
    #[doc(alias = "MDLVertexFormatUInt4")]
    pub const UInt4: Self = Self(MDLVertexFormat::UIntBits.0 | 4);
    #[doc(alias = "MDLVertexFormatInt")]
    pub const Int: Self = Self(MDLVertexFormat::IntBits.0 | 1);
    #[doc(alias = "MDLVertexFormatInt2")]
    pub const Int2: Self = Self(MDLVertexFormat::IntBits.0 | 2);
    #[doc(alias = "MDLVertexFormatInt3")]
    pub const Int3: Self = Self(MDLVertexFormat::IntBits.0 | 3);
    #[doc(alias = "MDLVertexFormatInt4")]
    pub const Int4: Self = Self(MDLVertexFormat::IntBits.0 | 4);
    #[doc(alias = "MDLVertexFormatHalf")]
    pub const Half: Self = Self(MDLVertexFormat::HalfBits.0 | 1);
    #[doc(alias = "MDLVertexFormatHalf2")]
    pub const Half2: Self = Self(MDLVertexFormat::HalfBits.0 | 2);
    #[doc(alias = "MDLVertexFormatHalf3")]
    pub const Half3: Self = Self(MDLVertexFormat::HalfBits.0 | 3);
    #[doc(alias = "MDLVertexFormatHalf4")]
    pub const Half4: Self = Self(MDLVertexFormat::HalfBits.0 | 4);
    #[doc(alias = "MDLVertexFormatFloat")]
    pub const Float: Self = Self(MDLVertexFormat::FloatBits.0 | 1);
    #[doc(alias = "MDLVertexFormatFloat2")]
    pub const Float2: Self = Self(MDLVertexFormat::FloatBits.0 | 2);
    #[doc(alias = "MDLVertexFormatFloat3")]
    pub const Float3: Self = Self(MDLVertexFormat::FloatBits.0 | 3);
    #[doc(alias = "MDLVertexFormatFloat4")]
    pub const Float4: Self = Self(MDLVertexFormat::FloatBits.0 | 4);
    #[doc(alias = "MDLVertexFormatInt1010102Normalized")]
    pub const Int1010102Normalized: Self =
        Self(MDLVertexFormat::IntBits.0 | MDLVertexFormat::PackedBit.0 | 4);
    #[doc(alias = "MDLVertexFormatUInt1010102Normalized")]
    pub const UInt1010102Normalized: Self =
        Self(MDLVertexFormat::UIntBits.0 | MDLVertexFormat::PackedBit.0 | 4);
}

unsafe impl Encode for MDLVertexFormat {
    const ENCODING: Encoding = NSUInteger::ENCODING;
}

unsafe impl RefEncode for MDLVertexFormat {
    const ENCODING_REF: Encoding = Encoding::Pointer(&Self::ENCODING);
}

extern_class!(
    /// Describes a vertex buffer's layout
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexbufferlayout?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MDLVertexBufferLayout;
);

extern_conformance!(
    unsafe impl NSCopying for MDLVertexBufferLayout {}
);

unsafe impl CopyingHelper for MDLVertexBufferLayout {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MDLVertexBufferLayout {}
);

impl MDLVertexBufferLayout {
    extern_methods!(
        #[unsafe(method(initWithStride:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithStride(this: Allocated<Self>, stride: NSUInteger) -> Retained<Self>;

        /// stride in bytes of each vertex element in the buffer.
        ///
        /// - If you store multiple attributes interleaved in the vertex
        /// buffer, the stride will be the sum of sizes of each attribute (and any padding).
        /// - If you store multiple attributes non-interleaved (back to back),
        /// the stride will be the size of an attribute (and all attributes are
        /// required to have the same size).
        #[unsafe(method(stride))]
        #[unsafe(method_family = none)]
        pub unsafe fn stride(&self) -> NSUInteger;

        /// Setter for [`stride`][Self::stride].
        #[unsafe(method(setStride:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setStride(&self, stride: NSUInteger);
    );
}

/// Methods declared on superclass `NSObject`.
impl MDLVertexBufferLayout {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Structure with properties of a vertex attribute
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexattribute?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MDLVertexAttribute;
);

extern_conformance!(
    unsafe impl NSCopying for MDLVertexAttribute {}
);

unsafe impl CopyingHelper for MDLVertexAttribute {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MDLVertexAttribute {}
);

impl MDLVertexAttribute {
    extern_methods!(
        /// Initialize attribute object with all properties
        #[unsafe(method(initWithName:format:offset:bufferIndex:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithName_format_offset_bufferIndex(
            this: Allocated<Self>,
            name: &NSString,
            format: MDLVertexFormat,
            offset: NSUInteger,
            buffer_index: NSUInteger,
        ) -> Retained<Self>;

        /// Identifying name of the attribute derived from model file, or one of
        /// the predefined MDLVertexAttribute strings
        #[unsafe(method(name))]
        #[unsafe(method_family = none)]
        pub unsafe fn name(&self) -> Retained<NSString>;

        /// Setter for [`name`][Self::name].
        ///
        /// This is [copied][objc2_foundation::NSCopying::copy] when set.
        #[unsafe(method(setName:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setName(&self, name: &NSString);

        /// Format (including number of components) of the attribute
        ///
        /// If the value is MDLVertexFormatInvalid.   Other values of this
        /// object will be ignored when setting the MDLVertexDescriptor object
        /// in a Mesh. The initial value is MDLVertexFormatInvalid.
        #[unsafe(method(format))]
        #[unsafe(method_family = none)]
        pub unsafe fn format(&self) -> MDLVertexFormat;

        /// Setter for [`format`][Self::format].
        #[unsafe(method(setFormat:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setFormat(&self, format: MDLVertexFormat);

        /// offset in bytes of the attrbute in each element of the vertex buffer
        #[unsafe(method(offset))]
        #[unsafe(method_family = none)]
        pub unsafe fn offset(&self) -> NSUInteger;

        /// Setter for [`offset`][Self::offset].
        #[unsafe(method(setOffset:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setOffset(&self, offset: NSUInteger);

        /// index of the buffer in mesh's vertexBuffer array in which this
        /// attribute resides
        #[unsafe(method(bufferIndex))]
        #[unsafe(method_family = none)]
        pub unsafe fn bufferIndex(&self) -> NSUInteger;

        /// Setter for [`bufferIndex`][Self::bufferIndex].
        #[unsafe(method(setBufferIndex:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setBufferIndex(&self, buffer_index: NSUInteger);

        /// the time the attribute is intended for.
        ///
        /// morph targets would store their times here
        #[unsafe(method(time))]
        #[unsafe(method_family = none)]
        pub unsafe fn time(&self) -> NSTimeInterval;

        /// Setter for [`time`][Self::time].
        #[unsafe(method(setTime:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setTime(&self, time: NSTimeInterval);
    );
}

/// Methods declared on superclass `NSObject`.
impl MDLVertexAttribute {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}

extern_class!(
    /// Describes the layout of vertex buffers in MDLMesh objects
    ///
    /// This object is a property of MDLMesh describing the current state of
    /// attributes and buffer layouts of the vertex buffers in the mesh. This must be
    /// immutable otherwise even small changes could cause the buffers to be out of sync
    /// with the layout described here.
    ///
    /// Designed to be very similar to MTLVertexDescriptor to ease creation of one from
    /// the other
    ///
    /// See also [Apple's documentation](https://developer.apple.com/documentation/modelio/mdlvertexdescriptor?language=objc)
    #[unsafe(super(NSObject))]
    #[derive(Debug, PartialEq, Eq, Hash)]
    pub struct MDLVertexDescriptor;
);

extern_conformance!(
    unsafe impl NSCopying for MDLVertexDescriptor {}
);

unsafe impl CopyingHelper for MDLVertexDescriptor {
    type Result = Self;
}

extern_conformance!(
    unsafe impl NSObjectProtocol for MDLVertexDescriptor {}
);

impl MDLVertexDescriptor {
    extern_methods!(
        /// Initializes the object with values from supplied vertexDescriptor
        ///
        /// This performs a deep copy of all data in the supplied descriptor.
        #[unsafe(method(initWithVertexDescriptor:))]
        #[unsafe(method_family = init)]
        pub unsafe fn initWithVertexDescriptor(
            this: Allocated<Self>,
            vertex_descriptor: &MDLVertexDescriptor,
        ) -> Retained<Self>;

        /// Retrieves the attribute with the given name
        ///
        /// Returns: The attribute with the supplied name or nil if attribute with the given
        /// name does not exist in the descriptor object
        #[unsafe(method(attributeNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributeNamed(
            &self,
            name: &NSString,
        ) -> Option<Retained<MDLVertexAttribute>>;

        /// Replace any attribute with the same name and time, or add it if it does not
        /// already exist.
        #[unsafe(method(addOrReplaceAttribute:))]
        #[unsafe(method_family = none)]
        pub unsafe fn addOrReplaceAttribute(&self, attribute: &MDLVertexAttribute);

        /// Remove the named attribute if it exists
        #[unsafe(method(removeAttributeNamed:))]
        #[unsafe(method_family = none)]
        pub unsafe fn removeAttributeNamed(&self, name: &NSString);

        /// An array of MDLVertexAttribute objects
        ///
        /// ay describing the current attribute state of vertex buffers in an
        /// MDLMesh mesh
        #[unsafe(method(attributes))]
        #[unsafe(method_family = none)]
        pub unsafe fn attributes(&self) -> Retained<NSMutableArray<MDLVertexAttribute>>;

        /// Setter for [`attributes`][Self::attributes].
        #[unsafe(method(setAttributes:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setAttributes(&self, attributes: &NSMutableArray<MDLVertexAttribute>);

        /// An array of MDLVertexBufferLayout
        ///
        /// An array describing the current layout state of vertex buffers in an
        /// MDLMesh mesh
        #[unsafe(method(layouts))]
        #[unsafe(method_family = none)]
        pub unsafe fn layouts(&self) -> Retained<NSMutableArray<MDLVertexBufferLayout>>;

        /// Setter for [`layouts`][Self::layouts].
        #[unsafe(method(setLayouts:))]
        #[unsafe(method_family = none)]
        pub unsafe fn setLayouts(&self, layouts: &NSMutableArray<MDLVertexBufferLayout>);

        /// Tesets the descriptor to initial values
        #[unsafe(method(reset))]
        #[unsafe(method_family = none)]
        pub unsafe fn reset(&self);

        /// Sets the stride in each VertexBufferLout in the layouts array to the
        /// minimum value encompassing all attributes in the vertex buffer
        #[unsafe(method(setPackedStrides))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPackedStrides(&self);

        /// Sets the stride in each VertexAttribute in the attributes array to
        /// the minimum value to pack each attribute next to each other in its
        /// vertexbuffer
        #[unsafe(method(setPackedOffsets))]
        #[unsafe(method_family = none)]
        pub unsafe fn setPackedOffsets(&self);
    );
}

/// Methods declared on superclass `NSObject`.
impl MDLVertexDescriptor {
    extern_methods!(
        #[unsafe(method(init))]
        #[unsafe(method_family = init)]
        pub unsafe fn init(this: Allocated<Self>) -> Retained<Self>;

        #[unsafe(method(new))]
        #[unsafe(method_family = new)]
        pub unsafe fn new() -> Retained<Self>;
    );
}