Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Nov 21, 2023
1 parent 93ec5f5 commit 63ce38c
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 33 deletions.
4 changes: 4 additions & 0 deletions DXFeedFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
647426AD2ABC85F20012F793 /* Arguments.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647426AC2ABC85F20012F793 /* Arguments.swift */; };
647426AF2ABC93900012F793 /* EventCode+String.swift in Sources */ = {isa = PBXBuildFile; fileRef = 647426AE2ABC93900012F793 /* EventCode+String.swift */; };
6479BC2B2A4F35A300A3D404 /* QuoteView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6479BC2A2A4F35A300A3D404 /* QuoteView.swift */; };
648468AC2B0D06FA008297AE /* DXDateOffset.swift in Sources */ = {isa = PBXBuildFile; fileRef = 648468AB2B0D06FA008297AE /* DXDateOffset.swift */; };
6486B9582AD00BDC00D8D5FA /* Summary.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6486B9572AD00BDC00D8D5FA /* Summary.swift */; };
6486B95B2AD015B400D8D5FA /* PriceType.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6486B95A2AD015B400D8D5FA /* PriceType.swift */; };
6486B95D2AD0287E00D8D5FA /* DateTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 6486B95C2AD0287E00D8D5FA /* DateTests.swift */; };
Expand Down Expand Up @@ -662,6 +663,7 @@
647426AC2ABC85F20012F793 /* Arguments.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Arguments.swift; sourceTree = "<group>"; };
647426AE2ABC93900012F793 /* EventCode+String.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "EventCode+String.swift"; sourceTree = "<group>"; };
6479BC2A2A4F35A300A3D404 /* QuoteView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = QuoteView.swift; sourceTree = "<group>"; };
648468AB2B0D06FA008297AE /* DXDateOffset.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DXDateOffset.swift; sourceTree = "<group>"; };
6486B9572AD00BDC00D8D5FA /* Summary.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Summary.swift; sourceTree = "<group>"; };
6486B95A2AD015B400D8D5FA /* PriceType.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PriceType.swift; sourceTree = "<group>"; };
6486B95C2AD0287E00D8D5FA /* DateTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DateTests.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -1286,6 +1288,7 @@
64A42F4D2B0B9FA4001C3ACC /* DXTimeZone.swift */,
64A42F4F2B0BA668001C3ACC /* DXTimeFormat.swift */,
64A42F512B0BBB6D001C3ACC /* DXTimePeriod.swift */,
648468AB2B0D06FA008297AE /* DXDateOffset.swift */,
);
path = DateTime;
sourceTree = "<group>";
Expand Down Expand Up @@ -2338,6 +2341,7 @@
64BDDB2A2AD7D9C700694210 /* SpreadOrder+Ext.swift in Sources */,
8088D77529C3A61000F240CB /* ErrorCheck.swift in Sources */,
64A42F4B2B0B96EF001C3ACC /* NativeTimePeriod.swift in Sources */,
648468AC2B0D06FA008297AE /* DXDateOffset.swift in Sources */,
64A42F522B0BBB6D001C3ACC /* DXTimePeriod.swift in Sources */,
6486B9672AD0390800D8D5FA /* GreeksMapper.swift in Sources */,
64AAF0572A82A3FC00E8942B /* ICandleSymbolProperty.swift in Sources */,
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Events/Market/OptionSale.swift
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ type=\(optionSaleType), \
underlyingPrice=\(underlyingPrice), \
volatility=\(volatility), \
delta=\(delta), \
optionSymbol='\(optionSymbol)'\
optionSymbol='\(optionSymbol ?? "null")'\
}
"""
}
Expand Down
2 changes: 1 addition & 1 deletion DXFeedFramework/Native/Utils/NativeTimeFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,5 @@ class NativeTimeFormat: NativeBox<dxfg_time_format_t> {
let timeFormat = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_asFullIso(thread, timeFormat.native))
self.init(native: timeFormat)
}

}
10 changes: 8 additions & 2 deletions DXFeedFramework/Native/Utils/NativeTimeUtil.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,19 @@ class NativeTimeUtil {

static func parse(timeFormat: NativeTimeFormat, value: String) throws -> Long {
let thread = currentThread()
let result = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_parse(thread, timeFormat.native, value.toCStringRef()))
let result = try ErrorCheck.nativeCall(thread,
dxfg_TimeFormat_parse(thread,
timeFormat.native,
value.toCStringRef()))
return result
}

static func format(timeFormat: NativeTimeFormat, value: Long) throws -> String {
let thread = currentThread()
let result = try ErrorCheck.nativeCall(thread, dxfg_TimeFormat_format(thread, timeFormat.native, value))
let result = try ErrorCheck.nativeCall(thread,
dxfg_TimeFormat_format(thread,
timeFormat.native,
value))
return String(pointee: result)
}

Expand Down
19 changes: 7 additions & 12 deletions DXFeedFramework/Native/Utils/NativeTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,21 +71,16 @@ class NativeTimeZone: NativeBox<dxfg_time_zone_t> {
return result
}

func getOffset2(era: Int32,
year: Int32,
month: Int32,
day: Int32,
dayOfWeek: Int32,
milliseconds: Int32) throws -> Int32 {
func getOffset2(offset: DXDateOffset) throws -> Int32 {
let thread = currentThread()
let result = try ErrorCheck.nativeCall(thread, dxfg_TimeZone_getOffset2(thread,
native,
era,
year,
month,
day,
dayOfWeek,
milliseconds))
offset.era,
offset.year,
offset.month,
offset.day,
offset.dayOfWeek,
offset.milliseconds))
return result
}

Expand Down
26 changes: 26 additions & 0 deletions DXFeedFramework/Utils/DateTime/DXDateOffset.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// DXDateOffset.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 21.11.23.
//

import Foundation

public class DXDateOffset {
public let era: Int32
public let year: Int32
public let month: Int32
public let day: Int32
public let dayOfWeek: Int32
public let milliseconds: Int32

public init(era: Int32, year: Int32, month: Int32, day: Int32, dayOfWeek: Int32, milliseconds: Int32) {
self.era = era
self.year = year
self.month = month
self.day = day
self.dayOfWeek = dayOfWeek
self.milliseconds = milliseconds
}
}
5 changes: 2 additions & 3 deletions DXFeedFramework/Utils/DateTime/DXTimeFormat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ public class DXTimeFormat {
return try? DXTimeFormat(withMillis: self)
}()


/// Returns TimeFormat instance for a specified timezone.
/// - Throws: GraalException. Rethrows exception from Java.
public convenience init(timeZone: DXTimeZone) throws {
Expand All @@ -61,7 +60,7 @@ public class DXTimeFormat {
let timeFormat = try NativeTimeFormat(withMillis: timeFormat.timeFormat)
self.init(timeFormat: timeFormat)
}

/// Returns TimeFormat instance that produces full ISO8610 string of "yyyy-MM-dd'T'HH:mm:ss.SSSX".
/// - Throws: GraalException. Rethrows exception from Java.
public convenience init(fullIso timeFormat: DXTimeFormat) throws {
Expand Down Expand Up @@ -183,7 +182,7 @@ public extension DXTimeFormat {
/// - value: time date and time to format.
/// - Returns: string representation of data and time.
/// - Throws: GraalException. Rethrows exception from Java.
func format(value: Long) throws -> String? {
func format(value: Long) throws -> String? {
return try NativeTimeUtil.format(timeFormat: timeFormat, value: value)
}
}
4 changes: 2 additions & 2 deletions DXFeedFramework/Utils/DateTime/DXTimePeriod.swift
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public class DXTimePeriod {
let timePeriod = try NativeTimePeriod(value: value)
self.init(timePeriod: timePeriod)
}

/// Returns TimePeriod represented with a given string.
///
/// Allowable format is ISO8601 duration, but there are some simplifications and modifications available:
Expand All @@ -64,7 +64,7 @@ public class DXTimePeriod {
public func getSeconds() throws -> Int32 {
return try timePeriod.getSeconds()
}

/// Returns value in nanoseconds.
public func getNanos() throws -> Long {
return try timePeriod.getNanos()
Expand Down
11 changes: 3 additions & 8 deletions DXFeedFramework/Utils/DateTime/DXTimeZone.swift
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public class DXTimeZone {
private init(timeZone: NativeTimeZone) {
self.timeZone = timeZone
}

public convenience init(timeZoneID: String) throws {
self.init(timeZone: try NativeTimeZone(timeZoneID: timeZoneID))
}
Expand Down Expand Up @@ -63,13 +63,8 @@ public class DXTimeZone {
return try self.timeZone.getOffset(date: date)
}

public func getOffset2(era: Int32, year: Int32, month: Int32, day: Int32, dayOfWeek: Int32, milliseconds: Int32) throws -> Int32 {
return try self.timeZone.getOffset2(era: era,
year: year,
month: month,
day: day,
dayOfWeek: dayOfWeek,
milliseconds: milliseconds)
public func getOffset2(offset: DXDateOffset) throws -> Int32 {
return try self.timeZone.getOffset2(offset: offset)
}

public func getRawOffset() throws -> Int32 {
Expand Down
2 changes: 2 additions & 0 deletions DXFeedFrameworkTests/IPFTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import XCTest
@testable import DXFeedFramework
@_implementationOnly import graal_api

// swiftlint:disable type_body_length
final class IPFTests: XCTestCase {
class AnonymousProfileListener: DXInstrumentProfileUpdateListener, Hashable {
static func == (lhs: AnonymousProfileListener, rhs: AnonymousProfileListener) -> Bool {
Expand Down Expand Up @@ -304,3 +305,4 @@ STOCK,EREGL:TR,EREĞLİ DEMİR VE ÇELİK FABRİKALARI1 T.A.Ş.,TR,XIST,XIST,TRY
XCTAssert(inputStr == resultstr)
}
}
// swiftlint:enable type_body_length
3 changes: 2 additions & 1 deletion Samples/IpfTableApp/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,8 @@ extension ViewController: DXInstrumentProfileUpdateListener {
self.ipfTableView.reloadData()
self.lastUpdateLabel.text =
"""
\(self.ipfList.count) profiles: \(try? DXTimeFormat.defaultTimeFormat?.withMillis?.format(value: self.collector?.getLastUpdateTime() ?? 0))
\(self.ipfList.count) profiles: \
\((try? DXTimeFormat.defaultTimeFormat?.withMillis?.format(value: self.collector?.getLastUpdateTime() ?? 0)) ?? "")
"""

}
Expand Down
2 changes: 1 addition & 1 deletion Samples/Tools/ConnectTool.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ Where:
func execute() {
isQuite = arguments.isQuite

try? arguments.properties.forEach { key, value in
arguments.properties.forEach { key, value in
try? SystemProperty.setProperty(key, value)
}

Expand Down
4 changes: 3 additions & 1 deletion Samples/Tools/LiveIpfSample.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ extension LiveIpfSample: DXInstrumentProfileUpdateListener {
Instrument Profiles:
Total number of profiles (1): \(self.ipfList.count)
Last modified: \(try? DXTimeFormat.defaultTimeFormat?.withMillis?.format(value: collector?.getLastUpdateTime() ?? 0))
Last modified: \(
(try? DXTimeFormat.defaultTimeFormat?.withMillis?.format(value: collector?.getLastUpdateTime() ?? 0)) ?? ""
)
"""
)
}
Expand Down
4 changes: 3 additions & 1 deletion Samples/Tools/SubscriptionUtils.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ class Subscription {
var endpoint: DXEndpoint?
var subscriptions = [DXFeedSubcription]()

// swiftlint:disable function_parameter_count
func createSubscription<O>(address: String,
symbols: [Symbol],
types: [EventCode],
Expand Down Expand Up @@ -59,5 +60,6 @@ Create subscription to \(address) for \(types):\(symbols) with properties:\(prop
}
}
}
}
// swiftlint:enable function_parameter_count

}

0 comments on commit 63ce38c

Please sign in to comment.