mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[SwiftCompiler] Move common bridging facilities to 'Basic'
A preparation for AST/DiagnosticEngine bridging
This commit is contained in:
34
include/swift/Basic/SwiftObjectHeader.h
Normal file
34
include/swift/Basic/SwiftObjectHeader.h
Normal file
@@ -0,0 +1,34 @@
|
||||
//===--- SwiftObjectHeader.h - Defines SwiftObjectHeader ------------------===//
|
||||
//
|
||||
// This source file is part of the Swift.org open source project
|
||||
//
|
||||
// Copyright (c) 2014 - 2021 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_BASIC_SWIFTOBJECTHEADER_H
|
||||
#define SWIFT_BASIC_SWIFTOBJECTHEADER_H
|
||||
|
||||
#include "BridgedSwiftObject.h"
|
||||
|
||||
/// The C++ version of SwiftObject.
|
||||
///
|
||||
/// It is used for bridging the SIL core classes (e.g. SILFunction, SILNode,
|
||||
/// etc.) with Swift.
|
||||
/// For details see SwiftCompilerSources/README.md.
|
||||
///
|
||||
/// In C++ code, never use BridgedSwiftObject directly. SwiftObjectHeader has
|
||||
/// the proper constructor, which avoids the header to be uninitialized.
|
||||
struct SwiftObjectHeader : BridgedSwiftObject {
|
||||
SwiftObjectHeader(SwiftMetatype metatype) {
|
||||
this->metatype = metatype;
|
||||
this->refCounts = ~(uint64_t)0;
|
||||
}
|
||||
|
||||
bool isBridged() const { return metatype != nullptr; }
|
||||
};
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user