|
| 1 | +//===--- BinaryScan.h - C API for Swift Binary Scanning ---*- C -*-===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift.org open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2014 - 2020 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See https://swift.org/LICENSE.txt for license information |
| 9 | +// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | +// |
| 13 | +// This C API is primarily intended to serve as a "static mirror" library |
| 14 | +// for querying Swift type information from binary object files. |
| 15 | +// |
| 16 | +//===----------------------------------------------------------------------===// |
| 17 | + |
| 18 | +#include "StaticMirrorMacros.h" |
| 19 | +#include "swift-c/CommonString/CommonString.h" |
| 20 | + |
| 21 | +#ifndef SWIFT_C_BINARY_SCAN_H |
| 22 | +#define SWIFT_C_BINARY_SCAN_H |
| 23 | + |
| 24 | +/// The version constants for the SwiftStaticMirror C API. |
| 25 | +/// SWIFTSTATICMIRROR_VERSION_MINOR should increase when there are API additions. |
| 26 | +/// SWIFTSTATICMIRROR_VERSION_MAJOR is intended for "major" source/ABI breaking changes. |
| 27 | +#define SWIFTSTATICMIRROR_VERSION_MAJOR 0 |
| 28 | +#define SWIFTSTATICMIRROR_VERSION_MINOR 1 |
| 29 | + |
| 30 | +SWIFTSTATICMIRROR_BEGIN_DECLS |
| 31 | + |
| 32 | +//=== Public Binary Scanner Data Types ------------------------------------===// |
| 33 | + |
| 34 | +typedef swiftscan_string_ref_t swift_static_mirror_string_ref_t; |
| 35 | +typedef swiftscan_string_set_t swift_static_mirror_string_set_t; |
| 36 | + |
| 37 | +/// Container of the configuration state for binary static mirror scanning |
| 38 | +/// instance |
| 39 | +typedef void *swift_static_mirror_t; |
| 40 | + |
| 41 | +/// Opaque container to a conformance type info of a given protocol conformance. |
| 42 | +typedef struct swift_static_mirror_conformance_info_s |
| 43 | + *swift_static_mirror_conformance_info_t; |
| 44 | + |
| 45 | +typedef struct { |
| 46 | + swift_static_mirror_conformance_info_t *conformances; |
| 47 | + size_t count; |
| 48 | +} swift_static_mirror_conformances_set_t; |
| 49 | + |
| 50 | +SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t |
| 51 | + swift_static_mirror_conformance_info_get_type_name( |
| 52 | + swift_static_mirror_conformance_info_t); |
| 53 | + |
| 54 | +SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t |
| 55 | + swift_static_mirror_conformance_info_get_protocol_name( |
| 56 | + swift_static_mirror_conformance_info_t); |
| 57 | + |
| 58 | +SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_string_ref_t |
| 59 | + swift_static_mirror_conformance_info_get_mangled_type_name( |
| 60 | + swift_static_mirror_conformance_info_t); |
| 61 | + |
| 62 | +SWIFTSTATICMIRROR_PUBLIC void |
| 63 | + swift_static_mirror_conformance_info_dispose( |
| 64 | + swift_static_mirror_conformance_info_t); |
| 65 | + |
| 66 | +/// Create an \c swift_static_mirror_t instance. |
| 67 | +/// The returned \c swift_static_mirror_t is owned by the caller and must be |
| 68 | +/// disposed of using \c swift_static_mirror_dispose . |
| 69 | +SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_t |
| 70 | +swift_static_mirror_create(int, const char **, const char *); |
| 71 | + |
| 72 | +SWIFTSTATICMIRROR_PUBLIC void |
| 73 | +swift_static_mirror_dispose(swift_static_mirror_t); |
| 74 | + |
| 75 | +/// Identify and collect all types conforming to any of the protocol names |
| 76 | +/// specified as arguments |
| 77 | +SWIFTSTATICMIRROR_PUBLIC swift_static_mirror_conformances_set_t * |
| 78 | +swift_static_mirror_conformances_set_create( |
| 79 | + swift_static_mirror_t, int, const char **); |
| 80 | + |
| 81 | +SWIFTSTATICMIRROR_PUBLIC void swift_static_mirror_conformances_set_dispose( |
| 82 | + swift_static_mirror_conformances_set_t *); |
| 83 | + |
| 84 | +SWIFTSTATICMIRROR_END_DECLS |
| 85 | + |
| 86 | +#endif // SWIFT_C_BINARY_SCAN_H |
0 commit comments