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