Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/cppparser/cppTemplateScope.cxx

Go to the documentation of this file.
00001 // Filename: cppTemplateScope.cxx
00002 // Created by:  drose (28Oct99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 
00020 #include "cppTemplateScope.h"
00021 #include "cppExtensionType.h"
00022 #include "cppClassTemplateParameter.h"
00023 #include "cppIdentifier.h"
00024 #include "cppTypedef.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: CPPTemplateScope::Constructor
00028 //       Access: Public
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 CPPTemplateScope::
00032 CPPTemplateScope(CPPScope *parent_scope) :
00033   CPPScope(parent_scope, CPPNameComponent("template"), V_public)
00034 {
00035 }
00036 
00037 
00038 ////////////////////////////////////////////////////////////////////
00039 //     Function: CPPTemplateScope::add_declaration
00040 //       Access: Public, Virtual
00041 //  Description:
00042 ////////////////////////////////////////////////////////////////////
00043 void CPPTemplateScope::
00044 add_declaration(CPPDeclaration *decl, CPPScope *global_scope,
00045                 CPPPreprocessor *preprocessor,
00046                 const cppyyltype &pos) {
00047   decl->_template_scope = this;
00048   assert(_parent_scope != NULL);
00049   _parent_scope->add_declaration(decl, global_scope, preprocessor, pos);
00050 }
00051 
00052 ////////////////////////////////////////////////////////////////////
00053 //     Function: CPPTemplateScope::add_enum_value
00054 //       Access: Public, Virtual
00055 //  Description:
00056 ////////////////////////////////////////////////////////////////////
00057 void CPPTemplateScope::
00058 add_enum_value(CPPInstance *inst) {
00059   inst->_template_scope = this;
00060   assert(_parent_scope != NULL);
00061   _parent_scope->add_enum_value(inst);
00062 }
00063 
00064 ////////////////////////////////////////////////////////////////////
00065 //     Function: CPPTemplateScope::define_extension_type
00066 //       Access: Public, Virtual
00067 //  Description:
00068 ////////////////////////////////////////////////////////////////////
00069 void CPPTemplateScope::
00070 define_extension_type(CPPExtensionType *type) {
00071   type->_template_scope = this;
00072   assert(_parent_scope != NULL);
00073   _parent_scope->define_extension_type(type);
00074 }
00075 
00076 ////////////////////////////////////////////////////////////////////
00077 //     Function: CPPTemplateScope::define_namespace
00078 //       Access: Public, Virtual
00079 //  Description:
00080 ////////////////////////////////////////////////////////////////////
00081 void CPPTemplateScope::
00082 define_namespace(CPPNamespace *scope) {
00083   assert(_parent_scope != NULL);
00084   _parent_scope->define_namespace(scope);
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: CPPTemplateScope::add_using
00089 //       Access: Public, Virtual
00090 //  Description:
00091 ////////////////////////////////////////////////////////////////////
00092 void CPPTemplateScope::
00093 add_using(CPPUsing *using_decl, CPPScope *global_scope,
00094           CPPPreprocessor *error_sink) {
00095   assert(_parent_scope != NULL);
00096   _parent_scope->add_using(using_decl, global_scope, error_sink);
00097 }
00098 
00099 ////////////////////////////////////////////////////////////////////
00100 //     Function: CPPTemplateScope::add_template_parameter
00101 //       Access: Public
00102 //  Description:
00103 ////////////////////////////////////////////////////////////////////
00104 void CPPTemplateScope::
00105 add_template_parameter(CPPDeclaration *param) {
00106   _parameters._parameters.push_back(param);
00107   CPPClassTemplateParameter *cl = param->as_class_template_parameter();
00108   if (cl != NULL) {
00109     // Create an implicit typedef for this class parameter.
00110     string name = cl->_ident->get_local_name();
00111     _typedefs[name] = new CPPTypedef(new CPPInstance(cl, cl->_ident), false);
00112   }
00113   CPPInstance *inst = param->as_instance();
00114   if (inst != NULL) {
00115     // Register the variable for this value parameter.
00116     string name = inst->get_local_name();
00117     if (!name.empty()) {
00118       _variables[name] = inst;
00119     }
00120   }
00121 }
00122 
00123 ////////////////////////////////////////////////////////////////////
00124 //     Function: CPPTemplateScope::is_fully_specified
00125 //       Access: Public, Virtual
00126 //  Description: Returns true if this declaration is an actual,
00127 //               factual declaration, or false if some part of the
00128 //               declaration depends on a template parameter which has
00129 //               not yet been instantiated.
00130 ////////////////////////////////////////////////////////////////////
00131 bool CPPTemplateScope::
00132 is_fully_specified() const {
00133   return false;
00134 }
00135 
00136 ////////////////////////////////////////////////////////////////////
00137 //     Function: CPPTemplateScope::get_simple_name
00138 //       Access: Public, Virtual
00139 //  Description:
00140 ////////////////////////////////////////////////////////////////////
00141 string CPPTemplateScope::
00142 get_simple_name() const {
00143   assert(_parent_scope != NULL);
00144   return _parent_scope->get_simple_name();
00145 }
00146 
00147 ////////////////////////////////////////////////////////////////////
00148 //     Function: CPPTemplateScope::get_local_name
00149 //       Access: Public, Virtual
00150 //  Description:
00151 ////////////////////////////////////////////////////////////////////
00152 string CPPTemplateScope::
00153 get_local_name(CPPScope *scope) const {
00154   assert(_parent_scope != NULL);
00155   return _parent_scope->get_local_name(scope);
00156 }
00157 
00158 ////////////////////////////////////////////////////////////////////
00159 //     Function: CPPTemplateScope::get_fully_scoped_name
00160 //       Access: Public, Virtual
00161 //  Description:
00162 ////////////////////////////////////////////////////////////////////
00163 string CPPTemplateScope::
00164 get_fully_scoped_name() const {
00165   assert(_parent_scope != NULL);
00166   return _parent_scope->get_fully_scoped_name();
00167 }
00168 
00169 ////////////////////////////////////////////////////////////////////
00170 //     Function: CPPTemplateScope::output
00171 //       Access: Public, Virtual
00172 //  Description:
00173 ////////////////////////////////////////////////////////////////////
00174 void CPPTemplateScope::
00175 output(ostream &out, CPPScope *scope) const {
00176   CPPScope::output(out, scope);
00177   out << "< ";
00178   _parameters.output(out, scope);
00179   out << " >";
00180 }
00181 
00182 ////////////////////////////////////////////////////////////////////
00183 //     Function: CPPTemplateScope::as_template_scope
00184 //       Access: Public, Virtual
00185 //  Description:
00186 ////////////////////////////////////////////////////////////////////
00187 CPPTemplateScope *CPPTemplateScope::
00188 as_template_scope() {
00189   return this;
00190 }

Generated on Thu May 1 22:12:55 2003 for DTool by doxygen1.3