CodePorting.Translator Cs2Cpp
CodePorting.Translator.Cs2Cpp.Framework
object.h
1
2#pragma once
3
4#include <defines.h>
5
6#include <system/type_info.h>
7#include <system/reflection.h>
8#include <system/smart_ptr.h>
9#include <system/weak_ptr.h>
10#include <system/dynamic_weak_ptr.h>
11#include <system/refcount.h>
12
13#include <system/cycles_detection.h>
14#include <system/details/dbg_tools.h>
15#include <system/details/dbg_garbage_collection.h>
16#include <system/details/leakage_detector.h>
17#include <system/details/lock_context.h>
18
19#include <type_traits>
20#include <string>
21#include <list>
22#include <utility>
23#include <map>
24#include <memory>
25#include <cmath>
26#include <mutex>
27
28
29#ifdef ASPOSECPPLIB_BEING_BUILT
30#include <boost/thread/recursive_mutex.hpp>
31#endif
32
33namespace boost {
35 ASPOSECPP_3RD_PARTY_CLASS(recursive_mutex);
36}
37
38
39namespace System
40{
41
42class String;
43class Details_Exception;
44
61class ASPOSECPP_SHARED_CLASS Object
62{
63public:
66#ifdef ASPOSE_GET_SHARED_MEMBERS
68 typedef System::Details::SharedMembersType shared_members_type;
69#endif
71 ASPOSECPP_SHARED_API Object();
73 virtual ASPOSECPP_SHARED_API ~Object();
74
75 // the following 2 members needed for MemberwiseClone()
78 ASPOSECPP_SHARED_API Object(Object const& x);
81 Object& operator = (Object const& x){ ASPOSE_UNUSED(x); return *this; } // does nothing
84 Object* SharedRefAdded();
87 int SharedRefRemovedSafe();
91 int RemovedSharedRefs(int count);
94 Detail::SmartPtrCounter* WeakRefAdded();
96 void WeakRefRemoved();
99 inline Detail::SmartPtrCounter* GetCounter();
102 int SharedCount() const;
104 ASPOSECPP_SHARED_API void Lock();
106 ASPOSECPP_SHARED_API void Unlock();
110 virtual ASPOSECPP_SHARED_API bool Equals(ptr obj);
115 static bool ReferenceEquals(ptr const& objA, ptr const& objB)
116 {
117 return objA == objB;
118 }
124 template<typename T>
125 static typename std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const& objA, T const& objB)
126 {
127 return &objA == &objB;
128 }
133 template<typename T>
134 static typename std::enable_if<!IsSmartPtr<T>::value, bool>::type ReferenceEquals(T const& objA, std::nullptr_t)
135 {
136 return false;
137 }
144 template<typename T1, typename T2>
145 static typename std::enable_if<IsSmartPtr<T1>::value && IsSmartPtr<T2>::value, bool>::type Equals(T1 const& objA, T2 const& objB)
146 {
147 return ReferenceEquals(objA, objB) || (objA != nullptr && objB != nullptr && objA->Equals(objB));
148 }
155 template<typename T1, typename T2>
156 static typename std::enable_if<!IsSmartPtr<T1>::value && !IsSmartPtr<T2>::value, bool>::type Equals(T1 const& objA, T2 const& objB)
157 {
158 return objA == objB;
159 }
162 virtual ASPOSECPP_SHARED_API int32_t GetHashCode() const;
165 virtual ASPOSECPP_SHARED_API String ToString() const;
169 virtual ASPOSECPP_SHARED_API ptr MemberwiseClone() const;
172 static const TypeInfo& Type()
173 {
174 return *static_holder<ThisTypeInfo>();
175 }
178 virtual ASPOSECPP_SHARED_API const TypeInfo& GetType() const;
182 virtual ASPOSECPP_SHARED_API bool Is(const TypeInfo& targetType) const;
185 virtual ASPOSECPP_SHARED_API void SetTemplateWeakPtr(uint32_t argument);
186#ifdef ASPOSE_GET_SHARED_MEMBERS
188 virtual ASPOSECPP_SHARED_API void GetSharedMembers(shared_members_type&) const;
189#endif
194 virtual ASPOSECPP_SHARED_API bool FastCast(const Details::FastRttiBase& helper, void** out_ptr) const;
195
196#ifdef __DBG_TOOLS
197private:
198 friend struct ::System::Details::DbgTools;
199
201 System::Details::DbgTools::stack_s_int_string_t m_personal_st;
203 bool m_rec_personal_st;
205 mutable int m_instanceNo;
206#endif
207
208#if defined(ENABLE_CYCLES_DETECTION_EXT)
209private:
210 friend class System::Debug::ExternalObjectCollector;
211 unsigned m_instance_id;
212#endif
213
214#ifdef __DBG_FOR_EACH_MEMBER
215public:
218 virtual ASPOSECPP_SHARED_API void DBG_for_each_member(DBG::for_each_member_visitor &visitor) const;
221 virtual const char* DBG_class_name() const { return "Object"; }
222#endif
223
224private:
225 friend class ::System::Detail::SmartPtrCounter;
226 friend class ::System::Details::LeakageDetector;
227
228#ifdef ENABLE_EXTERNAL_REFCOUNT
230 std::unique_ptr<Detail::SmartPtrCounter> m_external_count;
231#else
233 std::atomic<Detail::SmartPtrCounter*> m_external_count;
235 Detail::RefCount m_shared_count;
236#endif
237
239 struct ThisTypeInfo : TypeInfoPtr
240 {
242 ThisTypeInfo()
243 : TypeInfoPtr(u"System::Object")
244 {}
245
246 // Explicitly deleting several members to avoid warnings
247 ThisTypeInfo(const ThisTypeInfo&) = delete;
248 ThisTypeInfo(ThisTypeInfo&&) = delete;
249 ThisTypeInfo& operator = (const ThisTypeInfo&) = delete;
250 ThisTypeInfo& operator = (ThisTypeInfo&&) = delete;
251 };
252
254 typedef boost::recursive_mutex mutex;
256 class GlobalMutexHolder;
258 static GlobalMutexHolder s_globalMutex;
259
260 mutex* volatile m_objectMutex;
261
262#ifdef ASPOSECPP_DEBUG
264 mutable const std::string* m_currentConstructor;
265#endif
266
267#ifdef __DBG_GARBAGE_COLLECTION
269 int m_generation;
270 friend bool ASPOSECPP_SHARED_API System::Details::__buildIsolationIsland(Object *&last, std::map<const Object*, shared_members_type> &island, int generation);
271#endif
272};
273
279template<>
280inline bool Object::Equals<float, float>(float const& objA, float const& objB)
281{
282 return (std::isnan(objA) && std::isnan(objB)) ? true : objA == objB;
283}
284
290template<>
291inline bool Object::Equals<double, double>(double const& objA, double const& objB)
292{
293 return (std::isnan(objA) && std::isnan(objB)) ? true : objA == objB;
294}
295
298{
299#ifdef ENABLE_EXTERNAL_REFCOUNT
300 return GetCounter()->SharedRefAdded();
301#else
302 ++m_shared_count;
303 return this;
304#endif
305}
306
309{
310#ifdef ENABLE_EXTERNAL_REFCOUNT
311 return GetCounter()->SharedRefRemovedSafe();
312#else
313 return --m_shared_count;
314#endif
315}
316
318inline int Object::RemovedSharedRefs(int count)
319{
320#ifdef ENABLE_EXTERNAL_REFCOUNT
321 return m_external_count->DecreaseSharedRef(count);
322#else
323 return (m_shared_count -= count);
324#endif
325}
326
328inline Detail::SmartPtrCounter* Object::WeakRefAdded()
329{
330 return GetCounter()->WeakRefAdded();
331}
332
335{
336 GetCounter()->WeakRefRemoved();
337}
338
340inline Detail::SmartPtrCounter* Object::GetCounter()
341{
342#ifdef ENABLE_EXTERNAL_REFCOUNT
343 return m_external_count.get();
344#else
345 Detail::SmartPtrCounter *counter = m_external_count.load();
346 if (counter == nullptr)
347 {
348 std::unique_ptr<Detail::SmartPtrCounter> new_counter(new Detail::SmartPtrCounter(this));
349 if (m_external_count.compare_exchange_strong(counter, new_counter.get()))
350 return new_counter.release();
351 }
352 return counter;
353#endif
354}
355
357inline int Object::SharedCount() const
358{
359#ifdef ENABLE_EXTERNAL_REFCOUNT
360 return m_external_count->SharedCount();
361#else
362 return m_shared_count;
363#endif
364}
365
366// ------------------------ casting implemetation --------------------------------
367namespace Details {
370 [[noreturn]] ASPOSECPP_SHARED_API void ThrowInvalidCastException();
374 template <typename T>
375 T ThrowInvalidCastException_helper()
376 {
377 ThrowInvalidCastException();
378 return T();
379 }
380}
381
383template <typename TTo>
385{
388};
389
391template <typename TTo>
392struct CastResult<SmartPtr<TTo>>
393{
395 typedef SmartPtr<TTo> type;
396};
398
400struct ExceptionWrapperType {};
402
405template <typename T> struct IsExceptionWrapper : std::is_base_of<System::ExceptionWrapperType, T> {};
406
412template<typename TTo, typename TFrom>
413typename std::enable_if<!IsExceptionWrapper<TTo>::value, typename CastResult<TTo>::type>::type
414Cast_noexcept(SmartPtr<TFrom> const& obj) // throw()
415{
416 return obj.template dynamic_pointer_cast<TTo>();
417}
418
425template<typename TTo, typename TFrom>
426typename std::enable_if<!IsExceptionWrapper<TTo>::value, typename CastResult<TTo>::type>::type
427Cast(SmartPtr<TFrom> const& obj) // throw(System::InvalidCastException)
428{
429 auto casted = dynamic_cast<TTo*>(obj.get());
430 return obj && !casted
431 ? Details::ThrowInvalidCastException_helper<typename CastResult<TTo>::type>()
432 : SmartPtr<TTo>(obj, casted, obj.get_Mode());
433}
434
437
444template<typename TTo, typename TFrom>
445[[deprecated]] typename std::enable_if<IsExceptionWrapper<TFrom>::value && IsExceptionWrapper<TTo>::value && (std::is_convertible<TTo, TFrom>::value || std::is_base_of<TTo, TFrom>::value), TTo>::type
446DynamicCast_noexcept(const TFrom& obj) noexcept
447{
448 return
449 (DynamicCast_noexcept<typename TTo::ExceptionType>(obj.Get()) != nullptr)
450 ? TTo(obj.Get())
451 : TTo(nullptr)
452 ;
453}
454
462template<typename TTo, typename TFrom>
463[[deprecated]] typename std::enable_if<IsExceptionWrapper<TFrom>::value && IsExceptionWrapper<TTo>::value && (std::is_convertible<TTo, TFrom>::value || std::is_base_of<TTo, TFrom>::value), TTo>::type
464DynamicCast(const TFrom& obj) // throw(System::InvalidCastException)
465{
466 return
467 obj != nullptr
468 ? ((DynamicCast_noexcept<typename TTo::ExceptionType>(obj.Get()) != nullptr)
469 ? TTo(obj.Get())
470 : Details::ThrowInvalidCastException_helper<TTo>())
471 : TTo(nullptr)
472 ;
473}
474
475// static cast
476
483template<typename TTo, typename TFrom>
484[[deprecated]] typename std::enable_if<!IsExceptionWrapper<TTo>::value, typename CastResult<TTo>::type>::type
486{
487 return Cast_noexcept<TTo, TFrom>(obj);
488}
489
497template<typename TTo, typename TFrom>
498[[deprecated]] typename std::enable_if<!IsExceptionWrapper<TTo>::value, typename CastResult<TTo>::type>::type
499StaticCast(SmartPtr<TFrom> const& obj) // throw(System::InvalidCastException)
500{
501 return Cast<TTo, TFrom>(obj);
502}
503
510template<typename TTo, typename TFrom>
511[[deprecated]] typename CastResult<TTo>::type StaticCast_noexcept(WeakPtr<TFrom> const& obj) // throw()
512{
513 return Cast_noexcept<TTo, TFrom>(obj);
514}
515
523template<typename TTo, typename TFrom>
524[[deprecated]] typename CastResult<TTo>::type StaticCast(WeakPtr<TFrom> const& obj) // throw(System::InvalidCastException)
525{
526 return obj != nullptr ? Cast<TTo, TFrom>(obj) : typename CastResult<TTo>::type();
527}
528
533template<typename TTo>
534[[deprecated]] typename CastResult<TTo>::type StaticCast(std::nullptr_t) // throw()
535{
536 // to process code like System::ExplicitCast<System::Object>(nullptr)
537 return typename CastResult<TTo>::type(nullptr);
538}
539
541template<typename TTo, typename TFrom>
542[[deprecated]] typename std::enable_if<std::is_arithmetic<TFrom>::value, TTo>::type StaticCast(TFrom value)
543{
544 return TTo(value);
545}
546
548template<typename TTo>
549[[deprecated]] typename std::enable_if<std::is_same<TTo, System::String>::value, TTo>::type StaticCast(TTo value)
550{
551 return value;
552};
553
555template<typename TTo, typename TFrom>
556[[deprecated]] typename std::enable_if<std::is_arithmetic<TFrom>::value, TTo>::type StaticCast(const TFrom* value)
557{
558 return TTo(value);
559}
560
568template<typename TTo, typename TFrom>
569[[deprecated]] typename std::enable_if<!std::is_same<TFrom, System::String>::value && !IsExceptionWrapper<TFrom>::value && !IsSmartPtr<TFrom>::value && !std::is_arithmetic<TFrom>::value, TTo>::type StaticCast(const TFrom& obj)
570{
571 //it is for special cases, like exception classes
572 if (!obj.Is(TTo::Type()))
573 Details::ThrowInvalidCastException();
574 return static_cast<TTo&>(obj);
575}
576
577// dynamic cast
578
585template<typename TTo, typename TFrom>
586[[deprecated]] typename std::enable_if<!IsExceptionWrapper<TTo>::value, typename CastResult<TTo>::type>::type
588{
589 return Cast_noexcept<TTo, TFrom>(obj);
590}
591
598template<typename TTo, typename TFrom>
599[[deprecated]] typename std::enable_if<IsExceptionWrapper<TFrom>::value && IsExceptionWrapper<TTo>::value && (std::is_convertible<TTo, TFrom>::value || std::is_base_of<TTo, TFrom>::value), TTo>::type
600StaticCast_noexcept(const TFrom& obj) // throw()
601{
602 return
603 (DynamicCast_noexcept<typename TTo::ExceptionType>(obj.Get()) != nullptr)
604 ? TTo(obj.Get())
605 : TTo(nullptr)
606 ;
607}
608
616template<typename TTo, typename TFrom>
617[[deprecated]] typename std::enable_if<IsExceptionWrapper<TFrom>::value && IsExceptionWrapper<TTo>::value && (std::is_convertible<TTo, TFrom>::value || std::is_base_of<TTo, TFrom>::value), TTo>::type
618StaticCast(const TFrom& obj) // throw(System::InvalidCastException)
619{
620 return
621 obj != nullptr
622 ? ((DynamicCast_noexcept<typename TTo::ExceptionType>(obj.Get()) != nullptr)
623 ? TTo(obj.Get())
624 : Details::ThrowInvalidCastException_helper<TTo>())
625 : TTo(nullptr)
626 ;
627}
628
629
637template<typename TTo, typename TFrom>
638[[deprecated]] typename std::enable_if<!std::is_enum<TTo>::value && !IsExceptionWrapper<TTo>::value, typename CastResult<TTo>::type>::type
639DynamicCast(SmartPtr<TFrom> const& obj) // throw(System::InvalidCastException)
640{
641 return Cast<TTo, TFrom>(obj);
642}
643
644namespace Detail {
649 ASPOSECPP_SHARED_API uint64_t GetIEnumUnsignedLongLongValue(const SmartPtr<Object>& obj);
650}
651
659template<typename TTo, typename TFrom>
660[[deprecated]] typename std::enable_if<std::is_enum<TTo>::value, TTo>::type DynamicCast(SmartPtr<TFrom> obj)
661{
662 return static_cast<TTo>(Detail::GetIEnumUnsignedLongLongValue(obj));
663}
664
669template<typename TTo>
670[[deprecated]] typename CastResult<TTo>::type DynamicCast(std::nullptr_t) noexcept
671{
672 // to process code like System::ExplicitCast<System::Object>(nullptr)
673 return SmartPtr<TTo>();
674}
675
682template<typename TTo, typename TFrom>
683[[deprecated]] typename std::enable_if<
684 !IsExceptionWrapper<TFrom>::value && !IsSmartPtr<TFrom>::value && std::is_convertible<TTo, TFrom>::value /* check if TFrom is base for TTo */
685 , TTo>::type DynamicCast(TFrom &obj)
686{
687 return *dynamic_cast<TTo*>(&obj);
688}
689
696template<typename TTo, typename TFrom>
697[[deprecated]] typename std::enable_if<std::is_same<System::Object, TFrom>::value && IsExceptionWrapper<TTo>::value, TTo>::type
699{
700 auto exception_ptr = DynamicCast_noexcept<typename TTo::ExceptionType>(obj);
701 return exception_ptr != nullptr ? TTo(StaticCast_noexcept<System::Details_Exception>(exception_ptr)) : TTo(nullptr);
702}
703
711template<typename TTo, typename TFrom>
712[[deprecated]] typename std::enable_if<std::is_same<System::Object, TFrom>::value && IsExceptionWrapper<TTo>::value, TTo>::type
714{
715 if (obj == nullptr)
716 return TTo(nullptr);
717
718 auto exception_ptr = DynamicCast_noexcept<typename TTo::ExceptionType>(obj);
719 return exception_ptr != nullptr ? TTo(StaticCast_noexcept<System::Details_Exception>(exception_ptr)) : Details::ThrowInvalidCastException_helper<TTo>();
720}
721
728template<typename TTo, typename TFrom>
729[[deprecated]] typename std::enable_if<std::is_same<System::Object, TFrom>::value && IsExceptionWrapper<TTo>::value, TTo>::type
731{
732 auto exception_ptr = DynamicCast_noexcept<typename TTo::ExceptionType>(obj);
733 return exception_ptr != nullptr ? TTo(StaticCast_noexcept<System::Details_Exception>(exception_ptr)) : TTo(nullptr);
734}
735
743template <typename TTo, typename TFrom>
744[[deprecated]] typename std::enable_if<std::is_same<System::Object, TFrom>::value && IsExceptionWrapper<TTo>::value, TTo>::type
745DynamicCast(SmartPtr<TFrom> obj) // throw(System::InvalidCastException)
746{
747 if (obj == nullptr)
748 return TTo(nullptr);
749
750 auto exception_ptr = DynamicCast_noexcept<typename TTo::ExceptionType>(obj);
751 return exception_ptr != nullptr ? TTo(StaticCast_noexcept<System::Details_Exception>(exception_ptr)) : Details::ThrowInvalidCastException_helper<TTo>();
752}
753
760template<typename TTo, typename TFrom>
761[[deprecated]] typename std::enable_if<std::is_pointer<TTo>::value && std::is_same<IntPtr, TFrom>::value, TTo>::type DynamicCast(TFrom value) noexcept
762{
763 return reinterpret_cast<TTo>(value);
764}
765
768
774template<typename TTo, typename TFrom>
775typename CastResult<TTo>::type ConstCast(const SmartPtr<TFrom>& obj) // throw()
776{
777 return obj->Is(TTo::Type()) ? System::const_pointer_cast<TTo>(obj) : SmartPtr<TTo>();
778}
779
785template <typename TTo, typename TFrom>
786typename CastResult<TTo>::type ForceStaticCast(SmartPtr<TFrom> const& obj) // throw(System::InvalidCastException)
787{
788 return SmartPtr<TTo>(obj, static_cast<TTo*>(obj.get()));
789}
790
795template<typename T>
797{
798 return MakeObject<T>(*ptr);
799}
800
801namespace Runtime {
802 namespace CompilerServices {
805 {
806 public:
811 template<typename T>
812 static int GetHashCode(SmartPtr<T> const& obj)
813 {
814 return obj->Object::GetHashCode();
815 }
816 };
817 }
818}
819
821inline System::Object* System::Detail::SmartPtrCounter::Lock()
822{
823#ifdef ENABLE_EXTERNAL_REFCOUNT
824 return SharedRefAdded();
825#else
826 return m_object->SharedRefAdded();
827#endif
828}
829
831template <typename T>
833{
834 return SmartPtr<Object>(GetObjectOrNull());
835}
836
838template <typename T>
839void SmartPtr<T>::SetContainedTemplateWeakPtr(uint32_t argument) const
840{
841 if (Object *const object = GetObjectOrNull())
842 object->SetTemplateWeakPtr(argument);
843}
844
846template <typename T>
847bool SmartPtr<T>::Is(const System::TypeInfo &target) const
848{
849 if (m_data.IsNull())
850 return false;
851 else if (m_data.GetMode() == SmartPtrMode::Shared)
852 return m_data.SharedGetObject()->Is(target);
853 else
854 return m_data.WeakGetCounter()->GetObject()->Is(target);
855}
856
858template <typename T>
860{
861 const int count = releaser->SharedRefRemovedSafe();
862
863 System::Details::MakeObjectLeakageDetector::ReportLeakCycle(count);
864
865#ifdef ENABLE_EXTERNAL_REFCOUNT
866 if (releaser->GetOwnershipState() != System::Detail::SmartPtrCounter::ObjectOwnershipState::OwnedByPointers)
867 return nullptr;
868
869 Object *const object = releaser->GetObject();
870#else
871 Object *const& object = releaser;
872#endif
873
874 if (count == 0)
875 return object;
876
877 return nullptr;
878}
879
880
881namespace Details {
882
884 template <unsigned int leaf, unsigned int ...leafs>
885 void WeakLeafMaker<leaf, leafs...>::Apply(System::Object *ptr)
886 {
887 ptr->SetTemplateWeakPtr(leaf);
888 WeakLeafMaker<leafs...>::Apply(ptr);
889 }
890}
891
893ASPOSECPP_SHARED_API void PrintTo(const System::Object& value, std::ostream* stream);
894
899ASPOSECPP_SHARED_API std::ostream& operator<<(std::ostream& stream, const System::Object& object);
900
905ASPOSECPP_SHARED_API std::wostream& operator<<(std::wostream& stream, const System::Object& object);
906
907} // namespace System
908
910typedef System::Object object;
911
912#include <system/details/this_protector.h>
913#include <system/details/for_each_member_visitor.h>
Base class that enables using methods available for System.Object class in C#. All non-trivial classe...
Definition: object.h:62
Object * SharedRefAdded()
Increments shared reference count. Shouldn't be called directly; instead, use smart pointers or ThisP...
Definition: object.h:297
virtual int32_t GetHashCode() const
Analog of C# Object.GetHashCode() method. Enables hashing of custom objects.
void Lock()
Implements C# lock() statement locking. Call directly or use LockContext sentry object.
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals(T const &objA, std::nullptr_t)
Reference-compares value type object with nullptr.
Definition: object.h:134
virtual const TypeInfo & GetType() const
Gets actual type of object. Analog of C# System.Object.GetType() call.
virtual bool Is(const TypeInfo &targetType) const
Check if object represents an instance of type described by targetType. Analog of C# 'is' operator.
virtual bool Equals(ptr obj)
Compares objects using C# Object.Equals semantics.
void WeakRefRemoved()
Decrements weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisPro...
Definition: object.h:334
Detail::SmartPtrCounter * GetCounter()
Gets reference counter data structure associated with the object.
Definition: object.h:340
static bool ReferenceEquals(ptr const &objA, ptr const &objB)
Compares objects by reference.
Definition: object.h:115
Object()
Creates object. Initializes all internal data structures.
virtual String ToString() const
Analog of C# Object.ToString() method. Enables converting custom objects to string.
virtual ptr MemberwiseClone() const
Analog of C# Object.MemberwiseClone() method. Enables cloning custom types.
Detail::SmartPtrCounter * WeakRefAdded()
Increments weak reference count. Shouldn't be called directly; instead, use smart pointers or ThisPro...
Definition: object.h:328
static std::enable_if< IsSmartPtr< T1 >::value &&IsSmartPtr< T2 >::value, bool >::type Equals(T1 const &objA, T2 const &objB)
Compares reference type objects in C# style.
Definition: object.h:145
void Unlock()
Implements C# lock() statement unlocking. Call directly or use LockContext sentry object.
static std::enable_if<!IsSmartPtr< T1 >::value &&!IsSmartPtr< T2 >::value, bool >::type Equals(T1 const &objA, T2 const &objB)
Compares value type objects in C# style.
Definition: object.h:156
int RemovedSharedRefs(int count)
Decreases shared reference count by specified value.
Definition: object.h:318
int SharedCount() const
Gets current value of shared reference counter.
Definition: object.h:357
static std::enable_if<!IsSmartPtr< T >::value, bool >::type ReferenceEquals(T const &objA, T const &objB)
Compares objects by reference.
Definition: object.h:125
virtual ~Object()
Destroys object. Frees all internal data structures.
static const TypeInfo & Type()
Implements C# typeof(System.Object) construct.
Definition: object.h:172
int SharedRefRemovedSafe()
Decrements and returns shared reference count. Shouldn't be called directly; instead,...
Definition: object.h:308
Object(Object const &x)
Copy constructor. Doesn't copy anything, really, just initializes new object and enables copy constru...
virtual bool FastCast(const Details::FastRttiBase &helper, void **out_ptr) const
For internal purposes only.
SmartPtr< Object > ptr
Alias for smart pointer type.
Definition: object.h:65
virtual void SetTemplateWeakPtr(uint32_t argument)
Set n'th template argument a weak pointer (rather than shared). Allows switching pointers in containe...
Helper class to get some object information in runtime.
Definition: object.h:805
static int GetHashCode(SmartPtr< T > const &obj)
Gets hash code on arbitrary type. Calls Object::GetHashCode() to do so.
Definition: object.h:812
SmartPtr< Object > ToObjectPtr() const
Converts any pointer type to pointer to Object. Doesn't require Pointee_ type to be complete.
Definition: object.h:832
Pointee_ * get() const
Gets pointed object.
Definition: smart_ptr.h:518
void SetContainedTemplateWeakPtr(uint32_t argument) const
Calls SetTemplateWeakPtr() method on pointed object (if any).
Definition: object.h:839
bool Is(const System::TypeInfo &target) const
Checks if pointed object is of specific type or its child type. Follows C# 'is' semantics.
Definition: object.h:847
SmartPtrMode get_Mode() const
Gets pointer mode.
Definition: smart_ptr.h:543
Object * ReleaseSharedAndGetObjectToDelete()
Decrements currently referenced object's shared pointer counter.
Definition: smart_ptr.h:1033
String class used across the library. Is a substitute for C# System.String when translating code....
Definition: string.h:122
Represents a particular type and provides information about it.
Definition: type_info.h:109
Subclass of System::SmartPtr which sets itself to weak mode at construction. Please note that this cl...
Definition: weak_ptr.h:18
Definition: db_command.h:9
void PrintTo(DateTime value, std::ostream *stream)
Prints value to ostream. Mostly used for debug.
@ Shared
Shared mode: pointer participates in reference counting.
CastResult< TTo >::type ConstCast(const SmartPtr< TFrom > &obj)
End of deprecated casts.
Definition: object.h:775
std::enable_if<!IsExceptionWrapper< TTo >::value, typenameCastResult< TTo >::type >::type StaticCast(SmartPtr< TFrom > const &obj)
Performs static cast on SmartPtr objects.
Definition: object.h:499
std::enable_if<!IsExceptionWrapper< TTo >::value, typenameCastResult< TTo >::type >::type Cast(SmartPtr< TFrom > const &obj)
Performs cast on SmartPtr objects.
Definition: object.h:427
std::enable_if< IsExceptionWrapper< TFrom >::value &&IsExceptionWrapper< TTo >::value &&(std::is_convertible< TTo, TFrom >::value||std::is_base_of< TTo, TFrom >::value), TTo >::type DynamicCast_noexcept(const TFrom &obj) noexcept
Old obsolete casts. Will be removed in future versions.
Definition: object.h:446
std::enable_if<!IsExceptionWrapper< TTo >::value, typenameCastResult< TTo >::type >::type StaticCast_noexcept(SmartPtr< TFrom > const &obj)
Performs static cast on SmartPtr objects.
Definition: object.h:485
std::enable_if<!IsExceptionWrapper< TTo >::value, typenameCastResult< TTo >::type >::type Cast_noexcept(SmartPtr< TFrom > const &obj)
Performs cast on SmartPtr objects.
Definition: object.h:414
CastResult< TTo >::type ForceStaticCast(SmartPtr< TFrom > const &obj)
Performs real static cast on SmartPtr objects.
Definition: object.h:786
SmartPtr< Object > MemberwiseClone(T *ptr)
Performs memberwise cloning using copy constructor.
Definition: object.h:796
std::ostream & operator<<(std::ostream &stream, DateTime date_time)
Insert data into the stream using UTF-8 encoding.
Definition: date_time.h:729
std::enable_if< IsExceptionWrapper< TFrom >::value &&IsExceptionWrapper< TTo >::value &&(std::is_convertible< TTo, TFrom >::value||std::is_base_of< TTo, TFrom >::value), TTo >::type DynamicCast(const TFrom &obj)
Performs dynamic cast on Exception objects.
Definition: object.h:464
Template magic to deduce cast results.
Definition: object.h:385
SmartPtr< TTo > type
An alias for a pointer to an instance of TTo.
Definition: object.h:387
A template predicate that determines if the specified type is a Exception class or its descendant.
Definition: object.h:405
Trait class to check if a type is a specialization of SmartPtr class.
Definition: smart_ptr.h:1499
Wrapper for a pointer to an instance of TypeInfo class. This type should be allocated on stack and pa...
Definition: type_info.h:72