File: Discovery.h

package info (click to toggle)
swiftlang 6.2.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,856,264 kB
  • sloc: cpp: 9,995,718; ansic: 2,234,019; asm: 1,092,167; python: 313,940; objc: 82,726; f90: 80,126; lisp: 38,373; pascal: 25,580; sh: 20,378; ml: 5,058; perl: 4,751; makefile: 4,725; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (54 lines) | stat: -rw-r--r-- 1,789 bytes parent folder | download
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
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2023–2025 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
//

#if !defined(SWT_DISCOVERY_H)
#define SWT_DISCOVERY_H

#include "Defines.h"
#include "Includes.h"

SWT_ASSUME_NONNULL_BEGIN

#if defined(__ELF__) && defined(__swift__)
#pragma mark - ELF image enumeration

/// A function exported by the Swift runtime that enumerates all metadata
/// sections loaded into the current process.
///
/// This function is needed on ELF-based platforms because they do not preserve
/// section information that we can discover at runtime.
SWT_IMPORT_FROM_STDLIB void swift_enumerateAllMetadataSections(
  bool (* body)(const void *sections, void *context),
  void *context
);
#endif

#pragma mark - Legacy test discovery

/// The size, in bytes, of a Swift type metadata record.
SWT_EXTERN const size_t SWTTypeMetadataRecordByteCount;

/// Get the type represented by the type metadata record at the given address if
/// its name contains the given string.
///
/// - Parameters:
///   - recordAddress: The address of the Swift type metadata record.
///   - nameSubstring: A string which the names of matching types contain.
///
/// - Returns: A Swift metatype (as `const void *`) or `nullptr` if it wasn't a
///   usable type metadata record or its name did not contain `nameSubstring`.
SWT_EXTERN const void *_Nullable swt_getTypeFromTypeMetadataRecord(
  const void *recordAddress,
  const char *nameSubstring
) SWT_SWIFT_NAME(swt_getType(fromTypeMetadataRecord:ifNameContains:));

SWT_ASSUME_NONNULL_END

#endif