File indexing completed on 2025-02-27 07:20:01
0001 #ifndef _LIBCPP_VERSION
0002 #include <cxxabi.h>
0003 #endif
0004
0005 #include "FWCore/Reflection/interface/BaseWithDict.h"
0006 #include "FWCore/Reflection/interface/MemberWithDict.h"
0007 #include "FWCore/Reflection/interface/ObjectWithDict.h"
0008 #include "FWCore/Reflection/interface/TypeWithDict.h"
0009
0010 namespace edm {
0011
0012 ObjectWithDict ObjectWithDict::byType(TypeWithDict const& type) {
0013 ObjectWithDict obj(type.construct());
0014 return obj;
0015 }
0016
0017 class DummyVT {
0018 public:
0019 virtual ~DummyVT();
0020 };
0021
0022 DummyVT::~DummyVT() {}
0023
0024
0025 TypeWithDict ObjectWithDict::dynamicType() const {
0026 if (!type_.isVirtual()) {
0027 return type_;
0028 }
0029
0030
0031 return TypeWithDict::byTypeInfo(typeid(*(DummyVT*)address_));
0032 }
0033
0034 ObjectWithDict ObjectWithDict::get(std::string const& memberName) const {
0035 return type_.dataMemberByName(memberName).get(*this);
0036 }
0037
0038 ObjectWithDict ObjectWithDict::castObject(TypeWithDict const& to) const {
0039 TypeWithDict from = typeOf();
0040
0041
0042 if (from == to) {
0043 return *this;
0044 }
0045
0046 if (to.hasBase(from)) {
0047 #ifndef _LIBCPP_VERSION
0048
0049 void* address = abi::__dynamic_cast(address_,
0050 static_cast<abi::__class_type_info const*>(&from.typeInfo()),
0051 static_cast<abi::__class_type_info const*>(&to.typeInfo()),
0052 -1);
0053 return ObjectWithDict(to, address);
0054 #else
0055 return ObjectWithDict(to, address_);
0056 #endif
0057 }
0058
0059 if (from.hasBase(to)) {
0060 size_t offset = from.getBaseClassOffset(to);
0061 size_t address = reinterpret_cast<size_t>(address_) + offset;
0062 return ObjectWithDict(to, reinterpret_cast<void*>(address));
0063 }
0064
0065
0066 return ObjectWithDict();
0067 }
0068
0069
0070
0071
0072
0073
0074
0075
0076
0077
0078
0079 void ObjectWithDict::destruct(bool dealloc) const {
0080 TClass* cl = type_.getClass();
0081 if (cl != nullptr) {
0082 cl->Destructor(address_, !dealloc);
0083
0084
0085
0086 return;
0087 }
0088 if (dealloc) {
0089 delete[] reinterpret_cast<char*>(address_);
0090
0091 }
0092 }
0093
0094 }