From 032e8e7bcd2445093d72dcbcdc32ef2768b883ed Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Thu, 9 Feb 2023 18:23:28 +0100 Subject: [PATCH] WIP. Should fix errors in MT4, MT5 & C++ for TaskRunner. --- .github/workflows/compile-cpp.yml | 2 ++ Chart.struct.tf.h | 7 ++++++- Indicator/IndicatorData.h | 5 ++++- Storage/ValueStorage.history.h | 2 +- Storage/ValueStorage.indicator.h | 9 +++++++-- Tick/Tick.struct.h | 2 +- 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/.github/workflows/compile-cpp.yml b/.github/workflows/compile-cpp.yml index 9a2d220e4..b68563cfe 100644 --- a/.github/workflows/compile-cpp.yml +++ b/.github/workflows/compile-cpp.yml @@ -43,6 +43,8 @@ jobs: with: compiler: gcc-latest - name: Compile ${{ matrix.file }} via emcc + if: always() run: emcc "${{ matrix.file }}" - name: Compile ${{ matrix.file }} via g++ + if: always() run: g++ -c "${{ matrix.file }}" diff --git a/Chart.struct.tf.h b/Chart.struct.tf.h index f392ef0d5..8eb01b41c 100644 --- a/Chart.struct.tf.h +++ b/Chart.struct.tf.h @@ -195,7 +195,12 @@ struct ChartTf { static unsigned int TfToSeconds(const ENUM_TIMEFRAMES _tf) { switch (_tf) { case PERIOD_CURRENT: - return PeriodSeconds(_tf); +#ifdef __MQL__ + return ::PeriodSeconds(_tf); +#else + RUNTIME_ERROR("PeriodSeconds(PERIOD_CURRENT) is not implemented! Returning 0."); + return 0; +#endif case PERIOD_M1: // 1 minute. return 60; case PERIOD_M2: // 2 minutes (non-standard). diff --git a/Indicator/IndicatorData.h b/Indicator/IndicatorData.h index a08cdeae4..97fe40b4a 100644 --- a/Indicator/IndicatorData.h +++ b/Indicator/IndicatorData.h @@ -44,7 +44,6 @@ struct ExternInstantiateIndicatorBufferValueStorageDouble { #include "../Flags.h" #include "../Storage/IValueStorage.h" #include "../Storage/ItemsHistory.h" -#include "../Storage/ValueStorage.indicator.h" #include "../SymbolInfo.struct.h" #include "Indicator.enum.h" #include "IndicatorBase.h" @@ -1940,6 +1939,10 @@ int CopyBuffer(IndicatorData* _indi, int _mode, int _start, int _count, ValueSto return _num_copied; } +// clang-format off +#include "../Storage/ValueStorage.indicator.h" +// clang-format on + IValueStorage* ExternInstantiateIndicatorBufferValueStorageDouble::InstantiateIndicatorBufferValueStorageDouble( IndicatorData* _indi, int _mode) { return new IndicatorBufferValueStorage(_indi, _mode); diff --git a/Storage/ValueStorage.history.h b/Storage/ValueStorage.history.h index 73d64a74f..c78b69880 100644 --- a/Storage/ValueStorage.history.h +++ b/Storage/ValueStorage.history.h @@ -65,7 +65,7 @@ class HistoryValueStorage : public ValueStorage { /** * Initializes storage with given value. */ - virtual void Initialize(C _value) { + virtual void Initialize(C _value) override { Print("HistoryValueStorage does not implement Initialize()!"); DebugBreak(); } diff --git a/Storage/ValueStorage.indicator.h b/Storage/ValueStorage.indicator.h index 58d4db243..06c125d80 100644 --- a/Storage/ValueStorage.indicator.h +++ b/Storage/ValueStorage.indicator.h @@ -32,6 +32,8 @@ // Forward declarations. class IndicatorData; +template +class HistoryValueStorage; // Includes. #include "../Indicator/IndicatorData.h" @@ -50,10 +52,13 @@ class IndicatorBufferValueStorage : public HistoryValueStorage { * Constructor. */ IndicatorBufferValueStorage(IndicatorData* _indi_candle, int _mode = 0, bool _is_series = false) - : mode(_mode), HistoryValueStorage(_indi_candle) {} + : HistoryValueStorage(_indi_candle), mode(_mode) {} /** * Fetches value from a given shift. Takes into consideration as-series flag. */ - C Fetch(int _rel_shift) override { return indi_candle REF_DEREF GetValue(mode, RealShift(_rel_shift)); } + C Fetch(int _rel_shift) override { + IndicatorData* _indi = THIS_ATTR indi_candle.Ptr(); + return _indi PTR_DEREF GetValue(mode, THIS_ATTR RealShift(_rel_shift)); + } }; diff --git a/Tick/Tick.struct.h b/Tick/Tick.struct.h index bda8880d5..fb27ecbfa 100644 --- a/Tick/Tick.struct.h +++ b/Tick/Tick.struct.h @@ -51,7 +51,7 @@ struct MqlTick { MqlTick() {} // Copy constructor. - MqlTick(){const MqlTick & r} { + MqlTick(const MqlTick &r) { time = r.time; ask = r.ask; bid = r.bid;