2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
26#include "../types/gimbal_type.h"
29
30
31
32
34#define GBL_CLASS(klass) ((GblClass*)klass)
36#define GBL_CLASS_TYPEOF(klass) GBL_CLASS_TYPEOF_
(klass)
38#define GBL_CLASS_PRIVATE(cType, klass) GBL_CLASS_PRIVATE_
(cType, klass)
40#define GBL_CLASS_PUBLIC(cType, priv) GBL_CLASS_PUBLIC_
(cType, privKlass)
42#define GBL_CLASS_TYPECHECK(cType, klass) GBL_CLASS_TYPECHECK_
(type, klass)
44#define GBL_CLASS_CAST(cType, klass) GBL_CLASS_CAST_
(cType, klass)
46#define GBL_CLASS_AS(cType, klass) GBL_CLASS_AS_
(cType, klass)
50
51
52
54#define GBL_STATIC_CLASS(klass) GBL_STATIC_CLASS_
(klass)
57#define GBL_SELF_TYPE GblClass
62
63
64
65
66
67
68
69
70
71
72
73
74
75
83
84
85
95
96
97
110
111
112
113
123
124
125
126
134
135
136
137
149
150
151
169
170
171
181#define GblClass_createFloating(...)
182 GblClass_createFloatingDefault_
(__VA_ARGS__)
183#define GblClass_createFloatingDefault_(...)
184 GblClass_createFloatingDefault__
(__VA_ARGS__, 0
)
185#define GblClass_createFloatingDefault__(type, size, ...)
186 (GblClass_createFloating
)(type, size)
188#define GBL_CLASS_TYPEOF_(klass) (GblClass_typeOf(GBL_CLASS(klass)))
191#define GBL_CLASS_TYPECHECK_(cType, klass) (GblClass_check((GblClass*)klass, GBL_TYPEID(cType)))
198
199
200
203
204
205
206
207
210
211
212
213
214
215
218
219
220
221
222
223
226
227
228
229
230
231
234
235
236
237
238
239
240
241
244
245
246
247
248
249
250
253
254
255
256
257
258
259
260
262
263
264
265
266
267
268
269
270
271
272
275
276
277
278
279
280
281
282
283
286
287
288
289
290
291
292
293
294
295
296
297
298
299
302
303
304
305
306
307
308
309
310
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
330
331
332
333
334
335
336
337
338
339
340
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
363
364
365
366
367
368
369
370
371
372
373
377
378
379
380
381
382
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
402
403
404
405
406
407
408
409
410
413
414
415
416
417
418
419
420
421
422
423
424
425
426
429
430
431
432
433
434
435
436
437
438
441
442
443
444
445
446
447
448
449
452
453
454
455
456
457
458
459
460
461
462
465
466
467
468
469
470
471
472
473
476
477
478
479
480
481
482
483
486
487
488
489
490
491
492
495
496
497
498
499
500
501
502
505
506
507
508
509
510
511
512
513
516
517
518
519
520
521
522
523
524
527
528
529
530
531
532
533
534
535
536
537
538
539
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
559
560
561
562
563
564
565
566
567
568
569
570
573
574
575
576
577
578
579
580
581
582
583
584
587
588
589
590
591
592
593
594
595
596
597
600
601
602
603
604
605
606
607
608
609
610
613
614
615
616
617
618
619
620
623
624
625
626
627
628
629
630
633
634
635
636
637
638
639
640
641
642
645
646
647
648
649
650
651
652
653
654
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
#define GBL_BUILTIN_TYPE(prefix)
Returns a type from the macro prefix of a builtin type.
GBL_RESULT GblClass_destructFloating(GblClass *pSelf)
Destructs the standalone, "floating" class, without releasing any allocated resources.
GblRefCount GblClass_unrefDefault(GblClass *pSelf)
Releases a reference to the default version of the given class, possibly freeing it.
GblClass * GblClass_createFloating(GblType type, size_t size)
Creates a standalone, unowned, "floating" class for the given type, which can override defaults.
GBL_RESULT GblClass_constructFloating(GblClass *pSelf, GblType type)
Constructs a standalone, unowned, overridable, "floating" class for the given type in-place.
GBL_RESULT GblClass_destroyFloating(GblClass *pSelf)
Destroys the standalone, "floating" class, releasing its memory allocation.
GblClass * GblClass_weakRefDefault(GblType type)
Returns a reference to the default class for type or NULL if it hasn't been created.
GblClass * GblClass_refDefault(GblType type)
Returns a reference to the default class for type, instantiating it if necessary.
#define GBL_CLASS_PRIVATE_STRUCT(instanceStruct)
#define GBL_TYPEID(instanceStruct)
#define GBL_PRIVATE_BEGIN
#define GBL_CLASS_STRUCT(cType)
#define GBL_PRIVATE_END
Private data structure.
uint8_t GblBool
Basic boolean type, standardized to sizeof(char)
uint16_t GblRefCount
Type able to hold a reference counter across the codebase.
Base struct for all type classes.
size_t GblClass_size(const GblClass *pSelf)
Returns the size of the given class's public class structrue.
GblBool GblClass_isOverridden(const GblClass *pSelf)
Returns GBL_TRUE if the class differs from the default class for its type.
void * GblClass_private(const GblClass *pSelf, GblType base)
Returns the private structure associated with the given base type of the class.
GblClass * GblClass_cast(GblClass *pSelf, GblType toType)
Casts the given class to a toType class, or returns NULL and emits an error if unsuccessful.
GblClass * GblClass_public(const void *pPrivate, GblType base)
Casts back to the class structure from a base type's private data segment structure.
GblType GblClass_typeOf(const GblClass *pSelf)
Returns the GblType UUID associated with the given class.
GblBool GblClass_isInterface(const GblClass *pSelf)
Returns GBL_TRUE if the class is an interfaced type.
GblBool GblClass_check(const GblClass *pSelf, GblType toType)
Returns GBL_TRUE if the given class can be casted to toType.
GblClass * GblClass_super(const GblClass *pSelf)
Returns the default class of the class's parent type or NULL if it's a root class.
size_t GblClass_privateSize(const GblClass *pSelf)
Returns the combined size of the class's private data segments.
GblBool GblClass_isInPlace(const GblClass *pSelf)
Returns GBL_TRUE if the class was constructed in-place with an existing allocation.
GblBool GblClass_isOwned(const GblClass *pSelf)
Returns GBL_TRUE if the class is a non-default floating class is uowned by an instance.
GblBool GblClass_isFloating(const GblClass *pSelf)
Returns GBL_TRUE if the class is a non-default floating class and is unowned by an instance.
uintptr_t metaClassInfo
PRIVATE: Pointer-sized opaque member.
GblBool GblClass_isDefault(const GblClass *pSelf)
Returns GBL_TRUE if the class is the internally-managed default for its type.
GblClass * GblClass_as(GblClass *pSelf, GblType toType)
Casts the given class to a toType class, or gracefully returns NULL without erroring.
GblBool GblClass_isInterfaceImpl(const GblClass *pSelf)
Returns GBL_TRUE if the class is another class's implementation of an interface.
GblClass * GblClass_default(const GblClass *pSelf)
Returns the default implementation of the given class.
size_t GblClass_totalSize(const GblClass *pSelf)
Returns the class's combined DEFAULT size (not extended allocation size)