CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FunctionWithDict.cc
Go to the documentation of this file.
2 
6 
7 #include "TInterpreter.h"
8 #include "TMethod.h"
9 #include "TMethodArg.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 
23  FunctionWithDict::FunctionWithDict(TMethod* meth) : function_(meth) {
24  }
25 
27  if (function_ == nullptr) {
28  return false;
29  }
30  return function_->IsValid();
31  }
32 
34  return function_->GetName();
35  }
36 
39  return function_->GetReturnTypeNormalizedName();
40  }
41 
44  auto const& item = returnTypeMap.find(function_);
45  if(item != returnTypeMap.end()) {
46  return item->second;
47  }
48  TypeWithDict theType = TypeWithDict::byName(function_->GetReturnTypeNormalizedName());
49  returnTypeMap.insert(std::make_pair(function_, theType));
50  return theType;
51  }
52 
55  return TypeWithDict(function_->GetClass());
56  }
57 
58  bool
60  return function_->Property() & kIsConstMethod;
61  }
62 
63  bool
65  return function_->ExtraProperty() & kIsConstructor;
66  }
67 
68  bool
70  return function_->ExtraProperty() & kIsDestructor;
71  }
72 
73  bool
75  return function_->ExtraProperty() & kIsOperator;
76  }
77 
78  bool
80  return function_->Property() & kIsPublic;
81  }
82 
84  return function_->Property() & kIsStatic;
85  }
86 
87  size_t
89  if (required) {
90  return function_->GetNargs() - function_->GetNargsOpt();
91  }
92  return function_->GetNargs();
93  }
94 
95  size_t
97  return function_->GetNargs();
98  }
99 
101  void
103  std::vector<void*> const& values/*=std::vector<void*>()*/) const {
104  void const** data = const_cast<void const**>(values.data());
105  if (ret == nullptr) {
106  gInterpreter->ExecuteWithArgsAndReturn(function_, obj.address(), data, values.size(), nullptr);
107  return;
108  }
109  gInterpreter->ExecuteWithArgsAndReturn(function_, obj.address(), data, values.size(), ret->address());
110  }
111 
113  void
115  std::vector<void*> const& values/*=std::vector<void*>()*/) const {
116  void const** data = const_cast<void const**>(values.data());
117  if (ret == nullptr) {
118  gInterpreter->ExecuteWithArgsAndReturn(function_, nullptr, data, values.size(), nullptr);
119  return;
120  }
121  gInterpreter->ExecuteWithArgsAndReturn(function_, nullptr, data, values.size(), ret->address());
122  }
123 
126  if (function_ == nullptr) {
127  return IterWithDict<TMethodArg>();
128  }
129  return IterWithDict<TMethodArg>(function_->GetListOfMethodArgs());
130  }
131 
134  return IterWithDict<TMethodArg>();
135  }
136 
137 } // 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
string const
Definition: compareJSON.py:14
size_t functionParameterSize(bool required=false) const
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
bool isDestructor() const