CMS 3D CMS Logo

FunctionWithDict.cc
Go to the documentation of this file.
2 
6 
7 #include "TMethod.h"
8 #include "TMethodArg.h"
9 #include "TMethodCall.h"
10 
11 #include "tbb/concurrent_unordered_map.h"
12 
13 
14 namespace edm {
15  namespace {
16  typedef tbb::concurrent_unordered_map<TMethod const*, TypeWithDict> Map;
17  Map returnTypeMap;
18  }
19 
21  }
22 
24  if (meth and isPublic() and not isDestructor() and not isConstructor()) {
25  TMethodCall caller( meth );
26  auto callFunc = caller.GetCallFunc();
27  funcptr_ = gInterpreter->CallFunc_IFacePtr( callFunc );
28  }
29  }
30 
32  if (function_ == nullptr) {
33  return false;
34  }
35  return function_->IsValid();
36  }
37 
39  return function_->GetName();
40  }
41 
44  return function_->GetReturnTypeNormalizedName();
45  }
46 
49  auto const& item = returnTypeMap.find(function_);
50  if(item != returnTypeMap.end()) {
51  return item->second;
52  }
53  TypeWithDict theType = TypeWithDict::byName(function_->GetReturnTypeNormalizedName());
54  returnTypeMap.insert(std::make_pair(function_, theType));
55  return theType;
56  }
57 
60  return TypeWithDict(function_->GetClass());
61  }
62 
63  bool
65  return function_->Property() & kIsConstMethod;
66  }
67 
68  bool
70  return function_->ExtraProperty() & kIsConstructor;
71  }
72 
73  bool
75  return function_->ExtraProperty() & kIsDestructor;
76  }
77 
78  bool
80  return function_->ExtraProperty() & kIsOperator;
81  }
82 
83  bool
85  return function_->Property() & kIsPublic;
86  }
87 
89  return function_->Property() & kIsStatic;
90  }
91 
92  size_t
94  if (required) {
95  return function_->GetNargs() - function_->GetNargsOpt();
96  }
97  return function_->GetNargs();
98  }
99 
100  size_t
102  return function_->GetNargs();
103  }
104 
106  void
108  std::vector<void*> const& values/*=std::vector<void*>()*/) const {
109  void ** data = const_cast<void**>(values.data());
110  assert(funcptr_.fGeneric);
111  if (ret == nullptr) {
112  (*funcptr_.fGeneric)(obj.address(), values.size(), data, nullptr);
113  return;
114  }
115  (*funcptr_.fGeneric)(obj.address(), values.size(), data, ret->address());
116  }
117 
119  void
121  std::vector<void*> const& values/*=std::vector<void*>()*/) const {
122  void ** data = const_cast<void **>(values.data());
123  assert(funcptr_.fGeneric);
124  if (ret == nullptr) {
125  (*funcptr_.fGeneric)(nullptr, values.size(), data, nullptr);
126  return;
127  }
128  (*funcptr_.fGeneric)(nullptr, values.size(), data, ret->address());
129  }
130 
133  if (function_ == nullptr) {
134  return IterWithDict<TMethodArg>();
135  }
136  return IterWithDict<TMethodArg>(function_->GetListOfMethodArgs());
137  }
138 
141  return IterWithDict<TMethodArg>();
142  }
143 
144 } // namespace edm
void * address() const
bool isConstructor() const
TypeWithDict declaringType() const
IterWithDict< TMethodArg > end() const
std::string name() const
#define nullptr
IterWithDict< TMethodArg > begin() const
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:60
std::string typeName() const
void invoke(ObjectWithDict const &obj, ObjectWithDict *ret=nullptr, std::vector< void * > const &values=std::vector< void * >()) const
Call a member function.
TypeWithDict finalReturnType() const
size_t functionParameterSize(bool required=false) const
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
TInterpreter::CallFuncIFacePtr_t funcptr_
bool isDestructor() const