summaryrefslogtreecommitdiff
path: root/idlc/source/aststruct.cxx
diff options
context:
space:
mode:
authorOliver Bolte <obo@openoffice.org>2004-06-03 14:08:57 +0000
committerOliver Bolte <obo@openoffice.org>2004-06-03 14:08:57 +0000
commitd75a64e7677d31d217089f91ad253a8d75bf6ffe (patch)
treeb52022481d8d8bdf2f4287e5035557ad16696ca1 /idlc/source/aststruct.cxx
parentb7ca4cb9603db7f25df3471881c4a6abba993e62 (diff)
INTEGRATION: CWS sb18 (1.5.4); FILE MERGED
2004/05/18 15:36:49 sb 1.5.4.4: #i21150# Added new feature: published. 2004/04/21 15:55:11 sb 1.5.4.3: #i21150# Cleaned up nomenclature of polymorphic struct types. 2004/04/14 08:52:29 sb 1.5.4.2: #i21150# Added support for polymorphic struct types. 2004/04/08 14:37:16 sb 1.5.4.1: #i21150# Fixed UNOIDL typedef support; initial support for polymorphic struct types.
Diffstat (limited to 'idlc/source/aststruct.cxx')
-rw-r--r--idlc/source/aststruct.cxx80
1 files changed, 70 insertions, 10 deletions
diff --git a/idlc/source/aststruct.cxx b/idlc/source/aststruct.cxx
index fb86fe81c6b3..4eb8052e31bb 100644
--- a/idlc/source/aststruct.cxx
+++ b/idlc/source/aststruct.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: aststruct.cxx,v $
*
- * $Revision: 1.5 $
+ * $Revision: 1.6 $
*
- * last change: $Author: rt $ $Date: 2004-03-30 16:46:04 $
+ * last change: $Author: obo $ $Date: 2004-06-03 15:08:57 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -70,11 +70,19 @@
using namespace ::rtl;
-AstStruct::AstStruct(const OString& name, AstStruct* pBaseType, AstScope* pScope)
+AstStruct::AstStruct(
+ const OString& name, std::vector< rtl::OString > const & typeParameters,
+ AstStruct* pBaseType, AstScope* pScope)
: AstType(NT_struct, name, pScope)
, AstScope(NT_struct)
, m_pBaseType(pBaseType)
{
+ for (std::vector< rtl::OString >::const_iterator i(typeParameters.begin());
+ i != typeParameters.end(); ++i)
+ {
+ m_typeParameters.push_back(
+ new AstDeclaration(NT_type_parameter, *i, 0));
+ }
}
AstStruct::AstStruct(const NodeType type,
@@ -89,6 +97,29 @@ AstStruct::AstStruct(const NodeType type,
AstStruct::~AstStruct()
{
+ for (DeclList::iterator i(m_typeParameters.begin());
+ i != m_typeParameters.end(); ++i)
+ {
+ delete *i;
+ }
+}
+
+AstDeclaration const * AstStruct::findTypeParameter(rtl::OString const & name)
+ const
+{
+ for (DeclList::const_iterator i(m_typeParameters.begin());
+ i != m_typeParameters.end(); ++i)
+ {
+ if ((*i)->getLocalName() == name) {
+ return *i;
+ }
+ }
+ return 0;
+}
+
+bool AstStruct::isType() const {
+ return getNodeType() == NT_struct
+ ? getTypeParameterCount() == 0 : AstDeclaration::isType();
}
sal_Bool AstStruct::dump(RegistryKey& rKey)
@@ -102,6 +133,16 @@ sal_Bool AstStruct::dump(RegistryKey& rKey)
return sal_False;
}
+ if (m_typeParameters.size() > SAL_MAX_UINT16) {
+ fprintf(
+ stderr,
+ ("%s: polymorphic struct type template %s has too many type"
+ " parameters\n"),
+ idlc()->getOptions()->getProgramName().getStr(),
+ getScopedName().getStr());
+ return false;
+ }
+
sal_uInt16 nMember = getNodeCount(NT_member);
RTTypeClass typeClass = RT_TYPE_STRUCT;
@@ -109,10 +150,14 @@ sal_Bool AstStruct::dump(RegistryKey& rKey)
typeClass = RT_TYPE_EXCEPTION;
typereg::Writer aBlob(
- TYPEREG_VERSION_0, getDocumentation(),
+ (m_typeParameters.empty() && !m_bPublished
+ ? TYPEREG_VERSION_0 : TYPEREG_VERSION_1),
+ getDocumentation(),
OStringToOUString(getFileName(), RTL_TEXTENCODING_UTF8), typeClass,
+ m_bPublished,
OStringToOUString(getRelativName(), RTL_TEXTENCODING_UTF8),
- m_pBaseType == 0 ? 0 : 1, nMember, 0, 0);
+ m_pBaseType == 0 ? 0 : 1, nMember, 0,
+ static_cast< sal_uInt16 >(m_typeParameters.size()));
if (m_pBaseType != 0) {
aBlob.setSuperTypeName(
0,
@@ -134,20 +179,35 @@ sal_Bool AstStruct::dump(RegistryKey& rKey)
if ( pDecl->getNodeType() == NT_member )
{
pMember = (AstMember*)pDecl;
+ RTFieldAccess flags = RT_ACCESS_READWRITE;
+ rtl::OString typeName;
+ if (pMember->getType()->getNodeType() == NT_type_parameter) {
+ flags |= RT_ACCESS_PARAMETERIZED_TYPE;
+ typeName = pMember->getType()->getLocalName();
+ } else {
+ typeName = pMember->getType()->getRelativName();
+ }
aBlob.setFieldData(
- index++, pMember->getDocumentation(), OUString(),
- RT_ACCESS_READWRITE,
+ index++, pMember->getDocumentation(), OUString(), flags,
OStringToOUString(
pMember->getLocalName(), RTL_TEXTENCODING_UTF8),
- OStringToOUString(
- pMember->getType()->getRelativName(),
- RTL_TEXTENCODING_UTF8),
+ OStringToOUString(typeName, RTL_TEXTENCODING_UTF8),
RTConstValue());
}
++iter;
}
}
+ sal_uInt16 index = 0;
+ for (DeclList::iterator i(m_typeParameters.begin());
+ i != m_typeParameters.end(); ++i)
+ {
+ aBlob.setReferenceData(
+ index++, OUString(), RT_REF_TYPE_PARAMETER, RT_ACCESS_INVALID,
+ OStringToOUString(
+ (*i)->getLocalName(), RTL_TEXTENCODING_UTF8));
+ }
+
sal_uInt32 aBlobSize;
void const * pBlob = aBlob.getBlob(&aBlobSize);