Skip to content

Commit 9b89381

Browse files
committed
Mark override functions
If c++11 is used, we need to mark override functions. For older c++ versions we just define the macro as empty. Code that is only used for HXCPP_API_LEVEL 500 and above already requires c++11 as a minimum, so there we can just use the override keyword directly without the macro, as is already the case in some places.
1 parent 4cc1828 commit 9b89381

44 files changed

Lines changed: 1277 additions & 1267 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

include/Array.h

Lines changed: 65 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -152,18 +152,18 @@ class ArrayIterator : public cpp::FastIterator_obj<TO>
152152
ArrayIterator(Array<FROM> inArray) : mArray(inArray), mIdx(0) { }
153153

154154
// Fast versions ...
155-
bool hasNext() { return mIdx < mArray->length; }
155+
bool hasNext() HXCPP_OVERRIDE { return mIdx < mArray->length; }
156156

157157
inline TO toTo(const Dynamic &inD) { return inD.StaticCast<TO>(); }
158158

159159
template<typename T>
160160
inline TO toTo(T inT) { return inT; }
161161

162-
TO next() { return toTo(mArray->__get(mIdx++)); }
162+
TO next() HXCPP_OVERRIDE { return toTo(mArray->__get(mIdx++)); }
163163

164-
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER_NAME(mArray,"mArray"); }
164+
void __Mark(hx::MarkContext *__inCtx) HXCPP_OVERRIDE { HX_MARK_MEMBER_NAME(mArray,"mArray"); }
165165
#ifdef HXCPP_VISIT_ALLOCS
166-
void __Visit(hx::VisitContext *__inCtx) { HX_VISIT_MEMBER_NAME(mArray,"mArray"); }
166+
void __Visit(hx::VisitContext *__inCtx) HXCPP_OVERRIDE { HX_VISIT_MEMBER_NAME(mArray,"mArray"); }
167167
#endif
168168

169169
int mIdx;
@@ -179,19 +179,19 @@ class ArrayKeyValueIterator : public cpp::FastIterator_obj<Dynamic>
179179

180180
ArrayKeyValueIterator(Array<FROM> inArray) : mArray(inArray), mIdx(0) { }
181181

182-
bool hasNext() { return mIdx < mArray->length; }
182+
bool hasNext() HXCPP_OVERRIDE { return mIdx < mArray->length; }
183183

184184
inline TO toTo(const Dynamic &inD) { return inD.StaticCast<TO>(); }
185185

186186
template<typename T>
187187
inline TO toTo(T inT) { return inT; }
188188

189189

190-
Dynamic next();
190+
Dynamic next() HXCPP_OVERRIDE;
191191

192-
void __Mark(hx::MarkContext *__inCtx) { HX_MARK_MEMBER_NAME(mArray,"mArray"); }
192+
void __Mark(hx::MarkContext *__inCtx) HXCPP_OVERRIDE { HX_MARK_MEMBER_NAME(mArray,"mArray"); }
193193
#ifdef HXCPP_VISIT_ALLOCS
194-
void __Visit(hx::VisitContext *__inCtx) { HX_VISIT_MEMBER_NAME(mArray,"mArray"); }
194+
void __Visit(hx::VisitContext *__inCtx) HXCPP_OVERRIDE { HX_VISIT_MEMBER_NAME(mArray,"mArray"); }
195195
#endif
196196

197197
int mIdx;
@@ -265,14 +265,14 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES ArrayBase : public ArrayCommon
265265
inline char * getBase() const { return mBase; }
266266

267267

268-
hx::Val __SetField(const String &inString,const hx::Val &inValue ,hx::PropertyAccess inCallProp) { return null(); }
268+
hx::Val __SetField(const String &inString,const hx::Val &inValue ,hx::PropertyAccess inCallProp) HXCPP_OVERRIDE { return null(); }
269269

270270
static hx::Class __mClass;
271271
static hx::Class &__SGetClass() { return __mClass; }
272-
hx::Class __GetClass() const { return __mClass; }
273-
String toString();
274-
String __ToString() const;
275-
int __Compare(const hx::Object *inRHS) const;
272+
hx::Class __GetClass() const HXCPP_OVERRIDE { return __mClass; }
273+
String toString() HXCPP_OVERRIDE;
274+
String __ToString() const HXCPP_OVERRIDE;
275+
int __Compare(const hx::Object *inRHS) const HXCPP_OVERRIDE;
276276

277277

278278
void setData(void *inData, int inElements)
@@ -291,14 +291,14 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES ArrayBase : public ArrayCommon
291291
}
292292

293293

294-
int __GetType() const { return vtArray; }
294+
int __GetType() const HXCPP_OVERRIDE { return vtArray; }
295295

296296
inline size_t size() const { return length; }
297-
inline int __length() const { return (int)length; }
297+
inline int __length() const HXCPP_OVERRIDE { return (int)length; }
298298

299299
virtual String ItemString(int inI) = 0;
300300

301-
const char * __CStr() const { return mBase; }
301+
const char * __CStr() const HXCPP_OVERRIDE { return mBase; }
302302
inline const char *GetBase() const { return mBase; }
303303
inline char *GetBase() { return mBase; }
304304

@@ -344,7 +344,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES ArrayBase : public ArrayCommon
344344
hx::Val __pointerToBase();
345345
hx::Val __Field(const String &inString ,hx::PropertyAccess inCallProp) override = 0;
346346
#else
347-
hx::Val __Field(const String& inString, hx::PropertyAccess inCallProp);
347+
hx::Val __Field(const String& inString, hx::PropertyAccess inCallProp) HXCPP_OVERRIDE;
348348
#endif
349349

350350
inline void ____SetSize(int len) { resize(len); }
@@ -641,15 +641,15 @@ class Array_obj : public hx::ArrayBase
641641
hx::Val __Field(const String& inString, hx::PropertyAccess inCallProp) override;
642642
#endif
643643

644-
bool _hx_isInstanceOf(int inClassId)
644+
bool _hx_isInstanceOf(int inClassId) HXCPP_OVERRIDE
645645
{
646646
return inClassId==1 || inClassId==(int)hx::clsIdArrayBase || inClassId==(int)_hx_ClassId;
647647
}
648648

649-
virtual bool AllocAtomic() const { return !hx::ContainsPointers<ELEM_>(); }
649+
bool AllocAtomic() const HXCPP_OVERRIDE { return !hx::ContainsPointers<ELEM_>(); }
650650

651-
virtual Dynamic __GetItem(int inIndex) const { return __get(inIndex); }
652-
virtual Dynamic __SetItem(int inIndex,Dynamic inValue)
651+
Dynamic __GetItem(int inIndex) const HXCPP_OVERRIDE { return __get(inIndex); }
652+
Dynamic __SetItem(int inIndex, Dynamic inValue) HXCPP_OVERRIDE
653653
{
654654
ELEM_ &elem = Item(inIndex);
655655
elem = inValue;
@@ -709,7 +709,7 @@ class Array_obj : public hx::ArrayBase
709709
}
710710

711711

712-
void __Mark(hx::MarkContext *__inCtx)
712+
void __Mark(hx::MarkContext *__inCtx) HXCPP_OVERRIDE
713713
{
714714
if (mAlloc>0) hx::MarkAlloc((void *)mBase, __inCtx );
715715
if (length && hx::ContainsPointers<ELEM_>())
@@ -720,7 +720,7 @@ class Array_obj : public hx::ArrayBase
720720
}
721721

722722
#ifdef HXCPP_VISIT_ALLOCS
723-
void __Visit(hx::VisitContext *__inCtx)
723+
void __Visit(hx::VisitContext *__inCtx) HXCPP_OVERRIDE
724724
{
725725
if (mAlloc>0) __inCtx->visitAlloc((void **)&mBase);
726726
if (hx::ContainsPointers<ELEM_>())
@@ -736,9 +736,9 @@ class Array_obj : public hx::ArrayBase
736736

737737
inline Array<ELEM_> __SetSizeExact(int inLen);
738738

739-
int GetElementSize() const { return sizeof(ELEM_); }
739+
int GetElementSize() const HXCPP_OVERRIDE { return sizeof(ELEM_); }
740740

741-
String ItemString(int inI)
741+
String ItemString(int inI) HXCPP_OVERRIDE
742742
{
743743
String result(__get(inI));
744744
if (result==null()) return HX_CSTRING("null");
@@ -991,8 +991,8 @@ class Array_obj : public hx::ArrayBase
991991

992992
template<typename TO>
993993
Dynamic keyValueIteratorFast() { return new hx::ArrayKeyValueIterator<ELEM_,TO>(this); }
994-
995-
virtual hx::ArrayStore getStoreType() const
994+
995+
hx::ArrayStore getStoreType() const HXCPP_OVERRIDE
996996
{
997997
return (hx::ArrayStore) hx::ArrayTraits<ELEM_>::StoreType;
998998
}
@@ -1006,49 +1006,49 @@ class Array_obj : public hx::ArrayBase
10061006

10071007

10081008
// Dynamic interface
1009-
virtual hx::ArrayBase *__concat(const cpp::VirtualArray &a0) { return concat(a0).mPtr; }
1010-
virtual hx::ArrayBase *__copy() { return copy().mPtr; }
1011-
virtual void __insert(int inIndex,const Dynamic &a1) { insert(inIndex,a1);}
1012-
virtual Dynamic __iterator() { return iterator(); }
1013-
virtual Dynamic __keyValueIterator() { return keyValueIterator(); }
1014-
virtual ::String __join(::String a0) { return join(a0); }
1015-
virtual Dynamic __pop() { return pop(); }
1016-
virtual int __push(const Dynamic &a0) { return push(a0);}
1017-
virtual bool __contains(const Dynamic &a0) { return contains(a0); }
1018-
virtual bool __remove(const Dynamic &a0) { return remove(a0); }
1019-
virtual bool __removeAt(int inIndex) { return removeAt(inIndex); }
1020-
virtual int __indexOf(const Dynamic &a0,const Dynamic &a1) { return indexOf(a0, a1); }
1021-
virtual int __lastIndexOf(const Dynamic &a0,const Dynamic &a1) { return lastIndexOf(a0, a1); }
1022-
virtual void __reverse() { reverse(); }
1023-
virtual Dynamic __shift() { return shift(); }
1024-
virtual hx::ArrayBase *__slice(const Dynamic &a0,const Dynamic &a1) { return slice(a0,a1).mPtr; }
1025-
virtual hx::ArrayBase *__splice(const Dynamic &a0,const Dynamic &a1) { return splice(a0,a1).mPtr; }
1026-
virtual void __sort(const DynamicSorterFunc& a0) override { sort(a0); }
1027-
virtual ::String __toString() { return toString(); }
1028-
virtual void __unshift(const Dynamic &a0) { unshift(a0); }
1009+
hx::ArrayBase* __concat(const cpp::VirtualArray& a0) HXCPP_OVERRIDE { return concat(a0).mPtr; }
1010+
hx::ArrayBase *__copy() HXCPP_OVERRIDE { return copy().mPtr; }
1011+
void __insert(int inIndex,const Dynamic &a1) HXCPP_OVERRIDE { insert(inIndex,a1);}
1012+
Dynamic __iterator() HXCPP_OVERRIDE { return iterator(); }
1013+
Dynamic __keyValueIterator() HXCPP_OVERRIDE { return keyValueIterator(); }
1014+
::String __join(::String a0) HXCPP_OVERRIDE { return join(a0); }
1015+
Dynamic __pop() HXCPP_OVERRIDE { return pop(); }
1016+
int __push(const Dynamic &a0) HXCPP_OVERRIDE { return push(a0);}
1017+
bool __contains(const Dynamic &a0) HXCPP_OVERRIDE { return contains(a0); }
1018+
bool __remove(const Dynamic &a0) HXCPP_OVERRIDE { return remove(a0); }
1019+
bool __removeAt(int inIndex) HXCPP_OVERRIDE { return removeAt(inIndex); }
1020+
int __indexOf(const Dynamic &a0,const Dynamic &a1) HXCPP_OVERRIDE { return indexOf(a0, a1); }
1021+
int __lastIndexOf(const Dynamic &a0,const Dynamic &a1) HXCPP_OVERRIDE { return lastIndexOf(a0, a1); }
1022+
void __reverse() HXCPP_OVERRIDE { reverse(); }
1023+
Dynamic __shift() HXCPP_OVERRIDE { return shift(); }
1024+
hx::ArrayBase *__slice(const Dynamic &a0,const Dynamic &a1) HXCPP_OVERRIDE { return slice(a0,a1).mPtr; }
1025+
hx::ArrayBase *__splice(const Dynamic &a0,const Dynamic &a1) HXCPP_OVERRIDE { return splice(a0,a1).mPtr; }
1026+
void __sort(const DynamicSorterFunc& a0) HXCPP_OVERRIDE { sort(a0); }
1027+
::String __toString() HXCPP_OVERRIDE { return toString(); }
1028+
void __unshift(const Dynamic &a0) HXCPP_OVERRIDE { unshift(a0); }
10291029
#if (HXCPP_API_LEVEL>=500)
1030-
virtual cpp::VirtualArray_obj* __map(const DynamicMappingFunc& func) { return cpp::VirtualArray(map<Dynamic>(func)).mPtr; }
1030+
cpp::VirtualArray_obj* __map(const DynamicMappingFunc& func) override { return cpp::VirtualArray(map<Dynamic>(func)).mPtr; }
10311031
#else
1032-
virtual cpp::VirtualArray_obj* __map(const DynamicMappingFunc& func) { return map(func).mPtr; }
1032+
cpp::VirtualArray_obj* __map(const DynamicMappingFunc& func) HXCPP_OVERRIDE { return map(func).mPtr; }
10331033
#endif
1034-
virtual void __resize(int inLen) { resize(inLen); }
1034+
void __resize(int inLen) HXCPP_OVERRIDE { resize(inLen); }
10351035

1036-
virtual hx::ArrayBase *__filter(const DynamicFilterFunc &func) override { return filter(func).mPtr; }
1037-
virtual void __blit(int inDestElement,const cpp::VirtualArray &inSourceArray,int inSourceElement,int inElementCount)
1036+
hx::ArrayBase *__filter(const DynamicFilterFunc &func) HXCPP_OVERRIDE { return filter(func).mPtr; }
1037+
void __blit(int inDestElement,const cpp::VirtualArray &inSourceArray,int inSourceElement,int inElementCount) HXCPP_OVERRIDE
10381038
{
10391039
blit(inDestElement,inSourceArray,inSourceElement,inElementCount);
10401040
}
1041-
virtual int __memcmp(const cpp::VirtualArray &a0) { return memcmp(a0); }
1042-
virtual void __qsort(DynamicSorterFunc inCompare) override { this->qsort(inCompare); };
1041+
int __memcmp(const cpp::VirtualArray &a0) HXCPP_OVERRIDE { return memcmp(a0); }
1042+
void __qsort(DynamicSorterFunc inCompare) HXCPP_OVERRIDE { this->qsort(inCompare); };
10431043

1044-
virtual void set(int inIndex, const cpp::Variant &inValue) {
1044+
void set(int inIndex, const cpp::Variant &inValue) HXCPP_OVERRIDE {
10451045
ELEM_ &elem = Item(inIndex);
10461046
elem = ELEM_(inValue);
10471047
if (hx::ContainsPointers<ELEM_>()) {
10481048
HX_OBJ_WB_GET(this, hx::PointerOf(elem));
10491049
}
10501050
}
1051-
virtual void setUnsafe(int inIndex, const cpp::Variant &inValue) {
1051+
void setUnsafe(int inIndex, const cpp::Variant& inValue) HXCPP_OVERRIDE {
10521052
ELEM_ &elem = *(ELEM_ *)(mBase + inIndex*sizeof(ELEM_));
10531053
elem = ELEM_(inValue);
10541054
if (hx::ContainsPointers<ELEM_>()) { HX_OBJ_WB_GET(this,hx::PointerOf(elem)); }
@@ -1378,7 +1378,7 @@ cpp::VirtualArray Array_obj<ELEM_>::map(MappingFunc inFunc)
13781378

13791379
#ifdef HXCPP_VISIT_ALLOCS
13801380
#define ARRAY_VISIT_FUNC \
1381-
void __Visit(::hx::VisitContext *__inCtx) { HX_VISIT_MEMBER(mThis); }
1381+
void __Visit(::hx::VisitContext *__inCtx) HXCPP_OVERRIDE { HX_VISIT_MEMBER(mThis); }
13821382
#else
13831383
#define ARRAY_VISIT_FUNC
13841384
#endif
@@ -1517,19 +1517,19 @@ hx::Val Array_obj<ELEM_>::__Field(const String& inString, hx::PropertyAccess inC
15171517
bool __IsFunction() const { return true; } \
15181518
::Array_obj<ELEM_> *mThis; \
15191519
Reflective_##func(::Array_obj<ELEM_> *inThis) : mThis(inThis) { } \
1520-
::String toString() const{ return HX_CSTRING(#func) ; } \
1521-
::String __ToString() const{ return HX_CSTRING(#func) ; } \
1522-
int __GetType() const { return vtFunction; } \
1523-
void *__GetHandle() const { return mThis; } \
1524-
int __ArgCount() const { return ARG_C; } \
1525-
void __Mark(::hx::MarkContext *__inCtx) { HX_MARK_MEMBER(mThis); } \
1520+
::String toString() const { return HX_CSTRING(#func) ; } \
1521+
::String __ToString() const override { return HX_CSTRING(#func) ; } \
1522+
int __GetType() const override { return vtFunction; } \
1523+
void *__GetHandle() const override { return mThis; } \
1524+
int __ArgCount() const override { return ARG_C; } \
1525+
void __Mark(::hx::MarkContext *__inCtx) override { HX_MARK_MEMBER(mThis); } \
15261526
ARRAY_VISIT_FUNC \
1527-
::Dynamic __Run(const ::Array<::Dynamic> &inArgs) \
1527+
::Dynamic __Run(const ::Array<::Dynamic> &inArgs) override \
15281528
{ \
15291529
ret mThis->__##func(array_list); return ::Dynamic(); \
15301530
} \
15311531
run_func \
1532-
int __Compare(const ::hx::Object *inRHS) const \
1532+
int __Compare(const ::hx::Object *inRHS) const override \
15331533
{ \
15341534
if (!dynamic_cast<const Reflective_##func *>(inRHS)) return -1; \
15351535
return (mThis==inRHS->__GetHandle() ? 0 : -1); \

include/Enum.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES EnumBase_obj : public hx::Object
4747
static hx::ObjectPtr<hx::Class_obj> &__SGetClass();
4848

4949

50-
String toString();
50+
String toString() HXCPP_OVERRIDE;
5151

5252
EnumBase_obj() : index(-1) { }
5353
EnumBase_obj(const null &inNull) : index(-1) { }
54-
int __GetType() const { return vtEnum; }
54+
int __GetType() const HXCPP_OVERRIDE { return vtEnum; }
5555
static Dynamic __CreateEmpty();
5656
static Dynamic __Create(DynamicArray inArgs);
5757
static void __boot();
5858

59-
void __Mark(hx::MarkContext *__inCtx);
59+
void __Mark(hx::MarkContext *__inCtx) HXCPP_OVERRIDE;
6060
#ifdef HXCPP_VISIT_ALLOCS
61-
void __Visit(hx::VisitContext *__inCtx);
61+
void __Visit(hx::VisitContext *__inCtx) HXCPP_OVERRIDE;
6262
#endif
6363

6464
static hx::ObjectPtr<EnumBase_obj> Resolve(String inName);
@@ -98,7 +98,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES EnumBase_obj : public hx::Object
9898
inline ::Dynamic _hx_getParamI(int inId) { return _hx_getFixed()[inId]; }
9999
inline int _hx_getParamCount() { return mFixedFields; }
100100
// Alias for _hx_getParamI
101-
Dynamic __GetItem(int inIndex) const;
101+
Dynamic __GetItem(int inIndex) const HXCPP_OVERRIDE;
102102

103103
// For legacy
104104
inline String __Tag() const { return _hx_tag; }
@@ -108,7 +108,7 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES EnumBase_obj : public hx::Object
108108
int _hx_getIndex() const { return index; }
109109

110110

111-
int __Compare(const hx::Object *inRHS) const;
111+
int __Compare(const hx::Object *inRHS) const HXCPP_OVERRIDE;
112112

113113
virtual String GetEnumName( ) const { return HX_CSTRING("Enum"); }
114114
};

include/cpp/FastIterator.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ namespace cpp
77
class HXCPP_EXTERN_CLASS_ATTRIBUTES IteratorBase : public hx::Object
88
{
99
public:
10-
hx::Val __Field(const String &inString ,hx::PropertyAccess inCallProp);
10+
hx::Val __Field(const String &inString ,hx::PropertyAccess inCallProp) HXCPP_OVERRIDE;
1111
virtual bool hasNext() = 0;
1212
virtual Dynamic _dynamicNext() = 0;
1313

@@ -26,10 +26,10 @@ template<typename T>
2626
class HXCPP_EXTERN_CLASS_ATTRIBUTES FastIterator_obj : public IteratorBase
2727
{
2828
public:
29-
virtual bool hasNext() = 0;
29+
bool hasNext() HXCPP_OVERRIDE = 0;
3030
virtual T next() = 0;
3131

32-
virtual Dynamic _dynamicNext() { return next(); }
32+
Dynamic _dynamicNext() HXCPP_OVERRIDE { return next(); }
3333
};
3434

3535

@@ -84,15 +84,15 @@ class HXCPP_EXTERN_CLASS_ATTRIBUTES StringIterator : public cpp::FastIterator_ob
8484

8585
StringIterator(const String &inValue) : value(inValue), pos(0) { }
8686

87-
bool hasNext() { return pos<value.length; }
88-
void __Mark(hx::MarkContext *__inCtx)
87+
bool hasNext() HXCPP_OVERRIDE { return pos<value.length; }
88+
void __Mark(hx::MarkContext *__inCtx) HXCPP_OVERRIDE
8989
{
9090
cpp::FastIterator_obj<T>::__Mark(__inCtx);
9191
HX_MARK_MEMBER_NAME(value,"value");
9292
}
9393

9494
#ifdef HXCPP_VISIT_ALLOCS
95-
void __Visit(hx::VisitContext *__inCtx)
95+
void __Visit(hx::VisitContext *__inCtx) HXCPP_OVERRIDE
9696
{
9797
cpp::FastIterator_obj<T>::__Visit(__inCtx);
9898
HX_VISIT_MEMBER_NAME(value,"value");

0 commit comments

Comments
 (0)