|
| 1 | +//===----------------------------------------------------------------------===// |
| 2 | +// |
| 3 | +// This source file is part of the Swift open source project |
| 4 | +// |
| 5 | +// Copyright (c) 2025 Apple Inc. and the Swift project authors |
| 6 | +// Licensed under Apache License v2.0 with Runtime Library Exception |
| 7 | +// |
| 8 | +// See http://swift.org/LICENSE.txt for license information |
| 9 | +// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors |
| 10 | +// |
| 11 | +//===----------------------------------------------------------------------===// |
| 12 | + |
| 13 | +#ifndef INDEXSTORE_H |
| 14 | +#define INDEXSTORE_H |
| 15 | + |
| 16 | +#include <stdbool.h> |
| 17 | +#include <stddef.h> |
| 18 | +#include <stdint.h> |
| 19 | +#include <time.h> |
| 20 | + |
| 21 | +typedef void *indexstore_error_t; |
| 22 | + |
| 23 | +typedef struct { |
| 24 | + const char *data; |
| 25 | + size_t length; |
| 26 | +} indexstore_string_ref_t; |
| 27 | + |
| 28 | +typedef void *indexstore_t; |
| 29 | +typedef void *indexstore_symbol_t; |
| 30 | + |
| 31 | +typedef enum { |
| 32 | + INDEXSTORE_SYMBOL_KIND_UNKNOWN = 0, |
| 33 | + INDEXSTORE_SYMBOL_KIND_MODULE = 1, |
| 34 | + INDEXSTORE_SYMBOL_KIND_NAMESPACE = 2, |
| 35 | + INDEXSTORE_SYMBOL_KIND_NAMESPACEALIAS = 3, |
| 36 | + INDEXSTORE_SYMBOL_KIND_MACRO = 4, |
| 37 | + INDEXSTORE_SYMBOL_KIND_ENUM = 5, |
| 38 | + INDEXSTORE_SYMBOL_KIND_STRUCT = 6, |
| 39 | + INDEXSTORE_SYMBOL_KIND_CLASS = 7, |
| 40 | + INDEXSTORE_SYMBOL_KIND_PROTOCOL = 8, |
| 41 | + INDEXSTORE_SYMBOL_KIND_EXTENSION = 9, |
| 42 | + INDEXSTORE_SYMBOL_KIND_UNION = 10, |
| 43 | + INDEXSTORE_SYMBOL_KIND_TYPEALIAS = 11, |
| 44 | + INDEXSTORE_SYMBOL_KIND_FUNCTION = 12, |
| 45 | + INDEXSTORE_SYMBOL_KIND_VARIABLE = 13, |
| 46 | + INDEXSTORE_SYMBOL_KIND_FIELD = 14, |
| 47 | + INDEXSTORE_SYMBOL_KIND_ENUMCONSTANT = 15, |
| 48 | + INDEXSTORE_SYMBOL_KIND_INSTANCEMETHOD = 16, |
| 49 | + INDEXSTORE_SYMBOL_KIND_CLASSMETHOD = 17, |
| 50 | + INDEXSTORE_SYMBOL_KIND_STATICMETHOD = 18, |
| 51 | + INDEXSTORE_SYMBOL_KIND_INSTANCEPROPERTY = 19, |
| 52 | + INDEXSTORE_SYMBOL_KIND_CLASSPROPERTY = 20, |
| 53 | + INDEXSTORE_SYMBOL_KIND_STATICPROPERTY = 21, |
| 54 | + INDEXSTORE_SYMBOL_KIND_CONSTRUCTOR = 22, |
| 55 | + INDEXSTORE_SYMBOL_KIND_DESTRUCTOR = 23, |
| 56 | + INDEXSTORE_SYMBOL_KIND_CONVERSIONFUNCTION = 24, |
| 57 | + INDEXSTORE_SYMBOL_KIND_PARAMETER = 25, |
| 58 | + INDEXSTORE_SYMBOL_KIND_USING = 26, |
| 59 | + |
| 60 | + INDEXSTORE_SYMBOL_KIND_COMMENTTAG = 1000, |
| 61 | +} indexstore_symbol_kind_t; |
| 62 | + |
| 63 | +typedef enum { |
| 64 | + INDEXSTORE_SYMBOL_PROPERTY_GENERIC = 1 << 0, |
| 65 | + INDEXSTORE_SYMBOL_PROPERTY_TEMPLATE_PARTIAL_SPECIALIZATION = 1 << 1, |
| 66 | + INDEXSTORE_SYMBOL_PROPERTY_TEMPLATE_SPECIALIZATION = 1 << 2, |
| 67 | + INDEXSTORE_SYMBOL_PROPERTY_UNITTEST = 1 << 3, |
| 68 | + INDEXSTORE_SYMBOL_PROPERTY_IBANNOTATED = 1 << 4, |
| 69 | + INDEXSTORE_SYMBOL_PROPERTY_IBOUTLETCOLLECTION = 1 << 5, |
| 70 | + INDEXSTORE_SYMBOL_PROPERTY_GKINSPECTABLE = 1 << 6, |
| 71 | + INDEXSTORE_SYMBOL_PROPERTY_LOCAL = 1 << 7, |
| 72 | + INDEXSTORE_SYMBOL_PROPERTY_PROTOCOL_INTERFACE = 1 << 8, |
| 73 | + INDEXSTORE_SYMBOL_PROPERTY_SWIFT_ASYNC = 1 << 16, |
| 74 | +} indexstore_symbol_property_t; |
| 75 | + |
| 76 | +typedef enum { |
| 77 | + INDEXSTORE_SYMBOL_ROLE_DECLARATION = 1 << 0, |
| 78 | + INDEXSTORE_SYMBOL_ROLE_DEFINITION = 1 << 1, |
| 79 | + INDEXSTORE_SYMBOL_ROLE_REFERENCE = 1 << 2, |
| 80 | + INDEXSTORE_SYMBOL_ROLE_READ = 1 << 3, |
| 81 | + INDEXSTORE_SYMBOL_ROLE_WRITE = 1 << 4, |
| 82 | + INDEXSTORE_SYMBOL_ROLE_CALL = 1 << 5, |
| 83 | + INDEXSTORE_SYMBOL_ROLE_DYNAMIC = 1 << 6, |
| 84 | + INDEXSTORE_SYMBOL_ROLE_ADDRESSOF = 1 << 7, |
| 85 | + INDEXSTORE_SYMBOL_ROLE_IMPLICIT = 1 << 8, |
| 86 | + INDEXSTORE_SYMBOL_ROLE_UNDEFINITION = 1 << 19, |
| 87 | + |
| 88 | + // Relation roles. |
| 89 | + INDEXSTORE_SYMBOL_ROLE_REL_CHILDOF = 1 << 9, |
| 90 | + INDEXSTORE_SYMBOL_ROLE_REL_BASEOF = 1 << 10, |
| 91 | + INDEXSTORE_SYMBOL_ROLE_REL_OVERRIDEOF = 1 << 11, |
| 92 | + INDEXSTORE_SYMBOL_ROLE_REL_RECEIVEDBY = 1 << 12, |
| 93 | + INDEXSTORE_SYMBOL_ROLE_REL_CALLEDBY = 1 << 13, |
| 94 | + INDEXSTORE_SYMBOL_ROLE_REL_EXTENDEDBY = 1 << 14, |
| 95 | + INDEXSTORE_SYMBOL_ROLE_REL_ACCESSOROF = 1 << 15, |
| 96 | + INDEXSTORE_SYMBOL_ROLE_REL_CONTAINEDBY = 1 << 16, |
| 97 | + INDEXSTORE_SYMBOL_ROLE_REL_IBTYPEOF = 1 << 17, |
| 98 | + INDEXSTORE_SYMBOL_ROLE_REL_SPECIALIZATIONOF = 1 << 18, |
| 99 | +} indexstore_symbol_role_t; |
| 100 | + |
| 101 | +typedef void *indexstore_unit_dependency_t; |
| 102 | + |
| 103 | +typedef enum { |
| 104 | + INDEXSTORE_UNIT_DEPENDENCY_UNIT = 1, |
| 105 | + INDEXSTORE_UNIT_DEPENDENCY_RECORD = 2, |
| 106 | + INDEXSTORE_UNIT_DEPENDENCY_FILE = 3, |
| 107 | +} indexstore_unit_dependency_kind_t; |
| 108 | + |
| 109 | +typedef void *indexstore_symbol_relation_t; |
| 110 | +typedef void *indexstore_occurrence_t; |
| 111 | +typedef void *indexstore_record_reader_t; |
| 112 | +typedef void *indexstore_unit_reader_t; |
| 113 | + |
| 114 | +typedef struct { |
| 115 | + const char * |
| 116 | + (*error_get_description)(indexstore_error_t); |
| 117 | + |
| 118 | + void |
| 119 | + (*error_dispose)(indexstore_error_t); |
| 120 | + |
| 121 | + indexstore_t |
| 122 | + (*store_create)(const char *store_path, indexstore_error_t *error); |
| 123 | + |
| 124 | + void |
| 125 | + (*store_dispose)(indexstore_t); |
| 126 | + |
| 127 | + size_t |
| 128 | + (*store_get_unit_name_from_output_path)(indexstore_t store, |
| 129 | + const char *output_path, |
| 130 | + char *name_buf, |
| 131 | + size_t buf_size); |
| 132 | + |
| 133 | + indexstore_symbol_kind_t |
| 134 | + (*symbol_get_kind)(indexstore_symbol_t); |
| 135 | + |
| 136 | + uint64_t |
| 137 | + (*symbol_get_properties)(indexstore_symbol_t); |
| 138 | + |
| 139 | + indexstore_string_ref_t |
| 140 | + (*symbol_get_name)(indexstore_symbol_t); |
| 141 | + |
| 142 | + uint64_t |
| 143 | + (*symbol_relation_get_roles)(indexstore_symbol_relation_t); |
| 144 | + |
| 145 | + indexstore_symbol_t |
| 146 | + (*symbol_relation_get_symbol)(indexstore_symbol_relation_t); |
| 147 | + |
| 148 | + indexstore_symbol_t |
| 149 | + (*occurrence_get_symbol)(indexstore_occurrence_t); |
| 150 | + |
| 151 | + bool |
| 152 | + (*occurrence_relations_apply_f)(indexstore_occurrence_t, |
| 153 | + void *context, |
| 154 | + bool(*applier)(void *context, indexstore_symbol_relation_t symbol_rel)); |
| 155 | + |
| 156 | + indexstore_record_reader_t |
| 157 | + (*record_reader_create)(indexstore_t store, const char *record_name, |
| 158 | + indexstore_error_t *error); |
| 159 | + |
| 160 | + void |
| 161 | + (*record_reader_dispose)(indexstore_record_reader_t); |
| 162 | + |
| 163 | + bool |
| 164 | + (*record_reader_occurrences_apply_f)(indexstore_record_reader_t, |
| 165 | + void *context, |
| 166 | + bool(*applier)(void *context, indexstore_occurrence_t occur)); |
| 167 | + |
| 168 | + indexstore_unit_reader_t |
| 169 | + (*unit_reader_create)(indexstore_t store, const char *unit_name, |
| 170 | + indexstore_error_t *error); |
| 171 | + |
| 172 | + void |
| 173 | + (*unit_reader_dispose)(indexstore_unit_reader_t); |
| 174 | + |
| 175 | + indexstore_string_ref_t |
| 176 | + (*unit_reader_get_module_name)(indexstore_unit_reader_t); |
| 177 | + |
| 178 | + indexstore_unit_dependency_kind_t |
| 179 | + (*unit_dependency_get_kind)(indexstore_unit_dependency_t); |
| 180 | + |
| 181 | + indexstore_string_ref_t |
| 182 | + (*unit_dependency_get_name)(indexstore_unit_dependency_t); |
| 183 | + |
| 184 | + bool |
| 185 | + (*unit_reader_dependencies_apply)(indexstore_unit_reader_t, |
| 186 | + bool(^applier)(indexstore_unit_dependency_t)); |
| 187 | + |
| 188 | + bool |
| 189 | + (*unit_reader_dependencies_apply_f)(indexstore_unit_reader_t, |
| 190 | + void *context, |
| 191 | + bool(*applier)(void *context, indexstore_unit_dependency_t)); |
| 192 | +} indexstore_functions_t; |
| 193 | + |
| 194 | +#endif |
0 commit comments