|
| 1 | +//===-- swiftscan_header.h - C API for Swift Dependency 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 | +#ifndef SWIFT_C_DEPENDENCY_SCAN_H |
| 14 | +#define SWIFT_C_DEPENDENCY_SCAN_H |
| 15 | + |
| 16 | +#include <stdbool.h> |
| 17 | +#include <stddef.h> |
| 18 | +#include <stdint.h> |
| 19 | + |
| 20 | +#define SWIFTSCAN_VERSION_MAJOR 0 |
| 21 | +#define SWIFTSCAN_VERSION_MINOR 1 |
| 22 | + |
| 23 | +//=== Public Scanner Data Types -------------------------------------------===// |
| 24 | + |
| 25 | +typedef struct { |
| 26 | + const void *data; |
| 27 | + size_t length; |
| 28 | +} swiftscan_string_ref_t; |
| 29 | + |
| 30 | +typedef struct { |
| 31 | + swiftscan_string_ref_t *strings; |
| 32 | + size_t count; |
| 33 | +} swiftscan_string_set_t; |
| 34 | + |
| 35 | +typedef enum { |
| 36 | + SWIFTSCAN_DEPENDENCY_INFO_SWIFT_TEXTUAL = 0, |
| 37 | + SWIFTSCAN_DEPENDENCY_INFO_SWIFT_BINARY = 1, |
| 38 | + SWIFTSCAN_DEPENDENCY_INFO_SWIFT_PLACEHOLDER = 2, |
| 39 | + SWIFTSCAN_DEPENDENCY_INFO_CLANG = 3 |
| 40 | +} swiftscan_dependency_info_kind_t; |
| 41 | + |
| 42 | +typedef struct swiftscan_module_details_s *swiftscan_module_details_t; |
| 43 | +typedef struct swiftscan_dependency_info_s *swiftscan_dependency_info_t; |
| 44 | +typedef struct swiftscan_dependency_graph_s *swiftscan_dependency_graph_t; |
| 45 | +typedef struct swiftscan_import_set_s *swiftscan_import_set_t; |
| 46 | +typedef struct { |
| 47 | + swiftscan_dependency_info_t *modules; |
| 48 | + size_t count; |
| 49 | +} swiftscan_dependency_set_t; |
| 50 | + |
| 51 | +//=== Batch Scan Input Specification --------------------------------------===// |
| 52 | + |
| 53 | +typedef struct swiftscan_batch_scan_entry_s *swiftscan_batch_scan_entry_t; |
| 54 | +typedef struct { |
| 55 | + swiftscan_batch_scan_entry_t *modules; |
| 56 | + size_t count; |
| 57 | +} swiftscan_batch_scan_input_t; |
| 58 | +typedef struct { |
| 59 | + swiftscan_dependency_graph_t *results; |
| 60 | + size_t count; |
| 61 | +} swiftscan_batch_scan_result_t; |
| 62 | + |
| 63 | +//=== Scanner Invocation Specification ------------------------------------===// |
| 64 | + |
| 65 | +typedef struct swiftscan_scan_invocation_s *swiftscan_scan_invocation_t; |
| 66 | +typedef void *swiftscan_scanner_t; |
| 67 | + |
| 68 | +//=== libSwiftScan Functions ------------------------------------------------===// |
| 69 | + |
| 70 | +typedef struct { |
| 71 | + |
| 72 | + //=== Dependency Result Functions -----------------------------------------===// |
| 73 | + swiftscan_string_ref_t |
| 74 | + (*swiftscan_dependency_graph_get_main_module_name)(swiftscan_dependency_graph_t); |
| 75 | + swiftscan_dependency_set_t * |
| 76 | + (*swiftscan_dependency_graph_get_dependencies)(swiftscan_dependency_graph_t); |
| 77 | + |
| 78 | + //=== Dependency Module Info Functions ------------------------------------===// |
| 79 | + swiftscan_string_ref_t |
| 80 | + (*swiftscan_module_info_get_module_name)(swiftscan_dependency_info_t); |
| 81 | + swiftscan_string_ref_t |
| 82 | + (*swiftscan_module_info_get_module_path)(swiftscan_dependency_info_t); |
| 83 | + swiftscan_string_set_t * |
| 84 | + (*swiftscan_module_info_get_source_files)(swiftscan_dependency_info_t); |
| 85 | + swiftscan_string_set_t * |
| 86 | + (*swiftscan_module_info_get_direct_dependencies)(swiftscan_dependency_info_t); |
| 87 | + swiftscan_module_details_t |
| 88 | + (*swiftscan_module_info_get_details)(swiftscan_dependency_info_t); |
| 89 | + |
| 90 | + //=== Dependency Module Info Details Functions ----------------------------===// |
| 91 | + swiftscan_dependency_info_kind_t |
| 92 | + (*swiftscan_module_detail_get_kind)(swiftscan_module_details_t); |
| 93 | + |
| 94 | + //=== Swift Textual Module Details query APIs -----------------------------===// |
| 95 | + swiftscan_string_ref_t |
| 96 | + (*swiftscan_swift_textual_detail_get_module_interface_path)(swiftscan_module_details_t); |
| 97 | + swiftscan_string_set_t * |
| 98 | + (*swiftscan_swift_textual_detail_get_compiled_module_candidates)(swiftscan_module_details_t); |
| 99 | + swiftscan_string_ref_t |
| 100 | + (*swiftscan_swift_textual_detail_get_bridging_header_path)(swiftscan_module_details_t); |
| 101 | + swiftscan_string_set_t * |
| 102 | + (*swiftscan_swift_textual_detail_get_bridging_source_files)(swiftscan_module_details_t); |
| 103 | + swiftscan_string_set_t * |
| 104 | + (*swiftscan_swift_textual_detail_get_bridging_module_dependencies)(swiftscan_module_details_t); |
| 105 | + swiftscan_string_set_t * |
| 106 | + (*swiftscan_swift_textual_detail_get_command_line)(swiftscan_module_details_t); |
| 107 | + swiftscan_string_set_t * |
| 108 | + (*swiftscan_swift_textual_detail_get_extra_pcm_args)(swiftscan_module_details_t); |
| 109 | + swiftscan_string_ref_t |
| 110 | + (*swiftscan_swift_textual_detail_get_context_hash)(swiftscan_module_details_t); |
| 111 | + bool |
| 112 | + (*swiftscan_swift_textual_detail_get_is_framework)(swiftscan_module_details_t); |
| 113 | + |
| 114 | + //=== Swift Binary Module Details query APIs ------------------------------===// |
| 115 | + swiftscan_string_ref_t |
| 116 | + (*swiftscan_swift_binary_detail_get_compiled_module_path)(swiftscan_module_details_t); |
| 117 | + swiftscan_string_ref_t |
| 118 | + (*swiftscan_swift_binary_detail_get_module_doc_path)(swiftscan_module_details_t); |
| 119 | + swiftscan_string_ref_t |
| 120 | + (*swiftscan_swift_binary_detail_get_module_source_info_path)(swiftscan_module_details_t); |
| 121 | + |
| 122 | + //=== Swift Placeholder Module Details query APIs -------------------------===// |
| 123 | + swiftscan_string_ref_t |
| 124 | + (*swiftscan_swift_placeholder_detail_get_compiled_module_path)(swiftscan_module_details_t); |
| 125 | + swiftscan_string_ref_t |
| 126 | + (*swiftscan_swift_placeholder_detail_get_module_doc_path)(swiftscan_module_details_t); |
| 127 | + swiftscan_string_ref_t |
| 128 | + (*swiftscan_swift_placeholder_detail_get_module_source_info_path)(swiftscan_module_details_t); |
| 129 | + |
| 130 | + //=== Clang Module Details query APIs -------------------------------------===// |
| 131 | + swiftscan_string_ref_t |
| 132 | + (*swiftscan_clang_detail_get_module_map_path)(swiftscan_module_details_t); |
| 133 | + swiftscan_string_ref_t |
| 134 | + (*swiftscan_clang_detail_get_context_hash)(swiftscan_module_details_t); |
| 135 | + swiftscan_string_set_t * |
| 136 | + (*swiftscan_clang_detail_get_command_line)(swiftscan_module_details_t); |
| 137 | + |
| 138 | + //=== Batch Scan Input Functions ------------------------------------------===// |
| 139 | + swiftscan_batch_scan_input_t * |
| 140 | + (*swiftscan_batch_scan_input_create)(void); |
| 141 | + void |
| 142 | + (*swiftscan_batch_scan_input_set_modules)(swiftscan_batch_scan_input_t *, int, swiftscan_batch_scan_entry_t *); |
| 143 | + |
| 144 | + //=== Batch Scan Entry Functions ------------------------------------------===// |
| 145 | + swiftscan_batch_scan_entry_t |
| 146 | + (*swiftscan_batch_scan_entry_create)(void); |
| 147 | + void |
| 148 | + (*swiftscan_batch_scan_entry_set_module_name)(swiftscan_batch_scan_entry_t, const char *); |
| 149 | + void |
| 150 | + (*swiftscan_batch_scan_entry_set_arguments)(swiftscan_batch_scan_entry_t, const char *); |
| 151 | + void |
| 152 | + (*swiftscan_batch_scan_entry_set_is_swift)(swiftscan_batch_scan_entry_t, bool); |
| 153 | + swiftscan_string_ref_t |
| 154 | + (*swiftscan_batch_scan_entry_get_module_name)(swiftscan_batch_scan_entry_t); |
| 155 | + swiftscan_string_ref_t |
| 156 | + (*swiftscan_batch_scan_entry_get_arguments)(swiftscan_batch_scan_entry_t); |
| 157 | + bool |
| 158 | + (*swiftscan_batch_scan_entry_get_is_swift)(swiftscan_batch_scan_entry_t); |
| 159 | + |
| 160 | + //=== Prescan Result Functions --------------------------------------------===// |
| 161 | + swiftscan_string_set_t * |
| 162 | + (*swiftscan_import_set_get_imports)(swiftscan_import_set_t); |
| 163 | + |
| 164 | + //=== Scanner Invocation Functions ----------------------------------------===// |
| 165 | + swiftscan_scan_invocation_t |
| 166 | + (*swiftscan_scan_invocation_create)(); |
| 167 | + void |
| 168 | + (*swiftscan_scan_invocation_set_working_directory)(swiftscan_scan_invocation_t, const char *); |
| 169 | + void |
| 170 | + (*swiftscan_scan_invocation_set_argv)(swiftscan_scan_invocation_t, int, const char **); |
| 171 | + swiftscan_string_ref_t |
| 172 | + (*swiftscan_scan_invocation_get_working_directory)(swiftscan_scan_invocation_t); |
| 173 | + int |
| 174 | + (*swiftscan_scan_invocation_get_argc)(swiftscan_scan_invocation_t); |
| 175 | + swiftscan_string_set_t * |
| 176 | + (*swiftscan_scan_invocation_get_argv)(swiftscan_scan_invocation_t); |
| 177 | + |
| 178 | + //=== Cleanup Functions ---------------------------------------------------===// |
| 179 | + void |
| 180 | + (*swiftscan_dependency_graph_dispose)(swiftscan_dependency_graph_t); |
| 181 | + void |
| 182 | + (*swiftscan_import_set_dispose)(swiftscan_import_set_t); |
| 183 | + void |
| 184 | + (*swiftscan_batch_scan_entry_dispose)(swiftscan_batch_scan_entry_t); |
| 185 | + void |
| 186 | + (*swiftscan_batch_scan_input_dispose)(swiftscan_batch_scan_input_t *); |
| 187 | + void |
| 188 | + (*swiftscan_batch_scan_result_dispose)(swiftscan_batch_scan_result_t *); |
| 189 | + void |
| 190 | + (*swiftscan_scan_invocation_dispose)(swiftscan_scan_invocation_t); |
| 191 | + |
| 192 | + //=== Scanner Functions ---------------------------------------------------===// |
| 193 | + swiftscan_scanner_t (*swiftscan_scanner_create)(void); |
| 194 | + void (*swiftscan_scanner_dispose)(swiftscan_scanner_t); |
| 195 | + |
| 196 | + swiftscan_dependency_graph_t |
| 197 | + (*swiftscan_dependency_graph_create)(swiftscan_scanner_t, swiftscan_scan_invocation_t); |
| 198 | + |
| 199 | + swiftscan_batch_scan_result_t * |
| 200 | + (*swiftscan_batch_scan_result_create)(swiftscan_scanner_t, |
| 201 | + swiftscan_batch_scan_input_t *, |
| 202 | + swiftscan_scan_invocation_t); |
| 203 | + |
| 204 | + swiftscan_import_set_t |
| 205 | + (*swiftscan_import_set_create)(swiftscan_scanner_t, swiftscan_scan_invocation_t); |
| 206 | +} swiftscan_functions_t; |
| 207 | + |
| 208 | +#endif // SWIFT_C_DEPENDENCY_SCAN_H |
0 commit comments