2010-10-14 01:30:07 -05:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2001-03-15 05:30:43 -06:00
|
|
|
/*************************************************************************
|
|
|
|
*
|
2008-04-11 04:26:47 -05:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2010-02-12 08:01:35 -06:00
|
|
|
* Copyright 2000, 2010 Oracle and/or its affiliates.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2008-04-11 04:26:47 -05:00
|
|
|
* OpenOffice.org - a multi-platform office productivity suite
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2008-04-11 04:26:47 -05:00
|
|
|
* This file is part of OpenOffice.org.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2008-04-11 04:26:47 -05:00
|
|
|
* 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.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2008-04-11 04:26:47 -05:00
|
|
|
* 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).
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
2008-04-11 04:26:47 -05:00
|
|
|
* 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.
|
2001-03-15 05:30:43 -06:00
|
|
|
*
|
|
|
|
************************************************************************/
|
2006-09-17 02:11:14 -05:00
|
|
|
|
|
|
|
// MARKER(update_precomp.py): autogen include statement, do not remove
|
|
|
|
#include "precompiled_idlc.hxx"
|
2001-03-15 05:30:43 -06:00
|
|
|
#include <idlc/astdeclaration.hxx>
|
|
|
|
#include <idlc/astscope.hxx>
|
|
|
|
#include <rtl/strbuf.hxx>
|
|
|
|
|
|
|
|
using namespace ::rtl;
|
|
|
|
|
|
|
|
static OString sGlobal("::");
|
|
|
|
|
|
|
|
static OString convertName(const OString& name)
|
|
|
|
{
|
|
|
|
OStringBuffer nameBuffer(name.getLength()+1);
|
2001-05-10 07:07:49 -05:00
|
|
|
sal_Int32 nIndex = 0;
|
|
|
|
do
|
2001-03-15 05:30:43 -06:00
|
|
|
{
|
2001-05-10 07:07:49 -05:00
|
|
|
OString token( name.getToken( 0, ':', nIndex ) );
|
|
|
|
if( token.getLength() )
|
2001-03-15 05:30:43 -06:00
|
|
|
{
|
|
|
|
nameBuffer.append('/');
|
2001-05-10 07:07:49 -05:00
|
|
|
nameBuffer.append( token );
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
2001-05-10 07:07:49 -05:00
|
|
|
} while( nIndex != -1 );
|
2001-03-15 05:30:43 -06:00
|
|
|
return nameBuffer.makeStringAndClear();
|
|
|
|
}
|
|
|
|
|
|
|
|
AstDeclaration::AstDeclaration(NodeType type, const OString& name, AstScope* pScope)
|
2006-06-19 21:46:53 -05:00
|
|
|
: m_localName(name)
|
2001-03-15 05:30:43 -06:00
|
|
|
, m_pScope(pScope)
|
2006-06-19 21:46:53 -05:00
|
|
|
, m_nodeType(type)
|
2001-03-15 05:30:43 -06:00
|
|
|
, m_bImported(sal_False)
|
2006-06-19 21:46:53 -05:00
|
|
|
, m_bIsAdded(sal_False)
|
2001-03-15 05:30:43 -06:00
|
|
|
, m_bInMainFile(sal_False)
|
2007-01-25 04:00:41 -06:00
|
|
|
, m_bPredefined(false)
|
2001-03-15 05:30:43 -06:00
|
|
|
{
|
|
|
|
if ( m_pScope )
|
|
|
|
{
|
|
|
|
AstDeclaration* pDecl = scopeAsDecl(m_pScope);
|
|
|
|
if (pDecl)
|
|
|
|
{
|
|
|
|
m_scopedName = pDecl->getScopedName();
|
|
|
|
if (m_scopedName.getLength() > 0)
|
|
|
|
m_scopedName += sGlobal;
|
|
|
|
m_scopedName += m_localName;
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
m_scopedName = m_localName;
|
|
|
|
}
|
|
|
|
m_fullName = convertName(m_scopedName);
|
|
|
|
|
|
|
|
if ( idlc()->getFileName() == idlc()->getRealFileName() )
|
|
|
|
{
|
|
|
|
m_fileName = idlc()->getMainFileName();
|
|
|
|
m_bInMainFile = sal_True;
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
m_fileName = idlc()->getFileName();
|
|
|
|
m_bImported = sal_True;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( idlc()->isDocValid() )
|
|
|
|
m_documentation = OStringToOUString(idlc()->getDocumentation(), RTL_TEXTENCODING_UTF8);
|
2004-06-03 09:07:13 -05:00
|
|
|
|
|
|
|
m_bPublished = idlc()->isPublished();
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
AstDeclaration::~AstDeclaration()
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-01-25 04:00:41 -06:00
|
|
|
void AstDeclaration::setPredefined(bool bPredefined)
|
|
|
|
{
|
|
|
|
m_bPredefined = bPredefined;
|
|
|
|
if ( m_bPredefined )
|
|
|
|
{
|
|
|
|
m_fileName = OString();
|
|
|
|
m_bInMainFile = sal_False;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2001-03-15 05:30:43 -06:00
|
|
|
void AstDeclaration::setName(const ::rtl::OString& name)
|
|
|
|
{
|
2001-05-10 07:07:49 -05:00
|
|
|
m_scopedName = name;
|
|
|
|
sal_Int32 nIndex = name.lastIndexOf( ':' );
|
2001-05-10 10:29:19 -05:00
|
|
|
m_localName = name.copy( nIndex+1 );
|
2001-05-10 07:07:49 -05:00
|
|
|
|
|
|
|
// Huh ? There is always at least one token
|
|
|
|
|
|
|
|
// sal_Int32 count = name.getTokenCount(':');
|
|
|
|
|
|
|
|
// if ( count > 0 )
|
|
|
|
// {
|
|
|
|
// m_localName = name.getToken(count-1, ':');
|
|
|
|
// m_scopedName = name;
|
|
|
|
// } else if ( m_pScope )
|
|
|
|
// {
|
|
|
|
// m_localName = name;
|
|
|
|
// AstDeclaration* pDecl = scopeAsDecl(m_pScope);
|
|
|
|
// if (pDecl)
|
|
|
|
// {
|
|
|
|
// m_scopedName = pDecl->getScopedName();
|
|
|
|
// if (m_scopedName.getLength() > 0)
|
|
|
|
// m_scopedName += sGlobal;
|
|
|
|
// m_scopedName += m_localName;
|
|
|
|
// }
|
|
|
|
// } else
|
|
|
|
// {
|
|
|
|
// m_localName = name;
|
|
|
|
// m_scopedName = name;
|
|
|
|
// }
|
2001-03-15 05:30:43 -06:00
|
|
|
m_fullName = convertName(m_scopedName);
|
|
|
|
}
|
|
|
|
|
2004-06-03 09:07:13 -05:00
|
|
|
bool AstDeclaration::isType() const {
|
|
|
|
switch (m_nodeType) {
|
|
|
|
case NT_interface:
|
|
|
|
case NT_instantiated_struct:
|
|
|
|
case NT_union:
|
|
|
|
case NT_enum:
|
|
|
|
case NT_sequence:
|
|
|
|
case NT_array:
|
|
|
|
case NT_typedef:
|
|
|
|
case NT_predefined:
|
|
|
|
case NT_type_parameter:
|
|
|
|
return true;
|
|
|
|
|
|
|
|
default:
|
|
|
|
OSL_ASSERT(m_nodeType != NT_struct); // see AstStruct::isType
|
|
|
|
return false;
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sal_Bool AstDeclaration::hasAncestor(AstDeclaration* pDecl)
|
|
|
|
{
|
|
|
|
if (this == pDecl)
|
|
|
|
return sal_True;
|
|
|
|
if ( !m_pScope )
|
|
|
|
return sal_False;
|
|
|
|
return scopeAsDecl(m_pScope)->hasAncestor(pDecl);
|
|
|
|
}
|
|
|
|
|
2004-03-30 09:44:35 -06:00
|
|
|
sal_Bool AstDeclaration::dump(RegistryKey& rKey)
|
2001-03-15 05:30:43 -06:00
|
|
|
{
|
|
|
|
AstScope* pScope = declAsScope(this);
|
|
|
|
sal_Bool bRet = sal_True;
|
|
|
|
|
|
|
|
if ( pScope )
|
|
|
|
{
|
2004-03-30 09:44:35 -06:00
|
|
|
DeclList::const_iterator iter = pScope->getIteratorBegin();
|
|
|
|
DeclList::const_iterator end = pScope->getIteratorEnd();
|
2001-03-15 05:30:43 -06:00
|
|
|
AstDeclaration* pDecl = NULL;
|
|
|
|
while ( iter != end && bRet)
|
|
|
|
{
|
|
|
|
pDecl = *iter;
|
|
|
|
if ( pDecl->isInMainfile() )
|
|
|
|
{
|
|
|
|
switch ( pDecl->getNodeType() )
|
|
|
|
{
|
|
|
|
case NT_module:
|
|
|
|
case NT_constants:
|
|
|
|
case NT_interface:
|
|
|
|
case NT_struct:
|
|
|
|
case NT_exception:
|
|
|
|
case NT_enum:
|
|
|
|
case NT_union:
|
|
|
|
case NT_typedef:
|
|
|
|
case NT_service:
|
2001-05-18 09:38:10 -05:00
|
|
|
case NT_singleton:
|
2004-03-30 09:44:35 -06:00
|
|
|
bRet = pDecl->dump(rKey);
|
2006-06-19 21:46:53 -05:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
|
|
|
}
|
2007-01-25 04:00:41 -06:00
|
|
|
|
2001-04-11 01:29:27 -05:00
|
|
|
++iter;
|
2001-03-15 05:30:43 -06:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return bRet;
|
|
|
|
}
|
2007-01-25 04:00:41 -06:00
|
|
|
|
2010-10-14 01:30:07 -05:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|