diff options
Diffstat (limited to 'autodoc/source/ary/cpp')
34 files changed, 5776 insertions, 0 deletions
diff --git a/autodoc/source/ary/cpp/c_builtintype.cxx b/autodoc/source/ary/cpp/c_builtintype.cxx new file mode 100644 index 000000000000..f6168f197856 --- /dev/null +++ b/autodoc/source/ary/cpp/c_builtintype.cxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_builtintype.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/c_type.hxx> + + +namespace ary +{ +namespace cpp +{ + + + + +//********************** Type **************************// +Rid +Type::inq_RelatedCe() const +{ + return 0; +} + + +//********************** BuiltInType **************************// + +BuiltInType::BuiltInType( const String & i_sName, + E_TypeSpecialisation i_eSpecialisation ) + : sName( i_sName ), + eSpecialisation( i_eSpecialisation ) +{ +} + +String +BuiltInType::SpecializedName_( const char * i_sName, + E_TypeSpecialisation i_eTypeSpecialisation ) +{ + StreamLock + aStrLock(60); + StreamStr & + ret = aStrLock(); + + switch ( i_eTypeSpecialisation ) + { + case TYSP_unsigned: + ret << "u_"; + break; + case TYSP_signed: + if (strcmp(i_sName,"char") == 0) + ret << "s_"; + break; + default: + ; + + } // end switch + + ret << i_sName; + return String(ret.c_str()); +} + +void +BuiltInType::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ary::ClassId +BuiltInType::get_AryClass() const +{ + return class_id; +} + +bool +BuiltInType::inq_IsConst() const +{ + return false; +} + +void +BuiltInType::inq_Get_Text( StreamStr & , // o_rPreName + StreamStr & o_rName, + StreamStr & , // o_rPostName + const Gate & ) const // i_rGate +{ + switch (eSpecialisation) + { + case TYSP_unsigned: o_rName << "unsigned "; break; + case TYSP_signed: o_rName << "signed "; break; + + default: // Does nothing. + ; + } + o_rName << sName; +} + + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_class.cxx b/autodoc/source/ary/cpp/c_class.cxx new file mode 100644 index 000000000000..33aa04a8c5ac --- /dev/null +++ b/autodoc/source/ary/cpp/c_class.cxx @@ -0,0 +1,287 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_class.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <slots.hxx> +#include "c_slots.hxx" + + + +namespace ary +{ +namespace cpp +{ + +Class::Class( const String & i_sLocalName, + Ce_id i_nOwner, + E_Protection i_eProtection, + loc::Le_id i_nFile, + E_ClassKey i_eClassKey ) + : aEssentials( i_sLocalName, + i_nOwner, + i_nFile ), + aAssignedNode(), + aBaseClasses(), + aTemplateParameterTypes(), + aClasses(), + aEnums(), + aTypedefs(), + aOperations(), + aStaticOperations(), + aData(), + aStaticData(), + aFriendClasses(), + aFriendOperations(), + aKnownDerivatives(), + eClassKey(i_eClassKey), + eProtection(i_eProtection), + eVirtuality(VIRTUAL_none) +{ + aAssignedNode.Assign_Entity(*this); +} + +Class::~Class() +{ +} + +void +Class::Add_BaseClass( const S_Classes_Base & i_rBaseClass ) +{ + aBaseClasses.push_back(i_rBaseClass); +} + +void +Class::Add_TemplateParameterType( const String & i_sLocalName, + Type_id i_nIdAsType ) +{ + aTemplateParameterTypes.push_back( + List_TplParam::value_type(i_sLocalName,i_nIdAsType) ); +} + +void +Class::Add_LocalClass( const String & i_sLocalName, + Cid i_nId ) +{ + aClasses.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + +void +Class::Add_LocalEnum( const String & i_sLocalName, + Cid i_nId ) +{ + aEnums.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + +void +Class::Add_LocalTypedef( const String & i_sLocalName, + Cid i_nId ) +{ + aTypedefs.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + +void +Class::Add_LocalOperation( const String & i_sLocalName, + Cid i_nId ) +{ + aOperations.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + +void +Class::Add_LocalStaticOperation( const String & i_sLocalName, + Cid i_nId ) +{ + aStaticOperations.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + +void +Class::Add_LocalData( const String & i_sLocalName, + Cid i_nId ) +{ + aData.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + +void +Class::Add_LocalStaticData( const String & i_sLocalName, + Cid i_nId ) +{ + aStaticData.push_back( S_LocalCe(i_sLocalName, i_nId) ); +} + + +struct find_name +{ + find_name( + const String & i_name ) + : sName(i_name) {} + + bool operator()( + const S_LocalCe & i_lce ) const + { return i_lce.sLocalName == sName; } + private: + String sName; +}; + +Ce_id +Class::Search_Child(const String & i_key) const +{ + Ce_id + ret = Ce_id(Search_LocalClass(i_key)); + if (ret.IsValid()) + return ret; + + CIterator_Locals + itret = std::find_if(aEnums.begin(), aEnums.end(), find_name(i_key)); + if (itret != aEnums.end()) + return (*itret).nId; + itret = std::find_if(aTypedefs.begin(), aTypedefs.end(), find_name(i_key)); + if (itret != aTypedefs.end()) + return (*itret).nId; + itret = std::find_if(aData.begin(), aData.end(), find_name(i_key)); + if (itret != aData.end()) + return (*itret).nId; + itret = std::find_if(aStaticData.begin(), aStaticData.end(), find_name(i_key)); + if (itret != aStaticData.end()) + return (*itret).nId; + return Ce_id(0); +} + +Rid +Class::Search_LocalClass( const String & i_sName ) const +{ + CIterator_Locals itFound = PosOfName(aClasses, i_sName); + if (itFound != aClasses.end()) + return (*itFound).nId.Value(); + return 0; +} + +const String & +Class::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +Class::inq_Owner() const +{ + return aEssentials.Owner(); +} + +loc::Le_id +Class::inq_Location() const +{ + return aEssentials.Location(); +} + +void +Class::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Class::get_AryClass() const +{ + return class_id; +} + +Gid +Class::inq_Id_Group() const +{ + return static_cast<Gid>(Id()); +} + +const ary::cpp::CppEntity & +Class::inq_RE_Group() const +{ + return *this; +} + +const group::SlotList & +Class::inq_Slots() const +{ + static const SlotAccessId aProjectSlotData[] + = { SLOT_Bases, + SLOT_NestedClasses, + SLOT_Enums, + SLOT_Typedefs, + SLOT_Operations, + SLOT_StaticOperations, + SLOT_Data, + SLOT_StaticData, + SLOT_FriendClasses, + SLOT_FriendOperations }; + static const std::vector< SlotAccessId > + aSlots( &aProjectSlotData[0], + &aProjectSlotData[0] + + sizeof aProjectSlotData / sizeof (SlotAccessId) ); + return aSlots; +} + + +DYN Slot * +Class::inq_Create_Slot( SlotAccessId i_nSlot ) const +{ + switch ( i_nSlot ) + { + case SLOT_Bases: return new Slot_BaseClass(aBaseClasses); + case SLOT_NestedClasses: return new Slot_ListLocalCe(aClasses); + case SLOT_Enums: return new Slot_ListLocalCe(aEnums); + case SLOT_Typedefs: return new Slot_ListLocalCe(aTypedefs); + case SLOT_Operations: return new Slot_ListLocalCe(aOperations); + case SLOT_StaticOperations: return new Slot_ListLocalCe(aStaticOperations); + case SLOT_Data: return new Slot_ListLocalCe(aData); + case SLOT_StaticData: return new Slot_ListLocalCe(aStaticData); + case SLOT_FriendClasses: return new Slot_SequentialIds<Ce_id>(aFriendClasses); + case SLOT_FriendOperations: return new Slot_SequentialIds<Ce_id>(aFriendOperations); + default: + return new Slot_Null; + } // end switch +} + +Class::CIterator_Locals +Class::PosOfName( const List_LocalCe & i_rList, + const String & i_sName ) const +{ + for ( CIterator_Locals ret = i_rList.begin(); + ret != i_rList.end(); + ++ret ) + { + if ( (*ret).sLocalName == i_sName ) + return ret; + } + return i_rList.end(); +} + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_de.cxx b/autodoc/source/ary/cpp/c_de.cxx new file mode 100644 index 000000000000..704bc697e239 --- /dev/null +++ b/autodoc/source/ary/cpp/c_de.cxx @@ -0,0 +1,54 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_de.hxx> + + + +namespace ary +{ +namespace cpp +{ + + + +DefineEntity::DefineEntity( const String & i_name, + loc::Le_id i_declaringFile ) + : sName(i_name), + nLocation(i_declaringFile) +{ +} + + + + +} // end namespace cpp +} // end namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_define.cxx b/autodoc/source/ary/cpp/c_define.cxx new file mode 100644 index 000000000000..6ea6b8f6a04f --- /dev/null +++ b/autodoc/source/ary/cpp/c_define.cxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_define.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <prprpr.hxx> + + + + +namespace ary +{ +namespace cpp +{ + + + +Define::Define( const String & i_name, + const StringVector & i_definition, + loc::Le_id i_declaringFile) + : DefineEntity(i_name, i_declaringFile), + aDefinition(i_definition) +{ +} + +Define::~Define() +{ +} + +void +Define::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor, *this); +} + +ClassId +Define::get_AryClass() const +{ + return class_id; +} + +const StringVector & +Define::inq_DefinitionText() const +{ + return aDefinition; +} + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_enum.cxx b/autodoc/source/ary/cpp/c_enum.cxx new file mode 100644 index 000000000000..e4f8ad15983c --- /dev/null +++ b/autodoc/source/ary/cpp/c_enum.cxx @@ -0,0 +1,137 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_enum.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <slots.hxx> +#include "c_slots.hxx" + + + + +namespace ary +{ +namespace cpp +{ + +Enum::Enum( const String & i_sLocalName, + Ce_id i_nOwner, + E_Protection i_eProtection, + Lid i_nFile ) + : aEssentials( i_sLocalName, + i_nOwner, + i_nFile ), + aValues(), + eProtection(i_eProtection) +{ +} + +Enum::~Enum() +{ +} + +void +Enum::Add_Value( Ce_id i_nId ) +{ + aValues.Add( i_nId ); +} + +const String & +Enum::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +Enum::inq_Owner() const +{ + return aEssentials.Owner(); +} + +Lid +Enum::inq_Location() const +{ + return aEssentials.Location(); +} + +void +Enum::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Enum::get_AryClass() const +{ + return class_id; +} + +Gid +Enum::inq_Id_Group() const +{ + return static_cast<Gid>(Id()); +} + +const ary::cpp::CppEntity & +Enum::inq_RE_Group() const +{ + return *this; +} + +const group::SlotList & +Enum::inq_Slots() const +{ + static const SlotAccessId aProjectSlotData[] + = { SLOT_Values }; + static const std::vector< SlotAccessId > + aSlots( &aProjectSlotData[0], + &aProjectSlotData[0] + + sizeof aProjectSlotData / sizeof (SlotAccessId) ); + return aSlots; +} + +DYN Slot * +Enum::inq_Create_Slot( SlotAccessId i_nSlot ) const +{ + switch ( i_nSlot ) + { + case SLOT_Values: return new Slot_SequentialIds<Ce_id>(aValues); + default: + return new Slot_Null; + } // end switch +} + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_enuval.cxx b/autodoc/source/ary/cpp/c_enuval.cxx new file mode 100644 index 000000000000..1641689895d4 --- /dev/null +++ b/autodoc/source/ary/cpp/c_enuval.cxx @@ -0,0 +1,90 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_enuval.hxx> + + +// NOT FULLY DECLARED SERVICES + + +namespace ary +{ +namespace cpp +{ + + +EnumValue::EnumValue( const String & i_sLocalName, + Ce_id i_nOwner, + String i_sInitialisation ) + : aEssentials( i_sLocalName, + i_nOwner, + Lid(0) ), + sInitialisation(i_sInitialisation) +{ +} + +EnumValue::~EnumValue() +{ +} + +const String & +EnumValue::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +EnumValue::inq_Owner() const +{ + return aEssentials.Owner(); +} + +Lid +EnumValue::inq_Location() const +{ + return aEssentials.Location(); +} + +void +EnumValue::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +EnumValue::get_AryClass() const +{ + return class_id; +} + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_funct.cxx b/autodoc/source/ary/cpp/c_funct.cxx new file mode 100644 index 000000000000..514e294f2bef --- /dev/null +++ b/autodoc/source/ary/cpp/c_funct.cxx @@ -0,0 +1,250 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_funct.hxx> + + + +// NOT FULLY DECLARED SERVICES +#include <algorithm> +#include <ary/cpp/c_funct.hxx> + + + + + +namespace +{ +using namespace ::ary::cpp; + + +class Parameter_2_NonTypeParamInfo +{ + public: + String operator()( + const S_Parameter & i_rParam ) const; +}; + +class Parameter_2_Type +{ + public: + Type_id operator()( + const S_Parameter & i_rParam ) const + { return i_rParam.nType; } +}; + +/** @return + A vector with Strings like this: + "ParamName" or "ParamName[ArraySize]" or "ParamName = InitValue". +*/ +StringVector Create_NonTypeParameterInfos( + const std::vector<S_Parameter> & + i_rParameters ); +/** @return + A vector of the parameters' type ids. +*/ +std::vector<Type_id> + Create_ParameterTypeList( + const std::vector<S_Parameter> & + i_rParameters ); + +} // namspace anonymous + + +namespace ary +{ +namespace cpp +{ + +Function::Function( const String & i_sLocalName, + Ce_id i_nOwner, + E_Protection i_eProtection, + Lid i_nFile, + Type_id i_nReturnType, + const std::vector<S_Parameter> & + i_parameters, + E_ConVol i_conVol, + E_Virtuality i_eVirtuality, + FunctionFlags i_aFlags, + bool i_bThrowExists, + const std::vector<Type_id> & + i_rExceptions ) + : aEssentials( i_sLocalName, + i_nOwner, + i_nFile ), + aTemplateParameterTypes(), + aSignature( Create_ParameterTypeList(i_parameters), + i_conVol ), + nReturnType(i_nReturnType), + eProtection(i_eProtection), + eVirtuality(i_eVirtuality), + aFlags(i_aFlags), + aParameterInfos( Create_NonTypeParameterInfos(i_parameters) ), + pExceptions( i_bThrowExists ? new ExceptionTypeList(i_rExceptions) : 0 ) +{ +} + +Function::~Function() +{ +} + +bool +Function::IsIdentical( const Function & i_f ) const +{ + return + LocalName() == i_f.LocalName() + AND + Owner() == i_f.Owner() + AND + aSignature == i_f.aSignature + AND + nReturnType == i_f.nReturnType + AND + eProtection == i_f.eProtection + AND + eVirtuality == i_f.eVirtuality + AND + aFlags == i_f.aFlags + AND + ( ( NOT pExceptions AND NOT i_f.pExceptions ) + OR + ( pExceptions AND i_f.pExceptions + ? *pExceptions == *i_f.pExceptions + : false ) + ) + AND + aTemplateParameterTypes.size() == i_f.aTemplateParameterTypes.size(); +} + +void +Function::Add_TemplateParameterType( const String & i_sLocalName, + Type_id i_nIdAsType ) +{ + aTemplateParameterTypes.push_back( + List_TplParam::value_type(i_sLocalName, i_nIdAsType) ); +} + + +const String & +Function::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +Function::inq_Owner() const +{ + return aEssentials.Owner(); +} + +Lid +Function::inq_Location() const +{ + return aEssentials.Location(); +} + +void +Function::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Function::get_AryClass() const +{ + return class_id; +} + + + +} // namespace cpp +} // namespace ary + + + +namespace +{ + +String +Parameter_2_NonTypeParamInfo::operator()( const ary::cpp::S_Parameter & i_rParam ) const +{ + static StreamStr aParamName_(1020); + aParamName_.seekp(0); + + aParamName_ << i_rParam.sName; + if ( i_rParam.sSizeExpression.length() > 0 ) + { + aParamName_ << '[' + << i_rParam.sSizeExpression + << ']'; + } + if ( i_rParam.sInitExpression.length() > 0 ) + { + aParamName_ << " = " + << i_rParam.sInitExpression; + } + + return aParamName_.c_str(); +} + + +StringVector +Create_NonTypeParameterInfos( const std::vector<S_Parameter> & i_rParameters ) +{ + static Parameter_2_NonTypeParamInfo + aTransformFunction_; + + StringVector + ret(i_rParameters.size(), String::Null_()); + std::transform( i_rParameters.begin(), i_rParameters.end(), + ret.begin(), + aTransformFunction_ ); + return ret; +} + +std::vector<Type_id> +Create_ParameterTypeList( const std::vector<S_Parameter> & i_rParameters ) +{ + static Parameter_2_Type + aTransformFunction_; + + std::vector<Type_id> + ret(i_rParameters.size(), Type_id(0)); + std::transform( i_rParameters.begin(), i_rParameters.end(), + ret.begin(), + aTransformFunction_ ); + return ret; +} + + + + +} // namespace anonymous + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_macro.cxx b/autodoc/source/ary/cpp/c_macro.cxx new file mode 100644 index 000000000000..2fad2c0fe5aa --- /dev/null +++ b/autodoc/source/ary/cpp/c_macro.cxx @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_macro.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <prprpr.hxx> + + + +namespace ary +{ +namespace cpp +{ + + +Macro::Macro( const String & i_name, + const StringVector & i_params, + const StringVector & i_definition, + loc::Le_id i_declaringFile ) + : DefineEntity(i_name, i_declaringFile), + aParams(i_params), + aDefinition(i_definition) +{ +} + +Macro::~Macro() +{ +} + +void +Macro::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Macro::get_AryClass() const +{ + return class_id; + + // return RCID_MACRO; +} + +const StringVector & +Macro::inq_DefinitionText() const +{ + return aDefinition; +} + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_namesp.cxx b/autodoc/source/ary/cpp/c_namesp.cxx new file mode 100644 index 000000000000..133f8e96c812 --- /dev/null +++ b/autodoc/source/ary/cpp/c_namesp.cxx @@ -0,0 +1,295 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_namesp.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <algorithm> +#include <cosv/tpl/tpltools.hxx> +#include <ary/cpp/c_funct.hxx> +#include <ary/cpp/c_gate.hxx> +#include <ary/getncast.hxx> +#include <slots.hxx> +#include "c_slots.hxx" + + +namespace ary +{ +namespace cpp +{ + +typedef std::multimap<String, Ce_id>::const_iterator operations_citer; + +Namespace::Namespace() + : aEssentials(), + aAssignedNode(), + // aLocalNamespaces, + // aLocalClasses, + // aLocalEnums, + // aLocalTypedefs, + // aLocalOperations, + // aLocalVariables, + // aLocalConstants, + pParent(0), + nDepth(0) +{ + aAssignedNode.Assign_Entity(*this); +} + +Namespace::Namespace( const String & i_sLocalName, + Namespace & i_rParent ) + : aEssentials( i_sLocalName, + i_rParent.CeId(), + Lid(0) ), + aAssignedNode(), + // aLocalNamespaces, + // aLocalClasses, + // aLocalEnums, + // aLocalTypedefs, + // aLocalOperations, + // aLocalVariables, + // aLocalConstants, + pParent(&i_rParent), + nDepth(i_rParent.Depth()+1) +{ + aAssignedNode.Assign_Entity(*this); +} + +Namespace::~Namespace() +{ +} + +void +Namespace::Add_LocalNamespace( DYN Namespace & io_rLocalNamespace ) +{ + aLocalNamespaces[io_rLocalNamespace.LocalName()] = &io_rLocalNamespace; +} + +void +Namespace::Add_LocalClass( const String & i_sLocalName, + Cid i_nId ) +{ + aLocalClasses[i_sLocalName] = i_nId; +} + +void +Namespace::Add_LocalEnum( const String & i_sLocalName, + Cid i_nId ) +{ + aLocalEnums[i_sLocalName] = i_nId; +} + +void +Namespace::Add_LocalTypedef( const String & i_sLocalName, + Cid i_nId ) +{ + aLocalTypedefs[i_sLocalName] = i_nId; +} + +void +Namespace::Add_LocalOperation( const String & i_sLocalName, + Cid i_nId ) +{ + aLocalOperations.insert( Map_Operations::value_type(i_sLocalName, i_nId) ); +} + + +void +Namespace::Add_LocalVariable( const String & i_sLocalName, + Cid i_nId ) +{ + aLocalVariables[i_sLocalName] = i_nId; +} + +void +Namespace::Add_LocalConstant( const String & i_sLocalName, + Cid i_nId ) +{ + aLocalConstants[i_sLocalName] = i_nId; +} + +uintt +Namespace::Depth() const +{ + return nDepth; +} + +Namespace * +Namespace::Parent() const +{ + return pParent; +} + +Ce_id +Namespace::Search_Child(const String & i_key) const +{ + Namespace * + ret_nsp = Search_LocalNamespace(i_key); + if (ret_nsp != 0) + return ret_nsp->CeId(); + + Ce_id + ret = Search_LocalClass(i_key); + if (ret.IsValid()) + return ret; + + ret = csv::value_from_map(aLocalEnums, i_key, Ce_id(0)); + if (ret.IsValid()) + return ret; + ret = csv::value_from_map(aLocalTypedefs, i_key, Ce_id(0)); + if (ret.IsValid()) + return ret; + ret = csv::value_from_map(aLocalVariables, i_key, Ce_id(0)); + if (ret.IsValid()) + return ret; + return csv::value_from_map(aLocalConstants, i_key, Ce_id(0)); +} + +Namespace * +Namespace::Search_LocalNamespace( const String & i_sLocalName ) const +{ + return csv::value_from_map(aLocalNamespaces, i_sLocalName, (Namespace*)(0)); +} + +uintt +Namespace::Get_SubNamespaces( std::vector< const Namespace* > & o_rResultList ) const +{ + for ( Map_NamespacePtr::const_iterator it = aLocalNamespaces.begin(); + it != aLocalNamespaces.end(); + ++it ) + { + o_rResultList.push_back( (*it).second ); + } + return o_rResultList.size(); +} + +Ce_id +Namespace::Search_LocalClass( const String & i_sName ) const +{ + return csv::value_from_map(aLocalClasses, i_sName, Ce_id(0)); +} + +void +Namespace::Search_LocalOperations( std::vector<Ce_id> & o_result, + const String & i_sName ) const +{ + operations_citer + itLower = aLocalOperations.lower_bound(i_sName); + if (itLower == aLocalOperations.end()) + return; + if ( (*itLower).first != i_sName ) + return; + + for ( operations_citer it = itLower; + it != aLocalOperations.end() ? (*itLower).first == i_sName : false; + ++it ) + { + o_result.push_back((*it).second); + } +} + + +const String & +Namespace::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +Namespace::inq_Owner() const +{ + return aEssentials.Owner(); +} + +Lid +Namespace::inq_Location() const +{ + return Lid(0); +} + +void +Namespace::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Namespace::get_AryClass() const +{ + return class_id; +} + +Gid +Namespace::inq_Id_Group() const +{ + return static_cast<Gid>(Id()); +} + +const ary::cpp::CppEntity & +Namespace::inq_RE_Group() const +{ + return *this; +} + +const ary::group::SlotList & +Namespace::inq_Slots() const +{ + static const SlotAccessId aProjectSlotData[] + = { SLOT_SubNamespaces, SLOT_Classes, SLOT_Enums, SLOT_Typedefs, SLOT_Operations, + SLOT_Variables, SLOT_Constants }; + static const std::vector< SlotAccessId > + aSlots( &aProjectSlotData[0], + &aProjectSlotData[0] + + sizeof aProjectSlotData / sizeof (SlotAccessId) ); + return aSlots; +} + +DYN Slot * +Namespace::inq_Create_Slot( SlotAccessId i_nSlot ) const +{ + switch ( i_nSlot ) + { + case SLOT_SubNamespaces: return new Slot_SubNamespaces(aLocalNamespaces); + case SLOT_Classes: return new Slot_MapLocalCe(aLocalClasses); + case SLOT_Enums: return new Slot_MapLocalCe(aLocalEnums); + case SLOT_Typedefs: return new Slot_MapLocalCe(aLocalTypedefs); + case SLOT_Operations: return new Slot_MapOperations(aLocalOperations); + case SLOT_Variables: return new Slot_MapLocalCe(aLocalVariables); + case SLOT_Constants: return new Slot_MapLocalCe(aLocalConstants); + default: + return new Slot_Null; + } // end switch +} + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_osigna.cxx b/autodoc/source/ary/cpp/c_osigna.cxx new file mode 100644 index 000000000000..463c84b1f5f7 --- /dev/null +++ b/autodoc/source/ary/cpp/c_osigna.cxx @@ -0,0 +1,79 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_osigna.hxx> + + +// NOT FULLY DEFINED SERVICES + + +namespace ary +{ +namespace cpp +{ + + +OperationSignature::OperationSignature( std::vector<Type_id> i_parameterTypes, + E_ConVol i_conVol ) + : aParameterTypes(i_parameterTypes), + eConVol(i_conVol) +{ +} + +int +OperationSignature::Compare( const OperationSignature & i_rSig ) const +{ + if ( aParameterTypes.size() < i_rSig.aParameterTypes.size() ) + return -1; + else if ( i_rSig.aParameterTypes.size() < aParameterTypes.size() ) + return 1; + + ParameterTypeList::const_iterator iMe = aParameterTypes.begin(); + ParameterTypeList::const_iterator iOther = i_rSig.aParameterTypes.begin(); + for ( ; iMe != aParameterTypes.end(); ++iMe, ++iOther ) + { + if ( *iMe < *iOther ) + return -1; + else if ( *iOther < *iMe ) + return 1; + } + + if ( eConVol < i_rSig.eConVol ) + return -1; + else if ( eConVol != i_rSig.eConVol ) + return 1; + + return 0; +} + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_reposypart.cxx b/autodoc/source/ary/cpp/c_reposypart.cxx new file mode 100644 index 000000000000..05fb5947e259 --- /dev/null +++ b/autodoc/source/ary/cpp/c_reposypart.cxx @@ -0,0 +1,526 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "c_reposypart.hxx" + + +// NOT FULLY DECLARED SERVICES +#include <ary/getncast.hxx> +#include <ary/namesort.hxx> +#include <ary/cpp/c_builtintype.hxx> +#include <ary/cpp/c_class.hxx> +#include <ary/cpp/c_cppentity.hxx> +#include <ary/cpp/c_define.hxx> +#include <ary/cpp/c_enum.hxx> +#include <ary/cpp/c_enuval.hxx> +#include <ary/cpp/c_funct.hxx> +#include <ary/cpp/c_macro.hxx> +#include <ary/cpp/c_namesp.hxx> +#include <ary/cpp/c_tydef.hxx> +#include <ary/cpp/c_type.hxx> +#include <ary/cpp/usedtype.hxx> +#include <ary/cpp/c_vari.hxx> +#include <ary/loc/locp_le.hxx> +#include <ary/getncast.hxx> +#include <loc_internalgate.hxx> +#include <reposy.hxx> +#include "ca_ce.hxx" +#include "ca_def.hxx" +#include "ca_type.hxx" +#include "cs_ce.hxx" +#include "cs_def.hxx" +#include "cs_type.hxx" + + + +namespace +{ + +using ::ary::GlobalId; +using ::ary::Rid; +using namespace ::ary::cpp; + + +inline bool +IsDefine( const GlobalId & i_id ) +{ + return i_id.Class() == Define::class_id + OR + i_id.Class() == Macro::class_id; +} + + +/// Find Ces +class TypeConnector +{ + public: + TypeConnector( + Gate & i_gate ) + : pGate(&i_gate) {} + ~TypeConnector() {} + + void operator()( + Type & io_rType ) const; + private: + // DATA + Gate * pGate; +}; + +/// Find Ces only known from base class name scope. +class TypeConnector2ndTry +{ + public: + TypeConnector2ndTry( + Gate & i_gate ) + : pGate(&i_gate) {} + ~TypeConnector2ndTry() {} + + void operator()( + Type & io_rType ) const; + private: + // DATA + Gate * pGate; +}; + +/// Reconnect (in both directions) base-derived relations of classes. +class HierarchyLinker +{ + public: + HierarchyLinker( + Gate & i_gate ) + : pGate(&i_gate) {} + + ~HierarchyLinker() {} + + void operator()( + Class & io_rCe ) const; + private: + // DATA + Gate * pGate; +}; + + + +/// Helper functor for ->RepositoryPartition::Get_AlphabeticalList(). +template <class TRAITS> +struct MakeGlobalId +{ + GlobalId operator()( + typename TRAITS::id_type + i_id ) const + { + return GlobalId( TRAITS::EntityOf_(i_id).AryClass(), + i_id.Value() ); + } +}; + + + + +/** Compare two {->GlobalId}s. + + + @todo Move this up to the definition of GlobalId<>. +*/ +struct LesserGlobal +{ + LesserGlobal( + const Ce_Storage & i_ces, + const Def_Storage & i_des ) + : rCes(i_ces), rDes(i_des) {} + + bool operator()( + GlobalId i_1, + GlobalId i_2 ) const; + + private: + const String & NameOf( + GlobalId i_id ) const; + // DATA + const Ce_Storage & rCes; + const Def_Storage & rDes; + ::ary::LesserName aLess; +}; + + +bool +LesserGlobal::operator()( GlobalId i_1, + GlobalId i_2 ) const + { + String s1 = NameOf(i_1); + String s2 = NameOf(i_2); + + if (s1 != s2) + return aLess(s1, s2); + + if ( IsDefine(i_1) != IsDefine(i_2) ) + { + return NOT IsDefine(i_2); + } + else if (IsDefine(i_1)) + { + return i_1.Class() < i_2.Class(); + } + + return Ce_GlobalCompare::Lesser_( + rCes[i_1.Id()], + rCes[i_2.Id()] ); + } + + +} // namespace anonymous + + + + + + +namespace ary +{ +namespace cpp +{ + +DYN InternalGate & +InternalGate::Create_Partition_(RepositoryCenter & i_center) +{ + return *new RepositoryPartition(i_center); +} + + +RepositoryPartition::RepositoryPartition(RepositoryCenter & i_center) + : pRepositoryCenter(&i_center), + pCes(0), + pTypes(0), + pDefs(0), + pLocations(& loc::InternalGate::Create_Locations_()) +{ + pCes = new CeAdmin(*this); + pTypes = new TypeAdmin(*this); + pDefs = new DefAdmin(*this); + pCes->Set_Related(*pTypes); +} + +RepositoryPartition::~RepositoryPartition() +{ +} + +void +RepositoryPartition::Calculate_AllSecondaryInformation() +// const ::autodoc::Options & ) +{ + // KORR_FUTURE + // Forward the options from here. + + Connect_AllTypes_2_TheirRelated_CodeEntites(); +} + +const String & +RepositoryPartition::RepositoryTitle() const +{ + return static_cast< ary::Repository* >(pRepositoryCenter)->Title(); +} + +const CodeEntity * +RepositoryPartition::Search_RelatedCe(Type_id i_type) const +{ + if (NOT i_type.IsValid()) + return 0; + + Ce_id + ce_id = pTypes->Find_Type(i_type).RelatedCe(); + return ce_id.IsValid() + ? & pCes->Find_Ce(ce_id) + : (CodeEntity*)(0); +} + +const ::ary::cpp::CppEntity * +RepositoryPartition::Search_Entity(GlobalId i_id) const +{ + if (i_id.Id() == 0) + return 0; + + if ( NOT IsDefine(i_id) ) + { + // Shall make sure this is a C++ CodeEntity: + csv_assert( i_id.Class() >= Namespace::class_id + AND + i_id.Class() < BuiltInType::class_id + && "Unexpected entity type in cpp::RepositoryPartition" + "::Search_Entity()." ); + return & Ces().Find_Ce( Ce_id(i_id.Id()) ); + } + else + { + return & Defs().Find_Def( De_id(i_id.Id()) ); + } +} + + +const CePilot & +RepositoryPartition::Ces() const +{ + csv_assert(pCes != 0); + return *pCes; +} + +const DefPilot & +RepositoryPartition::Defs() const +{ + csv_assert(pDefs != 0); + return *pDefs; +} + +const TypePilot & +RepositoryPartition::Types() const +{ + csv_assert(pTypes != 0); + return *pTypes; +} + +const loc::LocationPilot & +RepositoryPartition::Locations() const +{ + csv_assert(pLocations != 0); + return *pLocations; +} + +CePilot & +RepositoryPartition::Ces() +{ + csv_assert(pCes != 0); + return *pCes; +} + +DefPilot & +RepositoryPartition::Defs() +{ + csv_assert(pDefs != 0); + return *pDefs; +} + +TypePilot & +RepositoryPartition::Types() +{ + csv_assert(pTypes != 0); + return *pTypes; +} + +loc::LocationPilot & +RepositoryPartition::Locations() +{ + csv_assert(pLocations != 0); + return *pLocations; +} + + +void +RepositoryPartition::Connect_AllTypes_2_TheirRelated_CodeEntites() +{ + TypeConnector + aConnector(*this); + std::for_each( pTypes->Storage().BeginUnreserved(), + pTypes->Storage().End(), + aConnector ); + + typedef ::ary::stg::filter_iterator<CodeEntity,Class> + filter_class_iter; + + HierarchyLinker + aHierarchyLinker(*this); + filter_class_iter itEnd( pCes->Storage().End() ); + for ( filter_class_iter it( pCes->Storage().BeginUnreserved() ); + it != itEnd; + ++it ) + { + if (NOT it.IsValid()) + continue; + + if (is_type<Class>(*it)) + aHierarchyLinker(ary_cast<Class>(*it)); + } + + TypeConnector2ndTry + aConnector2ndTry(*this); + std::for_each( pTypes->Storage().BeginUnreserved(), + pTypes->Storage().End(), + aConnector2ndTry ); +} + +template <class COMPARE> +void Add2Result( + List_GlobalIds & o_result, + const SortedIds<COMPARE> & + i_data, + const char * i_begin, + const char * i_end ); +template <class COMPARE> +void +Add2Result( List_GlobalIds & o_result, + const SortedIds<COMPARE> & i_data, + const char * i_begin, + const char * i_end ) +{ + const size_t + previous_size = o_result.size(); + typename std::vector<typename COMPARE::id_type>::const_iterator + it_beg = i_data.LowerBound(i_begin); + typename std::vector<typename COMPARE::id_type>::const_iterator + it_end = i_data.LowerBound(i_end); + size_t + count_added = static_cast<size_t>( std::distance(it_beg,it_end) ); + o_result.insert( o_result.end(), + count_added, + GlobalId() ); + List_GlobalIds::iterator + it_out = o_result.begin() + previous_size; + std::transform( it_beg, it_end, + it_out, + MakeGlobalId<COMPARE>() ); +} + + +uintt +RepositoryPartition::Get_AlphabeticalList( List_GlobalIds & o_result, + const char * i_begin, + const char * i_end ) const +{ + size_t + ret = o_result.size(); + + const Ce_Storage & + ce_storage = pCes->Storage(); + const Def_Storage & + def_storage = pDefs->Storage(); + + Add2Result( o_result, + ce_storage.TypeIndex(), + i_begin, i_end ); + Add2Result( o_result, + ce_storage.OperationIndex(), + i_begin, i_end ); + Add2Result( o_result, + ce_storage.DataIndex(), + i_begin, i_end ); + Add2Result( o_result, + def_storage.DefineIndex(), + i_begin, i_end ); + Add2Result( o_result, + def_storage.MacroIndex(), + i_begin, i_end ); + + LesserGlobal + aLess(ce_storage, def_storage); + + std::sort(o_result.begin(), o_result.end(), aLess); + + return o_result.size() - ret; +} + + + + +} // namespace cpp +} // namespace ary + + + + + +namespace +{ + + +void +TypeConnector::operator()( Type & io_rType ) const +{ + csv_assert(pGate != 0); + UsedType * + pt = ::ary::ary_cast<UsedType>(&io_rType); + if (pt != 0) + pt->Connect2Ce(pGate->Ces()); +} + +void +TypeConnector2ndTry::operator()( Type & io_rType ) const +{ + csv_assert(pGate != 0); + UsedType * + pt = ::ary::ary_cast<UsedType>(&io_rType); + if (pt != 0) + pt->Connect2CeOnlyKnownViaBaseClass(*pGate); +} + +void +HierarchyLinker::operator()( Class & io_rCe ) const +{ + csv_assert( ::ary::is_type<Class>(io_rCe) ); + Class & + rClass = io_rCe; + + for ( List_Bases::const_iterator it = rClass.BaseClasses().begin(); + it != rClass.BaseClasses().end(); + ++it ) + { + const CodeEntity * + pCe = 0; + Type_id + nTid = (*it).nId; + for ( pCe = pGate->Search_RelatedCe(nTid); + ary::ary_cast<Typedef>(pCe) != 0; + pCe = pGate->Search_RelatedCe(nTid) ) + { + nTid = static_cast< const Typedef* >(pCe)->DescribingType(); + } + const Class * + pClass = ary::ary_cast<Class>(pCe); + if (pClass == 0) + return; + // KORR_FUTURE: we need a non const Find_Class() + const_cast< Class* >(pClass)->Add_KnownDerivative( io_rCe.CeId() ); + } +} + +const String & +LesserGlobal::NameOf(GlobalId i_id) const +{ + if ( NOT IsDefine(i_id) ) + { + return rCes[i_id.Id()].LocalName(); + } + else + { + return rDes[i_id.Id()].LocalName(); + } +} + + + +} // namespace anonymous + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_reposypart.hxx b/autodoc/source/ary/cpp/c_reposypart.hxx new file mode 100644 index 000000000000..c3b200f1f71b --- /dev/null +++ b/autodoc/source/ary/cpp/c_reposypart.hxx @@ -0,0 +1,117 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_C_REPOSYPART_HXX +#define ARY_CPP_C_REPOSYPART_HXX + + + +// BASE CLASSES +#include <cpp_internalgate.hxx> + +namespace ary +{ +namespace cpp +{ + class CeAdmin; + class DefAdmin; + class TypeAdmin; +} +} + + + + +namespace ary +{ +namespace cpp +{ + + + +/** The C++ partition of the repository. +*/ +class RepositoryPartition : public InternalGate +{ + public: + RepositoryPartition( + RepositoryCenter & i_reposyImpl ); + virtual ~RepositoryPartition(); + + // INHERITED + // Interface Gate: + virtual void Calculate_AllSecondaryInformation(); +// const ::autodoc::Options & +// i_options ); + virtual const String & + RepositoryTitle() const; + virtual const CodeEntity * + Search_RelatedCe( + Type_id i_type ) const; + virtual const ::ary::cpp::CppEntity * + Search_Entity( + GlobalId i_id ) const; + virtual uintt Get_AlphabeticalList( + List_GlobalIds & o_result, + const char * i_begin, + const char * i_end ) const; + virtual const CePilot & + Ces() const; + virtual const DefPilot & + Defs() const; + virtual const TypePilot & + Types() const; + virtual const loc::LocationPilot & + Locations() const; + virtual CePilot & Ces(); + virtual DefPilot & Defs(); + virtual TypePilot & Types(); + virtual loc::LocationPilot & + Locations(); + private: + // Locals + void Connect_AllTypes_2_TheirRelated_CodeEntites(); + + // DATA + RepositoryCenter * pRepositoryCenter; + + Dyn<CeAdmin> pCes; + Dyn<TypeAdmin> pTypes; + Dyn<DefAdmin> pDefs; + Dyn<loc::LocationPilot> + pLocations; +}; + + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_slots.cxx b/autodoc/source/ary/cpp/c_slots.cxx new file mode 100644 index 000000000000..e93b25c60d5c --- /dev/null +++ b/autodoc/source/ary/cpp/c_slots.cxx @@ -0,0 +1,109 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <c_slots.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <ary/ary_disp.hxx> +#include <ary/cpp/c_namesp.hxx> + + + +namespace ary +{ +namespace cpp +{ + + + +//*********************** Slot_SubNamespaces ********************// + + +Slot_SubNamespaces::Slot_SubNamespaces( const Map_NamespacePtr & i_rData ) + : pData( &i_rData ) +{ +} + +Slot_SubNamespaces::~Slot_SubNamespaces() +{ +} + +uintt +Slot_SubNamespaces::Size() const +{ + return pData->size(); +} + +void +Slot_SubNamespaces::StoreEntries( ary::Display & o_rDestination ) const +{ + for ( Map_NamespacePtr::const_iterator it = pData->begin(); + it != pData->end(); + ++it ) + { + (*(*it).second).Accept(o_rDestination); + } +} + + +//*********************** Slot_BaseClass ********************// + +Slot_BaseClass::Slot_BaseClass( const List_Bases & i_rData ) + : pData( &i_rData ) +{ +} + +Slot_BaseClass::~Slot_BaseClass() +{ +} + +uintt +Slot_BaseClass::Size() const +{ + return pData->size(); +} + +void +Slot_BaseClass::StoreEntries( ary::Display & o_rDestination ) const +{ + for ( List_Bases::const_iterator it = pData->begin(); + it != pData->end(); + ++it ) + { + csv::CheckedCall(o_rDestination, *it); + } +} + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_slots.hxx b/autodoc/source/ary/cpp/c_slots.hxx new file mode 100644 index 000000000000..dab4f5d4552f --- /dev/null +++ b/autodoc/source/ary/cpp/c_slots.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_C_SLOTS_HXX +#define ARY_CPP_C_SLOTS_HXX + +// BASE CLASSES +#include <ary/ceslot.hxx> +// USED SERVICES +#include <ary/cpp/c_slntry.hxx> + + + + +namespace ary +{ +namespace cpp +{ + + +class Slot_SubNamespaces : public ary::Slot +{ + public: + Slot_SubNamespaces( + const Map_NamespacePtr & + i_rData ); + virtual ~Slot_SubNamespaces(); + + virtual uintt Size() const; + + private: + virtual void StoreEntries( + ary::Display & o_rDestination ) const; + // DATA + const Map_NamespacePtr * + pData; +}; + +class Slot_BaseClass : public ary::Slot +{ + public: + Slot_BaseClass( + const List_Bases & i_rData ); + virtual ~Slot_BaseClass(); + + virtual uintt Size() const; + + private: + virtual void StoreEntries( + ary::Display & o_rDestination ) const; + // DATA + const List_Bases * pData; +}; + + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_traits.cxx b/autodoc/source/ary/cpp/c_traits.cxx new file mode 100644 index 000000000000..e0bd26a06685 --- /dev/null +++ b/autodoc/source/ary/cpp/c_traits.cxx @@ -0,0 +1,226 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_traits.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <ary/namesort.hxx> +#include <ary/cpp/c_class.hxx> +#include <ary/cpp/c_enuval.hxx> +#include <ary/cpp/c_namesp.hxx> +#include <ary/cpp/usedtype.hxx> +#include <ary/getncast.hxx> +#include "cs_ce.hxx" +#include "cs_def.hxx" +#include "cs_type.hxx" + + + + +namespace ary +{ +namespace cpp +{ + + + +//******************** Ce_Traits ********************// +Ce_Traits::entity_base_type & +Ce_Traits::EntityOf_(id_type i_id) +{ + csv_assert(i_id.IsValid()); + return Ce_Storage::Instance_()[i_id]; +} + +//******************** CeNode_Traits ********************// +const symtree::Node<CeNode_Traits> * +CeNode_Traits::NodeOf_(const entity_base_type & i_entity) +{ + if (is_type<Namespace>(i_entity)) + return & ary_cast<Namespace>(i_entity).AsNode(); + else if (is_type<Class>(i_entity)) + return & ary_cast<Class>(i_entity).AsNode(); + return 0; +} + +symtree::Node<CeNode_Traits> * +CeNode_Traits::NodeOf_(entity_base_type & io_entity) +{ + if (is_type<Namespace>(io_entity)) + return & ary_cast<Namespace>(io_entity).AsNode(); + else if (is_type<Class>(io_entity)) + return & ary_cast<Class>(io_entity).AsNode(); + return 0; +} + +Ce_Traits::entity_base_type * +CeNode_Traits::ParentOf_(const entity_base_type & i_entity) +{ + Ce_Traits::id_type + ret = i_entity.Owner(); + if (ret.IsValid()) + { + if (is_type<EnumValue>(i_entity)) + { // Return not the Enum, but the owner of the Enum: + ret = EntityOf_(ret).Owner(); + csv_assert(ret.IsValid()); + } + return &EntityOf_(ret); + } + return 0; +} + +Ce_id +CeNode_Search( const CodeEntity & i_entity, + const String & i_localKey ) +{ + if (is_type<Namespace>(i_entity)) + return ary_cast<Namespace>(i_entity).Search_Child(i_localKey); + else if (is_type<Class>(i_entity)) + return ary_cast<Class>(i_entity).Search_Child(i_localKey); + return Ce_id(0); +} + + + + +//******************** Ce_Compare ********************// +const Ce_Compare::key_type & +Ce_Compare::KeyOf_(const entity_base_type & i_entity) +{ + return i_entity.LocalName(); +} + +bool +Ce_Compare::Lesser_( const key_type & i_1, + const key_type & i_2 ) +{ + static ::ary::LesserName less_; + return less_(i_1,i_2); +} + + +//******************** Ce_GlobalCompare ********************// +void +Get_Qualified( StreamStr & o_out, + const CodeEntity & i_ce ) +{ + if (i_ce.LocalName().empty()) + return; + if (i_ce.Owner().IsValid()) + Get_Qualified(o_out, Ce_Traits::EntityOf_(i_ce.Owner())); + + o_out << i_ce.LocalName() << "::"; +} + + +bool +Ce_GlobalCompare::Lesser_( const key_type & i_1, + const key_type & i_2 ) +{ + static ::ary::LesserName less_; + + if (i_1.LocalName() != i_2.LocalName()) + return less_(i_1.LocalName(), i_2.LocalName()); + + csv_assert(i_1.Owner().IsValid() AND i_2.Owner().IsValid()); + + static StreamStr + aBuffer1_(300); + static StreamStr + aBuffer2_(300); + aBuffer1_.reset(); + aBuffer2_.reset(); + + Get_Qualified(aBuffer1_, Ce_Traits::EntityOf_(i_1.Owner())); + Get_Qualified(aBuffer2_, Ce_Traits::EntityOf_(i_2.Owner())); + if (aBuffer1_.size() >= 2) + aBuffer1_.pop_back(2); + if (aBuffer2_.size() >= 2) + aBuffer2_.pop_back(2); + return less_(aBuffer1_.c_str(), aBuffer2_.c_str()); +} + + + +//******************** Def_Traits ********************// +Def_Traits::entity_base_type & +Def_Traits::EntityOf_(id_type i_id) +{ + csv_assert(i_id.IsValid()); + return Def_Storage::Instance_()[i_id]; +} + +//******************** Def_Compare ********************// +const Def_Compare::key_type & +Def_Compare::KeyOf_(const entity_base_type & i_entity) +{ + return i_entity.LocalName(); +} + +bool +Def_Compare::Lesser_( const key_type & i_1, + const key_type & i_2 ) +{ + static ::ary::LesserName less_; + return less_(i_1,i_2); +} + + + +//******************** Type_Traits ********************// +Type_Traits::entity_base_type & +Type_Traits::EntityOf_(id_type i_id) +{ + csv_assert(i_id.IsValid()); + return Type_Storage::Instance_()[i_id]; +} + +//******************** Type_Compare ********************// +const UsedType_Compare::key_type & +UsedType_Compare::KeyOf_(const entity_base_type & i_entity) +{ + csv_assert( is_type<UsedType>(i_entity) ); + return ary_cast<UsedType>(i_entity); +} + +bool +UsedType_Compare::Lesser_( const key_type & i_1, + const key_type & i_2 ) +{ + return i_1 < i_2; +} + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_tydef.cxx b/autodoc/source/ary/cpp/c_tydef.cxx new file mode 100644 index 000000000000..60f67e7e6c30 --- /dev/null +++ b/autodoc/source/ary/cpp/c_tydef.cxx @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_tydef.hxx> + + +// NOT FULLY DECLARED SERVICES +#include <slots.hxx> +#include "c_slots.hxx" + + + + +namespace ary +{ +namespace cpp +{ + +Typedef::Typedef( const String & i_sLocalName, + Cid i_nOwner, + E_Protection i_eProtection, + Lid i_nFile, + Tid i_nDescribingType ) + : aEssentials( i_sLocalName, + i_nOwner, + i_nFile ), + nDescribingType(i_nDescribingType), + eProtection(i_eProtection) +{ +} + +Typedef::~Typedef() +{ + +} + +const String & +Typedef::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +Typedef::inq_Owner() const +{ + return aEssentials.Owner(); +} + +Lid +Typedef::inq_Location() const +{ + return aEssentials.Location(); +} + +void +Typedef::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Typedef::get_AryClass() const +{ + return class_id; +} + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/c_vari.cxx b/autodoc/source/ary/cpp/c_vari.cxx new file mode 100644 index 000000000000..5006748f65c9 --- /dev/null +++ b/autodoc/source/ary/cpp/c_vari.cxx @@ -0,0 +1,99 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/c_vari.hxx> + + +// NOT FULLY DECLARED SERVICES + + + +namespace ary +{ +namespace cpp +{ + +Variable::Variable( const String & i_sLocalName, + Cid i_nOwner, + E_Protection i_eProtection, + Lid i_nFile, + Tid i_nType, + VariableFlags i_aFlags, + const String & i_sArraySize, + const String & i_sInitValue ) + : aEssentials( i_sLocalName, + i_nOwner, + i_nFile ), + nType(i_nType), + eProtection(i_eProtection), + aFlags(i_aFlags), + sArraySize(i_sArraySize), + sInitialisation(i_sInitValue) +{ +} + +Variable::~Variable() +{ +} + +const String & +Variable::inq_LocalName() const +{ + return aEssentials.LocalName(); +} + +Cid +Variable::inq_Owner() const +{ + return aEssentials.Owner(); +} + +Lid +Variable::inq_Location() const +{ + return aEssentials.Location(); +} + +void +Variable::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ClassId +Variable::get_AryClass() const +{ + return class_id; +} + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/ca_ce.cxx b/autodoc/source/ary/cpp/ca_ce.cxx new file mode 100644 index 000000000000..ea49b1446c49 --- /dev/null +++ b/autodoc/source/ary/cpp/ca_ce.cxx @@ -0,0 +1,625 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + + +#include <precomp.h> +#include "ca_ce.hxx" + + +// NOT FULLY DEFINED SERVICES +#include <ary/qualiname.hxx> +#include <ary/cpp/inpcontx.hxx> +#include <ary/cpp/c_namesp.hxx> +#include <ary/cpp/c_class.hxx> +#include <ary/cpp/c_enum.hxx> +#include <ary/cpp/c_enuval.hxx> +#include <ary/cpp/c_funct.hxx> +#include <ary/cpp/c_tydef.hxx> +#include <ary/cpp/c_type.hxx> +#include <ary/cpp/c_vari.hxx> +#include <ary/cpp/cp_type.hxx> +#include <ary/loc/loc_file.hxx> +#include <ary/getncast.hxx> + + + + + + +namespace +{ + +String Get_NewAnonymousNamespaceName(); +String Get_NewAnonymousName( + char i_start ); + + +} // anonymous namespace + + + + +namespace ary +{ +namespace cpp +{ + + +// KORR_FUTURE +// What about namespace visibility ? +// Perhaps handle all/some visibility transfer only after parse is complete. +void +transfer_visibility( const Class * i_owner, + CodeEntity & o_child ) +{ + if ( i_owner != 0 ? NOT i_owner->IsVisible() : false ) + o_child.Set_InVisible(); +} + +inline const TypePilot & +CeAdmin::Types() const +{ + csv_assert(pTypes != 0); + return *pTypes; +} + + + + + + +CeAdmin::CeAdmin(RepositoryPartition & io_myReposyPartition) + : aStorage(), + pTypes(0), + pCppRepositoryPartition(&io_myReposyPartition) +{ +} + +void +CeAdmin::Set_Related(const TypePilot & i_types) +{ + pTypes = &i_types; +} + +CeAdmin::~CeAdmin() +{ +} + +Namespace & +CeAdmin::CheckIn_Namespace( const InputContext & i_context, + const String & i_localName ) +{ + const String + local_name = NOT i_localName.empty() + ? i_localName + : Get_NewAnonymousNamespaceName(); + Namespace & + rParent = i_context.CurNamespace(); + Namespace * + ret = rParent.Search_LocalNamespace(local_name); + if ( ret == 0 ) + { + ret = &Create_Namespace(rParent, local_name); + } + return *ret; +} + +Class & +CeAdmin::Store_Class( const InputContext & i_context, + const String & i_localName, + E_ClassKey i_eClassKey ) +{ + const String + local_name = i_localName.empty() + ? Get_NewAnonymousName( i_eClassKey == CK_class + ? 'c' + : i_eClassKey == CK_struct + ? 's' + : 'u' ) + : i_localName; + + Class & + ret = * new Class( local_name, + i_context.CurOwner().CeId(), + i_context.CurProtection(), + i_context.CurFile().LeId(), + i_eClassKey ); + aStorage.Store_Type(ret); + i_context.CurOwner().Add_Class(local_name, ret.CeId()); + transfer_visibility(i_context.CurClass(), ret); + + return ret; +} + +Enum & +CeAdmin::Store_Enum( const InputContext & i_context, + const String & i_localName ) +{ + const String + local_name = i_localName.empty() + ? Get_NewAnonymousName('e') + : i_localName; + Enum & + ret = * new Enum( local_name, + i_context.CurOwner().CeId(), + i_context.CurProtection(), + i_context.CurFile().LeId() ); + aStorage.Store_Type(ret); + i_context.CurOwner().Add_Enum(local_name, ret.CeId()); + transfer_visibility(i_context.CurClass(), ret); + + return ret; +} + +Typedef & +CeAdmin::Store_Typedef( const InputContext& i_context, + const String & i_localName, + Type_id i_referredType ) +{ + Typedef & + ret = * new Typedef( i_localName, + i_context.CurOwner().CeId(), + i_context.CurProtection(), + i_context.CurFile().LeId(), + i_referredType ); + aStorage.Store_Type(ret); + i_context.CurOwner().Add_Typedef(i_localName, ret.CeId()); + transfer_visibility(i_context.CurClass(), ret); + + return ret; +} + +Function * +CeAdmin::Store_Operation( const InputContext & i_context, + const String & i_localName, + Type_id i_returnType, + const std::vector<S_Parameter> & i_parameters, + E_Virtuality i_virtuality, + E_ConVol i_conVol, + FunctionFlags i_flags, + bool i_throwExists, + const std::vector<Type_id> & i_exceptions ) +{ + Function & + ret = * new Function( i_localName, + i_context.CurOwner().CeId(), + i_context.CurProtection(), + i_context.CurFile().LeId(), + i_returnType, + i_parameters, + i_conVol, + i_virtuality, + i_flags, + i_throwExists, + i_exceptions ); + + // Check for double declaration: + Ce_id + nAlreadyExistingFunction(0); + switch ( lhf_CheckAndHandle_DuplicateOperation( + nAlreadyExistingFunction, + i_context, + ret) ) + { + case df_discard_new: + delete &ret; + return 0; + case df_replace: + csv_assert(nAlreadyExistingFunction.IsValid()); + aStorage.Replace_Entity( + nAlreadyExistingFunction, + ret ); + break; + case df_no: + aStorage.Store_Operation(ret); // Now it has a valid id. + i_context.CurOwner().Add_Operation( i_localName, ret.CeId(), i_flags.IsStaticMember() ); + break; + default: + csv_assert(false); + } + + transfer_visibility(i_context.CurClass(), ret); + if ( i_context.CurProtection() != PROTECT_global ) + { + Class * + pClass = i_context.CurClass(); + if ( pClass != 0 AND i_virtuality != VIRTUAL_none) + { + pClass->UpdateVirtuality(i_virtuality); + } + } + + return &ret; +} + +Variable & +CeAdmin::Store_Variable( const InputContext& i_context, + const String & i_localName, + Type_id i_type, + VariableFlags i_flags, + const String & i_arraySize, + const String & i_initValue ) +{ + Variable & + ret = * new Variable( i_localName, + i_context.CurOwner().CeId(), + i_context.CurProtection(), + i_context.CurFile().LeId(), + i_type, + i_flags, + i_arraySize, + i_initValue ); + + bool + is_const = Types().Find_Type(i_type).IsConst(); + aStorage.Store_Datum(ret); + i_context.CurOwner().Add_Variable( + i_localName, + ret.CeId(), + is_const, + i_flags.IsStaticMember() ); + transfer_visibility(i_context.CurClass(), ret); + + return ret; +} + +EnumValue & +CeAdmin::Store_EnumValue( const InputContext & i_context, + const String & i_localName, + const String & i_initValue ) +{ + Enum * + parent = i_context.CurEnum(); + csv_assert( parent != 0 ); + + EnumValue & + ret = * new EnumValue( i_localName, + parent->CeId(), + i_initValue ); + aStorage.Store_Datum(ret); + parent->Add_Value(ret.CeId()); + + // KORR also for current enum: + transfer_visibility(i_context.CurClass(), ret); + + return ret; +} + +const Namespace & +CeAdmin::GlobalNamespace() const +{ + return ary_cast<Namespace>( aStorage[predefined::ce_GlobalNamespace] ); +} + +const CodeEntity & +CeAdmin::Find_Ce(Ce_id i_id) const +{ + return aStorage[i_id]; +} + +const CodeEntity * +CeAdmin::Search_Ce(Ce_id i_id) const +{ + return aStorage.Exists(i_id) + ? & aStorage[i_id] + : (const CodeEntity*)(0); +} + +const CodeEntity * +CeAdmin::Search_CeAbsolute( const CodeEntity & i_curScope, + const QualifiedName & i_rSearchedName ) const +{ + const symtree::Node<CeNode_Traits> * + cur_node = CeNode_Traits::NodeOf_(i_curScope); + csv_assert(cur_node != 0); + + Ce_id + ret(0); + cur_node->SearchUp( ret, + i_rSearchedName.first_namespace(), + i_rSearchedName.end_namespace(), + i_rSearchedName.LocalName() ); + return Search_Ce(ret); +} + +const CodeEntity * +CeAdmin::Search_CeLocal( const String & i_localName, + bool i_bIsFunction, + const Namespace & i_rCurNamespace, + const Class * i_pCurClass ) const +{ + // KORR_FUTURE + // See if this is correct. + + Ce_id + ret(0); + + if ( NOT i_bIsFunction ) + { + CesResultList + type_instances = aStorage.TypeIndex().SearchAll(i_localName); + CesResultList + data_instances = aStorage.DataIndex().SearchAll(i_localName); + Ce_id + ret1 = Search_MatchingInstance( + type_instances, + (i_pCurClass + ? i_pCurClass->CeId() + : i_rCurNamespace.CeId()) + ); + Ce_id + ret2 = Search_MatchingInstance( + data_instances, + (i_pCurClass + ? i_pCurClass->CeId() + : i_rCurNamespace.CeId()) + ); + if (NOT ret2.IsValid()) + ret = ret1; + else if (NOT ret1.IsValid()) + ret = ret2; + } + else + { + CesResultList + function_instances = aStorage.OperationIndex().SearchAll(i_localName); + if ( function_instances.size() == 1 ) + ret = *function_instances.begin(); + else + { + ret = Search_MatchingInstance( + function_instances, + (i_pCurClass + ? i_pCurClass->CeId() + : i_rCurNamespace.CeId()) + ); + } + } + + if ( ret.IsValid() ) + return & Find_Ce(ret); + + return 0; +} + +void +CeAdmin::Get_QualifiedName( StreamStr & o_rOut, + const String & i_localName, + Ce_id i_nOwner, + const char * i_sDelimiter ) const +{ + if ( i_localName.empty() OR NOT i_nOwner.IsValid() ) + return; + + const CodeEntity * + pOwner = & Find_Ce( i_nOwner ); + if ( is_type<Enum>(*pOwner) ) + pOwner = &Find_Ce( Ce_id(pOwner->Owner()) ); + + Get_QualifiedName( o_rOut, + pOwner->LocalName(), + Ce_id(pOwner->Owner()), + i_sDelimiter ); + o_rOut + << i_sDelimiter + << i_localName; +} + +void +CeAdmin::Get_SignatureText( StreamStr & o_rOut, + const OperationSignature & i_signature, + const StringVector * i_sParameterNames ) const +{ + OperationSignature::ParameterTypeList::const_iterator + it = i_signature.Parameters().begin(); + OperationSignature::ParameterTypeList::const_iterator + it_end = i_signature.Parameters().end(); + + const StringVector aDummy; + StringVector::const_iterator + itName = i_sParameterNames != 0 + ? i_sParameterNames->begin() + : aDummy.begin(); + StringVector::const_iterator + itName_end = i_sParameterNames != 0 + ? i_sParameterNames->end() + : aDummy.end(); + + bool + bEmpty = (it == it_end); + if (NOT bEmpty) + { + o_rOut << "( "; + Types().Get_TypeText(o_rOut, *it); + if (itName != itName_end) + o_rOut << " " << (*itName); + + for ( ++it; it != it_end; ++it ) + { + o_rOut << ", "; + Types().Get_TypeText(o_rOut, *it); + if (itName != itName_end) + { + ++itName; + if (itName != itName_end) + o_rOut << " " << (*itName); + } + } + o_rOut << " )"; + } + else + { + o_rOut << "( )"; + } + + if ( intt(i_signature.ConVol()) & intt(ary::cpp::CONVOL_const) ) + o_rOut << " const"; + if ( intt(i_signature.ConVol()) & intt(ary::cpp::CONVOL_volatile) ) + o_rOut << " volatile"; +} + +CesResultList +CeAdmin::Search_TypeName(const String & i_sName) const +{ + return aStorage.TypeIndex().SearchAll(i_sName); +} + +Namespace & +CeAdmin::GlobalNamespace() +{ + return ary_cast<Namespace>( aStorage[predefined::ce_GlobalNamespace] ); +} + +CeAdmin::E_DuplicateFunction +CeAdmin::lhf_CheckAndHandle_DuplicateOperation( + Ce_id & o_existentFunction, + const InputContext & i_context, + const Function & i_newFunction ) +{ + if (i_context.CurProtection() != PROTECT_global) + { + // Assume, there will be no duplicates within the same class. + + // KORR_FUTURE + // Assumption may be wrong in case of #defines providing different + // versions for different compilers. + return df_no; + } + + std::vector<Ce_id> + aOperationsWithSameName; + i_context.CurNamespace().Search_LocalOperations( + aOperationsWithSameName, + i_newFunction.LocalName() ); + + for ( std::vector<Ce_id>::const_iterator + it = aOperationsWithSameName.begin(); + it != aOperationsWithSameName.end(); + ++it ) + { + const Function & + rFunction = ary_cast<Function>(aStorage[*it]); + if ( rFunction.LocalName() == i_newFunction.LocalName() + AND rFunction.Signature() == i_newFunction.Signature() ) + { + if (NOT rFunction.IsIdentical(i_newFunction)) + { + // KORR_FUTURE Make this more detailed. + Cerr() << "Non identical function with same signature " + << "found: " + << i_context.CurNamespace().LocalName() + << "::" + << i_newFunction.LocalName() + << "(..)" + << Endl(); + } + o_existentFunction = rFunction.CeId(); + if (rFunction.Docu().Data() == 0) + return df_replace; + else + return df_discard_new; + } + } // end for + + return df_no; +} + +Namespace & +CeAdmin::Create_Namespace( Namespace & o_parent, + const String & i_localName ) +{ + DYN Namespace & + ret = *new Namespace(i_localName, o_parent); + aStorage.Store_Entity(ret); + o_parent.Add_LocalNamespace(ret); + return ret; +} + +Ce_id +CeAdmin::Search_MatchingInstance( CesResultList i_list, + Ce_id i_owner ) const +{ + // KORR + // Multiple results? + + for ( CesList::const_iterator it = i_list.begin(); + it != i_list.end(); + ++it ) + { + const CodeEntity & + ce = aStorage[*it]; + if ( ce.Owner() == i_owner) + { + return *it; + } + } + return Ce_id(0); +} + + + +} // namespace cpp +} // namespace ary + + + +namespace +{ + +uintt G_nLastFreeAnonymousNamespaceNr = 0; +uintt G_nLastFreeAnonymousEntityNr = 0; + +String +Get_NewAnonymousNamespaceName() +{ + StreamLock + sl(100); + return String( sl() + << "namespace_anonymous_" + << ++G_nLastFreeAnonymousNamespaceNr + << csv::c_str ); + +} + +String +Get_NewAnonymousName(char i_cStart) +{ + StreamLock + sl(100); + return String( sl() + << i_cStart + << "_Anonymous__" + << ++G_nLastFreeAnonymousEntityNr + << c_str ); +} + + + +} // namespace anonymous + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/ca_ce.hxx b/autodoc/source/ary/cpp/ca_ce.hxx new file mode 100644 index 000000000000..00e722b170c4 --- /dev/null +++ b/autodoc/source/ary/cpp/ca_ce.hxx @@ -0,0 +1,216 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_CA_CE_HXX +#define ARY_CPP_CA_CE_HXX + +// USED SERVICES + // BASE CLASSES +#include <ary/cpp/cp_ce.hxx> + // OTHER +#include "cs_ce.hxx" + + +namespace ary +{ +namespace cpp +{ + class Ce_Storage; + class RepositoryPartition; +} +} + + + + + +namespace ary +{ +namespace cpp +{ + + + +/** Administrates all C++ code entities (types, operations, variables). +*/ +class CeAdmin : public CePilot +{ + public: + // LIFECYCLE + CeAdmin( + RepositoryPartition & + io_myReposyPartition ); + void Set_Related( + const TypePilot & i_types ); + virtual ~CeAdmin(); + + // INQUIRY + const Ce_Storage & Storage() const; + + // ACCESS + Ce_Storage & Storage(); + + // INHERITED + // Interface CePilot: + virtual Namespace & CheckIn_Namespace( + const InputContext & + i_context, + const String & i_localName ); + virtual Class & Store_Class( + const InputContext & + i_context, + const String & i_localName, + E_ClassKey i_classKey ); + virtual Enum & Store_Enum( + const InputContext & + i_context, + const String & i_localName ); + virtual Typedef & Store_Typedef( + const InputContext & + i_context, + const String & i_localName, + Type_id i_referredType ); + virtual Function * Store_Operation( + const InputContext & + i_context, + const String & i_localName, + Type_id i_returnType, + const std::vector<S_Parameter> & + i_parameters, + E_Virtuality i_virtuality, + E_ConVol i_conVol, + FunctionFlags i_flags, + bool i_throwExists, + const std::vector<Type_id> & + i_exceptions ); + virtual Variable & Store_Variable( + const InputContext & + i_context, + const String & i_localName, + Type_id i_type, + VariableFlags i_flags, + const String & i_arraySize, + const String & i_initValue ); + virtual EnumValue & Store_EnumValue( + const InputContext & + i_context, + const String & i_localName, + const String & i_initValue ); + virtual const Namespace & + GlobalNamespace() const; + virtual const CodeEntity & + Find_Ce( + Ce_id i_id ) const; + virtual const CodeEntity * + Search_Ce( + Ce_id i_id ) const; + virtual const CodeEntity * + Search_CeAbsolute( + const CodeEntity & i_curScope, + const QualifiedName & + i_absoluteName ) const; + virtual const CodeEntity * + Search_CeLocal( + const String & i_relativeName, + bool i_isFunction, + const Namespace & i_curNamespace, + const Class * i_curClass ) const; + virtual void Get_QualifiedName( + StreamStr & o_result, + const String & i_localName, + Ce_id i_owner, + const char * i_delimiter = "::" ) const; + virtual void Get_SignatureText( + StreamStr & o_rOut, + const OperationSignature & + i_signature, + const StringVector * + i_sParameterNames = 0 ) const; + virtual CesResultList + Search_TypeName( + const String & i_sName ) const; + virtual Namespace & GlobalNamespace(); + + private: + // Locals + /// @return true, if function is duplicate. + enum E_DuplicateFunction + { + df_no, + df_replace, + df_discard_new + }; + + /** @param o_existentFunction + The id of the already existing function, else unset. + */ + E_DuplicateFunction lhf_CheckAndHandle_DuplicateOperation( + Ce_id & o_existentFunction, + const InputContext & + i_context, + const Function & i_newFunction ); + Namespace & Create_Namespace( + Namespace & o_parent, + const String & i_localName ); + Ce_id Search_MatchingInstance( + CesResultList i_list, + Ce_id i_owner ) const; + const TypePilot & Types() const; + + // DATA + Ce_Storage aStorage; + const TypePilot * pTypes; + RepositoryPartition * + pCppRepositoryPartition; +}; + + + + +// IMPLEMENTATION +inline const Ce_Storage & +CeAdmin::Storage() const +{ + return aStorage; +} + +inline Ce_Storage & +CeAdmin::Storage() +{ + return aStorage; +} + + + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/ca_def.cxx b/autodoc/source/ary/cpp/ca_def.cxx new file mode 100644 index 000000000000..8a2daa8dd9ea --- /dev/null +++ b/autodoc/source/ary/cpp/ca_def.cxx @@ -0,0 +1,114 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "ca_def.hxx" + + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/c_define.hxx> +#include <ary/cpp/c_macro.hxx> +#include <ary/loc/loc_file.hxx> +#include <ary/cpp/inpcontx.hxx> + + + + +namespace ary +{ +namespace cpp +{ + + +DefAdmin::DefAdmin(RepositoryPartition & io_myReposyPartition) + : aStorage(), + pCppRepositoryPartition(&io_myReposyPartition) +{ +} + +DefAdmin::~DefAdmin() +{ +} + +Define & +DefAdmin::Store_Define( const InputContext& i_rContext, + const String & i_sName, + const StringVector & i_rDefinition ) +{ + Define & + ret = *new Define( i_sName, + i_rDefinition, + i_rContext.CurFile().LeId() ); + aStorage.Store_Define(ret); + return ret; + +} + +Macro & +DefAdmin::Store_Macro( const InputContext& i_rContext, + const String & i_sName, + const StringVector & i_rParams, + const StringVector & i_rDefinition ) +{ + Macro & + ret = *new Macro( i_sName, + i_rParams, + i_rDefinition, + i_rContext.CurFile().LeId() ); + aStorage.Store_Macro(ret); + return ret; +} + +const DefineEntity & +DefAdmin::Find_Def(De_id i_id) const +{ + return aStorage[i_id]; +} + +DefsResultList +DefAdmin::AllDefines() const +{ + return csv::make_range( aStorage.DefineIndex().Begin(), + aStorage.DefineIndex().End() ); +} + +DefsResultList +DefAdmin::AllMacros() const +{ + return csv::make_range( aStorage.MacroIndex().Begin(), + aStorage.MacroIndex().End() ); +} + + + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/ca_def.hxx b/autodoc/source/ary/cpp/ca_def.hxx new file mode 100644 index 000000000000..254ad1797b1b --- /dev/null +++ b/autodoc/source/ary/cpp/ca_def.hxx @@ -0,0 +1,118 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_CA_DEF_HXX +#define ARY_CPP_CA_DEF_HXX + +// USED SERVICES + // BASE CLASSES +#include <ary/cpp/cp_def.hxx> + // OTHER +#include "cs_def.hxx" + + + +namespace ary +{ +namespace cpp +{ + class Def_Storage; + class RepositoryPartition; +} +} + + + + + +namespace ary +{ +namespace cpp +{ + + + + +class DefAdmin : public DefPilot +{ + public: + // LIFECYCLE + DefAdmin( + RepositoryPartition & + io_myReposyPartition ); + ~DefAdmin(); + + // INQUIRY + const Def_Storage & Storage() const; + + // INHERITED + // Interface DefPilot: + virtual Define & Store_Define( + const InputContext& i_rContext, + const String & i_sName, + const StringVector & + i_rDefinition ); + virtual Macro & Store_Macro( + const InputContext& i_rContext, + const String & i_sName, + const StringVector & + i_rParams, + const StringVector & + i_rDefinition ); + virtual const DefineEntity & + Find_Def( + De_id i_id ) const; + virtual DefsResultList + AllDefines() const; + virtual DefsResultList + AllMacros() const; + + private: + // DATA + Def_Storage aStorage; + RepositoryPartition * + pCppRepositoryPartition; +}; + + + + +// IMPLEMENTATION +inline const Def_Storage & +DefAdmin::Storage() const +{ + return aStorage; +} + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/ca_type.cxx b/autodoc/source/ary/cpp/ca_type.cxx new file mode 100644 index 000000000000..29117aea7cd0 --- /dev/null +++ b/autodoc/source/ary/cpp/ca_type.cxx @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "ca_type.hxx" + + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/c_builtintype.hxx> +#include <ary/cpp/c_class.hxx> +#include <ary/cpp/c_namesp.hxx> +#include <ary/cpp/cp_ce.hxx> +#include <ary/cpp/inpcontx.hxx> +#include <ary/cpp/usedtype.hxx> +#include <ary/getncast.hxx> +#include "c_reposypart.hxx" +#include "cs_type.hxx" + + + + +namespace ary +{ +namespace cpp +{ + + +TypeAdmin::TypeAdmin(RepositoryPartition & io_myReposyPartition) + : aStorage(), + pCppRepositoryPartition(&io_myReposyPartition) +{ +} + +TypeAdmin::~TypeAdmin() +{ +} + + +// KORR_FUTURE +// Remove unused parameter. + +const Type & +TypeAdmin::CheckIn_UsedType( const InputContext & , + DYN UsedType & pass_type ) +{ + Dyn<UsedType> + pNewType(&pass_type); // Ensure clean up of heap object. + + Type_id + tid(0); + if (pass_type.IsBuiltInType()) + { + tid = aStorage.Search_BuiltInType( + BuiltInType::SpecializedName_( pass_type.LocalName().c_str(), + pass_type.TypeSpecialisation() )); + csv_assert(tid.IsValid()); + return aStorage[tid]; + } + + tid = aStorage.UsedTypeIndex().Search(pass_type); + if (tid.IsValid()) + { + return aStorage[tid]; + } + + // Type does not yet exist: + // Transfer ownership from pNewTypeand assign id: + aStorage.Store_Entity(*pNewType.Release()); + + aStorage.UsedTypeIndex().Add(pass_type.TypeId()); + return pass_type; +} + +const Type & +TypeAdmin::Find_Type(Type_id i_type) const +{ + return aStorage[i_type]; +} + +bool +TypeAdmin::Get_TypeText( StreamStr & o_result, + Type_id i_type ) const +{ + if (NOT i_type.IsValid()) + return false; + aStorage[i_type].Get_Text(o_result, *pCppRepositoryPartition); + return true; +} + +bool +TypeAdmin::Get_TypeText( StreamStr & o_preName, + StreamStr & o_name, + StreamStr & o_postName, + Type_id i_type ) const +{ + if (NOT i_type.IsValid()) + return false; + aStorage[i_type].Get_Text(o_preName, o_name, o_postName, *pCppRepositoryPartition); + return true; +} + +Type_id +TypeAdmin::Tid_Ellipse() const +{ + return Type_id(predefined::t_ellipse); +} + + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/ca_type.hxx b/autodoc/source/ary/cpp/ca_type.hxx new file mode 100644 index 000000000000..123912d7c389 --- /dev/null +++ b/autodoc/source/ary/cpp/ca_type.hxx @@ -0,0 +1,130 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_CA_TYPE_HXX +#define ARY_CPP_CA_TYPE_HXX + +// USED SERVICES + // BASE CLASSES +#include <ary/cpp/cp_type.hxx> + // OTHER +#include "cs_type.hxx" + + + +namespace ary +{ +namespace cpp +{ + class RepositoryPartition; +} +} + + + + + +namespace ary +{ +namespace cpp +{ + + + +/** Administrates all C++ types as uses in user declarations + as return-, parameter- or variable-types. +*/ +class TypeAdmin : public TypePilot +{ + public: + // LIFECYCLE + TypeAdmin( + RepositoryPartition & + io_myReposyPartition ); + virtual ~TypeAdmin(); + + // INQUIRY + /// @return A list of all stored types that are not C++ or STL builtin types. + const Type_Storage & + Storage() const; + + // ACCESS + Type_Storage & Storage(); + + // INHERITED + // Interface TypePilot: + virtual const Type & + CheckIn_UsedType( + const InputContext & + i_context, + DYN UsedType & pass_type ); + virtual const Type & + Find_Type( + Type_id i_type ) const; + virtual bool Get_TypeText( + StreamStr & o_result, + Type_id i_type ) const; + virtual bool Get_TypeText( + StreamStr & o_preName, /// ::ary::cpp:: + StreamStr & o_name, /// MyClass + StreamStr & o_postName, /// <TplArgument> * const & + Type_id i_type ) const; + virtual Type_id Tid_Ellipse() const; + + private: + // DATA + Type_Storage aStorage; + RepositoryPartition * + pCppRepositoryPartition; +}; + + + + +// IMPLEMENTATION +inline const Type_Storage & +TypeAdmin::Storage() const +{ + return aStorage; +} + +inline Type_Storage & +TypeAdmin::Storage() +{ + return aStorage; +} + + + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/cs_ce.cxx b/autodoc/source/ary/cpp/cs_ce.cxx new file mode 100644 index 000000000000..3b4828b67230 --- /dev/null +++ b/autodoc/source/ary/cpp/cs_ce.cxx @@ -0,0 +1,107 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "cs_ce.hxx" + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/c_namesp.hxx> + + + +namespace +{ +const uintt + C_nReservedElements = ::ary::cpp::predefined::ce_MAX; // Skipping "0" and the GlobalNamespace +} + + + + +namespace ary +{ +namespace cpp +{ + +Ce_Storage * Ce_Storage::pInstance_ = 0; + + + +Ce_Storage::Ce_Storage() + : stg::Storage<CodeEntity>(C_nReservedElements), + aTypes(), + aOperations(), + aData() + +{ + Set_Reserved( predefined::ce_GlobalNamespace, + *new Namespace ); + + csv_assert(pInstance_ == 0); + pInstance_ = this; +} + +Ce_Storage::~Ce_Storage() +{ + csv_assert(pInstance_ != 0); + pInstance_ = 0; +} + +Ce_id +Ce_Storage::Store_Type(DYN CodeEntity & pass_ce) +{ + Ce_id + ret = Store_Entity(pass_ce); + aTypes.Add(ret); + return ret; +} + +Ce_id +Ce_Storage::Store_Operation(DYN CodeEntity & pass_ce) +{ + Ce_id + ret = Store_Entity(pass_ce); + aOperations.Add(ret); + return ret; +} + +Ce_id +Ce_Storage::Store_Datum(DYN CodeEntity & pass_ce) +{ + Ce_id + ret = Store_Entity(pass_ce); + aData.Add(ret); + return ret; +} + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/cs_ce.hxx b/autodoc/source/ary/cpp/cs_ce.hxx new file mode 100644 index 000000000000..a741f0d86c09 --- /dev/null +++ b/autodoc/source/ary/cpp/cs_ce.hxx @@ -0,0 +1,108 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_CS_CE_HXX +#define ARY_CPP_CS_CE_HXX + + + +// USED SERVICES + // BASE CLASSES +#include <store/s_storage.hxx> + // OTHER +#include <ary/cpp/c_ce.hxx> +#include <ary/cpp/c_traits.hxx> +#include <sortedids.hxx> + + + +namespace ary +{ +namespace cpp +{ + + +/** The data base for all ->ary::cpp::CodeEntity objects. +*/ +class Ce_Storage : public ::ary::stg::Storage<CodeEntity> +{ + public: + typedef SortedIds<Ce_Compare> Index; + + Ce_Storage(); + virtual ~Ce_Storage(); + + Ce_id Store_Type( + DYN CodeEntity & pass_ce ); + Ce_id Store_Operation( + DYN CodeEntity & pass_ce ); + Ce_id Store_Datum( + DYN CodeEntity & pass_ce ); + + const Index & TypeIndex() const { return aTypes; } + const Index & OperationIndex() const { return aOperations; } + const Index & DataIndex() const { return aData; } + + Index & TypeIndex() { return aTypes; } + Index & OperationIndex() { return aOperations; } + Index & DataIndex() { return aData; } + + static Ce_Storage & Instance_() { csv_assert(pInstance_ != 0); + return *pInstance_; } + private: + // DATA + Index aTypes; + Index aOperations; + Index aData; + + static Ce_Storage * pInstance_; +}; + + + + +namespace predefined +{ + +enum E_CodeEntity +{ + ce_GlobalNamespace = 1, + ce_MAX +}; + +} // namespace predefined + + + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/cs_def.cxx b/autodoc/source/ary/cpp/cs_def.cxx new file mode 100644 index 000000000000..713c2aaa63d8 --- /dev/null +++ b/autodoc/source/ary/cpp/cs_def.cxx @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "cs_def.hxx" + +// NOT FULLY DEFINED SERVICES + + +namespace +{ +const uintt + C_nReservedElements = ::ary::cpp::predefined::de_MAX; // Skipping "0" +} + + + +namespace ary +{ +namespace cpp +{ + +Def_Storage * Def_Storage::pInstance_ = 0; + + + + +Def_Storage::Def_Storage() + : stg::Storage<DefineEntity>(C_nReservedElements) +{ + csv_assert(pInstance_ == 0); + pInstance_ = this; +} + +Def_Storage::~Def_Storage() +{ + csv_assert(pInstance_ != 0); + pInstance_ = 0; +} + +De_id +Def_Storage::Store_Define(DYN DefineEntity & pass_de) +{ + De_id + ret = Store_Entity(pass_de); + aDefines.Add(ret); + return ret; +} + +De_id +Def_Storage::Store_Macro(DYN DefineEntity & pass_de) +{ + De_id + ret = Store_Entity(pass_de); + aMacros.Add(ret); + return ret; +} + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/cs_def.hxx b/autodoc/source/ary/cpp/cs_def.hxx new file mode 100644 index 000000000000..cfd6b5c61b53 --- /dev/null +++ b/autodoc/source/ary/cpp/cs_def.hxx @@ -0,0 +1,110 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_CS_DE_HXX +#define ARY_CPP_CS_DE_HXX + + + +// USED SERVICES + // BASE CLASSES +#include <store/s_storage.hxx> + // OTHER +#include <ary/cpp/c_de.hxx> +#include <ary/cpp/c_traits.hxx> +#include <sortedids.hxx> + + + +namespace ary +{ +namespace cpp +{ + + + + +/** The data base for all ->ary::cpp::Type objects. +*/ +class Def_Storage : public ::ary::stg::Storage<DefineEntity> +{ + public: + typedef SortedIds<Def_Compare> Index; + + // LIFECYCLE + Def_Storage(); + virtual ~Def_Storage(); + + De_id Store_Define( + DYN DefineEntity & pass_de ); + De_id Store_Macro( + DYN DefineEntity & pass_de ); + + const Index & DefineIndex() const { return aDefines; } + const Index & MacroIndex() const { return aMacros; } + + Index & DefineIndex() { return aDefines; } + Index & MacroIndex() { return aMacros; } + + static Def_Storage & + Instance_() { csv_assert(pInstance_ != 0); + return *pInstance_; } + private: + // DATA + Index aDefines; + Index aMacros; + + + static Def_Storage * + pInstance_; +}; + + + + +namespace predefined +{ + +enum E_DefineEntity +{ + // 0 is always unused with repository storages. + de_MAX = 1 +}; + +} // namespace predefined + + + + + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/cs_type.cxx b/autodoc/source/ary/cpp/cs_type.cxx new file mode 100644 index 000000000000..a5c6791a7ec2 --- /dev/null +++ b/autodoc/source/ary/cpp/cs_type.cxx @@ -0,0 +1,115 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "cs_type.hxx" + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/c_builtintype.hxx> + + +namespace +{ + const uintt + C_nReservedElements = ary::cpp::predefined::t_MAX; // Skipping "0" and the builtin types +} + + +namespace ary +{ +namespace cpp +{ + + + +Type_Storage * Type_Storage::pInstance_ = 0; + + + + +Type_Storage::Type_Storage() + : stg::Storage<Type>(C_nReservedElements), + aBuiltInTypes() +{ + Setup_BuiltInTypes(); + + csv_assert(pInstance_ == 0); + pInstance_ = this; +} + +Type_Storage::~Type_Storage() +{ + csv_assert(pInstance_ != 0); + pInstance_ = 0; +} + +Type_id +Type_Storage::Search_BuiltInType( const String & i_specializedName ) const +{ + return csv::value_from_map(aBuiltInTypes, i_specializedName, Tid(0)); +} + +void +Type_Storage::Setup_BuiltInTypes() +{ + Set_BuiltInType( predefined::t_void, "void" ); + Set_BuiltInType( predefined::t_bool, "bool" ); + Set_BuiltInType( predefined::t_char, "char" ); + Set_BuiltInType( predefined::t_signed_char, "char", TYSP_signed ); + Set_BuiltInType( predefined::t_unsigned_char, "char", TYSP_unsigned ); + Set_BuiltInType( predefined::t_short, "short" ); + Set_BuiltInType( predefined::t_unsigned_short, "short", TYSP_unsigned ); + Set_BuiltInType( predefined::t_int, "int" ); + Set_BuiltInType( predefined::t_unsigned_int, "int", TYSP_unsigned ); + Set_BuiltInType( predefined::t_long, "long" ); + Set_BuiltInType( predefined::t_unsigned_long, "long", TYSP_unsigned ); + Set_BuiltInType( predefined::t_float, "float" ); + Set_BuiltInType( predefined::t_double, "double" ); + Set_BuiltInType( predefined::t_size_t, "size_t" ); + Set_BuiltInType( predefined::t_wchar_t, "wchar_t" ); + Set_BuiltInType( predefined::t_ptrdiff_t, "ptrdiff_t" ); + Set_BuiltInType( predefined::t_ellipse, "..." ); +} + +void +Type_Storage::Set_BuiltInType( Rid i_id, + const char * i_sName, + ary::cpp::E_TypeSpecialisation i_eSpecialisation ) +{ + DYN BuiltInType & + rNew = *new BuiltInType(i_sName, i_eSpecialisation); + Set_Reserved( i_id, rNew); // Here goes the ownership for rNew. + aBuiltInTypes[rNew.SpecializedName()] = rNew.TypeId(); +} + + + +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/cs_type.hxx b/autodoc/source/ary/cpp/cs_type.hxx new file mode 100644 index 000000000000..c1f1568cb097 --- /dev/null +++ b/autodoc/source/ary/cpp/cs_type.hxx @@ -0,0 +1,141 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_CS_TYPE_HXX +#define ARY_CPP_CS_TYPE_HXX + + + +// USED SERVICES + // BASE CLASSES +#include <store/s_storage.hxx> + // COMPONENTS + // PARAMETERS +#include <ary/cpp/c_type.hxx> +#include <ary/cpp/c_traits.hxx> +#include <ary/cpp/usedtype.hxx> +#include <sortedids.hxx> + + + +namespace ary +{ +namespace cpp +{ + + + +/** The data base for all ->ary::cpp::Type objects. +*/ +class Type_Storage : public ::ary::stg::Storage<Type> +{ + public: + typedef SortedIds<UsedType_Compare> UT_Index; + + Type_Storage(); + virtual ~Type_Storage(); + + const UT_Index & UsedTypeIndex() const; + + UT_Index & UsedTypeIndex(); + Type_id Search_BuiltInType( + const String & i_specializedName ) const; + + static Type_Storage & + Instance_() { csv_assert(pInstance_ != 0); + return *pInstance_; } + private: + // Locals + void Setup_BuiltInTypes(); + void Set_BuiltInType( + Rid i_nId, + const char * i_sName, + ary::cpp::E_TypeSpecialisation + i_eSpecialisation = TYSP_none ); + // DATA + UT_Index aUsedTypes; + std::map<String,Type_id> + aBuiltInTypes; + + + static Type_Storage * + pInstance_; +}; + + + + +namespace predefined +{ + +enum E_Type +{ + // 0 is always unused with repository storages. + t_void = 1, + t_bool, + t_char, + t_signed_char, + t_unsigned_char, + t_short, + t_unsigned_short, + t_int, + t_unsigned_int, + t_long, + t_unsigned_long, + t_float, + t_double, + t_size_t, + t_wchar_t, + t_ptrdiff_t, + t_ellipse, + t_MAX +}; + +} // namespace predefined + + + +// IMPLEMENTATION +inline const Type_Storage::UT_Index & +Type_Storage::UsedTypeIndex() const +{ + return aUsedTypes; +} + +inline Type_Storage::UT_Index & +Type_Storage::UsedTypeIndex() +{ + return aUsedTypes; +} + + +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/makefile.mk b/autodoc/source/ary/cpp/makefile.mk new file mode 100644 index 000000000000..5c20a59bd82e --- /dev/null +++ b/autodoc/source/ary/cpp/makefile.mk @@ -0,0 +1,80 @@ +#************************************************************************* +# +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# Copyright 2000, 2010 Oracle and/or its affiliates. +# +# OpenOffice.org - a multi-platform office productivity suite +# +# This file is part of OpenOffice.org. +# +# OpenOffice.org is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License version 3 +# only, as published by the Free Software Foundation. +# +# OpenOffice.org is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Lesser General Public License version 3 for more details +# (a copy is included in the LICENSE file that accompanied this code). +# +# You should have received a copy of the GNU Lesser General Public License +# version 3 along with OpenOffice.org. If not, see +# <http://www.openoffice.org/license.html> +# for a copy of the LGPLv3 License. +# +#************************************************************************* + +PRJ=..$/..$/.. + +PRJNAME=autodoc +TARGET=ary_cpp + + + +# --- Settings ----------------------------------------------------- + +ENABLE_EXCEPTIONS=true +PRJINC=$(PRJ)$/source + +.INCLUDE : settings.mk +.INCLUDE : $(PRJ)$/source$/mkinc$/fullcpp.mk + + +# --- Files -------------------------------------------------------- + + +OBJFILES= \ + $(OBJ)$/c_builtintype.obj \ + $(OBJ)$/c_class.obj \ + $(OBJ)$/c_de.obj \ + $(OBJ)$/c_define.obj \ + $(OBJ)$/c_enum.obj \ + $(OBJ)$/c_enuval.obj \ + $(OBJ)$/c_funct.obj \ + $(OBJ)$/c_macro.obj \ + $(OBJ)$/c_namesp.obj \ + $(OBJ)$/c_osigna.obj \ + $(OBJ)$/c_reposypart.obj \ + $(OBJ)$/c_slots.obj \ + $(OBJ)$/c_traits.obj \ + $(OBJ)$/c_tydef.obj \ + $(OBJ)$/c_vari.obj \ + $(OBJ)$/ca_ce.obj \ + $(OBJ)$/ca_def.obj \ + $(OBJ)$/ca_type.obj \ + $(OBJ)$/cs_ce.obj \ + $(OBJ)$/cs_def.obj \ + $(OBJ)$/cs_type.obj \ + $(OBJ)$/namechain.obj \ + $(OBJ)$/tplparam.obj \ + $(OBJ)$/usedtype.obj + + + +# --- Targets ------------------------------------------------------ + +.INCLUDE : target.mk + + + diff --git a/autodoc/source/ary/cpp/namechain.cxx b/autodoc/source/ary/cpp/namechain.cxx new file mode 100644 index 000000000000..4df64afe3deb --- /dev/null +++ b/autodoc/source/ary/cpp/namechain.cxx @@ -0,0 +1,199 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/namechain.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/usedtype.hxx> +#include <ary/cpp/c_gate.hxx> +#include "tplparam.hxx" + + + +namespace ary +{ +namespace cpp +{ +namespace ut +{ + + +//********************* NameSegment ******************// + +NameSegment::NameSegment( const char * i_sName ) + : sName( i_sName ) + // pTemplate +{ +} + +NameSegment::NameSegment( const NameSegment & i_rSeg ) + : sName(i_rSeg.sName) + // pTemplate +{ + // KORR_FUTURE : Handling of copying of templates. +// csv_assert( NOT i_rSeg.pTemplate ); +} + +NameSegment& NameSegment::operator=(const NameSegment & i_rSeg) +{ + sName = i_rSeg.sName; + return *this; +} + +NameSegment::~NameSegment() +{ +} + +List_TplParameter & +NameSegment::AddTemplate() +{ + return * (pTemplate = new List_TplParameter); +} + +intt +NameSegment::Compare( const NameSegment & i_rOther ) const +{ + intt nResult = strcmp( sName.c_str(), i_rOther.sName.c_str() ); + if (nResult != 0) + return nResult; + if ( bool(pTemplate) != bool(i_rOther.pTemplate) ) + { + if ( NOT pTemplate ) + return -1; + else + return +1; + } + else if ( NOT pTemplate ) + return 0; + else + return pTemplate->Compare( *i_rOther.pTemplate ); +} + +void +NameSegment::Get_Text_AsScope( StreamStr & o_rOut, + const Gate & i_rGate ) const +{ + o_rOut << sName; + if ( pTemplate ) + pTemplate->Get_Text( o_rOut, i_rGate ); +} + +void +NameSegment::Get_Text_AsMainType( StreamStr & o_rName, + StreamStr & o_rPostName, + const Gate & i_rGate ) const +{ + o_rName << sName; + if ( pTemplate ) + pTemplate->Get_Text( o_rPostName, i_rGate ); +} + + +//********************* NameChain ******************// + +NameChain::NameChain() +// : aSegments +{ +} + +NameChain::~NameChain() +{ +} + +void +NameChain::Add_Segment( const char * i_sSeg ) +{ + aSegments.push_back( NameSegment(i_sSeg) ); +} + +List_TplParameter & +NameChain::Templatize_LastSegment() +{ + csv_assert( aSegments.size() > 0 ); + + return aSegments.back().AddTemplate(); +} + +intt +NameChain::Compare( const NameChain & i_rChain ) const +{ + intt nResult = intt(aSegments.size()) - intt(i_rChain.aSegments.size()); + if (nResult != 0) + return nResult; + + std::vector< NameSegment >::const_iterator it1 = aSegments.begin(); + std::vector< NameSegment >::const_iterator it1End = aSegments.end(); + std::vector< NameSegment >::const_iterator it2 = i_rChain.aSegments.begin(); + + for ( ; it1 != it1End; ++it1, ++it2 ) + { + nResult = (*it1).Compare(*it2); + if (nResult != 0) + return nResult; + } + + return 0; +} + +const String & +NameChain::LastSegment() const +{ + if ( aSegments.size() > 0 ) + return aSegments.back().Name(); + return String::Null_(); +} + +void +NameChain::Get_Text( StreamStr & o_rPreName, + StreamStr & o_rName, + StreamStr & o_rPostName, + const Gate & i_rGate ) const +{ + std::vector< NameSegment >::const_iterator it = aSegments.begin(); + std::vector< NameSegment >::const_iterator itEnd = aSegments.end(); + + if ( it == itEnd ) + return; + + for ( --itEnd; it != itEnd; ++it ) + { + (*it).Get_Text_AsScope( o_rPreName, i_rGate ); + o_rPreName << "::"; + } + (*it).Get_Text_AsMainType( o_rName, o_rPostName, i_rGate ); +} + + + +} // namespace ut +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/tplparam.cxx b/autodoc/source/ary/cpp/tplparam.cxx new file mode 100644 index 000000000000..c22fb78e4787 --- /dev/null +++ b/autodoc/source/ary/cpp/tplparam.cxx @@ -0,0 +1,77 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include "tplparam.hxx" + + +// NOT FULLY DEFINED SERVICES +#include <ary/cpp/c_gate.hxx> +#include <ary/cpp/cp_type.hxx> + + +namespace ary +{ +namespace cpp +{ +namespace ut +{ + +TplParameter_Type::TplParameter_Type( Tid i_nType ) + : nType(i_nType) +{ +} + +TplParameter_Type::~TplParameter_Type() +{ +} + +intt +TplParameter_Type::Compare( const TemplateParameter & i_rOther ) const +{ + const TplParameter_Type * pOther + = dynamic_cast< const TplParameter_Type* >( &i_rOther ); + if (pOther == 0) + return -1; + + return static_cast<long>(nType.Value()) + - static_cast<long>(pOther->nType.Value()); +} + +void +TplParameter_Type::Get_Text( StreamStr & o_rOut, + const ary::cpp::Gate & i_rGate ) const +{ + i_rGate.Types().Get_TypeText( o_rOut, nType ); +} + +} // namespace ut +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/tplparam.hxx b/autodoc/source/ary/cpp/tplparam.hxx new file mode 100644 index 000000000000..a720eff22776 --- /dev/null +++ b/autodoc/source/ary/cpp/tplparam.hxx @@ -0,0 +1,87 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#ifndef ARY_CPP_TPLPARAM_HXX +#define ARY_CPP_TPLPARAM_HXX + +// USED SERVICES +#include <ary/cpp/c_types4cpp.hxx> + + + + +namespace ary +{ +namespace cpp +{ + class UsedType; + class Gate; + +namespace ut +{ + + +class TemplateParameter +{ + public: + virtual ~TemplateParameter() {} + + virtual intt Compare( + const TemplateParameter & + i_rOther ) const = 0; + virtual void Get_Text( + StreamStr & o_rOut, + const ary::cpp::Gate & + i_rGate ) const = 0; +}; + + +class TplParameter_Type : public TemplateParameter +{ + public: + TplParameter_Type( + Tid i_nType ); + ~TplParameter_Type(); + + virtual intt Compare( + const TemplateParameter & + i_rOther ) const; + virtual void Get_Text( + StreamStr & o_rOut, + const ary::cpp::Gate & + i_rGate ) const; + private: + Tid nType; +}; + +} // namespace ut +} // namespace cpp +} // namespace ary +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/autodoc/source/ary/cpp/usedtype.cxx b/autodoc/source/ary/cpp/usedtype.cxx new file mode 100644 index 000000000000..bde91e5b644b --- /dev/null +++ b/autodoc/source/ary/cpp/usedtype.cxx @@ -0,0 +1,578 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <precomp.h> +#include <ary/cpp/usedtype.hxx> + + +// NOT FULLY DEFINED SERVICES +#include <cosv/tpl/tpltools.hxx> +#include <ary/symtreenode.hxx> +#include <ary/cpp/c_ce.hxx> +#include <ary/cpp/c_class.hxx> +#include <ary/cpp/c_namesp.hxx> +#include <ary/cpp/c_slntry.hxx> +#include <ary/cpp/c_tydef.hxx> +#include <ary/cpp/c_traits.hxx> +#include <ary/cpp/c_types4cpp.hxx> +#include <ary/cpp/c_gate.hxx> +#include <ary/cpp/cp_ce.hxx> +#include <ary/cpp/cp_type.hxx> +#include <ary/doc/d_oldcppdocu.hxx> +#include <ary/getncast.hxx> +#include "tplparam.hxx" + + + +namespace +{ + +using namespace ::ary::cpp; +typedef std::vector< ary::cpp::E_ConVol > PtrLevelVector; + + +inline bool +result2bool( intt i_nResult ) + { return i_nResult < 0; } + + +intt compare_PtrLevelVector( + const PtrLevelVector & + i_r1, + const PtrLevelVector & + i_r2 ); +inline intt +compare_ConVol( E_ConVol i_e1, + E_ConVol i_e2 ) + { return intt(i_e1) - intt(i_e2); } + +inline intt +compare_bool( bool i_b1, + bool i_b2 ) + { return i_b1 == i_b2 + ? 0 + : i_b1 + ? -1 + : +1; } +inline intt +compare_Specialisation( E_TypeSpecialisation i_e1, + E_TypeSpecialisation i_e2 ) + { return intt(i_e1) - intt(i_e2); } + +inline bool +is_const( E_ConVol i_eCV ) + { return ( intt(i_eCV) & intt(CONVOL_const) ) != 0; } + +inline bool +is_volatile( E_ConVol i_eCV ) + { return ( intt(i_eCV) & intt(CONVOL_volatile) ) != 0; } + + +intt +compare_PtrLevelVector( const PtrLevelVector & i_r1, + const PtrLevelVector & i_r2 ) +{ + intt nResult = i_r1.size() - i_r2.size(); + if ( nResult != 0 ) + return nResult; + + PtrLevelVector::const_iterator it1 = i_r1.begin(); + PtrLevelVector::const_iterator it1End = i_r1.end(); + PtrLevelVector::const_iterator it2 = i_r2.begin(); + + for ( ; it1 != it1End; ++it1, ++it2 ) + { + nResult = compare_ConVol(*it1, *it2); + if ( nResult != 0 ) + return nResult; + } + + return 0; +} + + +} // anonymous namespace + + + + +namespace ary +{ +namespace cpp +{ + +typedef symtree::Node<CeNode_Traits> CeNode; +typedef ut::NameChain::const_iterator nc_iter; + +Ce_id CheckForRelatedCe_inNode( + const CeNode & i_node, + const StringVector& i_qualification, + const String & i_name ); + + +UsedType::UsedType(Ce_id i_scope ) + : aPath(), + aPtrLevels(), + eConVol_Type(CONVOL_none), + bIsReference(false), + bIsAbsolute(false), + bRefers2BuiltInType(false), + eTypeSpecialisation(TYSP_none), + nRelatedCe(0), + nScope(i_scope) +{ +} + +UsedType::~UsedType() +{ +} + + +bool +UsedType::operator<( const UsedType & i_rType ) const +{ + intt nResult = compare_bool( bIsAbsolute, i_rType.bIsAbsolute ); + if ( nResult != 0 ) + return result2bool(nResult); + + nResult = static_cast<intt>(nScope.Value()) + - + static_cast<intt>(i_rType.nScope.Value()); + if ( nResult != 0 ) + return result2bool(nResult); + + nResult = aPath.Compare( i_rType.aPath ); + if ( nResult != 0 ) + return result2bool(nResult); + + nResult = compare_ConVol( eConVol_Type, i_rType.eConVol_Type ); + if ( nResult != 0 ) + return result2bool(nResult); + + nResult = compare_PtrLevelVector( aPtrLevels, i_rType.aPtrLevels ); + if ( nResult != 0 ) + return result2bool(nResult); + + nResult = compare_bool( bIsReference, i_rType.bIsReference ); + if ( nResult != 0 ) + return result2bool(nResult); + + nResult = compare_Specialisation( eTypeSpecialisation, i_rType.eTypeSpecialisation ); + if ( nResult != 0 ) + return result2bool(nResult); + + return false; +} + +void +UsedType::Set_Absolute() +{ + bIsAbsolute = true; +} + +void +UsedType::Add_NameSegment( const char * i_sSeg ) +{ + aPath.Add_Segment(i_sSeg); +} + +ut::List_TplParameter & +UsedType::Enter_Template() +{ + return aPath.Templatize_LastSegment(); +} + +void +UsedType::Set_Unsigned() +{ + eTypeSpecialisation = TYSP_unsigned; +} + +void +UsedType::Set_Signed() +{ + eTypeSpecialisation = TYSP_signed; +} + +void +UsedType::Set_BuiltIn( const char * i_sType ) +{ + aPath.Add_Segment(i_sType); + bRefers2BuiltInType = true; +} + +void +UsedType::Set_Const() +{ + if (PtrLevel() == 0) + eConVol_Type = E_ConVol(eConVol_Type | CONVOL_const); + else + aPtrLevels.back() = E_ConVol(aPtrLevels.back() | CONVOL_const); +} + +void +UsedType::Set_Volatile() +{ + if (PtrLevel() == 0) + eConVol_Type = E_ConVol(eConVol_Type | CONVOL_volatile); + else + aPtrLevels.back() = E_ConVol(aPtrLevels.back() | CONVOL_volatile); +} + +void +UsedType::Add_PtrLevel() +{ + aPtrLevels.push_back(CONVOL_none); +} + +void +UsedType::Set_Reference() +{ + bIsReference = true; +} + +inline bool +IsInternal(const ary::cpp::CodeEntity & i_ce) +{ + const ary::doc::OldCppDocu * + docu = dynamic_cast< const ary::doc::OldCppDocu* >(i_ce.Docu().Data()); + if (docu != 0) + return docu->IsInternal(); + return false; +} + + +void +UsedType::Connect2Ce( const CePilot & i_ces) +{ + StringVector + qualification; + String + name; + Get_NameParts(qualification, name); + + for ( const CeNode * scope_node = CeNode_Traits::NodeOf_( + i_ces.Find_Ce(nScope)); + scope_node != 0; + scope_node = scope_node->Parent() ) + { + nRelatedCe = CheckForRelatedCe_inNode(*scope_node, qualification, name); + if ( nRelatedCe.IsValid() ) + { + if ( IsInternal(i_ces.Find_Ce(nRelatedCe)) ) + nRelatedCe = Ce_id(0); + return; + } + } // end for +} + +void +UsedType::Connect2CeOnlyKnownViaBaseClass(const Gate & i_gate) +{ + csv_assert(nScope.IsValid()); + CesResultList + instances = i_gate.Ces().Search_TypeName( LocalName() ); + + // If there are no matches, or only one match that was already + // accepted, all work is done. + if ( (nRelatedCe.IsValid() AND instances.size() == 1) + OR instances.size() == 0 ) + return; + + StringVector + qualification; + String + name; + Get_NameParts(qualification, name); + + const CodeEntity & + scopece = i_gate.Ces().Find_Ce(nScope); + + // Else search for declaration in own class and then in base classes. + // These would be of higher priority than those in parent namespaces. + Ce_id + foundce = RecursiveSearchCe_InBaseClassesOf( + scopece, qualification, name, i_gate); + if (foundce.IsValid()) + nRelatedCe = foundce; + + if ( nRelatedCe.IsValid() AND IsInternal(i_gate.Ces().Find_Ce(nRelatedCe)) ) + { + nRelatedCe = Ce_id(0); + } +} + +bool +UsedType::IsBuiltInType() const +{ + return bRefers2BuiltInType + AND aPtrLevels.size() == 0 + AND NOT bIsReference + AND eConVol_Type == ary::cpp::CONVOL_none; +} + +const String & +UsedType::LocalName() const +{ + return aPath.LastSegment(); +} + +E_TypeSpecialisation +UsedType::TypeSpecialisation() const +{ + return eTypeSpecialisation; +} + +void +UsedType::do_Accept(csv::ProcessorIfc & io_processor) const +{ + csv::CheckedCall(io_processor,*this); +} + +ary::ClassId +UsedType::get_AryClass() const +{ + return class_id; +} + +Rid +UsedType::inq_RelatedCe() const +{ + return nRelatedCe.Value(); +} + +bool +UsedType::inq_IsConst() const +{ + if ( is_const(eConVol_Type) ) + return true; + for ( PtrLevelVector::const_iterator it = aPtrLevels.begin(); + it != aPtrLevels.end(); + ++it ) + { + if ( is_const(*it) ) + return true; + } + + return false; +} + +void +UsedType::inq_Get_Text( StreamStr & o_rPreName, + StreamStr & o_rName, + StreamStr & o_rPostName, + const Gate & i_rGate ) const +{ + if ( is_const(eConVol_Type) ) + o_rPreName << "const "; + if ( is_volatile(eConVol_Type) ) + o_rPreName << "volatile "; + if ( bIsAbsolute ) + o_rPreName << "::"; + + aPath.Get_Text( o_rPreName, o_rName, o_rPostName, i_rGate ); + + for ( PtrLevelVector::const_iterator it = aPtrLevels.begin(); + it != aPtrLevels.end(); + ++it ) + { + o_rPostName << " *"; + if ( is_const(*it) ) + o_rPostName << " const"; + if ( is_volatile(*it) ) + o_rPostName << " volatile"; + } + if ( bIsReference ) + o_rPostName << " &"; +} + +Ce_id +UsedType::RecursiveSearchCe_InBaseClassesOf( const CodeEntity & i_mayBeClass, + const StringVector & i_myQualification, + const String & i_myName, + const Gate & i_gate ) const +{ + // Find in this class? + const CeNode * + basenode = CeNode_Traits::NodeOf_(i_mayBeClass); + if (basenode == 0) + return Ce_id(0); + Ce_id + found = CheckForRelatedCe_inNode(*basenode, i_myQualification, i_myName); + if (found.IsValid()) + return found; + + + const Class * + cl = ary_cast<Class>(&i_mayBeClass); + if (cl == 0) + return Ce_id(0); + + for ( List_Bases::const_iterator it = cl->BaseClasses().begin(); + it != cl->BaseClasses().end(); + ++it ) + { + csv_assert((*it).nId.IsValid()); + Ce_id + base = i_gate.Types().Find_Type((*it).nId).RelatedCe(); + while (base.IsValid() AND is_type<Typedef>(i_gate.Ces().Find_Ce(base)) ) + { + base = i_gate.Types().Find_Type( + ary_cast<Typedef>(i_gate.Ces().Find_Ce(base)) + .DescribingType() ) + .RelatedCe(); + } + + if (base.IsValid()) + { + const CodeEntity & + basece = i_gate.Ces().Find_Ce(base); + found = RecursiveSearchCe_InBaseClassesOf( + basece, i_myQualification, i_myName, i_gate); + if (found.IsValid()) + return found; + } + } // end for + + return Ce_id(0); +} + + +void +UsedType::Get_NameParts( StringVector & o_qualification, + String & o_name ) +{ + nc_iter nit = aPath.begin(); + nc_iter nit_end = aPath.end(); + csv_assert(nit != nit_end); // Each UsedType has to have a local name. + + --nit_end; + o_name = (*nit_end).Name(); + for ( ; + nit != nit_end; + ++nit ) + { + o_qualification.push_back( (*nit).Name() ); + } +} + +Ce_id +CheckForRelatedCe_inNode( const CeNode & i_node, + const StringVector & i_qualification, + const String & i_name ) +{ + if (i_qualification.size() > 0) + { + Ce_id + ret(0); + i_node.SearchBelow( ret, + i_qualification.begin(), + i_qualification.end(), + i_name ); + return ret; + } + else + { + return i_node.Search(i_name); + } +} + + +namespace ut +{ + +List_TplParameter::List_TplParameter() + : aTplParameters() +{ +} + +List_TplParameter::~List_TplParameter() +{ + csv::erase_container_of_heap_ptrs(aTplParameters); +} + +void +List_TplParameter::AddParam_Type( Type_id i_nType ) +{ + aTplParameters.push_back( new TplParameter_Type(i_nType) ); +} + +void +List_TplParameter::Get_Text( StreamStr & o_rOut, + const ary::cpp::Gate & i_rGate ) const +{ + Vector_TplArgument::const_iterator it = aTplParameters.begin(); + Vector_TplArgument::const_iterator itEnd = aTplParameters.end(); + + if ( it == itEnd ) + { + o_rOut << "<>"; + return; + } + + o_rOut << "< "; + + (*it)->Get_Text( o_rOut, i_rGate ); + + for ( ++it; it != itEnd; ++it ) + { + o_rOut << ", "; + (*it)->Get_Text( o_rOut, i_rGate ); + } + + o_rOut << " >"; +} + +intt +List_TplParameter::Compare( const List_TplParameter & i_rOther ) const +{ + intt nResult = intt(aTplParameters.size()) - intt(i_rOther.aTplParameters.size()); + + if (nResult != 0) + return nResult; + + Vector_TplArgument::const_iterator it1 = aTplParameters.begin(); + Vector_TplArgument::const_iterator it1End = aTplParameters.end(); + Vector_TplArgument::const_iterator it2 = i_rOther.aTplParameters.begin(); + + for ( ; it1 != it1End; ++it1, ++it2 ) + { + nResult = (*it1)->Compare( *(*it2) ); + if (nResult != 0) + return nResult; + } + + return 0; +} + + +} // namespace ut +} // namespace cpp +} // namespace ary + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |