Skip to content

A few miscellaneous updates #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 5, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/IndexStoreDB/IndexStoreDB.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import Bionic
import Darwin.POSIX
#endif

public struct PathMapping {
public struct PathMapping: Equatable {
/// Path prefix to be replaced, typically the canonical or hermetic path.
let original: String

Expand Down
6 changes: 6 additions & 0 deletions Sources/IndexStoreDB_CIndexStoreDB/CIndexStoreDB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ indexstoredb_index_create(const char *storePath, const char *databasePath,
return nullptr;
}

indexstoredb_index_t
indexstoredb_index_create_from_existing(void *opaqueIndexSystem) {
std::shared_ptr<IndexSystem> *indexSystem = static_cast<std::shared_ptr<IndexSystem> *>(opaqueIndexSystem);
return make_object(*indexSystem);
}

void indexstoredb_index_add_delegate(indexstoredb_index_t index,
indexstoredb_delegate_event_receiver_t delegateCallback) {
auto delegate = std::make_shared<BlockIndexSystemDelegate>(delegateCallback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,12 @@ indexstoredb_index_create(const char * _Nonnull storePath,
indexstoredb_creation_options_t _Nonnull options,
indexstoredb_error_t _Nullable * _Nullable);

/// Create an `indexstoredb_index_t` from an existing `std::shared_ptr<IndexSystem>`.
///
/// `opaqueIndexSystem` must be a `std::shared_ptr<IndexSystem> *`.
INDEXSTOREDB_PUBLIC _Nonnull indexstoredb_index_t
indexstoredb_index_create_from_existing(void *_Nonnull opaqueIndexSystem);

/// Add an additional delegate to the given index.
INDEXSTOREDB_PUBLIC void
indexstoredb_index_add_delegate(_Nonnull indexstoredb_index_t index,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class IndexStoreCreationOptions {

bool hasPrefixMappings() const { return !prefixMap.empty(); }

const std::vector<std::pair<std::string, std::string>> &getPrefixMap() const { return prefixMap; }

/// Convert this into a `indexstore_creation_options_t` that the caller
/// owns and is responsible for disposing.
indexstore_creation_options_t createOptions(const indexstore_functions_t &api) const {
Expand Down