Logo ROOT   6.14/05
Reference Guide
Cppyy.cxx
Go to the documentation of this file.
1 // Bindings
2 #include "PyROOT.h"
3 #include "Cppyy.h"
4 #include "TCallContext.h"
5 
6 // ROOT
7 #include "TBaseClass.h"
8 #include "TClass.h"
9 #include "TClassRef.h"
10 #include "TClassTable.h"
11 #include "TClassEdit.h"
12 #include "TCollection.h"
13 #include "TDataMember.h"
14 #include "TDataType.h"
15 #include "TError.h"
16 #include "TFunction.h"
17 #include "TGlobal.h"
18 #include "TInterpreter.h"
19 #include "TList.h"
20 #include "TMethod.h"
21 #include "TMethodArg.h"
22 #include "TROOT.h"
23 
24 // Standard
25 #include <assert.h>
26 #include <map>
27 #include <set>
28 #include <sstream>
29 
30 // temp
31 #include <iostream>
32 // FIXME: Should refer to PyROOT::TParameter in the code.
33 #ifdef R__CXXMODULES
34  #define TParameter PyROOT::TParameter
35 #else
37 #endif
38 // --temp
39 
40 
41 // small number that allows use of stack for argument passing
42 const int SMALL_ARGS_N = 8;
43 
44 
45 // data for life time management ---------------------------------------------
46 typedef std::vector< TClassRef > ClassRefs_t;
47 static ClassRefs_t g_classrefs( 1 );
48 static const ClassRefs_t::size_type GLOBAL_HANDLE = 1;
49 
50 typedef std::map< std::string, ClassRefs_t::size_type > Name2ClassRefIndex_t;
52 
53 typedef std::map< Cppyy::TCppMethod_t, CallFunc_t* > Method2CallFunc_t;
55 
56 typedef std::vector< TFunction > GlobalFuncs_t;
58 
59 typedef std::vector< TGlobal* > GlobalVars_t;
61 
62 // data ----------------------------------------------------------------------
64 
65 // smart pointer types
66 static std::set< std::string > gSmartPtrTypes =
67  { "auto_ptr", "shared_ptr", "weak_ptr", "unique_ptr" };
68 
69 
70 // global initialization -----------------------------------------------------
71 namespace {
72 
73 class ApplicationStarter {
74 public:
75  ApplicationStarter() {
76  // setup dummy holders for global and std namespaces
77  assert( g_classrefs.size() == GLOBAL_HANDLE );
79  g_classrefs.push_back(TClassRef(""));
80  // ROOT ignores std/::std, so point them to the global namespace
81  g_name2classrefidx[ "std" ] = GLOBAL_HANDLE;
82  g_name2classrefidx[ "::std" ] = GLOBAL_HANDLE;
83  // add a dummy global to refer to as null at index 0
84  g_globalvars.push_back( nullptr );
85  }
86 
87  ~ApplicationStarter() {
88  for ( auto ifunc : g_method2callfunc )
89  gInterpreter->CallFunc_Delete( ifunc.second );
90  }
91 } _applicationStarter;
92 
93 } // unnamed namespace
94 
95 
96 // local helpers -------------------------------------------------------------
97 static inline
99 {
100  assert( (ClassRefs_t::size_type) scope < g_classrefs.size() );
101  return g_classrefs[ (ClassRefs_t::size_type)scope ];
102 }
103 
104 // type_from_handle to go here
105 static inline
107 {
108  TClassRef& cr = type_from_handle( klass );
109  if ( cr.GetClass() )
110  return (TFunction*)cr->GetListOfMethods()->At( idx );
111  assert( klass == (Cppyy::TCppType_t)GLOBAL_HANDLE );
112  return (TFunction*)idx;
113 }
114 
115 static inline
117 {
118  TMethod* m = dynamic_cast<TMethod*>( (TFunction*)method );
119  if ( m ) return Cppyy::GetScope( m->GetClass()->GetName() );
121 }
122 
123 
124 // name to opaque C++ scope representation -----------------------------------
126 {
127  TClassRef& cr = type_from_handle( scope );
128  if ( cr.GetClass() ) return 0; // not supported if not at global scope
129  assert( scope == (TCppScope_t)GLOBAL_HANDLE );
130  return gClassTable->Classes();
131 }
132 
133 std::string Cppyy::GetScopeName( TCppScope_t parent, TCppIndex_t iscope )
134 {
135 // Retrieve the scope name of the scope indexed with iscope in parent.
136  TClassRef& cr = type_from_handle( parent );
137  if ( cr.GetClass() ) return 0; // not supported if not at global scope
138  assert( parent == (TCppScope_t)GLOBAL_HANDLE );
139  std::string name = gClassTable->At( iscope );
140  if ( name.find("::") == std::string::npos )
141  return name;
142  return "";
143 }
144 
145 std::string Cppyy::GetName( const std::string& name )
146 {
147  if( name.size() == 0) return name;
148  // need to deal with template paremeters that can have scopes themselves
149  Int_t tpl_open = 0;
150  for ( std::string::size_type pos = name.size() - 1; pos > 0; pos-- ) {
151  std::string::value_type c = name[pos];
152  // count '<' and '>' to be able to skip template contents
153  if ( c == '>' )
154  ++tpl_open;
155  else if ( c == '<' )
156  --tpl_open;
157  // by only checking for "::" the last part (class name) is dropped
158  else if ( tpl_open == 0 && c == ':'&& name[ pos - 1 ] == ':' ) {
159  // found a new scope part
160  return name.substr( pos+1 );
161  }
162  }
163  return name;
164 }
165 
166 std::string Cppyy::ResolveName( const std::string& cppitem_name )
167 {
168 // Fully resolve the given name to the final type name.
169  std::string tclean = TClassEdit::CleanType( cppitem_name.c_str() );
170 
171  TDataType* dt = gROOT->GetType( tclean.c_str() );
172  if ( dt ) return dt->GetFullTypeName();
173  return TClassEdit::ResolveTypedef( tclean.c_str(), true );
174 }
175 
176 Cppyy::TCppScope_t Cppyy::GetScope( const std::string& sname )
177 {
178  std::string scope_name;
179  if ( sname.find( "std::", 0, 5 ) == 0 )
180  scope_name = sname.substr( 5, std::string::npos );
181  else
182  scope_name = sname;
183 
184  scope_name = ResolveName( scope_name );
185  auto icr = g_name2classrefidx.find( scope_name );
186  if ( icr != g_name2classrefidx.end() )
187  return (TCppType_t)icr->second;
188 
189  // use TClass directly, to enable auto-loading
190  TClassRef cr( TClass::GetClass( scope_name.c_str(), kTRUE, kTRUE ) );
191  if ( !cr.GetClass() )
192  return (TCppScope_t)NULL;
193 
194  // no check for ClassInfo as forward declared classes are okay (fragile)
195 
196  ClassRefs_t::size_type sz = g_classrefs.size();
197  g_name2classrefidx[ scope_name ] = sz;
198  g_classrefs.push_back( TClassRef( scope_name.c_str() ) );
199  return (TCppScope_t)sz;
200 }
201 
202 Cppyy::TCppType_t Cppyy::GetTemplate( const std::string& /* template_name */ )
203 {
204  return (TCppType_t)0;
205 }
206 
208 {
209  TClassRef& cr = type_from_handle( klass );
210  TClass* clActual = cr->GetActualClass( (void*)obj );
211  if ( clActual && clActual != cr.GetClass() ) {
212  // TODO: lookup through name should not be needed
213  return (TCppType_t)GetScope( clActual->GetName() );
214  }
215  return klass;
216 }
217 
218 size_t Cppyy::SizeOf( TCppType_t klass )
219 {
220  TClassRef& cr = type_from_handle( klass );
221  if ( cr.GetClass() ) return (size_t)cr->Size();
222  return (size_t)0;
223 }
224 
225 Bool_t Cppyy::IsBuiltin( const std::string& type_name )
226 {
227  TDataType* dt = gROOT->GetType( TClassEdit::CleanType( type_name.c_str(), 1 ).c_str() );
228  if ( dt ) return dt->GetType() != kOther_t;
229  return kFALSE;
230 }
231 
232 Bool_t Cppyy::IsComplete( const std::string& type_name )
233 {
234 // verify whether the dictionary of this class is fully available
235  Bool_t b = kFALSE;
236 
237  Int_t oldEIL = gErrorIgnoreLevel;
238  gErrorIgnoreLevel = 3000;
239  TClass* klass = TClass::GetClass( TClassEdit::ShortType( type_name.c_str(), 1 ).c_str() );
240  if ( klass && klass->GetClassInfo() ) // works for normal case w/ dict
241  b = gInterpreter->ClassInfo_IsLoaded( klass->GetClassInfo() );
242  else { // special case for forward declared classes
243  ClassInfo_t* ci = gInterpreter->ClassInfo_Factory( type_name.c_str() );
244  if ( ci ) {
245  b = gInterpreter->ClassInfo_IsLoaded( ci );
246  gInterpreter->ClassInfo_Delete( ci ); // we own the fresh class info
247  }
248  }
249  gErrorIgnoreLevel = oldEIL;
250  return b;
251 }
252 
253 // memory management ---------------------------------------------------------
255 {
256  TClassRef& cr = type_from_handle( type );
257  return (TCppObject_t)malloc( cr->Size() );
258 }
259 
260 void Cppyy::Deallocate( TCppType_t /* type */, TCppObject_t instance )
261 {
262  free( instance );
263 }
264 
266 {
267  TClassRef& cr = type_from_handle( type );
268  return (TCppObject_t)cr->New();
269 }
270 
272 {
273  TClassRef& cr = type_from_handle( type );
274  cr->Destructor( (void*)instance );
275 }
276 
277 
278 // method/function dispatching -----------------------------------------------
279 static inline ClassInfo_t* GetGlobalNamespaceInfo()
280 {
281  static ClassInfo_t* gcl = gInterpreter->ClassInfo_Factory();
282  return gcl;
283 }
284 
285 static CallFunc_t* GetCallFunc( Cppyy::TCppMethod_t method )
286 {
287  auto icf = g_method2callfunc.find( method );
288  if ( icf != g_method2callfunc.end() )
289  return icf->second;
290 
291  CallFunc_t* callf = nullptr;
292  TFunction* func = (TFunction*)method;
293  std::string callString = "";
294 
295 // create, if not cached
296  Cppyy::TCppScope_t scope = declaring_scope( method );
297  const TClassRef& klass = type_from_handle( scope );
298  if ( klass.GetClass() || (func && scope == GLOBAL_HANDLE) ) {
299  ClassInfo_t* gcl = klass.GetClass() ? klass->GetClassInfo() : nullptr;
300  if ( ! gcl )
301  gcl = GetGlobalNamespaceInfo();
302 
303  TCollection* method_args = func->GetListOfMethodArgs();
304  TIter iarg( method_args );
305 
306  TMethodArg* method_arg = 0;
307  while ((method_arg = (TMethodArg*)iarg.Next())) {
308  std::string fullType = method_arg->GetTypeNormalizedName();
309  if ( callString.empty() )
310  callString = fullType;
311  else
312  callString += ", " + fullType;
313  }
314 
315  Long_t offset = 0;
316  callf = gInterpreter->CallFunc_Factory();
317 
318  gInterpreter->CallFunc_SetFuncProto(
319  callf,
320  gcl,
321  func ? func->GetName() : klass->GetName(),
322  callString.c_str(),
323  func ? (func->Property() & kIsConstMethod) : kFALSE,
324  &offset,
326 
327 // CLING WORKAROUND -- The number of arguments is not always correct (e.g. when there
328 // are default parameters, causing the callString to be wrong and
329 // the exact match to fail); or the method may have been inline or
330 // be compiler generated. In all those cases the exact match fails,
331 // whereas the conversion match sometimes works.
332  if ( ! gInterpreter->CallFunc_IsValid( callf ) ) {
333  gInterpreter->CallFunc_SetFuncProto(
334  callf,
335  gcl,
336  func ? func->GetName() : klass->GetName(),
337  callString.c_str(),
338  func ? (func->Property() & kIsConstMethod) : kFALSE,
339  &offset ); // <- no kExactMatch as that will fail
340  }
341 // -- CLING WORKAROUND
342 
343  }
344 
345  if ( !( callf && gInterpreter->CallFunc_IsValid( callf ) ) ) {
346  PyErr_Format( PyExc_RuntimeError, "could not resolve %s::%s(%s)",
347  const_cast<TClassRef&>(klass).GetClassName(),
348  func ? func->GetName() : const_cast<TClassRef&>(klass).GetClassName(),
349  callString.c_str() );
350  if ( callf ) gInterpreter->CallFunc_Delete( callf );
351  return nullptr;
352  }
353 
354  g_method2callfunc[ method ] = callf;
355  return callf;
356 }
357 
358 static inline void copy_args( void* args_, void** vargs ) {
359  std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
360  for ( std::vector<TParameter>::size_type i = 0; i < args.size(); ++i ) {
361  switch ( args[i].fTypeCode ) {
362  case 'l': /* long */
363  vargs[i] = (void*)&args[i].fValue.fLong;
364  break;
365  case 'f': /* double */
366  vargs[i] = (void*)&args[i].fValue.fFloat;
367  break;
368  case 'd': /* double */
369  vargs[i] = (void*)&args[i].fValue.fDouble;
370  break;
371  case 'D': /* long double */
372  vargs[i] = (void*)&args[i].fValue.fLongDouble;
373  break;
374  case 'k': /* long long */
375  case 'K': /* unsigned long long */
376  case 'U': /* unsigned long */
377  case 'p': /* void* */
378  vargs[i] = (void*)&args[i].fValue.fVoidp;
379  break;
380  case 'V': /* (void*)type& */
381  vargs[i] = args[i].fValue.fVoidp;
382  break;
383  case 'r': /* const type& */
384  vargs[i] = args[i].fRef;
385  break;
386  default:
387  std::cerr << "unknown type code: " << args[i].fTypeCode << std::endl;
388  break;
389  }
390  }
391 }
392 
394  Cppyy::TCppMethod_t method, void* args_, void* self, void* result )
395 {
396  const std::vector<TParameter>& args = *(std::vector<TParameter>*)args_;
397 
398  CallFunc_t* callf = GetCallFunc( method );
399  if ( ! callf )
400  return kFALSE;
401 
404  if ( args.size() <= SMALL_ARGS_N ) {
405  void* smallbuf[SMALL_ARGS_N];
406  copy_args( args_, smallbuf );
407  faceptr.fGeneric( self, args.size(), smallbuf, result );
408  } else {
409  std::vector<void*> buf( args.size() );
410  copy_args( args_, buf.data() );
411  faceptr.fGeneric( self, args.size(), buf.data(), result );
412  }
413  return kTRUE;
414  }
415 
417  if ( args.size() <= SMALL_ARGS_N ) {
418  void* smallbuf[SMALL_ARGS_N];
419  copy_args( args_, (void**)smallbuf );
420  faceptr.fCtor( (void**)smallbuf, result, args.size() );
421  } else {
422  std::vector<void*> buf( args.size() );
423  copy_args( args_, buf.data() );
424  faceptr.fCtor( buf.data(), result, args.size() );
425  }
426  return kTRUE;
427  }
428 
430  std::cerr << " DESTRUCTOR NOT IMPLEMENTED YET! " << std::endl;
431  return kFALSE;
432  }
433 
434  return kFALSE;
435 }
436 
437 template< typename T >
438 static inline T CallT( Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, void* args )
439 {
440  T t{};
441  if ( FastCall( method, args, (void*)self, &t ) )
442  return t;
443  return (T)-1;
444 }
445 
446 #define CPPYY_IMP_CALL( typecode, rtype ) \
447 rtype Cppyy::Call##typecode( TCppMethod_t method, TCppObject_t self, void* args )\
448 { \
449  return CallT< rtype >( method, self, args ); \
450 }
451 
452 void Cppyy::CallV( TCppMethod_t method, TCppObject_t self, void* args )
453 {
454  if ( ! FastCall( method, args, (void*)self, nullptr ) )
455  return /* TODO ... report error */;
456 }
457 
467 
468 void* Cppyy::CallR( TCppMethod_t method, TCppObject_t self, void* args )
469 {
470  void* r = nullptr;
471  if ( FastCall( method, args, (void*)self, &r ) )
472  return r;
473  return nullptr;
474 }
475 
476 Char_t* Cppyy::CallS( TCppMethod_t method, TCppObject_t self, void* args )
477 {
478  Char_t* s = nullptr;
479  if ( FastCall( method, args, (void*)self, &s ) )
480  return s;
481  return nullptr;
482 }
483 
485  TCppMethod_t method, TCppType_t /* klass */, void* args ) {
486  void* obj = nullptr;
487  if ( FastCall( method, args, nullptr, &obj ) )
488  return (TCppObject_t)obj;
489  return (TCppObject_t)0;
490 }
491 
493 {
494  TClassRef& cr = type_from_handle( type );
495  cr->Destructor( (void*)self, kTRUE );
496 }
497 
499  TCppObject_t self, void* args, TCppType_t result_type )
500 {
501  TClassRef& cr = type_from_handle( result_type );
502  size_t s = gInterpreter->ClassInfo_Size(cr->GetClassInfo());
503  void* obj = malloc( s );
504  if ( FastCall( method, args, self, obj ) )
505  return (TCppObject_t)obj;
506  return (TCppObject_t)0;
507 }
508 
510  TCppScope_t /* scope */, TCppIndex_t /* imeth */ )
511 {
512  return (TCppMethPtrGetter_t)0;
513 }
514 
515 
516 // handling of function argument buffer --------------------------------------
517 void* Cppyy::AllocateFunctionArgs( size_t nargs )
518 {
519  return new TParameter[nargs];
520 }
521 
523 {
524  delete [] (TParameter*)args;
525 }
526 
528 {
529  return sizeof( TParameter );
530 }
531 
533 {
534  return offsetof( TParameter, fTypeCode );
535 }
536 
537 
538 // scope reflection information ----------------------------------------------
540 // Test if this scope represents a namespace.
541  TClassRef& cr = type_from_handle( scope );
542  if ( cr.GetClass() )
543  return cr->Property() & kIsNamespace;
544  return kFALSE;
545 }
546 
548 // Test if this type may not be instantiated.
549  TClassRef& cr = type_from_handle( klass );
550  if ( cr.GetClass() )
551  return cr->Property() & kIsAbstract;
552  return kFALSE;
553 }
554 
555 Bool_t Cppyy::IsEnum( const std::string& type_name ) {
556  return gInterpreter->ClassInfo_IsEnum( type_name.c_str() );
557 }
558 
559 
560 // class reflection information ----------------------------------------------
561 std::string Cppyy::GetFinalName( TCppType_t klass )
562 {
563  if ( klass == GLOBAL_HANDLE ) // due to CLING WORKAROUND in InitConverters_
564  return "";
565  // TODO: either this or GetScopedFinalName is wrong
566  TClassRef& cr = type_from_handle( klass );
567  return cr->GetName();
568 }
569 
571 {
572  // TODO: either this or GetFinalName is wrong
573  TClassRef& cr = type_from_handle( klass );
574  return cr->GetName();
575 }
576 
578 {
579 // Always TRUE for now (pre-empts certain optimizations).
580  return kTRUE;
581 }
582 
584 {
585 // Get the total number of base classes that this class has.
586  TClassRef& cr = type_from_handle( klass );
587  if ( cr.GetClass() && cr->GetListOfBases() != 0 )
588  return cr->GetListOfBases()->GetSize();
589  return 0;
590 }
591 
592 std::string Cppyy::GetBaseName( TCppType_t klass, TCppIndex_t ibase )
593 {
594  TClassRef& cr = type_from_handle( klass );
595  return ((TBaseClass*)cr->GetListOfBases()->At( ibase ))->GetName();
596 }
597 
599 {
600  if ( derived == base )
601  return kTRUE;
602  TClassRef& derived_type = type_from_handle( derived );
603  TClassRef& base_type = type_from_handle( base );
604  return derived_type->GetBaseClass( base_type ) != 0;
605 }
606 
607 void Cppyy::AddSmartPtrType( const std::string& type_name ) {
608  gSmartPtrTypes.insert( ResolveName( type_name ) );
609 }
610 
611 Bool_t Cppyy::IsSmartPtr( const std::string& type_name ) {
612 // checks if typename denotes a smart pointer
613 // TODO: perhaps make this stricter?
614  const std::string& real_name = ResolveName( type_name );
615  return gSmartPtrTypes.find(
616  real_name.substr( 0,real_name.find( "<" ) ) ) != gSmartPtrTypes.end();
617 }
618 
619 // type offsets --------------------------------------------------------------
620 ptrdiff_t Cppyy::GetBaseOffset( TCppType_t derived, TCppType_t base,
621  TCppObject_t address, int direction, bool rerror )
622 {
623 // calculate offsets between declared and actual type, up-cast: direction > 0; down-cast: direction < 0
624  if ( derived == base || !(base && derived) )
625  return (ptrdiff_t)0;
626 
627  TClassRef& cd = type_from_handle( derived );
628  TClassRef& cb = type_from_handle( base );
629 
630  if ( !cd.GetClass() || !cb.GetClass() )
631  return (ptrdiff_t)0;
632 
633  Long_t offset = -1;
634  if ( ! (cd->GetClassInfo() && cb->GetClassInfo()) ) { // gInterpreter requirement
635  // would like to warn, but can't quite determine error from intentional
636  // hiding by developers, so only cover the case where we really should have
637  // had a class info, but apparently don't:
638  if ( cd->IsLoaded() ) {
639  // warn to allow diagnostics
640  std::ostringstream msg;
641  msg << "failed offset calculation between " << cb->GetName() << " and " << cd->GetName();
642  PyErr_Warn( PyExc_RuntimeWarning, const_cast<char*>( msg.str().c_str() ) );
643  }
644 
645  // return -1 to signal caller NOT to apply offset
646  return rerror ? (ptrdiff_t)offset : 0;
647  }
648 
649  offset = gInterpreter->ClassInfo_GetBaseOffset(
650  cd->GetClassInfo(), cb->GetClassInfo(), (void*)address, direction > 0 );
651  if ( offset == -1 ) // Cling error, treat silently
652  return rerror ? (ptrdiff_t)offset : 0;
653 
654  return (ptrdiff_t)(direction < 0 ? -offset : offset);
655 }
656 
657 
658 // method/function reflection information ------------------------------------
660 {
661  TClassRef& cr = type_from_handle( scope );
662  if ( cr.GetClass() && cr->GetListOfMethods() ) {
664  if ( nMethods == (TCppIndex_t)0 ) {
665  std::string clName = GetScopedFinalName( scope );
666  if ( clName.find( '<' ) != std::string::npos ) {
667  // chicken-and-egg problem: TClass does not know about methods until instantiation: force it
668  if ( TClass::GetClass( ("std::" + clName).c_str() ) )
669  clName = "std::" + clName;
670  std::ostringstream stmt;
671  stmt << "template class " << clName << ";";
672  gInterpreter->Declare( stmt.str().c_str() );
673  // now reload the methods
674  return (TCppIndex_t)cr->GetListOfMethods( kTRUE )->GetSize();
675  }
676  }
677  return nMethods;
678  } else if ( scope == (TCppScope_t)GLOBAL_HANDLE ) {
679  // enforce lazines by denying the existence of methods
680  return (TCppIndex_t)0;
681  }
682  return (TCppIndex_t)0;
683 }
684 
686 {
687  return (TCppIndex_t)0;
688 }
689 
690 std::vector< Cppyy::TCppMethod_t > Cppyy::GetMethodsFromName(
691  TCppScope_t scope, const std::string& name )
692 {
693 // TODO: this method assumes that the call for this name is made only
694 // once, and thus there is no need to store the results of the search
695 // in g_globalfuncs ... probably true, but needs verification
696  std::vector< TCppMethod_t > methods;
697  if ( scope == GLOBAL_HANDLE ) {
698  TCollection* funcs = gROOT->GetListOfGlobalFunctions( kTRUE );
699  g_globalfuncs.reserve(funcs->GetSize());
700 
701  TIter ifunc(funcs);
702 
703  TFunction* func = 0;
704  while ( (func = (TFunction*)ifunc.Next()) ) {
705  // cover not only direct matches, but also template matches
706  std::string fn = func->GetName();
707  if ( fn.rfind( name, 0 ) == 0 ) {
708  // either match exactly, or match the name as template
709  if ( (name.size() == fn.size()) ||
710  (name.size() < fn.size() && fn[name.size()] == '<') ) {
711  methods.push_back( (TCppMethod_t)func );
712  }
713  }
714  }
715  } else {
716  TClassRef& cr = type_from_handle( scope );
717  if ( cr.GetClass() ) {
718  // todo: handle overloads
719  TMethod* m = cr->GetMethodAny( name.c_str() );
720  if ( m ) methods.push_back( (TCppMethod_t)m );
721  }
722  }
723 
724  return methods;
725 }
726 
728 {
729  TFunction* f = type_get_method( scope, imeth );
730  return (Cppyy::TCppMethod_t)f;
731 }
732 
733 std::string Cppyy::GetMethodName( TCppMethod_t method )
734 {
735  if ( method ) {
736  std::string name = ((TFunction*)method)->GetName();
737  //if ( IsMethodTemplate( method ) )
738  // return name.substr( 0, name.find('<') );
739  return name;
740  }
741  return "<unknown>";
742 }
743 
745 {
746  if ( method ) {
747  TFunction* f = (TFunction*)method;
748  if ( f->ExtraProperty() & kIsConstructor )
749  return "constructor";
750  return f->GetReturnTypeNormalizedName();
751  }
752  return "<unknown>";
753 }
754 
756 {
757  if ( method )
758  return ((TFunction*)method)->GetNargs();
759  return 0;
760 }
761 
763 {
764  if ( method ) {
765  TFunction* f = (TFunction*)method;
766  return (TCppIndex_t)(f->GetNargs() - f->GetNargsOpt());
767  }
768  return (TCppIndex_t)0;
769 }
770 
771 std::string Cppyy::GetMethodArgName( TCppMethod_t method, int iarg )
772 {
773  if ( method ) {
774  TFunction* f = (TFunction*)method;
775  TMethodArg* arg = (TMethodArg*)f->GetListOfMethodArgs()->At( iarg );
776  return arg->GetName();
777  }
778  return "<unknown>";
779 }
780 
781 std::string Cppyy::GetMethodArgType( TCppMethod_t method, int iarg )
782 {
783  if ( method ) {
784  TFunction* f = (TFunction*)method;
785  TMethodArg* arg = (TMethodArg*)f->GetListOfMethodArgs()->At( iarg );
786  return arg->GetTypeNormalizedName();
787  }
788  return "<unknown>";
789 }
790 
791 std::string Cppyy::GetMethodArgDefault( TCppMethod_t method, int iarg )
792 {
793  if ( method ) {
794  TFunction* f = (TFunction*)method;
795  TMethodArg* arg = (TMethodArg*)f->GetListOfMethodArgs()->At( iarg );
796  const char* def = arg->GetDefault();
797  if ( def )
798  return def;
799  }
800 
801  return "";
802 }
803 
804 std::string Cppyy::GetMethodSignature( TCppScope_t /* scope */, TCppIndex_t /* imeth */ )
805 {
806  return "<unknown>";
807 }
808 
810 {
811  if ( method ) {
812  TFunction* f = (TFunction*)method;
813  return f->Property() & kIsConstMethod;
814  }
815  return kFALSE;
816 }
817 
818 
820 {
821  if ( method ) {
822  TFunction* f = (TFunction*)method;
823  std::string name = f->GetName();
824  return (name[name.size()-1] == '>') && (name.find('<') != std::string::npos);
825  }
826  return kFALSE;
827 }
828 
830  TCppScope_t /* scope */, TCppIndex_t /* imeth */ )
831 {
832  return (TCppIndex_t)0;
833 }
834 
836  TCppScope_t /* scope */, TCppIndex_t /* imeth */, TCppIndex_t /* iarg */ )
837 {
838  return "<unknown>";
839 }
840 
842  TCppScope_t /* scope */, TCppType_t /* lc */, TCppType_t /* rc */, const std::string& /* op */ )
843 {
844  return (TCppIndex_t)0;
845 }
846 
847 // method properties ---------------------------------------------------------
849 {
850  if ( method ) {
851  TFunction* f = (TFunction*)method;
852  return f->ExtraProperty() & kIsConstructor;
853  }
854  return kFALSE;
855 }
856 
858 {
859  if ( method ) {
860  TFunction* f = (TFunction*)method;
861  return f->Property() & kIsPublic;
862  }
863  return kFALSE;
864 }
865 
867 {
868  if ( method ) {
869  TFunction* f = (TFunction*)method;
870  return f->Property() & kIsStatic;
871  }
872  return kFALSE;
873 }
874 
875 // data member reflection information ----------------------------------------
877 {
878  TClassRef& cr = type_from_handle( scope );
879  if ( cr.GetClass() && cr->GetListOfDataMembers() )
880  return cr->GetListOfDataMembers()->GetSize();
881  else if ( scope == (TCppScope_t)GLOBAL_HANDLE ) {
882  std::cerr << " global data should be retrieved lazily " << std::endl;
883  TCollection* vars = gROOT->GetListOfGlobals( kTRUE );
884  if ( g_globalvars.size() != (GlobalVars_t::size_type)vars->GetSize() ) {
885  g_globalvars.clear();
886  g_globalvars.reserve(vars->GetSize());
887 
888  TIter ivar(vars);
889 
890  TGlobal* var = 0;
891  while ( (var = (TGlobal*)ivar.Next()) )
892  g_globalvars.push_back( var );
893  }
894  return (TCppIndex_t)g_globalvars.size();
895  }
896  return (TCppIndex_t)0;
897 }
898 
900 {
901  TClassRef& cr = type_from_handle( scope );
902  if (cr.GetClass()) {
903  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
904  return m->GetName();
905  }
906  assert( scope == (TCppScope_t)GLOBAL_HANDLE );
907  TGlobal* gbl = g_globalvars[ idata ];
908  return gbl->GetName();
909 }
910 
912 {
913  if ( scope == GLOBAL_HANDLE ) {
914  TGlobal* gbl = g_globalvars[ idata ];
915  std::string fullType = gbl->GetFullTypeName();
916  if ( fullType[fullType.size()-1] == '*' && \
917  fullType.find( "char", 0, 4 ) == std::string::npos )
918  fullType.append( "*" );
919  else if ( (int)gbl->GetArrayDim() > 1 )
920  fullType.append( "*" );
921  else if ( (int)gbl->GetArrayDim() == 1 ) {
922  std::ostringstream s;
923  s << '[' << gbl->GetMaxIndex( 0 ) << ']' << std::ends;
924  fullType.append( s.str() );
925  }
926  return fullType;
927  }
928 
929  TClassRef& cr = type_from_handle( scope );
930  if ( cr.GetClass() ) {
931  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
932  std::string fullType = m->GetTrueTypeName();
933  if ( (int)m->GetArrayDim() > 1 || (!m->IsBasic() && m->IsaPointer()) )
934  fullType.append( "*" );
935  else if ( (int)m->GetArrayDim() == 1 ) {
936  std::ostringstream s;
937  s << '[' << m->GetMaxIndex( 0 ) << ']' << std::ends;
938  fullType.append( s.str() );
939  }
940  return fullType;
941  }
942 
943  return "<unknown>";
944 }
945 
947 {
948  if ( scope == GLOBAL_HANDLE ) {
949  TGlobal* gbl = g_globalvars[ idata ];
950  return (ptrdiff_t)gbl->GetAddress();
951  }
952 
953  TClassRef& cr = type_from_handle( scope );
954  if ( cr.GetClass() ) {
955  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
956  return (ptrdiff_t)m->GetOffsetCint(); // yes, CINT ...
957  }
958 
959  return (ptrdiff_t)0;
960 }
961 
963 {
964  if ( scope == GLOBAL_HANDLE ) {
965  TGlobal* gb = (TGlobal*)gROOT->GetListOfGlobals( kTRUE )->FindObject( name.c_str() );
966  if ( gb && gb->GetAddress() && gb->GetAddress() != (void*)-1 ) {
967  g_globalvars.push_back( gb );
968  return g_globalvars.size() - 1;
969  }
970 
971  } else {
972  TClassRef& cr = type_from_handle( scope );
973  if ( cr.GetClass() ) {
974  TDataMember* dm =
975  (TDataMember*)cr->GetListOfDataMembers()->FindObject( name.c_str() );
976  // TODO: turning this into an index is silly ...
977  if ( dm ) return (TCppIndex_t)cr->GetListOfDataMembers()->IndexOf( dm );
978  }
979  }
980 
981  return (TCppIndex_t)-1;
982 }
983 
984 
985 // data member properties ----------------------------------------------------
987 {
988  if ( scope == GLOBAL_HANDLE )
989  return kTRUE;
990  TClassRef& cr = type_from_handle( scope );
991  if ( cr->Property() & kIsNamespace )
992  return kTRUE;
993  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
994  return m->Property() & kIsPublic;
995 }
996 
998 {
999  if ( scope == GLOBAL_HANDLE )
1000  return kTRUE;
1001  TClassRef& cr = type_from_handle( scope );
1002  if ( cr->Property() & kIsNamespace )
1003  return kTRUE;
1004  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
1005  return m->Property() & kIsStatic;
1006 }
1007 
1009 {
1010  if ( scope == GLOBAL_HANDLE ) {
1011  TGlobal* gbl = g_globalvars[ idata ];
1012  return gbl->Property() & kIsConstant;
1013  }
1014  TClassRef& cr = type_from_handle( scope );
1015  if ( cr.GetClass() ) {
1016  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
1017  return m->Property() & kIsConstant;
1018  }
1019  return kFALSE;
1020 }
1021 
1023 {
1024  if ( scope == GLOBAL_HANDLE ) {
1025  TGlobal* gbl = g_globalvars[ idata ];
1026  return gbl->Property() & kIsEnum;
1027  }
1028  TClassRef& cr = type_from_handle( scope );
1029  if ( cr.GetClass() ) {
1030  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
1031  return m->Property() & kIsEnum;
1032  }
1033  return kFALSE;
1034 }
1035 
1037 {
1038  if ( scope == GLOBAL_HANDLE ) {
1039  TGlobal* gbl = g_globalvars[ idata ];
1040  return gbl->GetMaxIndex( dimension );
1041  }
1042  TClassRef& cr = type_from_handle( scope );
1043  if ( cr.GetClass() ) {
1044  TDataMember* m = (TDataMember*)cr->GetListOfDataMembers()->At( idata );
1045  return m->GetMaxIndex( dimension );
1046  }
1047  return (Int_t)-1;
1048 }
virtual const char * GetName() const
Returns name of object.
Definition: TNamed.h:47
std::map< std::string, ClassRefs_t::size_type > Name2ClassRefIndex_t
Definition: Cppyy.cxx:50
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:145
TCppScope_t TCppType_t
Definition: Cppyy.h:13
size_t GetFunctionArgSizeof()
Definition: Cppyy.cxx:527
static double B[]
TList * GetListOfBases()
Return list containing the TBaseClass(es) of a class.
Definition: TClass.cxx:3507
std::string GetScopedFinalName(TCppType_t type)
Definition: Cppyy.cxx:570
std::vector< TClassRef > ClassRefs_t
Definition: Cppyy.cxx:46
long long Long64_t
Definition: RtypesCore.h:69
auto * m
Definition: textangle.C:8
virtual Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
Definition: TGlobal.cxx:101
R__EXTERN Int_t gErrorIgnoreLevel
Definition: TError.h:105
std::vector< TGlobal *> GlobalVars_t
Definition: Cppyy.cxx:59
virtual const char * GetFullTypeName() const
Get full type description of global variable, e,g.: "class TDirectory*".
Definition: TGlobal.cxx:120
virtual CallFuncIFacePtr_t CallFunc_IFacePtr(CallFunc_t *) const
Definition: TInterpreter.h:299
static ClassRefs_t g_classrefs(1)
Bool_t IsNamespace(TCppScope_t scope)
Definition: Cppyy.cxx:539
Long_t GetOffsetCint() const
Get offset from "this" using the information in CINT only.
float Float_t
Definition: RtypesCore.h:53
R__EXTERN TClassTable * gClassTable
Definition: TClassTable.h:95
Bool_t IsBuiltin(const std::string &type_name)
Definition: Cppyy.cxx:225
TCppIndex_t GetGlobalOperator(TCppType_t scope, TCppType_t lc, TCppScope_t rc, const std::string &op)
Definition: Cppyy.cxx:841
All ROOT classes may have RTTI (run time type identification) support added.
Definition: TDataMember.h:31
double T(double x)
Definition: ChebyshevPol.h:34
Bool_t IsMethodTemplate(TCppMethod_t)
Definition: Cppyy.cxx:819
ptrdiff_t GetBaseOffset(TCppType_t derived, TCppType_t base, TCppObject_t address, int direction, bool rerror=false)
Definition: Cppyy.cxx:620
Bool_t IsPublicMethod(TCppMethod_t method)
Definition: Cppyy.cxx:857
static void copy_args(void *args_, void **vargs)
Definition: Cppyy.cxx:358
TCppIndex_t GetNumBases(TCppType_t type)
Definition: Cppyy.cxx:583
TCppIndex_t GetMethodReqArgs(TCppMethod_t)
Definition: Cppyy.cxx:762
std::vector< TCppMethod_t > GetMethodsFromName(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:690
#define gROOT
Definition: TROOT.h:410
#define H(x, y, z)
TList * GetListOfDataMembers(Bool_t load=kTRUE)
Return list containing the TDataMembers of a class.
Definition: TClass.cxx:3617
Bool_t IsAbstract(TCppType_t type)
Definition: Cppyy.cxx:547
std::string GetFinalName(TCppType_t type)
Definition: Cppyy.cxx:561
std::string GetMethodSignature(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:804
std::string CleanType(const char *typeDesc, int mode=0, const char **tail=0)
Cleanup type description, redundant blanks removed and redundant tail ignored return *tail = pointer ...
virtual void * GetAddress() const
Return address of global.
Definition: TGlobal.cxx:77
ptrdiff_t GetDatamemberOffset(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:946
#define f(i)
Definition: RSha256.hxx:104
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
static GlobalFuncs_t g_globalfuncs
Definition: Cppyy.cxx:57
#define gInterpreter
Definition: TInterpreter.h:527
Bool_t IsEnumData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:1022
std::string GetDatamemberType(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:911
Each ROOT method (see TMethod) has a linked list of its arguments.
Definition: TMethodArg.h:31
TCppIndex_t GetNumScopes(TCppScope_t parent)
Definition: Cppyy.cxx:125
Bool_t FastCall(Cppyy::TCppMethod_t method, void *args_, void *self, void *result)
Definition: Cppyy.cxx:393
TCppObject_t CallO(TCppMethod_t method, TCppObject_t self, void *args, TCppType_t result_type)
Definition: Cppyy.cxx:498
#define malloc
Definition: civetweb.c:1347
Int_t GetDimensionSize(TCppScope_t scope, TCppIndex_t idata, int dimension)
Definition: Cppyy.cxx:1036
virtual Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TGlobal.cxx:148
#define CPPYY_IMP_CALL(typecode, rtype)
Definition: Cppyy.cxx:446
TCppObject_t CallConstructor(TCppMethod_t method, TCppType_t type, void *args)
Definition: Cppyy.cxx:484
std::string GetBaseName(TCppType_t type, TCppIndex_t ibase)
Definition: Cppyy.cxx:592
TClass * GetClass() const
Definition: TClassRef.h:71
virtual TObject * FindObject(const char *name) const
Delete a TObjLink object.
Definition: TList.cxx:574
Char_t * CallS(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:476
TCppIndex_t GetMethodIndexAt(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:685
static TFunction * type_get_method(Cppyy::TCppType_t klass, Cppyy::TCppIndex_t idx)
Definition: Cppyy.cxx:106
Definition: Cppyy.h:10
TCppIndex_t GetMethodNumTemplateArgs(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:829
TCppType_t GetTemplate(const std::string &template_name)
Definition: Cppyy.cxx:202
Bool_t IsBasic() const
Return true if data member is a basic type, e.g. char, int, long...
std::string ResolveName(const std::string &cppitem_name)
Definition: Cppyy.cxx:166
Bool_t HasComplexHierarchy(TCppType_t type)
Definition: Cppyy.cxx:577
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Bool_t IsLoaded() const
Return true if the shared library of this class is currently in the a process&#39;s memory.
Definition: TClass.cxx:5642
std::string GetReturnTypeNormalizedName() const
Get the normalized name of the return type.
Definition: TFunction.cxx:154
TCppMethPtrGetter_t GetMethPtrGetter(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:509
std::string ResolveTypedef(const char *tname, bool resolveAll=false)
Long_t Property() const
Get property description word. For meaning of bits see EProperty.
Definition: TFunction.cxx:183
static constexpr double L
TCppIndex_t GetNumDatamembers(TCppScope_t scope)
Definition: Cppyy.cxx:876
ClassInfo_t * GetClassInfo() const
Definition: TClass.h:400
Bool_t IsConstData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:1008
static Method2CallFunc_t g_method2callfunc
Definition: Cppyy.cxx:54
void CallDestructor(TCppType_t type, TCppObject_t self)
Definition: Cppyy.cxx:492
static std::set< std::string > gSmartPtrTypes
Definition: Cppyy.cxx:66
std::string GetTypeNormalizedName() const
Get the normalized name of the return type.
Definition: TMethodArg.cxx:86
Bool_t IsComplete(const std::string &type_name)
Definition: Cppyy.cxx:232
TCppMethod_t GetMethod(TCppScope_t scope, TCppIndex_t imeth)
Definition: Cppyy.cxx:727
size_t GetFunctionArgTypeoffset()
Definition: Cppyy.cxx:532
std::string GetMethodTemplateArgName(TCppScope_t scope, TCppIndex_t imeth, TCppIndex_t iarg)
Definition: Cppyy.cxx:835
Int_t GetMaxIndex(Int_t dim) const
Return maximum index for array dimension "dim".
TClass * GetBaseClass(const char *classname)
Return pointer to the base class "classname".
Definition: TClass.cxx:2574
Int_t GetType() const
Definition: TDataType.h:68
Bool_t IsConstructor(TCppMethod_t method)
Definition: Cppyy.cxx:848
TCppType_t GetActualClass(TCppType_t klass, TCppObject_t obj)
Definition: Cppyy.cxx:207
PyROOT::TParameter TParameter
Definition: Cppyy.cxx:36
Named parameter, streamable and storable.
Definition: TParameter.h:37
#define F(x, y, z)
void AddSmartPtrType(const std::string &)
Definition: Cppyy.cxx:607
ptrdiff_t TCppMethod_t
Definition: Cppyy.h:15
Int_t GetNargs() const
Number of function arguments.
Definition: TFunction.cxx:164
TCppScope_t gGlobalScope
Definition: Cppyy.cxx:63
static double C[]
Bool_t IsPublicData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:986
std::string GetMethodName(TCppMethod_t)
Definition: Cppyy.cxx:733
ROOT::R::TRInterface & r
Definition: Object.C:4
Basic data type descriptor (datatype information is obtained from CINT).
Definition: TDataType.h:44
TClass * GetActualClass(const void *object) const
Return a pointer the the real class of the object.
Definition: TClass.cxx:2527
PyObject * fValue
TObject * Next()
Definition: TCollection.h:249
Collection abstract base class.
Definition: TCollection.h:63
void Destructor(void *obj, Bool_t dtorOnly=kFALSE)
Explicitly call destructor for object.
Definition: TClass.cxx:5149
void * AllocateFunctionArgs(size_t nargs)
Definition: Cppyy.cxx:517
Int_t Size() const
Return size of object of this class.
Definition: TClass.cxx:5434
static CallFunc_t * GetCallFunc(Cppyy::TCppMethod_t method)
Definition: Cppyy.cxx:285
short Short_t
Definition: RtypesCore.h:35
static GlobalVars_t g_globalvars
Definition: Cppyy.cxx:60
TCppIndex_t GetDatamemberIndex(TCppScope_t scope, const std::string &name)
Definition: Cppyy.cxx:962
Int_t GetArrayDim() const
Return number of array dimensions.
The ROOT global object gROOT contains a list of all defined classes.
Definition: TClass.h:75
long double LongDouble_t
Definition: RtypesCore.h:57
virtual TObject * At(Int_t idx) const
Returns the object at position idx. Returns 0 if idx is out of range.
Definition: TList.cxx:354
Global variables class (global variables are obtained from CINT).
Definition: TGlobal.h:27
void * TCppObject_t
Definition: Cppyy.h:14
virtual Int_t GetArrayDim() const
Return number of array dimensions.
Definition: TGlobal.cxx:85
static const ClassRefs_t::size_type GLOBAL_HANDLE
Definition: Cppyy.cxx:48
Long_t Property() const
Set TObject::fBits and fStreamerType to cache information about the class.
Definition: TClass.cxx:5768
Each class (see TClass) has a linked list of its base class(es).
Definition: TBaseClass.h:33
const Bool_t kFALSE
Definition: RtypesCore.h:88
const char * GetTrueTypeName() const
Get full type description of data member, e,g.: "class TDirectory*".
void * CallR(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:468
long Long_t
Definition: RtypesCore.h:50
Bool_t IsSubtype(TCppType_t derived, TCppType_t base)
Definition: Cppyy.cxx:598
static TClassRef & type_from_handle(Cppyy::TCppScope_t scope)
Definition: Cppyy.cxx:98
static T CallT(Cppyy::TCppMethod_t method, Cppyy::TCppObject_t self, void *args)
Definition: Cppyy.cxx:438
TCppScope_t GetScope(const std::string &scope_name)
Definition: Cppyy.cxx:176
TList * GetListOfMethodArgs()
Return list containing the TMethodArgs of a TFunction.
Definition: TFunction.cxx:126
double Double_t
Definition: RtypesCore.h:55
std::string GetMethodResultType(TCppMethod_t)
Definition: Cppyy.cxx:744
int type
Definition: TGX11.cxx:120
#define free
Definition: civetweb.c:1350
static constexpr double s
TCppIndex_t GetMethodNumArgs(TCppMethod_t)
Definition: Cppyy.cxx:755
std::string GetMethodArgName(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:771
static TClass * GetClass(const char *name, Bool_t load=kTRUE, Bool_t silent=kFALSE)
Static method returning pointer to TClass of the specified class name.
Definition: TClass.cxx:2887
void Deallocate(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:260
TCppObject_t Allocate(TCppType_t type)
Definition: Cppyy.cxx:254
std::string GetMethodArgType(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:781
Bool_t IsSmartPtr(const std::string &)
Definition: Cppyy.cxx:611
Long_t ExtraProperty() const
Get property description word. For meaning of bits see EProperty.
Definition: TFunction.cxx:191
Bool_t IsStaticMethod(TCppMethod_t method)
Definition: Cppyy.cxx:866
std::string GetDatamemberName(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:899
Global functions class (global functions are obtained from CINT).
Definition: TFunction.h:28
TClassRef is used to implement a permanent reference to a TClass object.
Definition: TClassRef.h:29
char Char_t
Definition: RtypesCore.h:29
typedef void((*Func_t)())
Bool_t IsStaticData(TCppScope_t scope, TCppIndex_t idata)
Definition: Cppyy.cxx:997
static Name2ClassRefIndex_t g_name2classrefidx
Definition: Cppyy.cxx:51
static ClassInfo_t * GetGlobalNamespaceInfo()
Definition: Cppyy.cxx:279
size_t SizeOf(TCppType_t klass)
Definition: Cppyy.cxx:218
const char * GetDefault() const
Get default value of method argument.
Definition: TMethodArg.cxx:58
Long_t TCppIndex_t
Definition: Cppyy.h:17
Bool_t IsConstMethod(TCppMethod_t)
Definition: Cppyy.cxx:809
TCppIndex_t GetNumMethods(TCppScope_t scope)
Definition: Cppyy.cxx:659
Each ROOT class (see TClass) has a linked list of methods.
Definition: TMethod.h:38
std::string ShortType(const char *typeDesc, int mode)
Return the absolute type of typeDesc.
void CallV(TCppMethod_t method, TCppObject_t self, void *args)
Definition: Cppyy.cxx:452
you should not use this method at all Int_t Int_t Double_t Double_t Double_t Int_t Double_t Double_t Double_t Double_t b
Definition: TRolke.cxx:630
TClass * GetClass() const
Definition: TMethod.h:55
static Cppyy::TCppScope_t declaring_scope(Cppyy::TCppMethod_t method)
Definition: Cppyy.cxx:116
#define c(i)
Definition: RSha256.hxx:101
std::map< Cppyy::TCppMethod_t, CallFunc_t *> Method2CallFunc_t
Definition: Cppyy.cxx:53
unsigned char UChar_t
Definition: RtypesCore.h:34
TCppObject_t Construct(TCppType_t type)
Definition: Cppyy.cxx:265
void Destruct(TCppType_t type, TCppObject_t instance)
Definition: Cppyy.cxx:271
TMethod * GetMethodAny(const char *method)
Return pointer to method without looking at parameters.
Definition: TClass.cxx:4195
void *(* TCppMethPtrGetter_t)(TCppObject_t)
Definition: Cppyy.h:18
R__EXTERN TInterpreter * gCling
Definition: TInterpreter.h:529
#define I(x, y, z)
virtual Int_t GetSize() const
Return the capacity of the collection, i.e.
Definition: TCollection.h:182
TList * GetListOfMethods(Bool_t load=kTRUE)
Return list containing the TMethods of a class.
Definition: TClass.cxx:3666
Bool_t IsaPointer() const
Return true if data member is a pointer.
std::string GetMethodArgDefault(TCppMethod_t, int iarg)
Definition: Cppyy.cxx:791
ptrdiff_t TCppScope_t
Definition: Cppyy.h:12
const Bool_t kTRUE
Definition: RtypesCore.h:87
static char * At(UInt_t index)
Returns class at index from sorted class table.
void DeallocateFunctionArgs(void *args)
Definition: Cppyy.cxx:522
Bool_t IsEnum(const std::string &type_name)
Definition: Cppyy.cxx:555
Int_t GetNargsOpt() const
Number of function optional (default) arguments.
Definition: TFunction.cxx:174
std::string GetScopeName(TCppScope_t parent, TCppIndex_t iscope)
Definition: Cppyy.cxx:133
char name[80]
Definition: TGX11.cxx:109
std::vector< TFunction > GlobalFuncs_t
Definition: Cppyy.cxx:56
void * New(ENewType defConstructor=kClassNew, Bool_t quiet=kFALSE) const
Return a pointer to a newly allocated object of this class.
Definition: TClass.cxx:4792
virtual Int_t IndexOf(const TObject *obj) const
Return index of object in collection.
const int SMALL_ARGS_N
Definition: Cppyy.cxx:42