From e66f603ccccf7e05057fb8685df3e4a001334f99 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Tue, 10 Sep 2024 14:37:30 +0200 Subject: [PATCH 1/2] Updated c++ compatibility table. --- CONTRIBUTING.md | 42 ++++++++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 12 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 313e71c91..fe650f54d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -32,18 +32,36 @@ For example, to format file inplace, run: To improve code compatibility, please use the following syntax: -| MQL | C++ | Syntax to use | -|:------------------|:------------------------|:---------------------------| -| `&this` | `this` | `THIS_PTR` | -| `GetPointer(obj)` | `*obj` | `GET_PTR(obj)` | -| `T name[]` | `_cpp_array name` | `ARRAY(T, name)` | -| `T N[]` | `_cpp_array> N` | `ARRAY(T, N)` | -| `long` | `long long` | `int64` | -| `obj.Method()` | `obj->Method()` | `obj PTR_DEREF Method()` | -| `obj.Ptr().a` | `obj.Ptr()->a` | `obj REF_DEREF a` | -| `obj.a1.a2` | `obj->a1->a2` | `PTR_ATTRIB2(obj, a1, a2)` | -| `obj.attr` | `obj->attr` | `PTR_ATTRIB(obj, attr)` | -| `str == NULL` | `str == NULL` | `IsNull(str)` | +| MQL | C++ | Syntax to use | +|:-------------------|:-------------------------|:---------------------------| +| `&this` | `this` | `THIS_PTR` | +| `this` | `*this` | `THIS_REF` | +| `GetPointer(obj)` | `&obj` | `GET_PTR(obj)` | +| `T name[]` | `std::vector name` | `ARRAY(T, name)` | +| `T name[5]` | `T name[5]` | `FIXED_ARRAY(T, name, 5)` | +| `X f(T[] v)` [ ]=5| `X f(T(&n)[5])` | `FIXED_ARRAY_REF(T, n, 5)` | +| `T name[]` | `vector> name` | `ARRAY(T, N)` | +| `long` | `long long` | `int64` | +| `unsigned long` | `unsigned long long` | `uint64` | +| `obj.Method()` *1| `obj->Method()` | `obj PTR_DEREF Method()` | +| `obj.Ptr().a` *3| `obj.Ptr()->a` | `obj REF_DEREF a` | +| `obj.a1.a2` *1| `obj->a1->a2` | `PTR_ATTRIB2(obj, a1, a2)` | +| `obj.attr` *1| `obj->attr` | `PTR_ATTRIB(obj, attr)` | +| `str == NULL` | `str == NULL` | `IsNull(str)` | +| `foo((Ba&)obj)` *2| `foo(*obj)` | `foo(PTR_TO_REF(obj))` | +| `foo((Ba*)obj)` *1| `foo(&obj)` | `foo(REF_TO_PTR(obj))` | +| `void* N` *4| `void*& N[]` | `VOID_DATA(N)` | +| `int foo` | `const int foo` | `CONST_CPP int foo` | +| `int foo(int v)` | `int foo(int& v)` | `int foo(int REF_CPP v)` | +| `X foo()` | `X& foo()` | `X REF_CPP foo()` | +| `obj == NULL` *1| `obj == nullptr` | `obj == nullptr` | +| `X foo(T* v)` | `X foo(T* v)` | `obj == nullptr` | +| `datetime d = NULL`| `datetime d = 0` | `datetime = 0` | + +**\*1** - Only if `obj` is a pointer. +**\*2** - Only if `obj` is an object or reference type (e.g., `Foo &`). +**\*3** - Only if `obj` is `Ref`. +**\*4** - Only when used as a parameter to function. ## Proposing changes From 6c09de3ab3264836704fe90d1b92dffb925beed5 Mon Sep 17 00:00:00 2001 From: Adrian Kierzkowski Date: Tue, 10 Sep 2024 17:25:52 +0200 Subject: [PATCH 2/2] Fixes to C++ compatibility table. --- CONTRIBUTING.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe650f54d..3e8525322 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -51,17 +51,17 @@ To improve code compatibility, please use the following syntax: | `foo((Ba&)obj)` *2| `foo(*obj)` | `foo(PTR_TO_REF(obj))` | | `foo((Ba*)obj)` *1| `foo(&obj)` | `foo(REF_TO_PTR(obj))` | | `void* N` *4| `void*& N[]` | `VOID_DATA(N)` | -| `int foo` | `const int foo` | `CONST_CPP int foo` | -| `int foo(int v)` | `int foo(int& v)` | `int foo(int REF_CPP v)` | -| `X foo()` | `X& foo()` | `X REF_CPP foo()` | +| `int foo` *5| `const int foo` | `CONST_CPP int foo` | +| `int foo(int v)` *5| `int foo(int& v)` | `int foo(int REF_CPP v)` | +| `X foo()` *5| `X& foo()` | `X REF_CPP foo()` | | `obj == NULL` *1| `obj == nullptr` | `obj == nullptr` | -| `X foo(T* v)` | `X foo(T* v)` | `obj == nullptr` | | `datetime d = NULL`| `datetime d = 0` | `datetime = 0` | **\*1** - Only if `obj` is a pointer. **\*2** - Only if `obj` is an object or reference type (e.g., `Foo &`). **\*3** - Only if `obj` is `Ref`. **\*4** - Only when used as a parameter to function. +**\*5** - In C++ we could want to return structure by reference or add `const` to the variable or result. ## Proposing changes