Skip to content

Commit b3d2611

Browse files
committed
EMCC compatibility fixes.
1 parent 542b3d7 commit b3d2611

File tree

19 files changed

+101
-112
lines changed

19 files changed

+101
-112
lines changed

Exchange/Account/Account.struct.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*/
2727

2828
#ifndef __MQL__
29-
// Allows the preprocessor to include a header file when it is needed.
30-
#pragma once
29+
// Allows the preprocessor to include a header file when it is needed.
30+
#pragma once
3131
#endif
3232

3333
// Forward class declaration.
@@ -123,7 +123,7 @@ struct AccountParams {
123123
// Default constructor.
124124
AccountParams(int _login = 0, string _name = "Current", string _currency = "USD", string _company = "Unknown",
125125
string _server = "Unknown")
126-
: company(_company), currency(_currency), login(_login), name(_name), server(_server) {}
126+
: login(_login), company(_company), currency(_currency), name(_name), server(_server) {}
127127
// Constructor based on JSON string.
128128
AccountParams(string _entry) { SerializerConverter::FromString<SerializerJson>(_entry).ToStruct(THIS_REF); }
129129
// Copy constructor.

Exchange/Account/AccountMt.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ class AccountMt : public AccountBase {
178178
* Returns margin value of the current account.
179179
*/
180180
static double AccountMargin() { return AccountInfoDouble(ACCOUNT_MARGIN); }
181-
float GetMarginUsed() const {
181+
float GetMarginUsed() const override {
182182
// @todo: Adds caching.
183183
// return UpdateStats(ACC_MARGIN_USED, AccountMargin());
184184
return (float)AccountMt::AccountMargin();
@@ -616,7 +616,7 @@ class AccountMt : public AccountBase {
616616
/**
617617
* Returns text info about the account.
618618
*/
619-
string const ToString() {
619+
string const ToString() override {
620620
return StringFormat(
621621
"Type: %s, Server/Company/Name: %s/%s/%s, Currency: %s, Balance: %g, Credit: %g, Equity: %g, Profit: %g, "
622622
"Margin Used/Free/Avail: %g(%.1f%%)/%g/%g, Orders limit: %g: Leverage: 1:%d, StopOut Level: %d (Mode: %d)",
@@ -639,7 +639,7 @@ class AccountMt : public AccountBase {
639639
/**
640640
* Returns serialized representation of the object instance.
641641
*/
642-
SerializerNodeType Serialize(Serializer &_s) {
642+
SerializerNodeType Serialize(Serializer &_s) override {
643643
AccountEntry _entry = GetEntry();
644644
_s.PassStruct(THIS_REF, "account-entry", _entry, SERIALIZER_FIELD_FLAG_DYNAMIC);
645645
return SerializerNodeObject;

Exchange/Exchange.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class Exchange : public Taskable<DataParamEntry> {
129129
/**
130130
* Checks a condition.
131131
*/
132-
bool Check(const TaskConditionEntry &_entry) {
132+
bool Check(const TaskConditionEntry &_entry) override {
133133
bool _result = true;
134134
switch (_entry.GetId()) {
135135
default:
@@ -142,7 +142,7 @@ class Exchange : public Taskable<DataParamEntry> {
142142
/**
143143
* Gets a data param entry.
144144
*/
145-
DataParamEntry Get(const TaskGetterEntry &_entry) {
145+
DataParamEntry Get(const TaskGetterEntry &_entry) override {
146146
DataParamEntry _result;
147147
switch (_entry.GetId()) {
148148
default:
@@ -154,7 +154,7 @@ class Exchange : public Taskable<DataParamEntry> {
154154
/**
155155
* Runs an action.
156156
*/
157-
bool Run(const TaskActionEntry &_entry) {
157+
bool Run(const TaskActionEntry &_entry) override {
158158
bool _result = true;
159159
switch (_entry.GetId()) {
160160
case EXCHANGE_ACTION_ADD_ACCOUNT:
@@ -176,7 +176,7 @@ class Exchange : public Taskable<DataParamEntry> {
176176
/**
177177
* Sets an entry value.
178178
*/
179-
bool Set(const TaskSetterEntry &_entry, const DataParamEntry &_entry_value) {
179+
bool Set(const TaskSetterEntry &_entry, const DataParamEntry &_entry_value) override {
180180
bool _result = true;
181181
switch (_entry.GetId()) {
182182
default:

Exchange/Exchange.struct.h

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
*/
2727

2828
#ifndef __MQL__
29-
// Allows the preprocessor to include a header file when it is needed.
30-
#pragma once
29+
// Allows the preprocessor to include a header file when it is needed.
30+
#pragma once
3131
#endif
3232

3333
// Includes.
@@ -70,11 +70,16 @@ struct ExchangeParams {
7070
template <typename T>
7171
void Set(ENUM_TRADE_PARAM _param, T _value) {
7272
switch (_param) {
73-
case EXCHANGE_PARAM_ID:
74-
ConvertBasic::Convert(_value, id);
75-
return;
76-
case EXCHANGE_PARAM_NAME:
77-
ConvertBasic::Convert(_value, name);
73+
case TRADE_PARAM_BARS_MIN:
74+
case TRADE_PARAM_LOG_LEVEL:
75+
case TRADE_PARAM_LOT_SIZE:
76+
case TRADE_PARAM_MAGIC_NO:
77+
case TRADE_PARAM_MAX_SPREAD:
78+
case TRADE_PARAM_ORDER_COMMENT:
79+
case TRADE_PARAM_RISK_MARGIN:
80+
case TRADE_PARAM_SLIPPAGE:
81+
Alert("ExchangeParams::Set don't yet support ENUM_TRADE_PARAM settings.");
82+
DebugBreak();
7883
return;
7984
default:
8085
break;

Indicator/Indicator.struct.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ struct IndicatorParams {
7171
/* Special methods */
7272
// Constructor.
7373
IndicatorParams(ENUM_INDICATOR_TYPE _itype = INDI_NONE, ENUM_TIMEFRAMES _tf = PERIOD_CURRENT, string _name = "")
74-
: bps(0),
75-
custom_indi_name(""),
74+
: custom_indi_name(""),
7675
name(_name),
7776
shift(0),
77+
bps(0),
7878
// max_modes(_max_modes),
7979
// max_buffers(10),
8080
// idstype(_idstype),
@@ -84,7 +84,7 @@ struct IndicatorParams {
8484
itype(_itype) {
8585
Init();
8686
};
87-
IndicatorParams(string _name) : bps(0), custom_indi_name(""), name(_name), shift(0) { Init(); };
87+
IndicatorParams(string _name) : custom_indi_name(""), name(_name), shift(0), bps(0) { Init(); };
8888
/* Getters */
8989
template <typename T>
9090
T Get(STRUCT_ENUM(IndicatorParams, ENUM_INDI_PARAMS_PROP) _prop) const {

Indicator/IndicatorData.h

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ struct ExternInstantiateIndicatorBufferValueStorageDouble {
3535
};
3636

3737
// Includes.
38-
#include "../Platform/Chart/Bar.struct.h"
3938
#include "../Exchange/SymbolInfo/SymbolInfo.struct.h"
39+
#include "../Platform/Chart/Bar.struct.h"
4040
#include "../Platform/Chart/Chart.struct.tf.h"
4141
#include "../Storage/Cache/IndiBufferCache.h"
4242
#include "../Storage/Flags.struct.h"
@@ -220,7 +220,7 @@ class IndicatorData : public IndicatorBase {
220220
/**
221221
* Get full name of the indicator (with "over ..." part).
222222
*/
223-
string GetFullName() {
223+
string GetFullName() override {
224224
int _max_modes = Get<int>(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES));
225225
string _mode;
226226

@@ -408,13 +408,13 @@ class IndicatorData : public IndicatorBase {
408408
*/
409409
template <typename T>
410410
double GetMax(int start_bar = 0, int count = WHOLE_ARRAY) {
411-
double max = NULL;
411+
double max = -DBL_MAX;
412412
int last_bar = count == WHOLE_ARRAY ? (int)(GetBarShift(GetLastBarTime())) : (start_bar + count - 1);
413413
int _max_modes = Get<int>(STRUCT_ENUM(IndicatorDataParams, IDATA_PARAM_MAX_MODES));
414414

415415
for (int shift = start_bar; shift <= last_bar; ++shift) {
416416
double value = GetEntry(shift).GetMax<T>(_max_modes);
417-
if (max == NULL || value > max) {
417+
if (max == -DBL_MAX || value > max) {
418418
max = value;
419419
}
420420
}
@@ -1323,7 +1323,7 @@ class IndicatorData : public IndicatorBase {
13231323
/**
13241324
* Returns the indicator's entry value.
13251325
*/
1326-
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) = 0;
1326+
virtual IndicatorDataEntryValue GetEntryValue(int _mode = 0, int _abs_shift = 0) override = 0;
13271327

13281328
/**
13291329
* Returns the shift of the maximum value over a specific number of periods depending on type.
@@ -1386,7 +1386,7 @@ class IndicatorData : public IndicatorBase {
13861386
/**
13871387
* Get name of the indicator.
13881388
*/
1389-
virtual string GetName() { return EnumToString(GetType()); }
1389+
virtual string GetName() override { return EnumToString(GetType()); }
13901390

13911391
/**
13921392
* Gets open price for a given, optional shift.
@@ -1404,7 +1404,7 @@ class IndicatorData : public IndicatorBase {
14041404
/**
14051405
* Gets OHLC price values.
14061406
*/
1407-
virtual BarOHLC GetOHLC(int _rel_shift = 0) {
1407+
virtual BarOHLC GetOHLC(int _rel_shift = 0) override {
14081408
if (GetCandle() == THIS_PTR) {
14091409
Alert(GetFullName(), " candle indicator must override ", __FUNCTION__, "()!");
14101410
DebugBreak();
@@ -1608,7 +1608,6 @@ class IndicatorData : public IndicatorBase {
16081608
}
16091609

16101610
/**
1611-
/**
16121611
* Traverses source indicators' hierarchy and tries to find Ask, Bid, Spread,
16131612
* Volume and Tick Volume-featured indicator. IndicatorTick satisfies such
16141613
* requirements.
@@ -2158,12 +2157,12 @@ class IndicatorData : public IndicatorBase {
21582157
/**
21592158
* Converts relative shift into absolute one.
21602159
*/
2161-
virtual int ToAbsShift(int _rel_shift) = 0;
2160+
virtual int ToAbsShift(int _rel_shift) override = 0;
21622161

21632162
/**
21642163
* Converts absolute shift into relative one.
21652164
*/
2166-
virtual int ToRelShift(int _abs_shift) = 0;
2165+
virtual int ToRelShift(int _abs_shift) override = 0;
21672166

21682167
/**
21692168
* Loads and validates built-in indicators whose can be used as data source.

Math/Math.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@
2121
*/
2222

2323
#ifndef __MQL__
24-
// Allows the preprocessor to include a header file when it is needed.
25-
#pragma once
24+
// Allows the preprocessor to include a header file when it is needed.
25+
#pragma once
2626
#endif
2727

2828
// Includes.
@@ -264,7 +264,7 @@ class Math {
264264
int data_count = ArraySize(probability);
265265
if (data_count == 0) return false;
266266

267-
int error_code = 0, i;
267+
int i;
268268
ArrayResize(result, data_count);
269269

270270
//--- case sigma==0
@@ -402,8 +402,6 @@ class Math {
402402
return true;
403403
}
404404

405-
int err_code = 0;
406-
407405
for (i = 0; i < data_count; i++) {
408406
result[i] = RandomNonZero();
409407
}

Math/Matrix.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2538,13 +2538,9 @@ class Matrix {
25382538

25392539
void FromString(string text) {
25402540
ARRAY(MatrixDimension<X>*, _dimensions), *_root_dimension = NULL;
2541-
int _dimensions_length[MATRIX_DIMENSIONS] = {0, 0, 0, 0, 0};
25422541
int i, _number_start_pos;
2543-
bool _had_values;
25442542
X _number;
25452543
bool _expecting_value_or_child = true;
2546-
bool _expecting_comma = false;
2547-
bool _expecting_end = false;
25482544

25492545
for (i = 0; i < StringLen(text); ++i) {
25502546
unsigned short _char = StringGetCharacter(text, i), c;
@@ -2556,8 +2552,6 @@ class Matrix {
25562552
return;
25572553
}
25582554

2559-
_had_values = false;
2560-
25612555
if (ArraySize(_dimensions) != 0) {
25622556
_dimensions[ArraySize(_dimensions) - 1].type = MATRIX_DIMENSION_TYPE_CONTAINERS;
25632557
}
@@ -2574,13 +2568,11 @@ class Matrix {
25742568
}
25752569

25762570
_expecting_value_or_child = true;
2577-
_expecting_end = true;
25782571
break;
25792572

25802573
case ']':
25812574
ArrayResize(_dimensions, ArraySize(_dimensions) - 1, MATRIX_DIMENSIONS);
25822575
_expecting_value_or_child = true;
2583-
_expecting_comma = false;
25842576
break;
25852577

25862578
case '0':
@@ -2609,15 +2601,11 @@ class Matrix {
26092601
i -= 2;
26102602
_dimensions[ArraySize(_dimensions) - 1].type = MATRIX_DIMENSION_TYPE_VALUES;
26112603
_dimensions[ArraySize(_dimensions) - 1].AddValue(_number);
2612-
_expecting_end = true;
26132604
_expecting_value_or_child = true;
2614-
_expecting_comma = false;
26152605
break;
26162606

26172607
case ',':
26182608
_expecting_value_or_child = true;
2619-
_expecting_comma = false;
2620-
_expecting_end = false;
26212609
break;
26222610
case ' ':
26232611
case '\t':

Platform/Order.h

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1774,8 +1774,6 @@ class Order : public SymbolInfo {
17741774
* Update specific double value of the current order.
17751775
*/
17761776
bool RefreshDummy(ENUM_ORDER_PROPERTY_DOUBLE _prop_id) {
1777-
bool _result = false;
1778-
double _value = WRONG_VALUE;
17791777
ResetLastError();
17801778
switch (_prop_id) {
17811779
case ORDER_PRICE_CURRENT:
@@ -2850,14 +2848,14 @@ class Order : public SymbolInfo {
28502848
bool ExecuteAction(ENUM_ORDER_ACTION _action, ARRAY_REF(DataParamEntry, _args)) {
28512849
switch (_action) {
28522850
case ORDER_ACTION_CLOSE:
2853-
switch (oparams.dummy) {
2854-
case false:
2855-
return ArraySize(_args) > 0 ? OrderClose((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
2856-
: OrderClose(ORDER_REASON_CLOSED_BY_ACTION);
2857-
case true:
2858-
return ArraySize(_args) > 0 ? OrderCloseDummy((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
2859-
: OrderCloseDummy(ORDER_REASON_CLOSED_BY_ACTION);
2851+
if (oparams.dummy) {
2852+
return ArraySize(_args) > 0 ? OrderCloseDummy((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
2853+
: OrderCloseDummy(ORDER_REASON_CLOSED_BY_ACTION);
2854+
} else {
2855+
return ArraySize(_args) > 0 ? OrderClose((ENUM_ORDER_REASON_CLOSE)_args[0].integer_value)
2856+
: OrderClose(ORDER_REASON_CLOSED_BY_ACTION);
28602857
}
2858+
break;
28612859
case ORDER_ACTION_OPEN:
28622860
return !oparams.dummy ? OrderSend() >= 0 : OrderSendDummy() >= 0;
28632861
case ORDER_ACTION_COND_CLOSE_ADD:

0 commit comments

Comments
 (0)