ROOT logo
// @(#)root/reflex:$Id: Kernel.cxx 27579 2009-02-23 15:15:06Z pcanal $
// Author: Stefan Roiser 2004

// Copyright CERN, CH-1211 Geneva 23, 2004-2006, All rights reserved.
//
// Permission to use, copy, modify, and distribute this software for any
// purpose is hereby granted without fee, provided that this copyright and
// permissions notice appear in all copies and derivatives.
//
// This software is provided "as is" without express or implied warranty.

#ifndef REFLEX_BUILD
#define REFLEX_BUILD
#endif

#include "Reflex/Kernel.h"

#include "Reflex/Scope.h"
#include "Reflex/internal/ScopeName.h"
#include "Reflex/PropertyList.h"
#include "Reflex/Type.h"
#include "Reflex/Base.h"
#include "Reflex/Member.h"
#include "Reflex/Object.h"
#include "Reflex/PropertyList.h"
#include "Reflex/MemberTemplate.h"
#include "Reflex/Any.h"

#include "Fundamental.h"
#include "Namespace.h"
#include "Typedef.h"
#include "Class.h"
#include <typeinfo>


//-------------------------------------------------------------------------------
Reflex::Instance::Instance() {
//-------------------------------------------------------------------------------
// Initialisation of Reflex.Setup of global scope, fundamental types.

   static bool initialized = false;

   if (initialized) {
      return;
   }

   initialized = true;

   /** initialisation of the global namespace */
   Namespace::GlobalScope();

   // initialising fundamental types
   TypeBase* tb = 0;
   Type t = Type();
 
   // char [3.9.1.1]
   tb = new TypeBase( "char", sizeof( char ), FUNDAMENTAL, typeid( char ), Type(), REPRES_CHAR);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   // signed integer types [3.9.1.2]
   tb = new TypeBase( "signed char", sizeof( signed char ), FUNDAMENTAL, typeid( signed char ), Type(), REPRES_SIGNED_CHAR);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   tb = new TypeBase( "short int", sizeof( short int ), FUNDAMENTAL, typeid( short int ), Type(), REPRES_SHORT_INT);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "short", t, FUNDAMENTAL, t );
   new Typedef( "signed short", t, FUNDAMENTAL, t );
   new Typedef( "short signed", t, FUNDAMENTAL, t );
   new Typedef( "signed short int", t, FUNDAMENTAL, t );
   new Typedef( "short signed int", t, FUNDAMENTAL, t );

   tb = new TypeBase( "int", sizeof( int ), FUNDAMENTAL, typeid( int ), Type(), REPRES_INT);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "signed", t, FUNDAMENTAL, t );
   new Typedef( "signed int", t, FUNDAMENTAL, t );

   tb = new TypeBase( "long int", sizeof( long int ), FUNDAMENTAL, typeid( long int ), Type(), REPRES_LONG_INT);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "long", t, FUNDAMENTAL, t );
   new Typedef( "signed long", t, FUNDAMENTAL, t );
   new Typedef( "long signed", t, FUNDAMENTAL, t );
   new Typedef( "signed long int", t, FUNDAMENTAL, t );
   new Typedef( "long signed int", t, FUNDAMENTAL, t );

   // unsigned integer types [3.9.1.3]
   tb = new TypeBase( "unsigned char", sizeof( unsigned char ), FUNDAMENTAL, typeid( unsigned char ), Type(), REPRES_UNSIGNED_CHAR);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   tb = new TypeBase( "unsigned short int", sizeof( unsigned short int ), FUNDAMENTAL, typeid( unsigned short int ), Type(), REPRES_UNSIGNED_SHORT_INT);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "unsigned short", t, FUNDAMENTAL, t );
   new Typedef( "short unsigned int", t, FUNDAMENTAL, t );

   tb = new TypeBase( "unsigned int", sizeof( unsigned int ), FUNDAMENTAL, typeid( unsigned int ), Type(), REPRES_UNSIGNED_INT);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "unsigned", t, FUNDAMENTAL, t );

   tb = new TypeBase( "unsigned long int", sizeof( unsigned long int ), FUNDAMENTAL, typeid( unsigned long int ), Type(), REPRES_UNSIGNED_LONG_INT);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "unsigned long", t, FUNDAMENTAL, t );
   new Typedef( "long unsigned", t, FUNDAMENTAL, t );
   new Typedef( "long unsigned int", t, FUNDAMENTAL, t );

   /*/ w_chart [3.9.1.5]
     tb = new TypeBase( "w_chart", 
     sizeof( w_chart ), 
     & typeid( w_chart ));
     tb->Properties().AddProperty( "Description", "fundamental type" );
   */

   // bool [3.9.1.6]
   tb = new TypeBase( "bool", sizeof( bool ), FUNDAMENTAL, typeid( bool ), Type(), REPRES_BOOL);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   // floating point types [3.9.1.8]
   tb = new TypeBase( "float", sizeof( float ), FUNDAMENTAL, typeid( float ), Type(), REPRES_FLOAT);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   tb = new TypeBase( "double", sizeof( double ), FUNDAMENTAL, typeid( double ), Type(), REPRES_DOUBLE);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   tb = new TypeBase( "long double", sizeof( long double ), FUNDAMENTAL, typeid( long double ), Type(), REPRES_LONG_DOUBLE);
   tb->Properties().AddProperty( "Description", "fundamental type" );

   // void [3.9.1.9]
   tb = new TypeBase( "void", 0, FUNDAMENTAL, typeid( void ), Type(), REPRES_VOID);
   tb->Properties().AddProperty( "Description", "fundamental type" );

      // Large integer definition depends of the platform
#if defined(_WIN32) && !defined(__CINT__)
   typedef __int64 longlong;
   typedef unsigned __int64 ulonglong;
#else
   typedef long long int longlong; /* */
   typedef unsigned long long int /**/ ulonglong;
#endif

   // non fundamental types but also supported at initialisation
   tb = new TypeBase( "long long", sizeof( longlong ), FUNDAMENTAL, typeid( longlong ), Type(), REPRES_LONGLONG);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "long long int", t, FUNDAMENTAL, t );

   tb = new TypeBase( "unsigned long long", sizeof( ulonglong ), FUNDAMENTAL, typeid( ulonglong ), Type(), REPRES_ULONGLONG);
   tb->Properties().AddProperty( "Description", "fundamental type" );
   t = tb->ThisType();
   new Typedef( "long long unsigned", t, FUNDAMENTAL, t );
   new Typedef( "unsigned long long int", t, FUNDAMENTAL, t );
   new Typedef( "long long unsigned int", t, FUNDAMENTAL, t );

}


//-------------------------------------------------------------------------------
void Reflex::Instance::Shutdown() {
//-------------------------------------------------------------------------------
   // function to be called at tear down of Reflex, removes all memory allocations
   MemberTemplateName::CleanUp();
   TypeTemplateName::CleanUp();
   TypeName::CleanUp();
   ScopeName::CleanUp();
}


//-------------------------------------------------------------------------------

Reflex::Instance::~Instance() {
//-------------------------------------------------------------------------------
   // Destructor

   // Uncomment this once Unload work:
   // Shutdown;
}


//-------------------------------------------------------------------------------
const Reflex::StdString_Cont_Type_t & Reflex::Dummy::StdStringCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of std strings.
   return Get< StdString_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::Type_Cont_Type_t & Reflex::Dummy::TypeCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of Types.
   return Get< Type_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::Base_Cont_Type_t & Reflex::Dummy::BaseCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of Bases.
   return Get< Base_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::Scope_Cont_Type_t & Reflex::Dummy::ScopeCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of Scopes.
   return Get< Scope_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::Object_Cont_Type_t & Reflex::Dummy::ObjectCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of Objects.
   return Get< Object_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::Member_Cont_Type_t & Reflex::Dummy::MemberCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of Members.
   return Get< Member_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::TypeTemplate_Cont_Type_t & Reflex::Dummy::TypeTemplateCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of TypeTemplates.
   return Get< TypeTemplate_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
const Reflex::MemberTemplate_Cont_Type_t & Reflex::Dummy::MemberTemplateCont() {
//-------------------------------------------------------------------------------
// static wrapper for an empty container of MemberTemplates.
   return Get< MemberTemplate_Cont_Type_t >();
}


//-------------------------------------------------------------------------------
Reflex::Any & Reflex::Dummy::Any() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty Any object 
   static Reflex::Any i;
   if ( i ) i.Clear();
   return i;
}


//-------------------------------------------------------------------------------
const Reflex::Object & Reflex::Dummy::Object() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty Object 
   return Get< Reflex::Object >();
}


//-------------------------------------------------------------------------------
const Reflex::Type & Reflex::Dummy::Type() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty Type 
   return Get< Reflex::Type >();
}


//-------------------------------------------------------------------------------
const Reflex::TypeTemplate & Reflex::Dummy::TypeTemplate() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty TypeTemplate 
   return Get< Reflex::TypeTemplate >();
}


//-------------------------------------------------------------------------------
const Reflex::Base & Reflex::Dummy::Base() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty Base 
   return Get< Reflex::Base >();
}


//-------------------------------------------------------------------------------
const Reflex::PropertyList & Reflex::Dummy::PropertyList() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty PropertyList 
   return Get< Reflex::PropertyList >();
}


//-------------------------------------------------------------------------------
const Reflex::Member & Reflex::Dummy::Member() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty Member 
   return Get< Reflex::Member >();
}


//-------------------------------------------------------------------------------
const Reflex::MemberTemplate & Reflex::Dummy::MemberTemplate() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty MemberTemplate 
   return Get< Reflex::MemberTemplate >();
}


//-------------------------------------------------------------------------------
const Reflex::Scope & Reflex::Dummy::Scope() {
//-------------------------------------------------------------------------------
   // static wrapper for an empty Scope 
   return Get< Reflex::Scope >();
}


//-------------------------------------------------------------------------------
const std::string & Reflex::Argv0() {
//-------------------------------------------------------------------------------
// Return the name of the package.
   static std::string str = "REFLEX";
   return str;
}


//-------------------------------------------------------------------------------
namespace {
   Reflex::Instance initialise;
}
//-------------------------------------------------------------------------------



 Kernel.cxx:1
 Kernel.cxx:2
 Kernel.cxx:3
 Kernel.cxx:4
 Kernel.cxx:5
 Kernel.cxx:6
 Kernel.cxx:7
 Kernel.cxx:8
 Kernel.cxx:9
 Kernel.cxx:10
 Kernel.cxx:11
 Kernel.cxx:12
 Kernel.cxx:13
 Kernel.cxx:14
 Kernel.cxx:15
 Kernel.cxx:16
 Kernel.cxx:17
 Kernel.cxx:18
 Kernel.cxx:19
 Kernel.cxx:20
 Kernel.cxx:21
 Kernel.cxx:22
 Kernel.cxx:23
 Kernel.cxx:24
 Kernel.cxx:25
 Kernel.cxx:26
 Kernel.cxx:27
 Kernel.cxx:28
 Kernel.cxx:29
 Kernel.cxx:30
 Kernel.cxx:31
 Kernel.cxx:32
 Kernel.cxx:33
 Kernel.cxx:34
 Kernel.cxx:35
 Kernel.cxx:36
 Kernel.cxx:37
 Kernel.cxx:38
 Kernel.cxx:39
 Kernel.cxx:40
 Kernel.cxx:41
 Kernel.cxx:42
 Kernel.cxx:43
 Kernel.cxx:44
 Kernel.cxx:45
 Kernel.cxx:46
 Kernel.cxx:47
 Kernel.cxx:48
 Kernel.cxx:49
 Kernel.cxx:50
 Kernel.cxx:51
 Kernel.cxx:52
 Kernel.cxx:53
 Kernel.cxx:54
 Kernel.cxx:55
 Kernel.cxx:56
 Kernel.cxx:57
 Kernel.cxx:58
 Kernel.cxx:59
 Kernel.cxx:60
 Kernel.cxx:61
 Kernel.cxx:62
 Kernel.cxx:63
 Kernel.cxx:64
 Kernel.cxx:65
 Kernel.cxx:66
 Kernel.cxx:67
 Kernel.cxx:68
 Kernel.cxx:69
 Kernel.cxx:70
 Kernel.cxx:71
 Kernel.cxx:72
 Kernel.cxx:73
 Kernel.cxx:74
 Kernel.cxx:75
 Kernel.cxx:76
 Kernel.cxx:77
 Kernel.cxx:78
 Kernel.cxx:79
 Kernel.cxx:80
 Kernel.cxx:81
 Kernel.cxx:82
 Kernel.cxx:83
 Kernel.cxx:84
 Kernel.cxx:85
 Kernel.cxx:86
 Kernel.cxx:87
 Kernel.cxx:88
 Kernel.cxx:89
 Kernel.cxx:90
 Kernel.cxx:91
 Kernel.cxx:92
 Kernel.cxx:93
 Kernel.cxx:94
 Kernel.cxx:95
 Kernel.cxx:96
 Kernel.cxx:97
 Kernel.cxx:98
 Kernel.cxx:99
 Kernel.cxx:100
 Kernel.cxx:101
 Kernel.cxx:102
 Kernel.cxx:103
 Kernel.cxx:104
 Kernel.cxx:105
 Kernel.cxx:106
 Kernel.cxx:107
 Kernel.cxx:108
 Kernel.cxx:109
 Kernel.cxx:110
 Kernel.cxx:111
 Kernel.cxx:112
 Kernel.cxx:113
 Kernel.cxx:114
 Kernel.cxx:115
 Kernel.cxx:116
 Kernel.cxx:117
 Kernel.cxx:118
 Kernel.cxx:119
 Kernel.cxx:120
 Kernel.cxx:121
 Kernel.cxx:122
 Kernel.cxx:123
 Kernel.cxx:124
 Kernel.cxx:125
 Kernel.cxx:126
 Kernel.cxx:127
 Kernel.cxx:128
 Kernel.cxx:129
 Kernel.cxx:130
 Kernel.cxx:131
 Kernel.cxx:132
 Kernel.cxx:133
 Kernel.cxx:134
 Kernel.cxx:135
 Kernel.cxx:136
 Kernel.cxx:137
 Kernel.cxx:138
 Kernel.cxx:139
 Kernel.cxx:140
 Kernel.cxx:141
 Kernel.cxx:142
 Kernel.cxx:143
 Kernel.cxx:144
 Kernel.cxx:145
 Kernel.cxx:146
 Kernel.cxx:147
 Kernel.cxx:148
 Kernel.cxx:149
 Kernel.cxx:150
 Kernel.cxx:151
 Kernel.cxx:152
 Kernel.cxx:153
 Kernel.cxx:154
 Kernel.cxx:155
 Kernel.cxx:156
 Kernel.cxx:157
 Kernel.cxx:158
 Kernel.cxx:159
 Kernel.cxx:160
 Kernel.cxx:161
 Kernel.cxx:162
 Kernel.cxx:163
 Kernel.cxx:164
 Kernel.cxx:165
 Kernel.cxx:166
 Kernel.cxx:167
 Kernel.cxx:168
 Kernel.cxx:169
 Kernel.cxx:170
 Kernel.cxx:171
 Kernel.cxx:172
 Kernel.cxx:173
 Kernel.cxx:174
 Kernel.cxx:175
 Kernel.cxx:176
 Kernel.cxx:177
 Kernel.cxx:178
 Kernel.cxx:179
 Kernel.cxx:180
 Kernel.cxx:181
 Kernel.cxx:182
 Kernel.cxx:183
 Kernel.cxx:184
 Kernel.cxx:185
 Kernel.cxx:186
 Kernel.cxx:187
 Kernel.cxx:188
 Kernel.cxx:189
 Kernel.cxx:190
 Kernel.cxx:191
 Kernel.cxx:192
 Kernel.cxx:193
 Kernel.cxx:194
 Kernel.cxx:195
 Kernel.cxx:196
 Kernel.cxx:197
 Kernel.cxx:198
 Kernel.cxx:199
 Kernel.cxx:200
 Kernel.cxx:201
 Kernel.cxx:202
 Kernel.cxx:203
 Kernel.cxx:204
 Kernel.cxx:205
 Kernel.cxx:206
 Kernel.cxx:207
 Kernel.cxx:208
 Kernel.cxx:209
 Kernel.cxx:210
 Kernel.cxx:211
 Kernel.cxx:212
 Kernel.cxx:213
 Kernel.cxx:214
 Kernel.cxx:215
 Kernel.cxx:216
 Kernel.cxx:217
 Kernel.cxx:218
 Kernel.cxx:219
 Kernel.cxx:220
 Kernel.cxx:221
 Kernel.cxx:222
 Kernel.cxx:223
 Kernel.cxx:224
 Kernel.cxx:225
 Kernel.cxx:226
 Kernel.cxx:227
 Kernel.cxx:228
 Kernel.cxx:229
 Kernel.cxx:230
 Kernel.cxx:231
 Kernel.cxx:232
 Kernel.cxx:233
 Kernel.cxx:234
 Kernel.cxx:235
 Kernel.cxx:236
 Kernel.cxx:237
 Kernel.cxx:238
 Kernel.cxx:239
 Kernel.cxx:240
 Kernel.cxx:241
 Kernel.cxx:242
 Kernel.cxx:243
 Kernel.cxx:244
 Kernel.cxx:245
 Kernel.cxx:246
 Kernel.cxx:247
 Kernel.cxx:248
 Kernel.cxx:249
 Kernel.cxx:250
 Kernel.cxx:251
 Kernel.cxx:252
 Kernel.cxx:253
 Kernel.cxx:254
 Kernel.cxx:255
 Kernel.cxx:256
 Kernel.cxx:257
 Kernel.cxx:258
 Kernel.cxx:259
 Kernel.cxx:260
 Kernel.cxx:261
 Kernel.cxx:262
 Kernel.cxx:263
 Kernel.cxx:264
 Kernel.cxx:265
 Kernel.cxx:266
 Kernel.cxx:267
 Kernel.cxx:268
 Kernel.cxx:269
 Kernel.cxx:270
 Kernel.cxx:271
 Kernel.cxx:272
 Kernel.cxx:273
 Kernel.cxx:274
 Kernel.cxx:275
 Kernel.cxx:276
 Kernel.cxx:277
 Kernel.cxx:278
 Kernel.cxx:279
 Kernel.cxx:280
 Kernel.cxx:281
 Kernel.cxx:282
 Kernel.cxx:283
 Kernel.cxx:284
 Kernel.cxx:285
 Kernel.cxx:286
 Kernel.cxx:287
 Kernel.cxx:288
 Kernel.cxx:289
 Kernel.cxx:290
 Kernel.cxx:291
 Kernel.cxx:292
 Kernel.cxx:293
 Kernel.cxx:294
 Kernel.cxx:295
 Kernel.cxx:296
 Kernel.cxx:297
 Kernel.cxx:298
 Kernel.cxx:299
 Kernel.cxx:300
 Kernel.cxx:301
 Kernel.cxx:302
 Kernel.cxx:303
 Kernel.cxx:304
 Kernel.cxx:305
 Kernel.cxx:306
 Kernel.cxx:307
 Kernel.cxx:308
 Kernel.cxx:309
 Kernel.cxx:310
 Kernel.cxx:311
 Kernel.cxx:312
 Kernel.cxx:313
 Kernel.cxx:314
 Kernel.cxx:315
 Kernel.cxx:316
 Kernel.cxx:317
 Kernel.cxx:318
 Kernel.cxx:319
 Kernel.cxx:320
 Kernel.cxx:321
 Kernel.cxx:322
 Kernel.cxx:323
 Kernel.cxx:324
 Kernel.cxx:325
 Kernel.cxx:326
 Kernel.cxx:327
 Kernel.cxx:328
 Kernel.cxx:329
 Kernel.cxx:330
 Kernel.cxx:331
 Kernel.cxx:332
 Kernel.cxx:333
 Kernel.cxx:334
 Kernel.cxx:335
 Kernel.cxx:336