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 namespace edm {
14  namespace {
15  typedef tbb::concurrent_unordered_map<TMethod const*, TypeWithDict> Map;
16  Map returnTypeMap;
17  } // namespace
18 
19  FunctionWithDict::FunctionWithDict() : function_(nullptr) {}
20 
21  FunctionWithDict::FunctionWithDict(TMethod* meth) : function_(meth) {
22  if (meth and isPublic() and not isDestructor() and not isConstructor()) {
23  TMethodCall caller(meth);
24  auto callFunc = caller.GetCallFunc();
25  funcptr_ = gInterpreter->CallFunc_IFacePtr(callFunc);
26  }
27  }
28 
30  if (function_ == nullptr) {
31  return false;
32  }
33  return function_->IsValid();
34  }
35 
36  std::string FunctionWithDict::name() const { return function_->GetName(); }
37 
38  std::string FunctionWithDict::typeName() const { return function_->GetReturnTypeNormalizedName(); }
39 
41  auto const& item = returnTypeMap.find(function_);
42  if (item != returnTypeMap.end()) {
43  return item->second;
44  }
45  TypeWithDict theType = TypeWithDict::byName(function_->GetReturnTypeNormalizedName());
46  returnTypeMap.insert(std::make_pair(function_, theType));
47  return theType;
48  }
49 
51 
52  bool FunctionWithDict::isConst() const { return function_->Property() & kIsConstMethod; }
53 
54  bool FunctionWithDict::isConstructor() const { return function_->ExtraProperty() & kIsConstructor; }
55 
56  bool FunctionWithDict::isDestructor() const { return function_->ExtraProperty() & kIsDestructor; }
57 
58  bool FunctionWithDict::isOperator() const { return function_->ExtraProperty() & kIsOperator; }
59 
60  bool FunctionWithDict::isPublic() const { return function_->Property() & kIsPublic; }
61 
62  bool FunctionWithDict::isStatic() const { return function_->Property() & kIsStatic; }
63 
64  size_t FunctionWithDict::functionParameterSize(bool required /*= false*/) const {
65  if (required) {
66  return function_->GetNargs() - function_->GetNargsOpt();
67  }
68  return function_->GetNargs();
69  }
70 
71  size_t FunctionWithDict::size() const { return function_->GetNargs(); }
72 
75  ObjectWithDict* ret /*=nullptr*/,
76  std::vector<void*> const& values /*=std::vector<void*>()*/) const {
77  void** data = const_cast<void**>(values.data());
78  assert(funcptr_.fGeneric);
79  if (ret == nullptr) {
80  (*funcptr_.fGeneric)(obj.address(), values.size(), data, nullptr);
81  return;
82  }
83  (*funcptr_.fGeneric)(obj.address(), values.size(), data, ret->address());
84  }
85 
88  std::vector<void*> const& values /*=std::vector<void*>()*/) const {
89  void** data = const_cast<void**>(values.data());
90  assert(funcptr_.fGeneric);
91  if (ret == nullptr) {
92  (*funcptr_.fGeneric)(nullptr, values.size(), data, nullptr);
93  return;
94  }
95  (*funcptr_.fGeneric)(nullptr, values.size(), data, ret->address());
96  }
97 
99  if (function_ == nullptr) {
100  return IterWithDict<TMethodArg>();
101  }
102  return IterWithDict<TMethodArg>(function_->GetListOfMethodArgs());
103  }
104 
106 
107 } // namespace edm
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:367
edm::FunctionWithDict::function_
TMethod * function_
Definition: FunctionWithDict.h:29
edm::TypeWithDict::byName
static TypeWithDict byName(std::string const &name)
Definition: TypeWithDict.cc:74
electrons_cff.bool
bool
Definition: electrons_cff.py:393
edm::FunctionWithDict::end
IterWithDict< TMethodArg > end() const
Definition: FunctionWithDict.cc:105
edm::FunctionWithDict::functionParameterSize
size_t functionParameterSize(bool required=false) const
Definition: FunctionWithDict.cc:64
reco::parser::kIsOperator
Definition: ErrorCodes.h:39
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::FunctionWithDict::declaringType
TypeWithDict declaringType() const
Definition: FunctionWithDict.cc:50
edm::ObjectWithDict
Definition: ObjectWithDict.h:17
edm::FunctionWithDict::invoke
void invoke(ObjectWithDict const &obj, ObjectWithDict *ret=nullptr, std::vector< void * > const &values=std::vector< void * >()) const
Call a member function.
Definition: FunctionWithDict.cc:74
edm::FunctionWithDict::begin
IterWithDict< TMethodArg > begin() const
Definition: FunctionWithDict.cc:98
cms::cuda::assert
assert(be >=bs)
edm::FunctionWithDict::isStatic
bool isStatic() const
Definition: FunctionWithDict.cc:62
TypeWithDict.h
Utilities.operator
operator
Definition: Utilities.py:24
TtSemiLepEvtBuilder_cfi.meth
meth
Definition: TtSemiLepEvtBuilder_cfi.py:59
edm::IterWithDict
Definition: IterWithDict.h:30
ObjectWithDict.h
edm::FunctionWithDict::isDestructor
bool isDestructor() const
Definition: FunctionWithDict.cc:56
edm::FunctionWithDict::size
size_t size() const
Definition: FunctionWithDict.cc:71
reco::parser::kIsDestructor
Definition: ErrorCodes.h:38
edm::FunctionWithDict::isConst
bool isConst() const
Definition: FunctionWithDict.cc:52
contentValuesCheck.values
values
Definition: contentValuesCheck.py:38
edm::FunctionWithDict::typeName
std::string typeName() const
Definition: FunctionWithDict.cc:38
edm::FunctionWithDict::isOperator
bool isOperator() const
Definition: FunctionWithDict.cc:58
getGTfromDQMFile.obj
obj
Definition: getGTfromDQMFile.py:32
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
IterWithDict.h
edm::TypeWithDict
Definition: TypeWithDict.h:38
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
edm::FunctionWithDict::funcptr_
TInterpreter::CallFuncIFacePtr_t funcptr_
Definition: FunctionWithDict.h:30
writedatasetfile.required
required
Definition: writedatasetfile.py:8
reco::parser::kIsStatic
Definition: ErrorCodes.h:34
edm::FunctionWithDict::isConstructor
bool isConstructor() const
Definition: FunctionWithDict.cc:54
edm::FunctionWithDict::name
std::string name() const
Definition: FunctionWithDict.cc:36
data
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
edm::FunctionWithDict::FunctionWithDict
FunctionWithDict()
Definition: FunctionWithDict.cc:19
reco::parser::kIsConstructor
Definition: ErrorCodes.h:37
edm::FunctionWithDict::finalReturnType
TypeWithDict finalReturnType() const
Definition: FunctionWithDict.cc:40
FunctionWithDict.h
edm::FunctionWithDict::isPublic
bool isPublic() const
Definition: FunctionWithDict.cc:60