Files
swift-mirror/include/swift/Bridging/MacroEvaluation.h
Doug Gregor 3082b04b75 [Macros] Feed the static build configuration into macro expansions
Thread the static build configuration (formed from language options) in
to the macro plugin handler, which will serialize it for use in the
macro implementation. test this with a simple macro that checks
whether a particular custom configuration (set via `-D`) is enabled or
not.

This required some re-layering, sinking the logic for building a
StaticBuildConfiguration from language options down into a new
swiftBasicSwift library, which sits on top of the C++ swiftBasic and
provides Swift functionality for it. That can be used by the C++
swiftAST to cache the StaticBuildConfiguration on the ASTContext,
making it available for other parts of ASTGen.
2025-09-29 18:42:15 -07:00

73 lines
2.8 KiB
C++

//===--- MacroEvaluation.h --------------------------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2024 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 the list of Swift project authors
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_BRIDGING_MACROS_H
#define SWIFT_BRIDGING_MACROS_H
#include "swift/Basic/BasicBridging.h"
#include "swift/AST/ASTBridging.h"
#ifdef __cplusplus
extern "C" {
#endif
void *_Nonnull swift_Macros_resolveExternalMacro(
const char *_Nonnull moduleName, const char *_Nonnull typeName,
void *_Nonnull opaquePluginHandle);
void swift_Macros_destroyExternalMacro(void *_Nonnull macro);
bool swift_Macros_checkDefaultArgumentMacroExpression(
void *_Nonnull diagEngine, void *_Nonnull sourceFile,
const void *_Nonnull macroSourceLocation);
ptrdiff_t swift_Macros_checkMacroDefinition(
void *_Nonnull diagEngine, BridgedStringRef sourceFileBuffer,
BridgedStringRef macroDeclText,
BridgedStringRef *_Nonnull expansionSourceOutPtr,
ptrdiff_t *_Nullable *_Nonnull replacementsPtr,
ptrdiff_t *_Nonnull numReplacements,
ptrdiff_t *_Nullable *_Nonnull genericReplacementsPtr,
ptrdiff_t *_Nonnull numGenericReplacements);
void swift_Macros_freeExpansionReplacements(
ptrdiff_t *_Nullable replacementsPtr, ptrdiff_t numReplacements);
ptrdiff_t swift_Macros_expandFreestandingMacro(
BridgedASTContext cContext, const void *_Nonnull macro,
const char *_Nonnull discriminator, uint8_t rawMacroRole,
void *_Nonnull sourceFile, const void *_Nullable sourceLocation,
BridgedStringRef *_Nonnull evaluatedSourceOut);
ptrdiff_t swift_Macros_expandAttachedMacro(
BridgedASTContext cContext, const void *_Nonnull macro,
const char *_Nonnull discriminator, const char *_Nonnull qualifiedType,
const char *_Nonnull conformances, uint8_t rawMacroRole,
void *_Nonnull customAttrSourceFile,
const void *_Nullable customAttrSourceLocation,
void *_Nonnull declarationSourceFile,
const void *_Nullable declarationSourceLocation,
void *_Nullable parentDeclSourceFile,
const void *_Nullable parentDeclSourceLocation,
BridgedStringRef *_Nonnull evaluatedSourceOut);
bool swift_Macros_initializePlugin(void *_Nonnull handle,
void *_Nullable diagEngine);
void swift_Macros_deinitializePlugin(void *_Nonnull handle);
bool swift_Macros_pluginServerLoadLibraryPlugin(
void *_Nonnull handle, const char *_Nonnull libraryPath,
const char *_Nonnull moduleName, BridgedStringRef *_Nullable errorOut);
#ifdef __cplusplus
}
#endif
#endif // SWIFT_BRIDGING_MACROS_H