Files
swift-mirror/include/swift/Basic/SwiftObjectHeader.h
Rintaro Ishizaki 7486cd1c21 [SwiftCompiler] Move common bridging facilities to 'Basic'
A preparation for AST/DiagnosticEngine bridging
2022-02-20 22:06:39 -08:00

35 lines
1.2 KiB
C

//===--- 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