Skip to content

Commit

Permalink
Revert "Switch to using swift-format from Apple (#2005)"
Browse files Browse the repository at this point in the history
This reverts commit 4805aa4.
  • Loading branch information
ReeceHumphreys committed Apr 2, 2024
1 parent afe1bcc commit 7b0f9a6
Show file tree
Hide file tree
Showing 205 changed files with 33,010 additions and 34,319 deletions.
29 changes: 21 additions & 8 deletions .github/workflows/swift.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,30 @@ on:
- "swift/**"

jobs:
swift-format:
name: Swift Format & Lint
swift-lint:
name: Swift Lint
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install swift-format
run: brew install swift-format
- name: swift-format Format

- name: Install SwiftLints
run: brew install swiftformat

- name: SwiftLint
working-directory: swift
run: swift-format . --recursive --configuration .swift-format.json
- name: swift-format Lint
run: swiftlint --config .swiftlint.yml --strict

swift-format:
name: Swift Format
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Install SwiftFormat
run: brew install swiftformat

- name: SwiftFormat
working-directory: swift
run: swift-format lint . --recursive --strict --configuration .swift-format.json
run: swiftformat --lint --verbose **/*.swift
69 changes: 0 additions & 69 deletions swift/.swift-format.json

This file was deleted.

2 changes: 2 additions & 0 deletions swift/.swiftformat
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--commas "inline"
--disable wrapMultilineStatementBraces
10 changes: 10 additions & 0 deletions swift/.swiftlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
disabled_rules:
- identifier_name
- function_parameter_count
- type_name
- type_body_length
- function_body_length
- file_length
- force_cast
- cyclomatic_complexity
- large_tuple
235 changes: 108 additions & 127 deletions swift/src/Ice/AdminFacetFactory.swift
Original file line number Diff line number Diff line change
Expand Up @@ -5,145 +5,126 @@
import IceImpl

class AdminFacetFacade: ICEBlobjectFacade {
private let communicator: Communicator
var disp: Disp

init(communicator: Communicator, disp: Disp) {
self.communicator = communicator
self.disp = disp
}

func facadeInvoke(
_ adapter: ICEObjectAdapter,
inEncapsBytes: UnsafeMutableRawPointer,
inEncapsCount: Int,
con: ICEConnection?,
name: String,
category: String,
facet: String,
operation: String,
mode: UInt8,
context: [String: String],
requestId: Int32,
encodingMajor: UInt8,
encodingMinor: UInt8,
response: @escaping ICEBlobjectResponse,
exception: @escaping ICEBlobjectException
) {
let objectAdapter = adapter.getSwiftObject(ObjectAdapterI.self) {
let oa = ObjectAdapterI(handle: adapter, communicator: communicator)

// Register the admin OA's id with the servant manager. This is used to distinguish between
// ObjectNotExistException and FacetNotExistException when a servant is not found on
// a Swift Admin OA.
oa.servantManager.setAdminId(Identity(name: name, category: category))
return oa
private let communicator: Communicator
var disp: Disp

init(communicator: Communicator, disp: Disp) {
self.communicator = communicator
self.disp = disp
}

let connection = con?.getSwiftObject(ConnectionI.self) { ConnectionI(handle: con!) } ?? nil

let current = Current(
adapter: objectAdapter,
con: connection,
id: Identity(name: name, category: category),
facet: facet,
operation: operation,
mode: OperationMode(rawValue: mode)!,
ctx: context,
requestId: requestId,
encoding: EncodingVersion(major: encodingMajor, minor: encodingMinor))

let incoming = Incoming(
istr: InputStream(
communicator: communicator,
encoding: EncodingVersion(
major: encodingMajor,
minor: encodingMinor),
bytes: Data(
bytesNoCopy: inEncapsBytes, count: inEncapsCount,
deallocator: .none)),
response: response,
exception: exception,
current: current)

dispatch(incoming: incoming, current: current)
}

func dispatch(incoming: Incoming, current: Current) {
// Dispatch directly to the servant. Do not call invoke on Incoming
do {
// Request was dispatched asynchronously if promise is non-nil
if let promise = try disp.dispatch(request: incoming, current: current) {
// Use the thread which fulfilled the promise (on: nil)
promise.done(on: nil) { ostr in
incoming.setResult(ostr)
incoming.response()
}.catch(on: nil) { error in
incoming.exception(error)
func facadeInvoke(_ adapter: ICEObjectAdapter,
inEncapsBytes: UnsafeMutableRawPointer,
inEncapsCount: Int,
con: ICEConnection?,
name: String,
category: String,
facet: String,
operation: String,
mode: UInt8,
context: [String: String],
requestId: Int32,
encodingMajor: UInt8,
encodingMinor: UInt8,
response: @escaping ICEBlobjectResponse,
exception: @escaping ICEBlobjectException) {
let objectAdapter = adapter.getSwiftObject(ObjectAdapterI.self) {
let oa = ObjectAdapterI(handle: adapter, communicator: communicator)

// Register the admin OA's id with the servant manager. This is used to distinguish between
// ObjectNotExistException and FacetNotExistException when a servant is not found on
// a Swift Admin OA.
oa.servantManager.setAdminId(Identity(name: name, category: category))
return oa
}
} else {
incoming.response()
}
} catch {
incoming.exception(error)

let connection = con?.getSwiftObject(ConnectionI.self) { ConnectionI(handle: con!) } ?? nil

let current = Current(adapter: objectAdapter,
con: connection,
id: Identity(name: name, category: category),
facet: facet,
operation: operation,
mode: OperationMode(rawValue: mode)!,
ctx: context,
requestId: requestId,
encoding: EncodingVersion(major: encodingMajor, minor: encodingMinor))

let incoming = Incoming(istr: InputStream(communicator: communicator,
encoding: EncodingVersion(major: encodingMajor,
minor: encodingMinor),
bytes: Data(bytesNoCopy: inEncapsBytes, count: inEncapsCount,
deallocator: .none)),
response: response,
exception: exception,
current: current)

dispatch(incoming: incoming, current: current)
}
}

func facadeRemoved() {}
func dispatch(incoming: Incoming, current: Current) {
// Dispatch directly to the servant. Do not call invoke on Incoming
do {
// Request was dispatched asynchronously if promise is non-nil
if let promise = try disp.dispatch(request: incoming, current: current) {
// Use the thread which fulfilled the promise (on: nil)
promise.done(on: nil) { ostr in
incoming.setResult(ostr)
incoming.response()
}.catch(on: nil) { error in
incoming.exception(error)
}
} else {
incoming.response()
}
} catch {
incoming.exception(error)
}
}

func facadeRemoved() {}
}

final class UnsupportedAdminFacet: LocalObject<ICEUnsupportedAdminFacet>, Object {
func ice_id(current _: Current) -> String {
return ObjectTraits.staticId
}
func ice_id(current _: Current) -> String {
return ObjectTraits.staticId
}

func ice_ids(current _: Current) -> [String] {
return ObjectTraits.staticIds
}
func ice_ids(current _: Current) -> [String] {
return ObjectTraits.staticIds
}

func ice_isA(id: String, current _: Current) -> Bool {
return id == ObjectTraits.staticId
}
func ice_isA(id: String, current _: Current) -> Bool {
return id == ObjectTraits.staticId
}

func ice_ping(current _: Current) {}
func ice_ping(current _: Current) {}
}

class AdminFacetFactory: ICEAdminFacetFactory {
static func createProcess(_ communicator: ICECommunicator, handle: ICEProcess)
-> ICEBlobjectFacade
{
let c = communicator.getCachedSwiftObject(CommunicatorI.self)
return AdminFacetFacade(
communicator: c,
disp: ProcessDisp(
handle.getSwiftObject(ProcessI.self) {
ProcessI(handle: handle)
}))
}

static func createProperties(_ communicator: ICECommunicator, handle: ICEPropertiesAdmin)
-> ICEBlobjectFacade
{
let c = communicator.getCachedSwiftObject(CommunicatorI.self)

return AdminFacetFacade(
communicator: c,
disp: PropertiesAdminDisp(
handle.getSwiftObject(PropertiesAdminI.self) {
PropertiesAdminI(communicator: c, handle: handle)
}))
}

static func createUnsupported(
_ communicator: ICECommunicator,
handle: ICEUnsupportedAdminFacet
) -> ICEBlobjectFacade {
let c = communicator.getCachedSwiftObject(CommunicatorI.self)
return AdminFacetFacade(
communicator: c,
disp: ObjectDisp(
handle.getSwiftObject(UnsupportedAdminFacet.self) {
UnsupportedAdminFacet(handle: handle)
}))
}
static func createProcess(_ communicator: ICECommunicator, handle: ICEProcess) -> ICEBlobjectFacade {
let c = communicator.getCachedSwiftObject(CommunicatorI.self)
return AdminFacetFacade(communicator: c,
disp: ProcessDisp(handle.getSwiftObject(ProcessI.self) {
ProcessI(handle: handle)
}))
}

static func createProperties(_ communicator: ICECommunicator, handle: ICEPropertiesAdmin) -> ICEBlobjectFacade {
let c = communicator.getCachedSwiftObject(CommunicatorI.self)

return AdminFacetFacade(communicator: c,
disp: PropertiesAdminDisp(handle.getSwiftObject(PropertiesAdminI.self) {
PropertiesAdminI(communicator: c, handle: handle)
}))
}

static func createUnsupported(_ communicator: ICECommunicator,
handle: ICEUnsupportedAdminFacet) -> ICEBlobjectFacade {
let c = communicator.getCachedSwiftObject(CommunicatorI.self)
return AdminFacetFacade(communicator: c,
disp: ObjectDisp(handle.getSwiftObject(UnsupportedAdminFacet.self) {
UnsupportedAdminFacet(handle: handle)
}))
}
}
Loading

0 comments on commit 7b0f9a6

Please sign in to comment.