Giter Site home page Giter Site logo

Comments (1)

amomchilov avatar amomchilov commented on June 29, 2024

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:

  1. "Fake" the implementation of Codable on the property wrapper
    • Make the init(from:) and encode(to:) call fatalError().
      • 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 their init(from:) or encode(to:) methods.
    • I haven't had time to spike this one out yet
  2. Conform to Codable for real
    • Make the init(from:) and encode(to:) cast their Encoder/Decoder param to a concrete XPCEncoderImpl/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:) and encode(to:) will be called like normal.
    • Add methods to XPCEncoder/XPCDecoder (their containers) that handle xpc_connection_t and xpc_endpoint_t. Use these to implement init(from:) and encode(to:)
    • I made a proof of concept of this for xpc_connection_t, here: #13

from securexpc.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.