From db3442db6185812fb7aab554227b92fce20aeb78 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Wed, 8 Mar 2023 17:20:36 +0100 Subject: [PATCH] Fixes recent syntax errors for C++. --- Chart.struct.static.h | 6 +++--- Indicator/IndicatorTf.h | 5 ++++- Orders.mqh | 4 ++-- Platform.h | 14 +++++++------- Std.h | 13 +++++++------ SymbolInfo.extern.h | 2 +- Tick/Tick.struct.h | 4 ++-- 7 files changed, 26 insertions(+), 22 deletions(-) diff --git a/Chart.struct.static.h b/Chart.struct.static.h index befc9946b..2758c2d02 100644 --- a/Chart.struct.static.h +++ b/Chart.struct.static.h @@ -151,7 +151,7 @@ struct ChartStatic { if (_start < 0) return (-1); _count = (_count <= 0 ? ChartStatic::iBars(_symbol_tf.Symbol(), _symbol_tf.Tf()) : _count); ARRAY(double, arr_d); - ARRAY(long, arr_l); + ARRAY(int64, arr_l); ARRAY(datetime, arr_dt); ArraySetAsSeries(arr_d, true); switch (_type) { @@ -208,7 +208,7 @@ struct ChartStatic { if (_start < 0) return (-1); _count = (_count <= 0 ? iBars(_symbol, _tf) : _count); ARRAY(double, arr_d); - ARRAY(long, arr_l); + ARRAY(int64, arr_l); ARRAY(datetime, arr_dt); ArraySetAsSeries(arr_d, true); switch (_type) { @@ -314,7 +314,7 @@ struct ChartStatic { } return _volume; #else // __MQL5__ - ARRAY(long, _arr); + ARRAY(int64, _arr); ArraySetAsSeries(_arr, true); return (_shift >= 0 && CopyTickVolume(_symbol, _tf, _shift, 1, _arr) > 0) ? _arr[0] : 0; #endif diff --git a/Indicator/IndicatorTf.h b/Indicator/IndicatorTf.h index 9f0aea621..c4195c68b 100644 --- a/Indicator/IndicatorTf.h +++ b/Indicator/IndicatorTf.h @@ -72,7 +72,10 @@ class IndicatorTf : public IndicatorCandle>(_icparams, _idparams) { + Init(); + } /** * Gets indicator's time-frame. diff --git a/Orders.mqh b/Orders.mqh index aa0add09b..89b821555 100644 --- a/Orders.mqh +++ b/Orders.mqh @@ -184,7 +184,7 @@ class Orders { // Terminal::GetErrorText(GetLastError())); break; } - if (Order::OrderSymbol() == _Symbol) { + if (Order::OrderSymbol() == (string)_Symbol) { double order_tp = Order::OrderTakeProfit(); double order_sl = Order::OrderStopLoss(); switch (Order::OrderType()) { @@ -268,7 +268,7 @@ class Orders { Terminal::GetErrorText(GetLastError())); break; } - if (Order::OrderSymbol() == _Symbol) { + if (Order::OrderSymbol() == (string)_Symbol) { switch (Order::OrderType()) { case ORDER_TYPE_BUY: buy_lots += Order::OrderLots(); diff --git a/Platform.h b/Platform.h index 9e4af58c7..f216c5d6b 100644 --- a/Platform.h +++ b/Platform.h @@ -747,19 +747,19 @@ string TimeToString(datetime value, int mode) { std::strftime(minutes, 32, "%H:%M", ptm); std::strftime(seconds, 32, "%S", ptm); - if (mode | TIME_DATE) ss << date; + if (mode & TIME_DATE) ss << date; - if (mode | TIME_MINUTES) { - if (mode | TIME_DATE) { + if (mode & TIME_MINUTES) { + if (mode & TIME_DATE) { ss << " "; } ss << minutes; } - if (mode | TIME_SECONDS) { - if (mode | TIME_DATE && !(mode | TIME_MINUTES)) { + if (mode & TIME_SECONDS) { + if (mode & TIME_DATE && !(mode & TIME_MINUTES)) { ss << " "; - } else if (mode | TIME_MINUTES) { + } else if (mode & TIME_MINUTES) { ss << ":"; } ss << seconds; @@ -785,7 +785,7 @@ bool TimeToStruct(datetime dt, MqlDateTime &dt_struct) { return true; } -SymbolGetter::operator string() { return Platform::GetSymbol(); } +SymbolGetter::operator string() const { return Platform::GetSymbol(); } ENUM_TIMEFRAMES Period() { return Platform::GetPeriod(); } diff --git a/Std.h b/Std.h index 13ffe0869..2d4848e6b 100644 --- a/Std.h +++ b/Std.h @@ -235,12 +235,13 @@ class _cpp_array { #ifdef EMSCRIPTEN #include -#define REGISTER_ARRAY_OF(N, T, D) \ - EMSCRIPTEN_BINDINGS(N) { \ - emscripten::class_<_cpp_array>(D) \ - .constructor() \ - .function("Push", &_cpp_array::push) \ - .function("Size", &_cpp_array::size); \ +#define REGISTER_ARRAY_OF(N, T, D) \ + EMSCRIPTEN_BINDINGS(N) { \ + emscripten::register_vector(D "CppVector"); \ + emscripten::class_<_cpp_array>(D) \ + .constructor() \ + .function("Push", &_cpp_array::push) \ + .function("Size", &_cpp_array::size); \ } #endif diff --git a/SymbolInfo.extern.h b/SymbolInfo.extern.h index f31450b70..0fe18dec6 100644 --- a/SymbolInfo.extern.h +++ b/SymbolInfo.extern.h @@ -38,6 +38,6 @@ extern bool SymbolInfoTick(string symbol, MqlTick &tick); // Define external global variables. class SymbolGetter { public: - operator string(); + operator string() const; } _Symbol; #endif diff --git a/Tick/Tick.struct.h b/Tick/Tick.struct.h index 708f4fc3c..66f59a9c9 100644 --- a/Tick/Tick.struct.h +++ b/Tick/Tick.struct.h @@ -123,8 +123,8 @@ EMSCRIPTEN_BINDINGS(TickAB) { EMSCRIPTEN_BINDINGS(TickTAB) { // emscripten::value_object, emscripten::base>>("TickTABDouble") emscripten::value_object>("TickTAB") - .field("ask", &TickAB::ask) - .field("bid", &TickAB::bid) + .field("ask", &TickTAB::ask) + .field("bid", &TickTAB::bid) .field("time_ms", &TickTAB::time_ms); }