Skip to content

Commit

Permalink
Use getIceProperty in Swift (#2947)
Browse files Browse the repository at this point in the history
  • Loading branch information
bernardnormier authored Oct 21, 2024
1 parent dbbea9e commit fbee227
Show file tree
Hide file tree
Showing 13 changed files with 28 additions and 31 deletions.
9 changes: 3 additions & 6 deletions swift/src/Ice/CommunicatorI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,14 @@ class CommunicatorI: LocalObject<ICECommunicator>, Communicator {
init(handle: ICECommunicator, initData: InitializationData) {
defaultsAndOverrides = DefaultsAndOverrides(handle: handle)
self.initData = initData
let num = initData.properties!.getPropertyAsIntWithDefault(
key: "Ice.ClassGraphDepthMax", value: 10)
let num = try! initData.properties!.getIcePropertyAsInt("Ice.ClassGraphDepthMax")
if num < 1 || num > 0x7FFF_FFFF {
classGraphDepthMax = 0x7FFF_FFFF
} else {
classGraphDepthMax = num
}
traceSlicing =
initData.properties!.getPropertyAsIntWithDefault(key: "Ice.Trace.Slicing", value: 0) > 0
acceptClassCycles =
initData.properties!.getPropertyAsIntWithDefault(key: "Ice.AcceptClassCycles", value: 0) > 0
traceSlicing = try! initData.properties!.getIcePropertyAsInt("Ice.Trace.Slicing") > 0
acceptClassCycles = try! initData.properties!.getIcePropertyAsInt("Ice.AcceptClassCycles") > 0

super.init(handle: handle)
}
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/binding/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ func testSecureEndpoints(helper: TestHelper, com: RemoteCommunicatorPrx) async t

let output = helper.getWriter()

if helper.communicator().getProperties().getProperty("Ice.Default.Protocol") == "ssl" {
if try helper.communicator().getProperties().getIceProperty("Ice.Default.Protocol") == "ssl" {
output.write("testing unsecure vs. secure endpoints... ")
do {
let adapters = try await [
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/enums/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ func allTests(_ helper: TestHelper) async throws -> TestIntfPrx {
output.write("testing enum streaming... ")

let encoding_1_0 =
communicator.getProperties().getProperty("Ice.Default.EncodingVersion") == "1.0"
try communicator.getProperties().getIceProperty("Ice.Default.EncodingVersion") == "1.0"

var ostr = Ice.OutputStream(communicator: communicator)
ostr.write(ByteEnum.benum11)
Expand Down
12 changes: 6 additions & 6 deletions swift/test/Ice/facets/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ func allTests(_ helper: TestHelper) async throws -> GPrx {
let communicator = helper.communicator()

output.write("testing Ice.Admin.Facets property... ")
try test(communicator.getProperties().getPropertyAsList("Ice.Admin.Facets").count == 0)
try test(communicator.getProperties().getIcePropertyAsList("Ice.Admin.Facets").count == 0)
communicator.getProperties().setProperty(key: "Ice.Admin.Facets", value: "foobar")
var facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")
var facetFilter = try communicator.getProperties().getIcePropertyAsList("Ice.Admin.Facets")
try test(facetFilter == ["foobar"])
communicator.getProperties().setProperty(key: "Ice.Admin.Facets", value: "foo\\'bar")
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")
facetFilter = try communicator.getProperties().getIcePropertyAsList("Ice.Admin.Facets")
try test(facetFilter == ["foo'bar"])
communicator.getProperties().setProperty(key: "Ice.Admin.Facets", value: "'foo bar' toto 'titi'")
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")
facetFilter = try communicator.getProperties().getIcePropertyAsList("Ice.Admin.Facets")
try test(facetFilter == ["foo bar", "toto", "titi"])
communicator.getProperties().setProperty(
key: "Ice.Admin.Facets", value: "'foo bar\\' toto' 'titi'")
facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets")
facetFilter = try communicator.getProperties().getIcePropertyAsList("Ice.Admin.Facets")
try test(facetFilter == ["foo bar' toto", "titi"])
// communicator.getProperties().setProperty("Ice.Admin.Facets", "'foo bar' 'toto titi");
// facetFilter = communicator.getProperties().getPropertyAsList("Ice.Admin.Facets");
// facetFilter = try communicator.getProperties().getIcePropertyAsList("Ice.Admin.Facets");
// test(facetFilter.Length == 0);
communicator.getProperties().setProperty(key: "Ice.Admin.Facets", value: "")
output.writeLine("ok")
Expand Down
4 changes: 2 additions & 2 deletions swift/test/Ice/info/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ func allTests(_ helper: TestHelper) async throws {

output.write("test object adapter endpoint information... ")
do {
let host = communicator.getProperties().getPropertyAsInt("Ice.IPv6") != 0 ? "::1" : "127.0.0.1"
let host = try communicator.getProperties().getIcePropertyAsInt("Ice.IPv6") != 0 ? "::1" : "127.0.0.1"
communicator.getProperties().setProperty(
key: "TestAdapter.Endpoints",
value: "tcp -h \"\(host)\" -t 15000:udp -h \"\(host)\"")
Expand Down Expand Up @@ -149,7 +149,7 @@ func allTests(_ helper: TestHelper) async throws {

let testIntf = try await checkedCast(prx: base, type: TestIntfPrx.self)!

let defaultHost = communicator.getProperties().getProperty("Ice.Default.Host")
let defaultHost = try communicator.getProperties().getIceProperty("Ice.Default.Host")

output.write("test connection endpoint information... ")
do {
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/objects/TestI.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class InitialI: Initial {

func acceptsClassCycles(current: Ice.Current) async throws -> Bool {
let properties = current.adapter.getCommunicator().getProperties()
return properties.getPropertyAsIntWithDefault(key: "Ice.AcceptClassCycles", value: 0) > 0
return try properties.getIcePropertyAsInt("Ice.AcceptClassCycles") > 0
}

func getD1(d1: D1?, current _: Ice.Current) async throws -> D1? {
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/operations/BatchOneways.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ func batchOneways(_ helper: TestHelper, _ p: MyClassPrx) async throws {
conn = try await p.ice_getConnection()
if supportsCompress,
conn != nil,
p.ice_getCommunicator().getProperties().getProperty("Ice.Override.Compress") == ""
try! p.ice_getCommunicator().getProperties().getIceProperty("Ice.Override.Compress") == ""
{
let prx = try await p.ice_getConnection()!.createProxy(p.ice_getIdentity()).ice_batchOneway()

Expand Down
12 changes: 6 additions & 6 deletions swift/test/Ice/properties/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ public class Client: TestHelperI {
output.write("testing load properties from UTF-8 path... ")
let properties = Ice.createProperties()
try properties.load("./config/中国_client.config")
try test(properties.getProperty("Ice.Trace.Network") == "1")
try test(properties.getProperty("Ice.Trace.Protocol") == "1")
try test(properties.getIceProperty("Ice.Trace.Network") == "1")
try test(properties.getIceProperty("Ice.Trace.Protocol") == "1")
try test(properties.getProperty("Config.Path") == "./config/中国_client.config")
try test(properties.getProperty("Ice.ProgramName") == "PropertiesClient")
try test(properties.getIceProperty("Ice.ProgramName") == "PropertiesClient")
output.writeLine("ok")
}

Expand Down Expand Up @@ -79,8 +79,8 @@ public class Client: TestHelperI {
var args1 = ["--Foo=1", "--Ice.Default.InvocationTimeout=12345", "-T", "--Bar=2"]
let properties1 = try Ice.createProperties(args1)
var properties2 = try Ice.createProperties(&args1)
try test(properties1.getPropertyAsInt("Ice.Default.InvocationTimeout") == 12345)
try test(properties2.getPropertyAsInt("Ice.Default.InvocationTimeout") == 12345)
try test(properties1.getIcePropertyAsInt("Ice.Default.InvocationTimeout") == 12345)
try test(properties2.getIcePropertyAsInt("Ice.Default.InvocationTimeout") == 12345)
try test(args1 == ["--Foo=1", "-T", "--Bar=2"])

args1 = ["--Ice.Default.InvocationTimeout=10000"]
Expand All @@ -92,7 +92,7 @@ public class Client: TestHelperI {
defer {
communicator.destroy()
}
try test(communicator.getProperties().getPropertyAsInt("Ice.Default.InvocationTimeout") == 12345)
try test(communicator.getProperties().getIcePropertyAsInt("Ice.Default.InvocationTimeout") == 12345)
try test(args1 == ["--Foo=1", "-T", "--Bar=2"])
output.writeLine("ok")
}
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/proxy/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,7 @@ public func allTests(_ helper: TestHelper) async throws -> MyClassPrx {
"test -e 1.1:opaque -e 1.1 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==")!
try test(communicator.proxyToString(p2) == "test -t -e 1.1:tcp -h 127.0.0.1 -p 12010 -t 10000")

if communicator.getProperties().getPropertyAsInt("Ice.IPv6") == 0 {
if try communicator.getProperties().getIcePropertyAsInt("Ice.IPv6") == 0 {
// Two legal TCP endpoints expressed as opaque endpoints
p1 = try communicator.stringToProxy(
"test -e 1.0:" + "opaque -e 1.0 -t 1 -v CTEyNy4wLjAuMeouAAAQJwAAAA==:"
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/stream/Client.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ public class Client: TestHelperI {
try inS.readPendingValues()
try test(o2!.bo == o.bo)
try test(o2!.by == o.by)
if communicator.getProperties().getProperty("Ice.Default.EncodingVersion") == "1.0" {
if try communicator.getProperties().getIceProperty("Ice.Default.EncodingVersion") == "1.0" {
try test(o2!.sh == nil)
try test(o2!.i == nil)
} else {
Expand Down
6 changes: 3 additions & 3 deletions swift/test/Ice/udp/AllTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public func allTests(_ helper: TestHelper) async throws {
}
try test(ret)

if communicator.getProperties().getPropertyAsInt("Ice.Override.Compress") == 0 {
if try communicator.getProperties().getIcePropertyAsInt("Ice.Override.Compress") == 0 {
//
// Only run this test if compression is disabled, the test expect fixed message size
// to be sent over the wire.
Expand Down Expand Up @@ -125,7 +125,7 @@ public func allTests(_ helper: TestHelper) async throws {
//
// Use loopback to prevent other machines to answer.
//
if communicator.getProperties().getProperty("Ice.IPv6") == "1" {
if try communicator.getProperties().getIceProperty("Ice.IPv6") == "1" {
endpoint += "udp -h \"ff15::1:1\" --interface \"::1\""
} else {
endpoint += "udp -h 239.255.1.1 --interface 127.0.0.1"
Expand All @@ -140,7 +140,7 @@ public func allTests(_ helper: TestHelper) async throws {
do {
try await objMcast.ping(reply)
ret = replyI.waitReply(expectedReplies: 5, timeout: 5000)
} catch is Ice.SocketException where communicator.getProperties().getProperty("Ice.IPv6") == "1" {
} catch is Ice.SocketException where try! communicator.getProperties().getIceProperty("Ice.IPv6") == "1" {
output.write("(not supported) ")
ret = true
}
Expand Down
2 changes: 1 addition & 1 deletion swift/test/Ice/udp/Server.swift
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Server: TestHelperI {
//
// Use loopback to prevent other machines to answer.
//
if properties.getProperty("Ice.IPv6") == "1" {
if try properties.getIceProperty("Ice.IPv6") == "1" {
endpoint += "udp -h \"ff15::1:1\" --interface \"::1\""
} else {
endpoint += "udp -h 239.255.1.1 --interface 127.0.0.1"
Expand Down
2 changes: 1 addition & 1 deletion swift/test/TestCommon/TestCommon.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ open class TestHelperI: TestHelper {
var s = ""
s +=
(prot == "")
? properties.getPropertyWithDefault(key: "Ice.Default.Protocol", value: "default") : prot
? try! properties.getIceProperty("Ice.Default.Protocol") : prot
s += " -p "
let port = properties.getPropertyAsIntWithDefault(key: "Test.BasePort", value: 12010) + num
s += String(port)
Expand Down

0 comments on commit fbee227

Please sign in to comment.