@@ -80,6 +80,7 @@ static MemorySegment findOrThrow(String symbol) {
8080
8181 // ==== ------------------------------------------------------------------------------------------------------------
8282 // free
83+
8384 /**
8485 * Descriptor for the free C runtime function.
8586 */
@@ -200,6 +201,7 @@ public static long release(SwiftHeapObject object) {
200201 }
201202
202203 // ==== ------------------------------------------------------------------------------------------------------------
204+ // getTypeByName
203205
204206 /**
205207 * {@snippet lang = swift:
@@ -395,38 +397,41 @@ public static long alignmentOfSwiftType(MemorySegment typeMetadata) {
395397 return (flags & 0xFF ) + 1 ;
396398 }
397399
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 {
409401
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+ );
414413
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+ }
419424
420425 /**
421426 * Produce the name of the Swift type given its Swift type metadata.
422427 * <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
424429 * disambiguate the type, producing a more complete (but longer) type name.
425430 */
426431 public static String nameOfSwiftType (MemorySegment typeMetadata , boolean qualified ) {
427432 try {
428433 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 );
430435 MemorySegment utf8Chars = charsAndLength .get (SWIFT_POINTER , 0 );
431436 String typeName = utf8Chars .getString (0 );
432437 cFree (utf8Chars );
0 commit comments