You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Unfortunately Image is not available in C++, as it is a protocol. I don't know how users are going to implement Image or if there are different implementations of Image (e.g. one that wraps UIImage, one that wraps CGImage, ...), so I need to stay at interface-level (or "protocol"-level).
I am not a compiler engineer nor do I understand the memory layout of protocols, so I am not even sure if it is possible to expose Swift protocols to C++, so that's why I'm creating this enhancement idea as a place for discussion.
Proposed solution
It would be cool if Swift protocols would be exposed to C++.
I have no idea how to represent protocols, if it's templated classes, compiler macros, or abstract/virtual classes, or if it's not possible at all.
Alternatives considered
I thought about using inheritance, but inheritance casting also doesn't work on Swift classes through C++.
Additional information
No response
The text was updated successfully, but these errors were encountered:
Motivation
I'm building a framework where people can build modules using Swift. Those modules are then exposed to JavaScript, using a C++ based interface.
For example, if a developer wants to implement an Image editing module, they can declare the module definition like this:
..and I now want to expose that to C++, by wrapping it in a C++ class.
Unfortunately
Image
is not available in C++, as it is a protocol. I don't know how users are going to implementImage
or if there are different implementations ofImage
(e.g. one that wrapsUIImage
, one that wrapsCGImage
, ...), so I need to stay at interface-level (or "protocol"-level).I am not a compiler engineer nor do I understand the memory layout of protocols, so I am not even sure if it is possible to expose Swift protocols to C++, so that's why I'm creating this enhancement idea as a place for discussion.
Proposed solution
It would be cool if Swift protocols would be exposed to C++.
I have no idea how to represent protocols, if it's templated classes, compiler macros, or abstract/virtual classes, or if it's not possible at all.
Alternatives considered
I thought about using inheritance, but inheritance casting also doesn't work on Swift classes through C++.
Additional information
No response
The text was updated successfully, but these errors were encountered: