Hi everyone!
For GSOC we decided to start by implementing @Joe_Groff's idea, and I have a couple of questions.
I started by writing a function that returns a pointer to swift::MetadataSections
that is accessible to Swift:
// in ImageInspectionElf.cpp
const swift::MetadataSections *swift_getMetadataSection() {
return registered;
}
// in Misc.swift, is this the correct place?
@_silgen_name("swift_getMetadataSection")
public func _getMetadataSection() -> UnsafeRawPointer?
I also wrote on the Swift side a struct that is exactly the same as MetadataSections
(defined in ImageInspectionElf.h
) so I can get a typed structure to work with in Swift. I checked that all the fields match in Swift and C++, and they do, but I'd like to ask you if you think if this is too fragile. If someone changes the fields of swift::MetadataSections
, or even their order, this would break the Swift version. So is this ok, and if not, what's the usual way to access a typed structure from C++ in Swift?
I also have a second question: should I modify SwiftReflectionTest.swift
with a bunch of #if macOS ... #elif Linux
etc, or should I write a second file that compiles on Linux (and maybe Windows) and implements the same API?