Skip to content

Commit

Permalink
fix problem in Mappers(When pointee is used as the left side of an …
Browse files Browse the repository at this point in the history
…assignment, the instance is updated.)
  • Loading branch information
kosyloa committed Oct 19, 2023
1 parent e5d620f commit eb6e6aa
Show file tree
Hide file tree
Showing 18 changed files with 316 additions and 211 deletions.
4 changes: 4 additions & 0 deletions DXFeedFramework.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@
645BE84F2AC3170F0028243D /* DXFeedFramework.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 803BAC0D29BFA50700FFAB1C /* DXFeedFramework.framework */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
645BE8522AC31E7C0028243D /* PerfTestCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 645BE8512AC31E7C0028243D /* PerfTestCommand.swift */; };
645BE8542AC3229D0028243D /* ToolsCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 645BE8532AC3229D0028243D /* ToolsCommand.swift */; };
645CD0042AE145E600F99FCF /* DumpCommand.swift in Sources */ = {isa = PBXBuildFile; fileRef = 645CD0032AE145E600F99FCF /* DumpCommand.swift */; };
646228512A376B0A0029DC97 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6462284D2A376B0A0029DC97 /* Main.storyboard */; };
646228522A376B0A0029DC97 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 6462284F2A376B0A0029DC97 /* LaunchScreen.storyboard */; };
646407492A9DF984006FF769 /* InstrumentProfileMapper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 646407482A9DF984006FF769 /* InstrumentProfileMapper.swift */; };
Expand Down Expand Up @@ -619,6 +620,7 @@
645A34942A937C7200709F29 /* BinaryInteger+Ext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BinaryInteger+Ext.swift"; sourceTree = "<group>"; };
645BE8512AC31E7C0028243D /* PerfTestCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PerfTestCommand.swift; sourceTree = "<group>"; };
645BE8532AC3229D0028243D /* ToolsCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ToolsCommand.swift; sourceTree = "<group>"; };
645CD0032AE145E600F99FCF /* DumpCommand.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DumpCommand.swift; sourceTree = "<group>"; };
6462284E2A376B0A0029DC97 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
646228502A376B0A0029DC97 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
646407482A9DF984006FF769 /* InstrumentProfileMapper.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = InstrumentProfileMapper.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -937,6 +939,7 @@
6486B97E2AD4167800D8D5FA /* LiveIpfCommand.swift */,
64FFE59E2AD430E4003D3353 /* ScheduleCommand.swift */,
649282E92AD55323008F0F04 /* IpfConnectCommand.swift */,
645CD0032AE145E600F99FCF /* DumpCommand.swift */,
648BD56A2AC4576F004A3A95 /* HelpCommand.swift */,
648BD56C2AC56A04004A3A95 /* SubscriptionUtils.swift */,
);
Expand Down Expand Up @@ -1983,6 +1986,7 @@
649282EB2AD55323008F0F04 /* IpfConnectCommand.swift in Sources */,
6486B97F2AD4167800D8D5FA /* LiveIpfCommand.swift in Sources */,
645BE8522AC31E7C0028243D /* PerfTestCommand.swift in Sources */,
645CD0042AE145E600F99FCF /* DumpCommand.swift in Sources */,
641BDD5D2ACD67A000236B78 /* LatencyListener.swift in Sources */,
641BDD622ACD697B00236B78 /* AbstractEventListener.swift in Sources */,
641BDD582AC71CCE00236B78 /* LatencyTestCommand.swift in Sources */,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
shouldAutocreateTestPlan = "YES">
</TestAction>
<LaunchAction
buildConfiguration = "Release"
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
Expand Down Expand Up @@ -73,6 +73,10 @@
</CommandLineArgument>
<CommandLineArgument
argument = "Connect mddqa.in.devexperts.com:7400 OptionSale AAPL"
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = " Dump demo.dxfeed.com:7300 timeandsale AAPL,IBM,ETH/USD:GDAX -t test_tape_ios.txt[format=text]"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
Expand Down
47 changes: 23 additions & 24 deletions DXFeedFramework/Native/Events/Markets/AnalyticOrderMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,33 +20,32 @@ class AnalyticOrderMapper: Mapper {

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<TypeAlias>.allocate(capacity: 1)
var pointee = pointer.pointee
pointee.order_base.order_base.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointee.order_base.order_base.market_event.event_time = event.eventTime
pointer.pointee.order_base.order_base.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.order_base.order_base.market_event.event_time = event.eventTime

let order = event.analyticOrder

pointee.order_base.order_base.market_event.event_time = order.eventTime
pointee.order_base.order_base.event_flags = order.eventFlags
pointee.order_base.order_base.index = order.index
pointee.order_base.order_base.time_sequence = order.timeSequence
pointee.order_base.order_base.time_nano_part = order.timeNanoPart
pointee.order_base.order_base.action_time = order.actionTime
pointee.order_base.order_base.order_id = order.orderId
pointee.order_base.order_base.aux_order_id = order.auxOrderId
pointee.order_base.order_base.price = order.price
pointee.order_base.order_base.size = order.size
pointee.order_base.order_base.executed_size = order.executedSize
pointee.order_base.order_base.count = order.count
pointee.order_base.order_base.flags = order.flags
pointee.order_base.order_base.trade_id = order.tradeId
pointee.order_base.order_base.trade_price = order.tradePrice
pointee.order_base.order_base.trade_size = order.tradeSize

pointee.iceberg_peak_size = order.icebergPeakSize
pointee.iceberg_hidden_size = order.icebergHiddenSize
pointee.iceberg_executed_size = order.icebergExecutedSize
pointee.iceberg_flags = order.icebergFlags
pointer.pointee.order_base.order_base.market_event.event_time = order.eventTime
pointer.pointee.order_base.order_base.event_flags = order.eventFlags
pointer.pointee.order_base.order_base.index = order.index
pointer.pointee.order_base.order_base.time_sequence = order.timeSequence
pointer.pointee.order_base.order_base.time_nano_part = order.timeNanoPart
pointer.pointee.order_base.order_base.action_time = order.actionTime
pointer.pointee.order_base.order_base.order_id = order.orderId
pointer.pointee.order_base.order_base.aux_order_id = order.auxOrderId
pointer.pointee.order_base.order_base.price = order.price
pointer.pointee.order_base.order_base.size = order.size
pointer.pointee.order_base.order_base.executed_size = order.executedSize
pointer.pointee.order_base.order_base.count = order.count
pointer.pointee.order_base.order_base.flags = order.flags
pointer.pointee.order_base.order_base.trade_id = order.tradeId
pointer.pointee.order_base.order_base.trade_price = order.tradePrice
pointer.pointee.order_base.order_base.trade_size = order.tradeSize

pointer.pointee.iceberg_peak_size = order.icebergPeakSize
pointer.pointee.iceberg_hidden_size = order.icebergHiddenSize
pointer.pointee.iceberg_executed_size = order.icebergExecutedSize
pointer.pointee.iceberg_flags = order.icebergFlags

let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_ANALYTIC_ORDER
Expand Down
31 changes: 15 additions & 16 deletions DXFeedFramework/Native/Events/Markets/CandleMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,23 @@ class CandleMapper: Mapper {

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<dxfg_candle_t>.allocate(capacity: 1)
var pointee = pointer.pointee
pointee.event_symbol = event.eventSymbol.toCStringRef()
pointee.event_time = event.eventTime
pointer.pointee.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.event_time = event.eventTime

let candle = event.candle
pointee.event_flags = candle.eventFlags
pointee.index = candle.index
pointee.count = candle.count
pointee.open = candle.open
pointee.high = candle.high
pointee.low = candle.low
pointee.close = candle.close
pointee.volume = candle.volume
pointee.vwap = candle.vwap
pointee.bid_volume = candle.bidVolume
pointee.ask_volume = candle.askVolume
pointee.imp_volatility = candle.impVolatility
pointee.open_interest = candle.openInterest
pointer.pointee.event_flags = candle.eventFlags
pointer.pointee.index = candle.index
pointer.pointee.count = candle.count
pointer.pointee.open = candle.open
pointer.pointee.high = candle.high
pointer.pointee.low = candle.low
pointer.pointee.close = candle.close
pointer.pointee.volume = candle.volume
pointer.pointee.vwap = candle.vwap
pointer.pointee.bid_volume = candle.bidVolume
pointer.pointee.ask_volume = candle.askVolume
pointer.pointee.imp_volatility = candle.impVolatility
pointer.pointee.open_interest = candle.openInterest

let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_CANDLE
Expand Down
23 changes: 11 additions & 12 deletions DXFeedFramework/Native/Events/Markets/GreeksMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,19 @@ class GreeksMapper: Mapper {

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<dxfg_greeks_t>.allocate(capacity: 1)
var pointee = pointer.pointee
pointee.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointee.market_event.event_time = event.eventTime
pointer.pointee.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.market_event.event_time = event.eventTime

let greeks = event.greeks
pointee.event_flags = greeks.eventFlags
pointee.index = greeks.index
pointee.price = greeks.price
pointee.volatility = greeks.volatility
pointee.delta = greeks.delta
pointee.gamma = greeks.gamma
pointee.theta = greeks.theta
pointee.rho = greeks.rho
pointee.vega = greeks.vega
pointer.pointee.event_flags = greeks.eventFlags
pointer.pointee.index = greeks.index
pointer.pointee.price = greeks.price
pointer.pointee.volatility = greeks.volatility
pointer.pointee.delta = greeks.delta
pointer.pointee.gamma = greeks.gamma
pointer.pointee.theta = greeks.theta
pointer.pointee.rho = greeks.rho
pointer.pointee.vega = greeks.vega

let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_GREEKS
Expand Down
35 changes: 17 additions & 18 deletions DXFeedFramework/Native/Events/Markets/OptionSaleMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@ class OptionSaleMapper: Mapper {

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<TypeAlias>.allocate(capacity: 1)
var pointee = pointer.pointee
pointee.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointee.market_event.event_time = event.eventTime
pointer.pointee.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.market_event.event_time = event.eventTime

let optionSale = event.optionSale

pointee.event_flags = optionSale.eventFlags
pointee.index = optionSale.index
pointee.time_sequence = optionSale.timeSequence
pointee.time_nano_part = optionSale.timeNanoPart
pointee.exchange_code = optionSale.exchangeCode
pointee.price = optionSale.price
pointee.size = optionSale.size
pointee.bid_price = optionSale.bidPrice
pointee.ask_price = optionSale.askPrice
pointee.exchange_sale_conditions = optionSale.exchangeSaleConditions.toCStringRef()
pointee.flags = optionSale.flags
pointee.underlying_price = optionSale.underlyingPrice
pointee.volatility = optionSale.volatility
pointee.delta = optionSale.delta
pointee.option_symbol = optionSale.optionSymbol.toCStringRef()
pointer.pointee.event_flags = optionSale.eventFlags
pointer.pointee.index = optionSale.index
pointer.pointee.time_sequence = optionSale.timeSequence
pointer.pointee.time_nano_part = optionSale.timeNanoPart
pointer.pointee.exchange_code = optionSale.exchangeCode
pointer.pointee.price = optionSale.price
pointer.pointee.size = optionSale.size
pointer.pointee.bid_price = optionSale.bidPrice
pointer.pointee.ask_price = optionSale.askPrice
pointer.pointee.exchange_sale_conditions = optionSale.exchangeSaleConditions.toCStringRef()
pointer.pointee.flags = optionSale.flags
pointer.pointee.underlying_price = optionSale.underlyingPrice
pointer.pointee.volatility = optionSale.volatility
pointer.pointee.delta = optionSale.delta
pointer.pointee.option_symbol = optionSale.optionSymbol.toCStringRef()

let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_OPTION_SALE
Expand Down
41 changes: 20 additions & 21 deletions DXFeedFramework/Native/Events/Markets/OrderMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,29 @@ class OrderMapper: Mapper {

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<TypeAlias>.allocate(capacity: 1)
var pointee = pointer.pointee
pointee.order_base.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointee.order_base.market_event.event_time = event.eventTime
pointer.pointee.order_base.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.order_base.market_event.event_time = event.eventTime

let order = event.order

pointee.order_base.market_event.event_time = order.eventTime
pointee.order_base.event_flags = order.eventFlags
pointee.order_base.index = order.index
pointee.order_base.time_sequence = order.timeSequence
pointee.order_base.time_nano_part = order.timeNanoPart
pointee.order_base.action_time = order.actionTime
pointee.order_base.order_id = order.orderId
pointee.order_base.aux_order_id = order.auxOrderId
pointee.order_base.price = order.price
pointee.order_base.size = order.size
pointee.order_base.executed_size = order.executedSize
pointee.order_base.count = order.count
pointee.order_base.flags = order.flags
pointee.order_base.trade_id = order.tradeId
pointee.order_base.trade_price = order.tradePrice
pointee.order_base.trade_size = order.tradeSize

pointee.market_maker = order.marketMaker?.toCStringRef()
pointer.pointee.order_base.market_event.event_time = order.eventTime
pointer.pointee.order_base.event_flags = order.eventFlags
pointer.pointee.order_base.index = order.index
pointer.pointee.order_base.time_sequence = order.timeSequence
pointer.pointee.order_base.time_nano_part = order.timeNanoPart
pointer.pointee.order_base.action_time = order.actionTime
pointer.pointee.order_base.order_id = order.orderId
pointer.pointee.order_base.aux_order_id = order.auxOrderId
pointer.pointee.order_base.price = order.price
pointer.pointee.order_base.size = order.size
pointer.pointee.order_base.executed_size = order.executedSize
pointer.pointee.order_base.count = order.count
pointer.pointee.order_base.flags = order.flags
pointer.pointee.order_base.trade_id = order.tradeId
pointer.pointee.order_base.trade_price = order.tradePrice
pointer.pointee.order_base.trade_size = order.tradeSize

pointer.pointee.market_maker = order.marketMaker?.toCStringRef()

let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_ORDER
Expand Down
37 changes: 18 additions & 19 deletions DXFeedFramework/Native/Events/Markets/ProfileMapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,26 @@ class ProfileMapper: Mapper {

func toNative(event: MarketEvent) -> UnsafeMutablePointer<dxfg_event_type_t>? {
let pointer = UnsafeMutablePointer<dxfg_profile_t>.allocate(capacity: 1)
var pointee = pointer.pointee
pointee.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointee.market_event.event_time = event.eventTime
pointer.pointee.market_event.event_symbol = event.eventSymbol.toCStringRef()
pointer.pointee.market_event.event_time = event.eventTime

let profile = event.profile
pointee.description = profile.descriptionStr?.toCStringRef()
pointee.status_reason = profile.statusReason?.toCStringRef()
pointee.halt_start_time = profile.haltStartTime
pointee.halt_end_time = profile.haltEndTime
pointee.high_limit_price = profile.highLimitPrice
pointee.low_limit_price = profile.lowLimitPrice
pointee.high_52_week_price = profile.high52WeekPrice
pointee.low_52_week_price = profile.low52WeekPrice
pointee.beta = profile.beta
pointee.earnings_per_share = profile.earningsPerShare
pointee.dividend_frequency = profile.dividendFrequency
pointee.ex_dividend_amount = profile.exDividendAmount
pointee.ex_dividend_day_id = profile.exDividendDayId
pointee.shares = profile.shares
pointee.free_float = profile.freeFloat
pointee.flags = profile.flags
pointer.pointee.description = profile.descriptionStr?.toCStringRef()
pointer.pointee.status_reason = profile.statusReason?.toCStringRef()
pointer.pointee.halt_start_time = profile.haltStartTime
pointer.pointee.halt_end_time = profile.haltEndTime
pointer.pointee.high_limit_price = profile.highLimitPrice
pointer.pointee.low_limit_price = profile.lowLimitPrice
pointer.pointee.high_52_week_price = profile.high52WeekPrice
pointer.pointee.low_52_week_price = profile.low52WeekPrice
pointer.pointee.beta = profile.beta
pointer.pointee.earnings_per_share = profile.earningsPerShare
pointer.pointee.dividend_frequency = profile.dividendFrequency
pointer.pointee.ex_dividend_amount = profile.exDividendAmount
pointer.pointee.ex_dividend_day_id = profile.exDividendDayId
pointer.pointee.shares = profile.shares
pointer.pointee.free_float = profile.freeFloat
pointer.pointee.flags = profile.flags
let eventType = pointer.withMemoryRebound(to: dxfg_event_type_t.self, capacity: 1) { pointer in
pointer.pointee.clazz = DXFG_EVENT_PROFILE
return pointer
Expand Down
Loading

0 comments on commit eb6e6aa

Please sign in to comment.