@@ -80,6 +80,7 @@ static MemorySegment findOrThrow(String symbol) {
80
80
81
81
// ==== ------------------------------------------------------------------------------------------------------------
82
82
// free
83
+
83
84
/**
84
85
* Descriptor for the free C runtime function.
85
86
*/
@@ -200,6 +201,7 @@ public static long release(SwiftHeapObject object) {
200
201
}
201
202
202
203
// ==== ------------------------------------------------------------------------------------------------------------
204
+ // getTypeByName
203
205
204
206
/**
205
207
* {@snippet lang = swift:
@@ -395,38 +397,41 @@ public static long alignmentOfSwiftType(MemorySegment typeMetadata) {
395
397
return (flags & 0xFF ) + 1 ;
396
398
}
397
399
398
- /**
399
- * Descriptor for the swift_getTypeName runtime function.
400
- */
401
- public static final FunctionDescriptor swift_getTypeName$descriptor = FunctionDescriptor .of (
402
- /*returns=*/ MemoryLayout .structLayout (
403
- SWIFT_POINTER .withName ("utf8Chars" ),
404
- SWIFT_INT .withName ("length" )
405
- ),
406
- ValueLayout .ADDRESS ,
407
- ValueLayout .JAVA_BOOLEAN
408
- );
400
+ private static class swift_getTypeName {
409
401
410
- /**
411
- * Address of the swift_getTypeName runtime function.
412
- */
413
- public static final MemorySegment swift_getTypeName$addr = findOrThrow ("swift_getTypeName" );
402
+ /**
403
+ * Descriptor for the swift_getTypeName runtime function.
404
+ */
405
+ public static final FunctionDescriptor DESC = FunctionDescriptor .of (
406
+ /*returns=*/ MemoryLayout .structLayout (
407
+ SWIFT_POINTER .withName ("utf8Chars" ),
408
+ SWIFT_INT .withName ("length" )
409
+ ),
410
+ ValueLayout .ADDRESS ,
411
+ ValueLayout .JAVA_BOOLEAN
412
+ );
414
413
415
- /**
416
- * Handle for the swift_getTypeName runtime function.
417
- */
418
- public static final MethodHandle swift_getTypeName$handle = Linker .nativeLinker ().downcallHandle (swift_getTypeName$addr , swift_getTypeName$descriptor );
414
+ /**
415
+ * Address of the swift_getTypeName runtime function.
416
+ */
417
+ public static final MemorySegment ADDR = findOrThrow ("swift_getTypeName" );
418
+
419
+ /**
420
+ * Handle for the swift_getTypeName runtime function.
421
+ */
422
+ public static final MethodHandle HANDLE = Linker .nativeLinker ().downcallHandle (ADDR , DESC );
423
+ }
419
424
420
425
/**
421
426
* Produce the name of the Swift type given its Swift type metadata.
422
427
* <p>
423
- * If 'qualified' is true, leave all of the qualification in place to
428
+ * If 'qualified' is true, leave all the qualification in place to
424
429
* disambiguate the type, producing a more complete (but longer) type name.
425
430
*/
426
431
public static String nameOfSwiftType (MemorySegment typeMetadata , boolean qualified ) {
427
432
try {
428
433
try (Arena arena = Arena .ofConfined ()) {
429
- MemorySegment charsAndLength = (MemorySegment ) swift_getTypeName$handle .invokeExact ((SegmentAllocator ) arena , typeMetadata , qualified );
434
+ MemorySegment charsAndLength = (MemorySegment ) swift_getTypeName . HANDLE .invokeExact ((SegmentAllocator ) arena , typeMetadata , qualified );
430
435
MemorySegment utf8Chars = charsAndLength .get (SWIFT_POINTER , 0 );
431
436
String typeName = utf8Chars .getString (0 );
432
437
cFree (utf8Chars );
0 commit comments