Comments (1)
Some observations:
-
You can't retroactively add protocol conformances to
xpc_object_t
(and its variants):// error: extension of protocol 'OS_xpc_object' cannot have an inheritance clause extension xpc_connection_t: Codable { }
-
You can use a property wrapper (which itself can be codable, even if its wrappedValue is not).
The only solution approaches I can think of involve wrapping the xpc_connection_t
(or xpc_endpoint_t
; I propose we make both codable). Either explicitly by the user, or implicitly via a property wrapper. I don't see any down-side to the latter over the former, so I propose we go with a property wrapper.
I see two ways we can make this work:
- "Fake" the implementation of
Codable
on the property wrapper- Make the
init(from:)
andencode(to:)
callfatalError()
.- The message should inform users that these values can only ever be encoded/decoded by the SecureXPC library.
- Add special-cases to the
XPCEncoder
/XPCDecoder
(well really, their containers), such that they intercept these values and never actually call theirinit(from:)
orencode(to:)
methods. - I haven't had time to spike this one out yet
- Make the
- Conform to
Codable
for real- Make the
init(from:)
andencode(to:)
cast theirEncoder
/Decoder
param to a concreteXPCEncoderImpl
/XPCDecoderImpl
. If the cast fails,fatalError()
out.- Again, the message should inform users that these values can only ever be encoded/decoded by the SecureXPC library.
- Make a single value container (in either case), and down cast to the
XPCSingleValueEncodingContainer
/XPCSingleValueDecodingContainer
(this is safe to force-cast) - Don't special case anything. Let the default implementation of
Codable
take its course.init(from:)
andencode(to:)
will be called like normal. - Add methods to
XPCEncoder
/XPCDecoder
(their containers) that handlexpc_connection_t
andxpc_endpoint_t
. Use these to implementinit(from:)
andencode(to:)
- I made a proof of concept of this for
xpc_connection_t
, here: #13
- Make the
from securexpc.
Related Issues (20)
- Add async variants of `XPCClient.send/sendMessage(...)` functions HOT 1
- Type errors in routes are conflated with missing routes HOT 2
- Add real XPC integration tests HOT 8
- Sample use case
- Verify that exporting a connection for a Mach service works correctly HOT 2
- Add support for client security requirements in anonymous services
- Throw error when attempting to reconnect to an anonymous service
- Document `startAndBlock()` must be called from main thread
- Verify that `endpoint` works for `XPCServiceServer` HOT 1
- Creating an `XPCAnonymousServer` or `XPCMachServer` and never starting it results in XPC API Misuse
- Client-level error handling HOT 6
- `XPC_ERROR_CONNECTION_INTERRUPTED` doesn't appear to actually behave as documented HOT 4
- [help] How can I use FileHandle as argument of withMessageType HOT 3
- Helper crashing in Catalina & Big Sur. HOT 9
- Using a concurrent DispatchQueue HOT 13
- Transfer MTLSharedTextureHandle HOT 1
- SMAppService and MachServiceCriteria HOT 12
- setErrorHandler won't be called when using on server with startAndBlock HOT 5
- Validation fails for sandboxed Mach service HOT 1
- Sandbox memory exhaustion
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from securexpc.