From 6bb1949ce9ce109d66b00a32c2312cf1be4a1b9f Mon Sep 17 00:00:00 2001 From: Andrew Niefer Date: Wed, 3 Jan 2007 22:56:30 +0000 Subject: [PATCH] bug 169134 --- .../core/dom/parser/cpp/CPPClassTemplate.java | 9 +++++--- .../cpp/CPPClassTemplateSpecialization.java | 15 +++++++++---- .../core/dom/parser/cpp/CPPTemplates.java | 9 ++++---- .../parser/cpp/ICPPInternalClassTemplate.java | 21 +++++++++++++++++++ 4 files changed, 43 insertions(+), 11 deletions(-) create mode 100644 core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTemplate.java diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java index 797e2c97db6..ef779629b84 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplate.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2006 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -57,9 +57,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassType.CPPClassTypePro * @author aniefer */ public class CPPClassTemplate extends CPPTemplateDefinition implements - ICPPClassTemplate, ICPPClassType, ICPPInternalClassType { + ICPPClassTemplate, ICPPClassType, ICPPInternalClassType, ICPPInternalClassTemplate { - public static class CPPClassTemplateDelegate extends CPPClassType.CPPClassTypeDelegate implements ICPPClassTemplate, ICPPInternalTemplate { + public static class CPPClassTemplateDelegate extends CPPClassType.CPPClassTypeDelegate implements ICPPClassTemplate, ICPPInternalClassTemplate { public CPPClassTemplateDelegate( IASTName name, ICPPClassType cls ) { super( name, cls ); } @@ -81,6 +81,9 @@ public class CPPClassTemplate extends CPPTemplateDefinition implements public ICPPSpecialization getInstance( IType[] arguments ) { return ((ICPPInternalTemplate)getBinding()).getInstance( arguments ); } + public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ) { + ((ICPPInternalClassTemplate)getBinding()).addPartialSpecialization( spec ); + } } private ICPPClassTemplatePartialSpecialization [] partialSpecializations = null; diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java index 34fa9140561..297a5790d3b 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPClassTemplateSpecialization.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPScope; import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization; import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter; +import org.eclipse.cdt.core.parser.util.ArrayUtil; import org.eclipse.cdt.core.parser.util.ObjectMap; /** @@ -29,9 +30,10 @@ import org.eclipse.cdt.core.parser.util.ObjectMap; * */ public class CPPClassTemplateSpecialization extends CPPClassSpecialization - implements ICPPClassTemplate, ICPPInternalTemplate { + implements ICPPClassTemplate, ICPPInternalClassTemplate { private ObjectMap instances = null; + private ICPPClassTemplatePartialSpecialization [] partialSpecializations = null; /** * @param specialized @@ -47,10 +49,11 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate#getPartialSpecializations() */ public ICPPClassTemplatePartialSpecialization[] getPartialSpecializations() { - // TODO Auto-generated method stub - return ICPPClassTemplatePartialSpecialization.EMPTY_PARTIAL_SPECIALIZATION_ARRAY; + partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.trim( ICPPClassTemplatePartialSpecialization.class, partialSpecializations ); + return partialSpecializations; } + /* (non-Javadoc) * @see org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateDefinition#getTemplateParameters() */ @@ -99,4 +102,8 @@ public class CPPClassTemplateSpecialization extends CPPClassSpecialization // TODO Auto-generated method stub return null; } + + public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ){ + partialSpecializations = (ICPPClassTemplatePartialSpecialization[]) ArrayUtil.append( ICPPClassTemplatePartialSpecialization.class, partialSpecializations, spec ); + } } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java index 3870f225d41..e24f9b71e9c 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPTemplates.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005 IBM Corporation and others. + * Copyright (c) 2005, 2007 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -358,7 +358,8 @@ public class CPPTemplates { } spec = new CPPClassTemplatePartialSpecialization( id ); - ((CPPClassTemplate)template).addPartialSpecialization( (ICPPClassTemplatePartialSpecialization) spec ); + if(template instanceof ICPPInternalClassTemplate) + ((ICPPInternalClassTemplate)template).addPartialSpecialization( (ICPPClassTemplatePartialSpecialization) spec ); return spec; } @@ -1481,8 +1482,8 @@ public class CPPTemplates { } } - if( template instanceof CPPClassTemplate ){ - return ((CPPClassTemplate)template).instantiate( args ); + if( template instanceof ICPPInternalTemplate ){ + return ((ICPPInternalTemplate)template).instantiate( args ); } return template; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTemplate.java new file mode 100644 index 00000000000..965842c5d34 --- /dev/null +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/ICPPInternalClassTemplate.java @@ -0,0 +1,21 @@ +/******************************************************************************* + * Copyright (c) 2007 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * IBM - Initial API and implementation + *******************************************************************************/ +package org.eclipse.cdt.internal.core.dom.parser.cpp; + +import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplatePartialSpecialization; + +/** + * @author aniefer + * + */ +public interface ICPPInternalClassTemplate extends ICPPInternalTemplate { + public void addPartialSpecialization( ICPPClassTemplatePartialSpecialization spec ); +}