git » swiftpm » main » tree

[main] / Sources / c_snikket / iinclude / cpp / VirtualArray.h

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
namespace cpp
{

// This file is included twice - either side of the Array definition
#ifndef HX_VARRAY_DEFINED
#define HX_VARRAY_DEFINED


class VirtualArray : public hx::ObjectPtr<VirtualArray_obj>
{
   typedef hx::ObjectPtr<VirtualArray_obj> super;
public:
   typedef Dynamic Elem;

   inline VirtualArray() : super(0) { }
   inline VirtualArray(VirtualArray_obj *inObj) : super(inObj) { }
   inline VirtualArray(const null &inNull) : super(0) { }
   inline VirtualArray(const VirtualArray &inOther) : super( inOther.mPtr ) {  }

   // Build from foreign array
   template<typename SOURCE_> inline VirtualArray( const Array<SOURCE_> &inRHS );


   inline VirtualArray( const Dynamic &inRHS ) : super(0) { setDynamic(inRHS); }
   inline VirtualArray( const cpp::ArrayBase &inRHS ) : super(0) { setDynamic(inRHS); }
   inline VirtualArray(const ::cpp::Variant &inVariant) { setDynamic(inVariant.asObject()); }




   inline VirtualArray &operator=(const null &inNull) { mPtr = 0; return *this; }
   inline VirtualArray &operator=(Ptr inRHS) { mPtr = inRHS; return *this; }
   inline VirtualArray &operator=(const VirtualArray &inRHS) { mPtr = inRHS.mPtr; return *this; }

   inline void setDynamic( const Dynamic &inRHS );

   template<typename T>
   inline VirtualArray Add(const T &inVal);


   inline bool operator==(const Dynamic &value) const { return value==*this; }
   template<typename SOURCE_> inline bool operator==( const Array<SOURCE_> &inRHS );

   inline bool operator!=(Dynamic value) const { return value!=*this; }
   template<typename SOURCE_> inline bool operator!=( const Array<SOURCE_> &inRHS ) { return inRHS!=*this; }

};






class HXCPP_EXTERN_CLASS_ATTRIBUTES VirtualArray_obj : public hx::ArrayCommon
{
   typedef hx::ArrayStore ArrayStore;
   typedef hx::ArrayBase ArrayBase;

public:
   HX_IS_INSTANCE_OF enum { _hx_ClassId = hx::clsIdVirtualArray };

   typedef hx::Object super;
   ArrayStore  store;
   ArrayBase   *base;

   VirtualArray_obj(ArrayBase *inBase=0, bool inFixed=false) : base(inBase)
   {
      mArrayConvertId = hx::aciVirtualArray;
      store = inFixed && inBase ? hx::arrayFixed : base ? base->getStoreType() : hx::arrayEmpty;
      #ifdef HXCPP_GC_GENERATIONAL
      if (base)
         HX_OBJ_WB_GET(this,base);
      #endif
   }

   VirtualArray_obj(ArrayStore inStore)
   {
      mArrayConvertId = hx::aciVirtualArray;
      store = inStore;
   }

   hx::Object *__GetRealObject() { return base?(hx::Object *)base:(hx::Object *)this; }

   inline static VirtualArray __new(int inSize=0,int inReserve=0)
   {
      VirtualArray result = new VirtualArray_obj(hx::arrayEmpty);
      if (inSize>0)
         result->__SetSizeExact(inSize);
      if (inReserve>0)
         result->reserve(inReserve);
      return result;
   }

   int __Compare(const hx::Object *inRHS) const;

   inline int get_length() const
   {
      return base ? base->length : 0;
   }

   inline void checkBase() const
   {
      #ifdef HXCPP_CHECK_POINTER
      if (store==hx::arrayNull)
      {
         hx::NullReference("Array", true);
         // The handler might have fixed up the null value
         if (store==hx::arrayNull) hx::NullReference("Array", false);
      }
      #endif
   }

   void EnsureStorage(const Dynamic &inValue)
   {
      if (!inValue.mPtr)
      {
         EnsureNullStorage();
      }
      else switch(inValue->__GetType())
      {
         case vtBool: EnsureBoolStorage(); break;
         case vtInt: EnsureIntStorage(); break;
         case vtFloat: EnsureFloatStorage(); break;
         case vtString: EnsureStringStorage(); break;
         case vtInt64: EnsureInt64Storage(); break;
         default: EnsureObjectStorage();
      }
   }


   void EnsureStorage(const cpp::Variant &inValue)
   {
      switch(inValue.type)
      {
         case Variant::typeObject:
               if (!inValue.valObject)
                  EnsureNullStorage();
               else
                  EnsureObjectStorage();
               break;
         case Variant::typeString: EnsureStringStorage(); break;
         case Variant::typeDouble: EnsureFloatStorage(); break;
         case Variant::typeInt: EnsureIntStorage(); break;
         case Variant::typeBool: EnsureBoolStorage(); break;
         case Variant::typeInt64: EnsureInt64Storage(); break;
      }
   }


   void MakeIntArray();
   void MakeInt64Array();
   void MakeObjectArray();
   void MakeFloatArray();
   void MakeBoolArray();
   void MakeStringArray();

   void EnsureStorage(const VirtualArray &inValue) { EnsureObjectStorage(); }
   void EnsureStorage(const unsigned char &inValue) { EnsureIntStorage(); }
   void EnsureStorage(const bool &inValue) { EnsureBoolStorage(); }
   void EnsureStorage(const String &inValue) { EnsureStringStorage(); }
   void EnsureStorage(const double &inValue) { EnsureFloatStorage(); }
   void EnsureStorage(const float &inValue) { EnsureFloatStorage(); }
   void EnsureStorage(const int &inValue) { EnsureIntStorage(); }
   void EnsureStorage(const cpp::Int64 &inValue) { EnsureInt64Storage(); }
   void EnsureStorage(const cpp::UInt64 &inValue) { EnsureInt64Storage(); }
   void EnsureStorage(const null &inValue) { EnsureNullStorage(); }
   template<typename T>
   void EnsureStorage(const T &inValue) { EnsureObjectStorage(); }

   inline void EnsureBoolStorage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayObject:
         case hx::arrayFixed:
         case hx::arrayBool:
            return;
         case hx::arrayEmpty:
            MakeBoolArray();
            break;
         case hx::arrayInt:
         case hx::arrayInt64:
         case hx::arrayFloat:
         case hx::arrayString:
            MakeObjectArray();
            break;
      }
   }
   inline void EnsureStringStorage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayObject:
         case hx::arrayFixed:
         case hx::arrayString:
            return;
         case hx::arrayEmpty:
            MakeStringArray();
            break;
         case hx::arrayInt:
         case hx::arrayInt64:
         case hx::arrayFloat:
         case hx::arrayBool:
            MakeObjectArray();
            break;
      }
   }
   inline void EnsureFloatStorage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayFloat:
         case hx::arrayObject:
         case hx::arrayFixed:
            return;
         case hx::arrayInt:
         case hx::arrayInt64:
         case hx::arrayEmpty:
            MakeFloatArray();
            break;
         case hx::arrayBool:
         case hx::arrayString:
            MakeObjectArray();
            break;
      }
   }

   inline void EnsureIntStorage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayInt:
         case hx::arrayInt64:
         case hx::arrayFloat:
         case hx::arrayObject:
         case hx::arrayFixed:
            return;
         case hx::arrayEmpty:
            MakeIntArray();
            break;
         case hx::arrayBool:
         case hx::arrayString:
            MakeObjectArray();
            break;
      }
   }

   inline void EnsureInt64Storage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayInt64:
         case hx::arrayFloat:
         case hx::arrayObject:
         case hx::arrayFixed:
            return;
         case hx::arrayInt:
         case hx::arrayEmpty:
            MakeInt64Array();
            break;
         case hx::arrayBool:
         case hx::arrayString:
            MakeObjectArray();
            break;
      }
   }

   inline void EnsureObjectStorage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayObject:
         case hx::arrayFixed:
            return;
         case hx::arrayEmpty:
         case hx::arrayInt:
         case hx::arrayInt64:
         case hx::arrayFloat:
         case hx::arrayBool:
         case hx::arrayString:
            MakeObjectArray();
            break;
      }
   }
   inline void EnsureNullStorage()
   {
      switch(store)
      {
         case hx::arrayNull:
         case hx::arrayObject:
         case hx::arrayFixed:
         case hx::arrayString:
            return;
         case hx::arrayEmpty:
         case hx::arrayInt:
         case hx::arrayInt64:
         case hx::arrayFloat:
         case hx::arrayBool:
            MakeObjectArray();
            break;
      }
   }

   template<typename F> void fixType();
   template<typename F> F castArray();

   void EnsureBase();
   void CreateEmptyArray(int inLen);

   void EnsureArrayStorage(ArrayStore inValue);
   void EnsureArrayStorage(VirtualArray inValue);

   void __Mark(hx::MarkContext *__inCtx)
   {
      HX_MARK_OBJECT(base);
   }
   #ifdef HXCPP_VISIT_ALLOCS
   void __Visit(hx::VisitContext *__inCtx)
   {
      if (base)
        __inCtx->visitObject( (hx::Object **)&base);
   }
   #endif


   // Used by cpp.ArrayBase
   inline int getElementSize() const { return base ? base->GetElementSize() : 0; }
   inline int getByteCount() const { return base ? base->getByteCount() : 0; }
   inline char * getBase() const { return base ? base->GetBase() : 0; }
   hx::Val __SetField(const String &inString,const hx::Val &inValue ,hx::PropertyAccess inCallProp) { return null(); }

   static hx::Class &__SGetClass() { return hx::ArrayBase::__mClass; }
   hx::Class __GetClass() const;
   String toString();
   String __ToString() const { return const_cast<VirtualArray_obj *>(this)->toString(); }

   void setData(void *inData, int inElements) { EnsureBase(); base->setData(inData, inElements); }
   void setUnmanagedData(void *inData, int inElements) { EnsureBase(); base->setUnmanagedData(inData, inElements); }

   int __GetType() const { return vtArray; }

   inline size_t size() const { checkBase(); return store==hx::arrayEmpty ? 0 : base->length; }
   inline int __length() const { checkBase(); return store==hx::arrayEmpty ? 0 : (int)base->length; }

   String ItemString(int inI) { checkBase(); return store==hx::arrayEmpty ? null() : base->ItemString(inI); }

   const char * __CStr() const { return store==hx::arrayEmpty ? "[]" : store==hx::arrayNull ? "null" : base->__CStr(); }
   inline const char *GetBase() const { return base ? base->GetBase() : 0; }
   inline char *GetBase() { return base ? base->GetBase() : 0; }

   int GetElementSize() const { checkBase(); return store==hx::arrayEmpty ? 0 : base->GetElementSize(); }

   inline void reserve(int inSize) const
   {
      if (base)
         base->reserve(inSize);
   }

   inline int capacity()
   {
      if (base)
         return base->capacity();
      return 0;
   }

   void resize(int inLen)
   {
      if (!base)
         CreateEmptyArray(inLen);
      else
         base->resize(inLen);
   }
   void __SetSize(int inLen) { resize(inLen); }

   VirtualArray __SetSizeExact(int inLen=0)
   {
      if (!base && inLen)
         CreateEmptyArray(inLen);
      else if (base)
         base->__SetSizeExact(inLen);
      return this;
   }

   void safeSort(Dynamic sorter, bool isString) { checkBase(); if (store!=hx::arrayEmpty) base->safeSort(sorter,isString); }

   inline void __unsafeStringReference(String inString) { if (base) base->__unsafeStringReference(inString); }


   Dynamic __GetItem(int inIndex) const;
   Dynamic __SetItem(int inIndex,Dynamic inValue);
   hx::Val __Field(const String &inString, hx::PropertyAccess inCallProp);

   template<typename T>
   inline const T &set(int inIdx, const T &inVal)
   {
      if (store!=hx::arrayFixed)
      {
         if (inIdx>(store==hx::arrayEmpty ? 0 : (int)base->length) )
            EnsureObjectStorage();
         else
            EnsureStorage(inVal);
      }
      base->set(inIdx, inVal);
      return inVal;
   }


   template<typename T>
   inline int push(const T &inVal)
   {
      if (store!=hx::arrayFixed) EnsureStorage(inVal);
      return base->__push(Dynamic(inVal));
   }


   template<typename T>
   inline VirtualArray_obj *Add(const T &inVal)
   {
      if (store!=hx::arrayFixed) EnsureStorage(inVal);
      base->__push(Dynamic(inVal));
      return this;
   }

   inline Dynamic pop() { checkBase(); return store==hx::arrayEmpty ? null() : base->__pop(); }

   inline bool contains(Dynamic inValue)
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return false;
      EnsureStorage(inValue);
      return base->__contains(inValue);
   }

   inline bool remove(Dynamic inValue)
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return false;
      EnsureStorage(inValue);
      return base->__remove(inValue);
   }

   inline bool removeAt(int inIndex) { checkBase(); return (store!=hx::arrayEmpty) && base->__removeAt(inIndex); }

   int indexOf(Dynamic inValue, Dynamic fromIndex = null())
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return -1;
      EnsureStorage(inValue);
      return (int)base->__indexOf(inValue,fromIndex);
   }
   int lastIndexOf(Dynamic inValue, Dynamic fromIndex = null())
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return -1;
      EnsureStorage(inValue);
      return (int)base->__lastIndexOf(inValue,fromIndex);
   }

   Dynamic shift() { checkBase(); return store==hx::arrayEmpty ? null() : base->__shift(); }

   VirtualArray concat( VirtualArray inTail )
   {
      inTail->checkBase();
      EnsureArrayStorage(inTail);
      if (inTail->__length()<1)
         return copy();
      return new VirtualArray_obj( base->__concat(inTail), store==hx::arrayFixed );
   }
   VirtualArray copy( )
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return new VirtualArray_obj(hx::arrayEmpty);

      return new VirtualArray_obj(base->__copy(), store==hx::arrayFixed);
   }
   VirtualArray slice(int inPos, Dynamic end = null())
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return new VirtualArray_obj(hx::arrayEmpty);
      return new VirtualArray_obj(base->__slice(inPos,end), store==hx::arrayFixed);
   }
   VirtualArray splice(int inPos, int len);
   VirtualArray map(Dynamic inFunc);
   VirtualArray filter(Dynamic inFunc);

   template<typename T>
   inline VirtualArray init(int inIndex, const T &inVal)
   {
      if (store!=hx::arrayFixed) EnsureStorage(inVal);
      __SetItem(inIndex,inVal);
      return this;
   } 

   inline Dynamic __unsafe_set(int inIndex, const Dynamic &val)  { return __SetItem(inIndex,val); } 
   inline Dynamic __unsafe_get(int inIndex)  { return __GetItem(inIndex); } 


   template<typename T>
   inline void insert(int inPos, const T &inValue)
   {
      if (store!=hx::arrayFixed)
      {
         if (inPos>(store==hx::arrayEmpty ? 0 : (int)base->length) )
            EnsureObjectStorage();
         else
            EnsureStorage(inValue);
      }

      base->__insert(inPos,inValue);
   }

   template<typename T>
   inline void unshift(const T& inValue)
   {
      if (store!=hx::arrayFixed) EnsureStorage(inValue);
      base->__unshift(inValue);
   }

   inline void reverse() { checkBase(); if (store!=hx::arrayEmpty) base->__reverse(); }

   inline void qsort(Dynamic inSorter) { checkBase(); if (base) base->__qsort(inSorter); }

   inline void sort(Dynamic inSorter) { checkBase(); if (base) base->__sort(inSorter); }

   Dynamic iterator() { checkBase(); return  !base ? getEmptyIterator() :  base->__iterator(); }
   static Dynamic getEmptyIterator();

   Dynamic keyValueIterator() { checkBase(); return  !base ? getEmptyIterator() :  base->__keyValueIterator(); }

   bool IsByteArray() const { checkBase(); return store!=hx::arrayEmpty && base->IsByteArray(); }

   void zero(Dynamic inFirst, Dynamic inCount) { checkBase(); if (store!=hx::arrayEmpty) base->zero(inFirst,inCount); }

   inline int memcmp(VirtualArray inOther)
   {
      checkBase();
      if (store==hx::arrayEmpty)
         return inOther->__length() == 0;
      return base->__memcmp(inOther);
   }
   inline void blit(int inDestElement,  cpp::VirtualArray inSourceArray, int inSourceElement, int inElementCount)
   {
      inSourceArray->checkBase();
      EnsureArrayStorage(inSourceArray);
      if (base)
         base->__blit(inDestElement, inSourceArray, inSourceElement, inElementCount);
   }

   String join(String inSeparator) { checkBase(); if (!base) return HX_CSTRING(""); return base->__join(inSeparator); }


   Dynamic __get(int inIndex) const { checkBase(); if (store==hx::arrayEmpty) return null(); return base->__GetItem(inIndex); }

   Dynamic concat_dyn();
   Dynamic copy_dyn();
   Dynamic insert_dyn();
   Dynamic iterator_dyn();
   Dynamic keyValueIterator_dyn();
   Dynamic join_dyn();
   Dynamic pop_dyn();
   Dynamic push_dyn();
   Dynamic contains_dyn();
   Dynamic remove_dyn();
   Dynamic removeAt_dyn();
   Dynamic indexOf_dyn();
   Dynamic lastIndexOf_dyn();
   Dynamic reverse_dyn();
   Dynamic shift_dyn();
   Dynamic slice_dyn();
   Dynamic splice_dyn();
   Dynamic sort_dyn();
   Dynamic toString_dyn();
   Dynamic unshift_dyn();
   Dynamic map_dyn();
   Dynamic filter_dyn();
   Dynamic __SetSize_dyn();
   Dynamic __SetSizeExact_dyn();
   Dynamic __unsafe_get_dyn();
   Dynamic __unsafe_set_dyn();
   Dynamic blit_dyn();
   Dynamic zero_dyn();
   Dynamic memcmp_dyn();
   Dynamic resize_dyn();
};


//typedef hx::ObjectPtr< VirtualArray_obj > VirtualArray;



#else // !HX_VARRAY_DEFINED


// Build dynamic array from foreign array
template<typename SOURCE_>
VirtualArray::VirtualArray( const Array<SOURCE_> &inRHS )
   : super( !inRHS.mPtr ? 0 : new VirtualArray_obj( inRHS.mPtr, true) )
{
}


template<typename T>
inline VirtualArray VirtualArray::Add(const T &inVal)
{
   mPtr->push(inVal);
   return *this;
}


inline void VirtualArray::setDynamic( const Dynamic &inRHS )
{
   hx::Object *ptr = inRHS.GetPtr(); 
   if (ptr)
   {
      if (ptr->__GetClass().mPtr == super::__SGetClass().mPtr )
      {
         cpp::VirtualArray_obj *varray = dynamic_cast<cpp::VirtualArray_obj *>(ptr);
         if (varray)
            mPtr = varray;
         else
            mPtr = new VirtualArray_obj(dynamic_cast<cpp::ArrayBase_obj *>(ptr), true);
      }
   }
}



template<typename F>
void VirtualArray_obj::fixType()
{
   if (store==hx::arrayFixed)
      return;

   store = hx::arrayFixed;
   if (base && base->length>0)
   {
      Array<F> fixedArray = Dynamic(base);
      base = fixedArray.mPtr;
   }
   else
   {
      base = new Array_obj<F>(0,0);
   }
   #ifdef HXCPP_GC_GENERATIONAL
   if (base)
      HX_OBJ_WB_GET(this,base);
   #endif
}

template<typename ARRAY >
ARRAY VirtualArray_obj::castArray()
{
   if (store==hx::arrayFixed)
      return Dynamic(base);

   store = hx::arrayFixed;
   if (base && base->length>0)
   {
      ARRAY fixedArray = Dynamic(base);
      base = fixedArray.mPtr;
      #ifdef HXCPP_GC_GENERATIONAL
      if (base)
         HX_OBJ_WB_GET(this,base);
      #endif
      return fixedArray;
   }
   else
   {
      ARRAY fixedArray(0,0);
      base = fixedArray.mPtr;
      #ifdef HXCPP_GC_GENERATIONAL
      if (base)
         HX_OBJ_WB_GET(this,base);
      #endif
      return fixedArray;
   }
}

template<typename SOURCE_>
inline bool VirtualArray::operator==( const Array<SOURCE_> &inRHS )
{
   if (!mPtr)
      return inRHS.mPtr;
   return mPtr->castArray< Array<SOURCE_> >() == inRHS;
}

} // end namespace cpp

HXCPP_EXTERN_CLASS_ATTRIBUTES Dynamic _hx_reslove_virtual_array(cpp::VirtualArray inArray);



namespace hx
{
// For type inference when marking
template<> inline void MarkMember(cpp::VirtualArray &outT,hx::MarkContext *__inCtx)
  { HX_MARK_OBJECT(outT.mPtr); }

#ifdef HXCPP_VISIT_ALLOCS
template<> inline void VisitMember(cpp::VirtualArray &outT,hx::VisitContext *__inCtx)
{
   HX_VISIT_OBJECT(outT.mPtr);
}
#endif

} // end namespace hx

namespace cpp
{
#endif // HX_VARRAY_DEFINED
}