mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Interop][SwiftToCxx] Implement enum case switching
This commit is contained in:
@@ -62,11 +62,12 @@ static void printKnownType(
|
||||
printKnownStruct(typeMapping, os, name, typeRecord);
|
||||
}
|
||||
|
||||
static void printValueWitnessTableFunctionType(raw_ostream &os, StringRef name,
|
||||
StringRef returnType,
|
||||
std::string paramTypes,
|
||||
uint16_t ptrauthDisc) {
|
||||
os << "using ValueWitness" << name << "Ty = " << returnType
|
||||
static void
|
||||
printValueWitnessTableFunctionType(raw_ostream &os, StringRef prefix,
|
||||
StringRef name, StringRef returnType,
|
||||
std::string paramTypes,
|
||||
uint16_t ptrauthDisc) {
|
||||
os << "using " << prefix << name << "Ty = " << returnType
|
||||
<< "(* __ptrauth_swift_value_witness_function_pointer(" << ptrauthDisc
|
||||
<< "))(" << paramTypes << ");\n";
|
||||
}
|
||||
@@ -87,7 +88,7 @@ static void printValueWitnessTable(raw_ostream &os) {
|
||||
membersOS << " " << type << " " << #lowerId << ";\n";
|
||||
#define FUNCTION_VALUE_WITNESS(lowerId, upperId, returnType, paramTypes) \
|
||||
printValueWitnessTableFunctionType( \
|
||||
os, #upperId, returnType, makeParams paramTypes, \
|
||||
os, "ValueWitness", #upperId, returnType, makeParams paramTypes, \
|
||||
SpecialPointerAuthDiscriminators::upperId); \
|
||||
membersOS << " ValueWitness" << #upperId << "Ty _Nonnull " << #lowerId \
|
||||
<< ";\n";
|
||||
@@ -102,7 +103,32 @@ static void printValueWitnessTable(raw_ostream &os) {
|
||||
#define VOID_TYPE "void"
|
||||
#include "swift/ABI/ValueWitness.def"
|
||||
|
||||
os << "\nstruct ValueWitnessTable {\n" << membersOS.str() << "};\n";
|
||||
os << "\nstruct ValueWitnessTable {\n" << membersOS.str() << "};\n\n";
|
||||
membersOS.str().clear();
|
||||
|
||||
#define WANT_ONLY_ENUM_VALUE_WITNESSES
|
||||
#define DATA_VALUE_WITNESS(lowerId, upperId, type) \
|
||||
membersOS << " " << type << " " << #lowerId << ";\n";
|
||||
#define FUNCTION_VALUE_WITNESS(lowerId, upperId, returnType, paramTypes) \
|
||||
printValueWitnessTableFunctionType( \
|
||||
os, "EnumValueWitness", #upperId, returnType, makeParams paramTypes, \
|
||||
SpecialPointerAuthDiscriminators::upperId); \
|
||||
membersOS << " EnumValueWitness" << #upperId << "Ty _Nonnull " << #lowerId \
|
||||
<< ";\n";
|
||||
#define MUTABLE_VALUE_TYPE "void * _Nonnull"
|
||||
#define IMMUTABLE_VALUE_TYPE "const void * _Nonnull"
|
||||
#define MUTABLE_BUFFER_TYPE "void * _Nonnull"
|
||||
#define IMMUTABLE_BUFFER_TYPE "const void * _Nonnull"
|
||||
#define TYPE_TYPE "void * _Nonnull"
|
||||
#define SIZE_TYPE "size_t"
|
||||
#define INT_TYPE "int"
|
||||
#define UINT_TYPE "unsigned"
|
||||
#define VOID_TYPE "void"
|
||||
#include "swift/ABI/ValueWitness.def"
|
||||
|
||||
os << "\nstruct EnumValueWitnessTable {\n"
|
||||
<< " ValueWitnessTable vwTable;\n"
|
||||
<< membersOS.str() << "};\n\n";
|
||||
}
|
||||
|
||||
static void printTypeMetadataResponseType(SwiftToClangInteropContext &ctx,
|
||||
|
||||
Reference in New Issue
Block a user