mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Merge remote-tracking branch 'cdt/master' into sd90
This commit is contained in:
commit
aabb8f418b
58 changed files with 1995 additions and 389 deletions
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005 Intel Corporation and others.
|
||||
* Copyright (c) 2005, 2012 Intel 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
|
||||
|
@ -11,24 +11,22 @@
|
|||
package org.eclipse.cdt.managedbuilder.core;
|
||||
|
||||
/**
|
||||
* this interface is to be implemented by the tool-integrator to provide some specific
|
||||
* logic for resolving the build path variable values to the build paths
|
||||
* This interface is to be implemented by the tool-integrator to provide some specific
|
||||
* logic for resolving the build path variable values to the build paths.
|
||||
* <br/><br/>
|
||||
* See extension point {@code org.eclipse.cdt.managedbuilder.core.buildDefinitions},
|
||||
* element {@code envVarBuildPath} attribute {@code buildPathResolver}.
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public interface IBuildPathResolver {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param pathType one of the IEnvVarBuildPath.BUILDPATH _xxx
|
||||
* @param variableName represents the name of the variable that holds the build paths
|
||||
* @param variableValue represents the value of the value specified with the
|
||||
* @param variableValue represents the value of the value specified with the
|
||||
* variableName argument
|
||||
* @param configuration represents configuration for which the build paths are requested
|
||||
*/
|
||||
String[] resolveBuildPaths(
|
||||
int pathType,
|
||||
String variableName,
|
||||
String variableValue,
|
||||
IConfiguration configuration);
|
||||
String[] resolveBuildPaths(int pathType, String variableName, String variableValue, IConfiguration configuration);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2003, 2007 IBM Corporation and others.
|
||||
* Copyright (c) 2003, 2012 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
|
||||
|
@ -24,42 +24,32 @@ public class BuildObject implements IBuildObject {
|
|||
protected Version version = null;
|
||||
protected String managedBuildRevision = null;
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getId()
|
||||
*/
|
||||
@Override
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IBuildObject#setId(java.lang.String)
|
||||
*/
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IBuildObject#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IBuildObject#setName(java.lang.String)
|
||||
*/
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@SuppressWarnings("nls")
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
if (name != null) {
|
||||
return name;
|
||||
} else {
|
||||
return "id=" + id;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -126,7 +116,7 @@ public class BuildObject implements IBuildObject {
|
|||
this.managedBuildRevision = managedBuildRevision;
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* updates revision for this build object and all its children
|
||||
*/
|
||||
public void updateManagedBuildRevision(String revision){
|
||||
|
|
|
@ -165,8 +165,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
ManagedBuildManager.addExtensionToolChain(this);
|
||||
|
||||
// Load the TargetPlatform child
|
||||
IManagedConfigElement[] targetPlatforms =
|
||||
element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
|
||||
IManagedConfigElement[] targetPlatforms = element.getChildren(ITargetPlatform.TARGET_PLATFORM_ELEMENT_NAME);
|
||||
if (targetPlatforms.length < 1 || targetPlatforms.length > 1) {
|
||||
// TODO: Report error
|
||||
}
|
||||
|
@ -175,8 +174,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
|
||||
// Load the Builder child
|
||||
IManagedConfigElement[] builders =
|
||||
element.getChildren(IBuilder.BUILDER_ELEMENT_NAME);
|
||||
IManagedConfigElement[] builders = element.getChildren(IBuilder.BUILDER_ELEMENT_NAME);
|
||||
if (builders.length < 1 || builders.length > 1) {
|
||||
// TODO: Report error
|
||||
}
|
||||
|
@ -342,13 +340,13 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
if (toolChain.isAbstract != null) {
|
||||
isAbstract = new Boolean(toolChain.isAbstract.booleanValue());
|
||||
}
|
||||
if (toolChain.scannerConfigDiscoveryProfileId != null) {
|
||||
scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId);
|
||||
}
|
||||
if (toolChain.scannerConfigDiscoveryProfileId != null) {
|
||||
scannerConfigDiscoveryProfileId = new String(toolChain.scannerConfigDiscoveryProfileId);
|
||||
}
|
||||
|
||||
isRcTypeBasedDiscovery = toolChain.isRcTypeBasedDiscovery;
|
||||
|
||||
supportsManagedBuild = toolChain.supportsManagedBuild;
|
||||
supportsManagedBuild = toolChain.supportsManagedBuild;
|
||||
|
||||
managedIsToolChainSupportedElement = toolChain.managedIsToolChainSupportedElement;
|
||||
managedIsToolChainSupported = toolChain.managedIsToolChainSupported;
|
||||
|
@ -377,9 +375,8 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
String subName;
|
||||
|
||||
if (toolChain.builder.getSuperClass() != null) {
|
||||
subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId(
|
||||
toolChain.builder.getSuperClass().getId(),
|
||||
null);
|
||||
subId = copyIds ? toolChain.builder.getId() :
|
||||
ManagedBuildManager.calculateChildId(toolChain.builder.getSuperClass().getId(), null);
|
||||
subName = toolChain.builder.getSuperClass().getName();
|
||||
} else {
|
||||
subId = copyIds ? toolChain.builder.getId() : ManagedBuildManager.calculateChildId(
|
||||
|
@ -392,32 +389,31 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
// if (toolChain.targetPlatform != null)
|
||||
{
|
||||
ITargetPlatform tpBase = toolChain.getTargetPlatform();
|
||||
if(tpBase != null){
|
||||
ITargetPlatform extTp = tpBase;
|
||||
for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass()) {
|
||||
// empty body, the loop is to find extension element
|
||||
}
|
||||
ITargetPlatform tpBase = toolChain.getTargetPlatform();
|
||||
if(tpBase != null){
|
||||
ITargetPlatform extTp = tpBase;
|
||||
for(;extTp != null && !extTp.isExtensionElement();extTp = extTp.getSuperClass()) {
|
||||
// empty body, the loop is to find extension element
|
||||
}
|
||||
|
||||
String subId;
|
||||
if(copyIds){
|
||||
subId = tpBase.getId();
|
||||
} else {
|
||||
subId = extTp != null ? ManagedBuildManager.calculateChildId(extTp.getId(), null):
|
||||
ManagedBuildManager.calculateChildId(getId(), null);
|
||||
}
|
||||
String subName = tpBase.getName();
|
||||
String subId;
|
||||
if(copyIds){
|
||||
subId = tpBase.getId();
|
||||
} else {
|
||||
subId = extTp != null ? ManagedBuildManager.calculateChildId(extTp.getId(), null):
|
||||
ManagedBuildManager.calculateChildId(getId(), null);
|
||||
}
|
||||
String subName = tpBase.getName();
|
||||
|
||||
// if (toolChain.targetPlatform.getSuperClass() != null) {
|
||||
// subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
|
||||
// subName = toolChain.targetPlatform.getSuperClass().getName();
|
||||
// } else {
|
||||
// subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
|
||||
// subName = toolChain.targetPlatform.getName();
|
||||
// }
|
||||
targetPlatform = new TargetPlatform(this, subId, subName, (TargetPlatform)tpBase);
|
||||
}
|
||||
//
|
||||
// if (toolChain.targetPlatform.getSuperClass() != null) {
|
||||
// subId = toolChain.targetPlatform.getSuperClass().getId() + "." + nnn; //$NON-NLS-1$
|
||||
// subName = toolChain.targetPlatform.getSuperClass().getName();
|
||||
// } else {
|
||||
// subId = toolChain.targetPlatform.getId() + "." + nnn; //$NON-NLS-1$
|
||||
// subName = toolChain.targetPlatform.getName();
|
||||
// }
|
||||
targetPlatform = new TargetPlatform(this, subId, subName, (TargetPlatform)tpBase);
|
||||
}
|
||||
}
|
||||
|
||||
IConfiguration cfg = parentFolderInfo.getParent();
|
||||
|
@ -439,10 +435,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
if(subId == null){
|
||||
if (extTool != null) {
|
||||
subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(extTool.getId(), null);
|
||||
// subName = toolChild.getSuperClass().getName();
|
||||
// subName = toolChild.getSuperClass().getName();
|
||||
} else {
|
||||
subId = copyIds ? toolChild.getId() : ManagedBuildManager.calculateChildId(toolChild.getId(), null);
|
||||
// subName = toolChild.getName();
|
||||
// subName = toolChild.getName();
|
||||
}
|
||||
}
|
||||
// version = ManagedBuildManager.getVersionFromIdAndVersion(tmpId);
|
||||
|
@ -544,10 +540,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(IProjectType.UNUSED_CHILDREN));
|
||||
|
||||
// isAbstract
|
||||
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
|
||||
if (isAbs != null){
|
||||
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
|
||||
}
|
||||
String isAbs = element.getAttribute(IProjectType.IS_ABSTRACT);
|
||||
if (isAbs != null){
|
||||
isAbstract = new Boolean("true".equals(isAbs)); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
// Get the semicolon separated list of IDs of the error parsers
|
||||
errorParserIds = SafeStringInterner.safeIntern(element.getAttribute(ERROR_PARSERS));
|
||||
|
@ -562,10 +558,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
defaultLanguageSettingsProviderIds = element.getAttribute(LANGUAGE_SETTINGS_PROVIDERS);
|
||||
|
||||
// Get the scanner config discovery profile id
|
||||
scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID));
|
||||
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
|
||||
if(tmp != null)
|
||||
isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
|
||||
scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID));
|
||||
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
|
||||
if(tmp != null)
|
||||
isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
|
||||
|
||||
// Get the 'versionsSupported' attribute
|
||||
versionsSupported = SafeStringInterner.safeIntern(element.getAttribute(VERSIONS_SUPPORTED));
|
||||
|
@ -577,9 +573,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
if(tmp != null)
|
||||
supportsManagedBuild = Boolean.valueOf(tmp);
|
||||
|
||||
tmp = element.getAttribute(IS_SYSTEM);
|
||||
if(tmp != null)
|
||||
isTest = Boolean.valueOf(tmp).booleanValue();
|
||||
tmp = element.getAttribute(IS_SYSTEM);
|
||||
if(tmp != null)
|
||||
isTest = Boolean.valueOf(tmp).booleanValue();
|
||||
|
||||
|
||||
// Get the comma-separated list of valid OS
|
||||
|
@ -630,7 +626,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* Initialize the tool-chain information from the XML element
|
||||
* specified in the argument
|
||||
*
|
||||
|
@ -659,7 +655,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
|
||||
// Get the unused children, if any
|
||||
if (element.getAttribute(IProjectType.UNUSED_CHILDREN) != null) {
|
||||
unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(IProjectType.UNUSED_CHILDREN));
|
||||
unusedChildren = SafeStringInterner.safeIntern(element.getAttribute(IProjectType.UNUSED_CHILDREN));
|
||||
}
|
||||
|
||||
// isAbstract
|
||||
|
@ -685,10 +681,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
targetToolIds = SafeStringInterner.safeIntern(element.getAttribute(TARGET_TOOL));
|
||||
}
|
||||
|
||||
// Get the scanner config discovery profile id
|
||||
if (element.getAttribute(SCANNER_CONFIG_PROFILE_ID) != null) {
|
||||
scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID));
|
||||
}
|
||||
// Get the scanner config discovery profile id
|
||||
if (element.getAttribute(SCANNER_CONFIG_PROFILE_ID) != null) {
|
||||
scannerConfigDiscoveryProfileId = SafeStringInterner.safeIntern(element.getAttribute(SCANNER_CONFIG_PROFILE_ID));
|
||||
}
|
||||
|
||||
// Get the 'versionSupported' attribute
|
||||
if (element.getAttribute(VERSIONS_SUPPORTED) != null) {
|
||||
|
@ -731,10 +727,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
|
||||
// Get the scanner config discovery profile id
|
||||
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
|
||||
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
|
||||
if(tmp != null)
|
||||
isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
|
||||
scannerConfigDiscoveryProfileId = element.getAttribute(SCANNER_CONFIG_PROFILE_ID);
|
||||
String tmp = element.getAttribute(RESOURCE_TYPE_BASED_DISCOVERY);
|
||||
if(tmp != null)
|
||||
isRcTypeBasedDiscovery = Boolean.valueOf(tmp);
|
||||
|
||||
nonInternalBuilderId = SafeStringInterner.safeIntern(element.getAttribute(NON_INTERNAL_BUILDER_ID));
|
||||
|
||||
|
@ -774,13 +770,13 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
element.setAttribute(SECONDARY_OUTPUTS, secondaryOutputIds);
|
||||
}
|
||||
|
||||
if (targetToolIds != null) {
|
||||
element.setAttribute(TARGET_TOOL, targetToolIds);
|
||||
}
|
||||
if (targetToolIds != null) {
|
||||
element.setAttribute(TARGET_TOOL, targetToolIds);
|
||||
}
|
||||
|
||||
if (scannerConfigDiscoveryProfileId != null) {
|
||||
element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
|
||||
}
|
||||
if (scannerConfigDiscoveryProfileId != null) {
|
||||
element.setAttribute(SCANNER_CONFIG_PROFILE_ID, scannerConfigDiscoveryProfileId);
|
||||
}
|
||||
|
||||
// versionsSupported
|
||||
if (versionsSupported != null) {
|
||||
|
@ -854,11 +850,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
|
||||
//serialize user-defined macros
|
||||
/* if(userDefinedMacros != null){
|
||||
ICStorageElement macrosElement = element.createChild(StorableMacros.MACROS_ELEMENT_NAME);
|
||||
userDefinedMacros.serialize(macrosElement);
|
||||
}
|
||||
*/
|
||||
// if(userDefinedMacros != null){
|
||||
// ICStorageElement macrosElement = element.createChild(StorableMacros.MACROS_ELEMENT_NAME);
|
||||
// userDefinedMacros.serialize(macrosElement);
|
||||
// }
|
||||
|
||||
// Note: optionPathConverter cannot be specified in a project file because
|
||||
// an IConfigurationElement is needed to load it!
|
||||
if (pathconverterElement != null) {
|
||||
|
@ -883,23 +879,17 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
} catch (Exception e) {
|
||||
// TODO: issue an error message
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* P A R E N T A N D C H I L D H A N D L I N G
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#getConfiguration()
|
||||
*/
|
||||
@Override
|
||||
public IConfiguration getParent() {
|
||||
return config;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#createTargetPlatform(ITargetPlatform, String, String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public ITargetPlatform createTargetPlatform(ITargetPlatform superClass, String id, String name, boolean isExtensionElement) {
|
||||
targetPlatform = new TargetPlatform(this, superClass, id, name, isExtensionElement);
|
||||
|
@ -907,9 +897,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return targetPlatform;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#getTargetPlatform()
|
||||
*/
|
||||
@Override
|
||||
public ITargetPlatform getTargetPlatform() {
|
||||
if (targetPlatform == null) {
|
||||
|
@ -920,9 +907,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return targetPlatform;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalTargetPlatform()
|
||||
*/
|
||||
@Override
|
||||
public void removeLocalTargetPlatform() {
|
||||
if (targetPlatform == null) return;
|
||||
|
@ -930,9 +914,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
setDirty(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#createBuilder(IBuilder, String, String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public IBuilder createBuilder(IBuilder superClass, String id, String name, boolean isExtensionElement) {
|
||||
builder = new Builder(this, superClass, id, name, isExtensionElement);
|
||||
|
@ -944,9 +925,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
this.builder = builder;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#getBuilder()
|
||||
*/
|
||||
@Override
|
||||
public IBuilder getBuilder() {
|
||||
if (builder == null) {
|
||||
|
@ -957,9 +935,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return builder;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#removeLocalBuilder()
|
||||
*/
|
||||
@Override
|
||||
public void removeLocalBuilder() {
|
||||
if (builder == null) return;
|
||||
|
@ -967,9 +942,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
setDirty(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#createTool(ITool, String, String, boolean)
|
||||
*/
|
||||
@Override
|
||||
public ITool createTool(ITool superClass, String id, String name, boolean isExtensionElement) {
|
||||
Tool tool = new Tool(this, superClass, id, name, isExtensionElement);
|
||||
|
@ -978,9 +950,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return tool;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#getTools()
|
||||
*/
|
||||
@Override
|
||||
public ITool[] getTools() {
|
||||
ITool tools[] = getAllTools(false);
|
||||
|
@ -1015,7 +984,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// No Match? Insert it (may be re-ordered)
|
||||
if (j == tools.length) {
|
||||
Tool[] newTools = new Tool[tools.length + 1];
|
||||
|
@ -1071,18 +1040,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return filterUsedTools(all, false);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTool(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ITool getTool(String id) {
|
||||
Tool tool = getToolMap().get(id);
|
||||
return tool;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getToolsBySuperClassId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public ITool[] getToolsBySuperClassId(String id) {
|
||||
List<ITool> retTools = new ArrayList<ITool>();
|
||||
|
@ -1160,15 +1123,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
* M O D E L A T T R I B U T E A C C E S S O R S
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSuperClass()
|
||||
*/
|
||||
@Override
|
||||
public IToolChain getSuperClass() {
|
||||
return (IToolChain)superClass;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
/**
|
||||
* Access function to set the superclass element that is defined in
|
||||
* the base class.
|
||||
*/
|
||||
|
@ -1190,17 +1150,11 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#getName()
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return (name == null && getSuperClass() != null) ? getSuperClass().getName() : name;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#isAbstract()
|
||||
*/
|
||||
@Override
|
||||
public boolean isAbstract() {
|
||||
if (isAbstract != null) {
|
||||
|
@ -1210,9 +1164,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.build.managed.IToolChain#getUnusedChildren()
|
||||
*/
|
||||
@Override
|
||||
public String getUnusedChildren() {
|
||||
if (unusedChildren != null) {
|
||||
|
@ -1221,9 +1172,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return EMPTY_STRING; // Note: no inheritance from superClass
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds()
|
||||
*/
|
||||
@Override
|
||||
public String getErrorParserIds() {
|
||||
String ids = errorParserIds;
|
||||
|
@ -1264,9 +1212,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return ids;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getSecondaryOutputs()
|
||||
*/
|
||||
@Override
|
||||
public IOutputType[] getSecondaryOutputs() {
|
||||
IOutputType[] types = null;
|
||||
|
@ -1297,9 +1242,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return types;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolIds()
|
||||
*/
|
||||
@Override
|
||||
public String getTargetToolIds() {
|
||||
if (targetToolIds == null) {
|
||||
|
@ -1313,9 +1255,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return targetToolIds;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getTargetToolList()
|
||||
*/
|
||||
@Override
|
||||
public String[] getTargetToolList() {
|
||||
String IDs = getTargetToolIds();
|
||||
|
@ -1339,9 +1278,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return targetTools;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserIds(IConfiguration)
|
||||
*/
|
||||
@Override
|
||||
public String getErrorParserIds(IConfiguration config) {
|
||||
String ids = errorParserIds;
|
||||
|
@ -1353,9 +1289,9 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
if (ids == null) {
|
||||
// Collect the error parsers from my children
|
||||
if (builder != null) {
|
||||
ids = builder.getErrorParserIds();
|
||||
}
|
||||
if (builder != null) {
|
||||
ids = builder.getErrorParserIds();
|
||||
}
|
||||
ITool[] tools = config.getFilteredTools();
|
||||
for (int i = 0; i < tools.length; i++) {
|
||||
ITool tool = tools[i];
|
||||
|
@ -1373,9 +1309,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return ids;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getErrorParserList()
|
||||
*/
|
||||
@Override
|
||||
public String[] getErrorParserList() {
|
||||
String parserIDs = getErrorParserIds();
|
||||
|
@ -1424,9 +1357,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return set;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getArchList()
|
||||
*/
|
||||
@Override
|
||||
public String[] getArchList() {
|
||||
if (archList == null) {
|
||||
|
@ -1441,9 +1371,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return archList.toArray(new String[archList.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getOSList()
|
||||
*/
|
||||
@Override
|
||||
public String[] getOSList() {
|
||||
if (osList == null) {
|
||||
|
@ -1458,18 +1385,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return osList.toArray(new String[osList.size()]);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setIsAbstract(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setIsAbstract(boolean b) {
|
||||
isAbstract = new Boolean(b);
|
||||
setDirty(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setErrorParserIds(String)
|
||||
*/
|
||||
@Override
|
||||
public void setErrorParserIds(String ids) {
|
||||
String currentIds = getErrorParserIds();
|
||||
|
@ -1480,9 +1401,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setSecondaryOutputs()
|
||||
*/
|
||||
@Override
|
||||
public void setSecondaryOutputs(String newIds) {
|
||||
if (secondaryOutputIds == null && newIds == null) return;
|
||||
|
@ -1492,9 +1410,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setTargetToolIds()
|
||||
*/
|
||||
@Override
|
||||
public void setTargetToolIds(String newIds) {
|
||||
if (targetToolIds == null && newIds == null) return;
|
||||
|
@ -1504,9 +1419,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setOSList(String[])
|
||||
*/
|
||||
@Override
|
||||
public void setOSList(String[] OSs) {
|
||||
if (osList == null) {
|
||||
|
@ -1520,9 +1432,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
setDirty(true);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setArchList(String[])
|
||||
*/
|
||||
@Override
|
||||
public void setArchList(String[] archs) {
|
||||
if (archList == null) {
|
||||
|
@ -1602,18 +1511,15 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return scannerConfigDiscoveryProfileId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setScannerConfigDiscoveryProfileId(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
@Override
|
||||
public void setScannerConfigDiscoveryProfileId(String profileId) {
|
||||
if (scannerConfigDiscoveryProfileId == null && profileId == null) return;
|
||||
if (scannerConfigDiscoveryProfileId == null ||
|
||||
!scannerConfigDiscoveryProfileId.equals(profileId)) {
|
||||
scannerConfigDiscoveryProfileId = profileId;
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
if (scannerConfigDiscoveryProfileId == null ||
|
||||
!scannerConfigDiscoveryProfileId.equals(profileId)) {
|
||||
scannerConfigDiscoveryProfileId = profileId;
|
||||
setDirty(true);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the pathconverterElement
|
||||
|
@ -1622,9 +1528,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return pathconverterElement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getPathConverter()
|
||||
*/
|
||||
@Override
|
||||
public IOptionPathConverter getOptionPathConverter() {
|
||||
if (optionPathConverter != null) {
|
||||
|
@ -1653,21 +1556,15 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
* O B J E C T S T A T E M A I N T E N A N C E
|
||||
*/
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#isExtensionElement()
|
||||
*/
|
||||
@Override
|
||||
public boolean isExtensionElement() {
|
||||
return isExtensionToolChain;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#isDirty()
|
||||
*/
|
||||
@Override
|
||||
public boolean isDirty() {
|
||||
// This shouldn't be called for an extension tool-chain
|
||||
if (isExtensionToolChain) return false;
|
||||
if (isExtensionToolChain) return false;
|
||||
|
||||
// If I need saving, just say yes
|
||||
if (isDirty) return true;
|
||||
|
@ -1696,9 +1593,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return isDirty;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setDirty(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setDirty(boolean isDirty) {
|
||||
this.isDirty = isDirty;
|
||||
|
@ -1766,15 +1660,12 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
if (extensions.length == 0){
|
||||
tool.setOutputsAttribute(""); //$NON-NLS-1$
|
||||
continue;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getConvertToId()
|
||||
*/
|
||||
@Override
|
||||
public String getConvertToId() {
|
||||
if (convertToId == null) {
|
||||
|
@ -1788,9 +1679,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return convertToId;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setConvertToId(String)
|
||||
*/
|
||||
@Override
|
||||
public void setConvertToId(String convertToId) {
|
||||
if (convertToId == null && this.convertToId == null) return;
|
||||
|
@ -1801,9 +1689,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getVersionsSupported()
|
||||
*/
|
||||
@Override
|
||||
public String getVersionsSupported() {
|
||||
if (versionsSupported == null) {
|
||||
|
@ -1817,9 +1702,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return versionsSupported;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#setVersionsSupported(String)
|
||||
*/
|
||||
@Override
|
||||
public void setVersionsSupported(String versionsSupported) {
|
||||
if (versionsSupported == null && this.versionsSupported == null) return;
|
||||
|
@ -1839,9 +1721,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return managedIsToolChainSupportedElement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#isSupported()
|
||||
*/
|
||||
@Override
|
||||
public boolean isSupported(){
|
||||
if (managedIsToolChainSupported == null) {
|
||||
|
@ -1857,7 +1736,7 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
|
||||
if(managedIsToolChainSupported != null)
|
||||
return managedIsToolChainSupported.isSupported(this,null,null);
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1875,9 +1754,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getEnvironmentVariableSupplier()
|
||||
*/
|
||||
@Override
|
||||
public IConfigurationEnvironmentVariableSupplier getEnvironmentVariableSupplier(){
|
||||
if (environmentVariableSupplier != null) {
|
||||
|
@ -1895,19 +1771,19 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return null;
|
||||
}
|
||||
|
||||
/*
|
||||
* this method is called by the UserDefinedMacroSupplier to obtain user-defined
|
||||
* macros available for this tool-chain
|
||||
*/
|
||||
/* public StorableMacros getUserDefinedMacros(){
|
||||
if(isExtensionToolChain)
|
||||
return null;
|
||||
// /*
|
||||
// * this method is called by the UserDefinedMacroSupplier to obtain user-defined
|
||||
// * macros available for this tool-chain
|
||||
// */
|
||||
// public StorableMacros getUserDefinedMacros(){
|
||||
// if(isExtensionToolChain)
|
||||
// return null;
|
||||
//
|
||||
// if(userDefinedMacros == null)
|
||||
// userDefinedMacros = new StorableMacros();
|
||||
// return userDefinedMacros;
|
||||
// }
|
||||
|
||||
if(userDefinedMacros == null)
|
||||
userDefinedMacros = new StorableMacros();
|
||||
return userDefinedMacros;
|
||||
}
|
||||
*/
|
||||
// public StorableEnvironment getUserDefinedEnvironment(){
|
||||
// if(isExtensionToolChain)
|
||||
// return null;
|
||||
|
@ -1936,9 +1812,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
}
|
||||
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.core.IToolChain#getBuildMacroSupplier()
|
||||
*/
|
||||
@Override
|
||||
public IConfigurationBuildMacroSupplier getBuildMacroSupplier(){
|
||||
if (buildMacroSupplier != null) {
|
||||
|
@ -2139,9 +2012,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return currentMbsVersionConversionElement;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.internal.core.BuildObject#updateManagedBuildRevision(java.lang.String)
|
||||
*/
|
||||
@Override
|
||||
public void updateManagedBuildRevision(String revision){
|
||||
super.updateManagedBuildRevision(revision);
|
||||
|
@ -2153,9 +2023,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
builder.updateManagedBuildRevision(revision);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.internal.core.HoldsOptions#needsRebuild()
|
||||
*/
|
||||
@Override
|
||||
public boolean needsRebuild() {
|
||||
if(rebuildState)
|
||||
|
@ -2170,9 +2037,6 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
return super.needsRebuild();
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.managedbuilder.internal.core.HoldsOptions#setRebuildState(boolean)
|
||||
*/
|
||||
@Override
|
||||
public void setRebuildState(boolean rebuild) {
|
||||
if(isExtensionElement() && rebuild)
|
||||
|
@ -2643,10 +2507,10 @@ public class ToolChain extends HoldsOptions implements IToolChain, IMatchKeyProv
|
|||
} else {
|
||||
String version = ManagedBuildManager.getVersionFromIdAndVersion(getId());
|
||||
if(version != null){
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(name);
|
||||
buf.append(" (v").append(version).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
name = buf.toString();
|
||||
StringBuffer buf = new StringBuffer();
|
||||
buf.append(name);
|
||||
buf.append(" (v").append(version).append(")"); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
name = buf.toString();
|
||||
}
|
||||
}
|
||||
return name;
|
||||
|
|
|
@ -12,35 +12,40 @@ package org.eclipse.cdt.managedbuilder.internal.envvar;
|
|||
|
||||
import org.eclipse.cdt.core.envvar.EnvironmentVariable;
|
||||
import org.eclipse.cdt.core.envvar.IEnvironmentVariable;
|
||||
import org.eclipse.cdt.internal.core.envvar.EnvironmentVariableManager;
|
||||
import org.eclipse.cdt.managedbuilder.envvar.IBuildEnvironmentVariable;
|
||||
|
||||
/**
|
||||
* a trivial implementation of the IBuildEnvironmentVariable
|
||||
*
|
||||
*
|
||||
* @since 3.0
|
||||
*/
|
||||
public class BuildEnvVar extends EnvironmentVariable implements IBuildEnvironmentVariable {
|
||||
public BuildEnvVar(String name, String value, int op, String delimiter){
|
||||
super(name, value, op, delimiter);
|
||||
}
|
||||
|
||||
protected BuildEnvVar(){
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
public BuildEnvVar(String name){
|
||||
super(name);
|
||||
}
|
||||
|
||||
|
||||
public BuildEnvVar(String name, String value){
|
||||
super(name, value);
|
||||
super(name, value);
|
||||
}
|
||||
|
||||
public BuildEnvVar(String name, String value, String delimiter){
|
||||
super(name, value, delimiter);
|
||||
super(name, value, delimiter);
|
||||
}
|
||||
|
||||
|
||||
public BuildEnvVar(String name, String value, int op){
|
||||
super(name, value, op, EnvironmentVariableManager.getDefault().getDefaultDelimiter());
|
||||
}
|
||||
|
||||
public BuildEnvVar(String name, String value, int op, String delimiter){
|
||||
super(name, value, op, delimiter);
|
||||
}
|
||||
|
||||
public BuildEnvVar(IEnvironmentVariable var){
|
||||
super(var);
|
||||
super(var);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,7 +38,7 @@ public interface IBuildMacroProvider{
|
|||
* @param contextData represents the additional data needed by the Build Macro Provider
|
||||
* and Macro Suppliers in order to obtain the macro value. The type of the context data
|
||||
* differs depending on the context type and can be one of the following:
|
||||
* 1. IFileContextData interface � used to represent currently selected file context
|
||||
* 1. IFileContextData interface - used to represent currently selected file context
|
||||
* the IFileContextData interface is defined as follows:
|
||||
* public interface IFileContextData{
|
||||
* IFile getFile();
|
||||
|
@ -46,13 +46,13 @@ public interface IBuildMacroProvider{
|
|||
* }
|
||||
* NOTE: the IFileContextData is passed that represents the current file and the option
|
||||
* for that file because Macro Value Provider needs to know what option should be used
|
||||
* as a context in case macro is not found for �current file� context
|
||||
* as a context in case macro is not found for "current file" context
|
||||
* 2. IOptionContextData interface used to represent the currently selected option context
|
||||
* 3. IConfiguration � used to represent the currently selected configuration context
|
||||
* 4. IProject � used to represent current project context
|
||||
* 5. IWorkspace � used to represent current workspace context
|
||||
* 6. null � to represent the CDT and Eclipse installation context
|
||||
* 7. null � to represent process environment context
|
||||
* 3. IConfiguration - used to represent the currently selected configuration context
|
||||
* 4. IProject - used to represent current project context
|
||||
* 5. IWorkspace - used to represent current workspace context
|
||||
* 6. null - to represent the CDT and Eclipse installation context
|
||||
* 7. null - to represent process environment context
|
||||
* @param includeParentContexts specifies whether lower-precedence context macros should
|
||||
* be included
|
||||
*/
|
||||
|
@ -107,7 +107,7 @@ public interface IBuildMacroProvider{
|
|||
* expanded to. If null the BuildMacroException is thrown in case the string to be resolved
|
||||
* references inexistent macros
|
||||
* @param listDelimiter if not null, StringList macros are expanded as
|
||||
* �<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>�
|
||||
* "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>"
|
||||
* otherwise the BuildMacroException is thrown in case the string to be resolved references
|
||||
* string-list macros
|
||||
* @param contextType context from which the macro search should be started
|
||||
|
@ -157,7 +157,7 @@ public interface IBuildMacroProvider{
|
|||
* expanded to. If null the BuildMacroException is thrown in case the string to be resolved
|
||||
* references inexistent macros
|
||||
* @param listDelimiter if not null, StringList macros are expanded as
|
||||
* �<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>�
|
||||
* "<value_1>< listDelimiter ><value_2>< listDelimiter > ... <value_n>"
|
||||
* otherwise the BuildMacroException is thrown in case the string to be resolved references
|
||||
* string-list macros
|
||||
* @param contextType context from which the macro search should be started
|
||||
|
@ -200,7 +200,7 @@ public interface IBuildMacroProvider{
|
|||
/**
|
||||
*
|
||||
* @return true if the specified expression can be treated as StringList
|
||||
* 1. The string value is �${<some_StringList_Macro_name>}�
|
||||
* 1. The string value is "${<some_StringList_Macro_name>}"
|
||||
*/
|
||||
public boolean isStringListValue(String value, int contextType, Object contextData)
|
||||
throws BuildMacroException;
|
||||
|
@ -213,7 +213,7 @@ public interface IBuildMacroProvider{
|
|||
* The BuildMacroException will contain the human-readable string describing
|
||||
* the inconsistency and the array of the IBuildMacro interfaces that will represent the macros that
|
||||
* caused the inconsistency. This information will be used in the UI to notify the user about
|
||||
* the macro inconsistencies (see also the �User interface for viewing and editing Build Macros�
|
||||
* the macro inconsistencies (see also the "User interface for viewing and editing Build Macros"
|
||||
* section of this design)
|
||||
*/
|
||||
public void checkIntegrity(int contextType,
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface IConfigurationBuildMacroSupplier {
|
|||
* @param configuration configuration
|
||||
* @param provider the instance of the build macro provider to be used for querying the
|
||||
* build macros from within the supplier. The supplier should use this provider to obtain
|
||||
* the already defined build macros instead of using the �default� provider returned by the
|
||||
* the already defined build macros instead of using the "default" provider returned by the
|
||||
* ManagedBuildManager.getBuildMacroProvider().
|
||||
* The provider passed to a supplier will ignore searching macros for the levels
|
||||
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||
|
@ -46,7 +46,7 @@ public interface IConfigurationBuildMacroSupplier {
|
|||
* @param configuration configuration
|
||||
* @param provider the instance of the build macro provider to be used for querying the
|
||||
* build macros from within the supplier. The supplier should use this provider to obtain
|
||||
* the already defined build macros instead of using the �default� provider returned by the
|
||||
* the already defined build macros instead of using the "default" provider returned by the
|
||||
* ManagedBuildManager.getBuildMacroProvider().
|
||||
* The provider passed to a supplier will ignore searching macros for the levels
|
||||
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||
|
|
|
@ -26,7 +26,7 @@ public interface IProjectBuildMacroSupplier {
|
|||
* @param project the instance of the managed project
|
||||
* @param provider the instance of the build macro provider to be used for querying the
|
||||
* build macros from within the supplier. The supplier should use this provider to obtain
|
||||
* the already defined build macros instead of using the �default� provider returned by the
|
||||
* the already defined build macros instead of using the "default" provider returned by the
|
||||
* ManagedBuildManager.getBuildMacroProvider().
|
||||
* The provider passed to a supplier will ignore searching macros for the levels
|
||||
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||
|
@ -46,7 +46,7 @@ public interface IProjectBuildMacroSupplier {
|
|||
* @param project the instance of the managed project
|
||||
* @param provider the instance of the build macro provider to be used for querying the
|
||||
* build macros from within the supplier. The supplier should use this provider to obtain
|
||||
* the already defined build macros instead of using the �default� provider returned by the
|
||||
* the already defined build macros instead of using the "default" provider returned by the
|
||||
* ManagedBuildManager.getBuildMacroProvider().
|
||||
* The provider passed to a supplier will ignore searching macros for the levels
|
||||
* higher than the current supplier level, will query only the lower-precedence suppliers
|
||||
|
|
|
@ -73,20 +73,20 @@ import org.eclipse.core.runtime.IPath;
|
|||
* We can use this to ensure that the dependency files are up to date
|
||||
* by adding rules to the make file for generating the dependency files.
|
||||
* These rules are returned by the call to getDependencyCommands.
|
||||
* However, this has a significant problem when we don�t want to build
|
||||
* the build target, but only want to �clean� the configuration,
|
||||
* However, this has a significant problem when we don't want to build
|
||||
* the build target, but only want to "clean" the configuration,
|
||||
* for example. If we invoke make just to clean the configuration,
|
||||
* make will still update the dependency files if necessary, thereby
|
||||
* re-generating the dependency files only to immediately delete them.
|
||||
* The workaround suggested by the make documentation is to check for
|
||||
* an invocation using the �clean� target, and to not include the
|
||||
* an invocation using the "clean" target, and to not include the
|
||||
* dependency files it that case. For example,
|
||||
*
|
||||
* ifneq ($(MAKECMDGOALS),clean)
|
||||
* include $(DEPS)
|
||||
* endif
|
||||
*
|
||||
* The restriction with this is that it only works if �clean� is the only
|
||||
* The restriction with this is that it only works if "clean" is the only
|
||||
* target specified on the make command line. Therefore, the build
|
||||
* "clean" step must be invoked separately.
|
||||
*/
|
||||
|
|
|
@ -366,6 +366,14 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
assertEquals(num, count);
|
||||
}
|
||||
|
||||
protected void assertSameType(IType expected, IType actual) {
|
||||
assertNotNull(expected);
|
||||
assertNotNull(actual);
|
||||
assertTrue("Expected same types, but the types were: '" +
|
||||
ASTTypeUtil.getType(expected, false) + "' and '" + ASTTypeUtil.getType(actual, false) + "'",
|
||||
expected.isSameType(actual));
|
||||
}
|
||||
|
||||
protected void isExpressionStringEqual(IASTInitializerClause exp, String str) {
|
||||
String expressionString = ASTStringUtil.getExpressionString((IASTExpression) exp);
|
||||
assertEquals(str, expressionString);
|
||||
|
@ -526,7 +534,25 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
binding instanceof IProblemBinding);
|
||||
return (IProblemBinding) binding;
|
||||
}
|
||||
|
||||
|
||||
public IProblemBinding assertProblem(String context, int len, int problemId) {
|
||||
IProblemBinding problemBinding = assertProblem(context, len);
|
||||
assertEquals(problemId, problemBinding.getID());
|
||||
return problemBinding;
|
||||
}
|
||||
|
||||
public IProblemBinding assertProblem(String context, String name) {
|
||||
IBinding binding= binding(context, name);
|
||||
assertTrue("Non-ProblemBinding for name: " + name, binding instanceof IProblemBinding);
|
||||
return (IProblemBinding) binding;
|
||||
}
|
||||
|
||||
public IProblemBinding assertProblem(String context, String name, int problemId) {
|
||||
IProblemBinding problemBinding = assertProblem(context, name);
|
||||
assertEquals(problemId, problemBinding.getID());
|
||||
return problemBinding;
|
||||
}
|
||||
|
||||
public <T extends IBinding> T assertNonProblem(String section, int len) {
|
||||
if (len <= 0)
|
||||
len= section.length() + len;
|
||||
|
|
|
@ -259,6 +259,12 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals(declNames.length, i);
|
||||
assertEquals(defNames.length, j);
|
||||
}
|
||||
|
||||
protected void assertSameType(IType first, IType second){
|
||||
assertNotNull(first);
|
||||
assertNotNull(second);
|
||||
assertTrue("Expected types to be the same, but first was: '" + first.toString() + "' and second was: '" + second + "'", first.isSameType(second));
|
||||
}
|
||||
|
||||
// #define CURLOPTTYPE_OBJECTPOINT 10000
|
||||
// #define CINIT(name,type,number) CURLOPT_ ## name = CURLOPTTYPE_ ## type + number
|
||||
|
@ -9868,7 +9874,7 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertEquals(expectOverride, declarator.isOverride());
|
||||
assertEquals(expectFinal, declarator.isFinal());
|
||||
}
|
||||
|
||||
|
||||
// struct Base {
|
||||
// };
|
||||
// struct S final : public Base {
|
||||
|
@ -9893,9 +9899,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertInstance(sDefinition, ICPPASTCompositeTypeSpecifier.class);
|
||||
assertTrue(((ICPPASTCompositeTypeSpecifier)sDefinition).isFinal());
|
||||
}
|
||||
|
||||
|
||||
// struct S{
|
||||
|
||||
// struct S {
|
||||
// template<typename T>
|
||||
// void foo(T t) final {
|
||||
// }
|
||||
|
@ -9915,8 +9920,8 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
assertFalse(fooTemplate.isOverride());
|
||||
assertTrue(fooTemplate.isFinal());
|
||||
}
|
||||
|
||||
// void foo(){
|
||||
|
||||
// void foo() {
|
||||
// int final, override;
|
||||
// final = 4;
|
||||
// override = 2;
|
||||
|
@ -9924,17 +9929,17 @@ public class AST2CPPTests extends AST2BaseTest {
|
|||
public void testFinalAndOverrideVariables() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// struct S{
|
||||
|
||||
// struct S {
|
||||
// int i;
|
||||
// };
|
||||
// void foo(struct S final){
|
||||
// void foo(struct S final) {
|
||||
// final.i = 23;
|
||||
// }
|
||||
public void testFinalParameter() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
|
||||
// struct S1 {};
|
||||
// S1 s1;
|
||||
// const int i= 1;
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
* Bryan Wilkinson (QNX)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.parser.tests.ast2;
|
||||
|
||||
|
@ -50,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|||
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IQualifierType;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
|
@ -58,6 +60,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
|
@ -87,6 +91,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
|||
import org.eclipse.cdt.core.parser.util.ObjectMap;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTNameBase;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPInternalUnknownScope;
|
||||
|
@ -6079,7 +6085,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testIsPOD_367993() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
|
||||
// template<typename T, void (T::*M)()> class A {
|
||||
// public:
|
||||
// static void Delegate(void* thiz) { ((T*)thiz->*M)(); }
|
||||
|
@ -6102,7 +6108,7 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
public void testDeductionOfNonTypeTemplateArg_372587() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
|
||||
// template<typename _Functor> void b(_Functor __f) {}
|
||||
// template<typename T, typename V> void f(T __first, T __last, const V& __val) {}
|
||||
// template<typename T> void f(T __first, T __last, const T& __val) {}
|
||||
|
@ -6111,8 +6117,8 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testFunctionSetWithNonMatchingTemplateArgs_379604() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// template <typename T> struct C {
|
||||
// typedef decltype(&T::m) dtm;
|
||||
// };
|
||||
|
@ -6127,8 +6133,8 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testPointerToMemberAsDependentExpression_391001() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// class Memory { };
|
||||
// Memory memory;
|
||||
// template<Memory* m> struct Container {
|
||||
|
@ -6142,8 +6148,8 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testAddressAsTemplateArgument_391190() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// template <typename T> struct CT {
|
||||
// const static int const_min= 1;
|
||||
// };
|
||||
|
@ -6152,5 +6158,575 @@ public class AST2TemplateTests extends AST2BaseTest {
|
|||
// }
|
||||
public void testTemplateIDAmbiguity_393959() throws Exception {
|
||||
parseAndCheckBindings(getAboveComment(), CPP, true);
|
||||
}
|
||||
}
|
||||
|
||||
// template<typename T> class CT {
|
||||
// void m() {
|
||||
// template<typename T> using Alias= T; // nesting level 1
|
||||
// Alias<int> x;
|
||||
// }
|
||||
// };
|
||||
public void testNestedAliasDeclarationNestingLevel() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
|
||||
ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class);
|
||||
ICPPTemplateParameter aliasParameterT= templateParameterAlias.getTemplateParameters()[0];
|
||||
assertEquals(1, aliasParameterT.getTemplateNestingLevel());
|
||||
|
||||
ICPPAliasTemplateInstance aliasIntInstance = bh.assertNonProblem("Alias<int>", ICPPAliasTemplateInstance.class);
|
||||
IType typeOfAliasIntInstance = aliasIntInstance.getType();
|
||||
assertTrue(typeOfAliasIntInstance instanceof ICPPBasicType);
|
||||
assertEquals(((ICPPBasicType)typeOfAliasIntInstance).getKind(), IBasicType.Kind.eInt);
|
||||
|
||||
parseAndCheckBindings(code);
|
||||
}
|
||||
|
||||
// template<typename T> class CT;
|
||||
// template<typename T> using Alias= CT<T>; // nesting level 0
|
||||
// template<typename T> class CT { // nesting level 0
|
||||
// typedef Alias<T> TYPE;
|
||||
// };
|
||||
public void testAliasDeclarationNestingLevel() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
BindingAssertionHelper bh= new BindingAssertionHelper(code, true);
|
||||
|
||||
ICPPAliasTemplate templateParameterAlias = bh.assertNonProblem("Alias=", "Alias", ICPPAliasTemplate.class);
|
||||
ICPPTemplateParameter aliasParameterT = templateParameterAlias.getTemplateParameters()[0];
|
||||
assertEquals(0, aliasParameterT.getTemplateNestingLevel());
|
||||
|
||||
ICPPTemplateDefinition templateCT = bh.assertNonProblem("CT {", "CT", ICPPTemplateDefinition.class);
|
||||
ICPPTemplateParameter templateParameterT = templateCT.getTemplateParameters()[0];
|
||||
assertEquals(0, templateParameterT.getTemplateNestingLevel());
|
||||
|
||||
parseAndCheckBindings(code);
|
||||
}
|
||||
|
||||
// struct S {
|
||||
// int x;
|
||||
// };
|
||||
// using Alias = S;
|
||||
// void foo() {
|
||||
// Alias myA;
|
||||
// myA.x = 42;
|
||||
// }
|
||||
public void testSimpleAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassType S = (ICPPClassType) collector.getName(0).resolveBinding();
|
||||
ICPPField x = (ICPPField) collector.getName(1).resolveBinding();
|
||||
ITypedef Alias = (ITypedef) collector.getName(2).resolveBinding();
|
||||
IFunction foo = (IFunction) collector.getName(4).resolveBinding();
|
||||
IVariable myA = (IVariable) collector.getName(6).resolveBinding();
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, x, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertInstances(collector, foo, 1);
|
||||
assertInstances(collector, myA, 2);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T x;
|
||||
// };
|
||||
// using Alias = S<int>;
|
||||
// void foo() {
|
||||
// Alias myA;
|
||||
// myA.x = 42;
|
||||
// }
|
||||
public void testSpecifiedTemplateAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassType S = (ICPPClassType) collector.getName(1).resolveBinding();
|
||||
ICPPField x = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ITypedef Alias = (ITypedef) collector.getName(4).resolveBinding();
|
||||
IVariable myA = (IVariable) collector.getName(9).resolveBinding();
|
||||
ICPPSpecialization xRef = (ICPPSpecialization) collector.getName(11).resolveBinding();
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertInstances(collector, myA, 2);
|
||||
assertEquals(x, xRef.getSpecializedBinding());
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// using Alias = int;
|
||||
// void foo() {
|
||||
// Alias<float> myA;
|
||||
// myA = 42;
|
||||
// }
|
||||
public void testTemplatedAliasBasicType() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPAliasTemplate Alias = (ICPPAliasTemplate) collector.getName(1).resolveBinding();
|
||||
ICPPAliasTemplateInstance AliasFloatInstance = (ICPPAliasTemplateInstance) collector.getName(3).resolveBinding();
|
||||
assertInstances(collector, Alias, 2);
|
||||
assertSameType(AliasFloatInstance, new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename T>
|
||||
// using TAlias = S<T>;
|
||||
// void foo() {
|
||||
// TAlias<int> myA;
|
||||
// myA.t = 42;
|
||||
// }
|
||||
public void testTemplatedAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassType S = (ICPPClassType) collector.getName(1).resolveBinding();
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPTemplateParameter T = (ICPPTemplateParameter) collector.getName(4).resolveBinding();
|
||||
ICPPTemplateParameter TRef = (ICPPTemplateParameter) collector.getName(8).resolveBinding();
|
||||
ICPPAliasTemplate TAlias = (ICPPAliasTemplate) collector.getName(5).resolveBinding();
|
||||
ICPPVariable myA = (ICPPVariable) collector.getName(12).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(14).resolveBinding();
|
||||
|
||||
assertInstances(collector, S, 2);
|
||||
assertInstances(collector, T, 2);
|
||||
assertEquals(T, TRef);
|
||||
assertInstances(collector, TAlias, 2);
|
||||
assertInstances(collector, myA, 2);
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
ICPPDeferredClassInstance aliasedType = (ICPPDeferredClassInstance) TAlias.getType();
|
||||
assertEquals(S, aliasedType.getClassTemplate());
|
||||
}
|
||||
|
||||
// template<typename T1, typename T2, typename T3>
|
||||
// struct S {
|
||||
// T1 t1;
|
||||
// T2 t2;
|
||||
// T3 t3;
|
||||
// };
|
||||
// template<typename P1, typename P2>
|
||||
// using TAlias = S<int, P2, P1>;
|
||||
// void foo() {
|
||||
// TAlias<bool, float> myA;
|
||||
// myA.t1 = 42;
|
||||
// myA.t2 = 42.0f;
|
||||
// myA.t3 = true;
|
||||
// }
|
||||
public void testTemplatedAliasDeclarationMultipleParameters() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField t1 = (ICPPField) collector.getName(5).resolveBinding();
|
||||
ICPPField t2 = (ICPPField) collector.getName(7).resolveBinding();
|
||||
ICPPField t3 = (ICPPField) collector.getName(9).resolveBinding();
|
||||
|
||||
ICPPTemplateParameter P1 = (ICPPTemplateParameter) collector.getName(10).resolveBinding();
|
||||
ICPPTemplateParameter P2 = (ICPPTemplateParameter) collector.getName(11).resolveBinding();
|
||||
|
||||
ICPPTemplateParameter P1Ref = (ICPPTemplateParameter) collector.getName(16).resolveBinding();
|
||||
ICPPTemplateParameter P2Ref = (ICPPTemplateParameter) collector.getName(15).resolveBinding();
|
||||
|
||||
ICPPAliasTemplateInstance TAliasInstance = (ICPPAliasTemplateInstance) collector.getName(18).resolveBinding();
|
||||
ICPPTemplateInstance aliasedTypeInstance = (ICPPTemplateInstance) TAliasInstance.getType();
|
||||
|
||||
ICPPSpecialization t1Ref = (ICPPSpecialization) collector.getName(22).resolveBinding();
|
||||
ICPPSpecialization t2Ref = (ICPPSpecialization) collector.getName(24).resolveBinding();
|
||||
ICPPSpecialization t3Ref = (ICPPSpecialization) collector.getName(26).resolveBinding();
|
||||
|
||||
assertEquals(P1, P1Ref);
|
||||
assertEquals(P2, P2Ref);
|
||||
|
||||
assertEquals(t1, t1Ref.getSpecializedBinding());
|
||||
assertEquals(t2, t2Ref.getSpecializedBinding());
|
||||
assertEquals(t3, t3Ref.getSpecializedBinding());
|
||||
assertSameType(new CPPBasicType(IBasicType.Kind.eInt, 0), aliasedTypeInstance.getTemplateArguments()[0].getTypeValue());
|
||||
assertSameType(new CPPBasicType(IBasicType.Kind.eFloat, 0), aliasedTypeInstance.getTemplateArguments()[1].getTypeValue());
|
||||
assertSameType(new CPPBasicType(IBasicType.Kind.eBoolean, 0), aliasedTypeInstance.getTemplateArguments()[2].getTypeValue());
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename P>
|
||||
// using TAlias = S<P>;
|
||||
// void foo() {
|
||||
// TAlias<S<int> > myA;
|
||||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasDeclarationTemplateArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
IType TAliasSInt = (IType) collector.getName(10).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(16).resolveBinding();
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertSameType(TAliasSInt, (IType)tRef.getOwner());
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename P>
|
||||
// using TAlias = S<P>;
|
||||
// void foo() {
|
||||
// S<TAlias<int> > myA;
|
||||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasAsTemplateArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPTemplateInstance STAliasInt = (ICPPTemplateInstance) collector.getName(10).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(16).resolveBinding();
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertEquals(STAliasInt, tRef.getOwner());
|
||||
}
|
||||
|
||||
// template<int Size, int Size2>
|
||||
// struct S {
|
||||
// int buff [Size];
|
||||
// };
|
||||
// template<int SizeArg, int SizeArg2>
|
||||
// using TAlias = S<SizeArg2, SizeArg>;
|
||||
// void foo() {
|
||||
// TAlias<5, 4> myA;
|
||||
// myA.buff[0] = 1;
|
||||
// }
|
||||
public void testTemplatedAliasDeclarationValueArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField buff = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPSpecialization buffRef = (ICPPSpecialization) collector.getName(17).resolveBinding();
|
||||
|
||||
assertEquals(buff, buffRef.getSpecializedBinding());
|
||||
assertEquals(buffRef.getTemplateParameterMap().getArgument(0).getNonTypeValue().numericalValue(), new Long(4));
|
||||
assertEquals(buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numericalValue(), new Long(5));
|
||||
}
|
||||
|
||||
// template<typename T, int Size>
|
||||
// struct S {
|
||||
// T buff [Size];
|
||||
// };
|
||||
// template<typename Type = int, int Items = 5>
|
||||
// using TAlias = S<Type, Items>;
|
||||
// void foo() {
|
||||
// TAlias<> myA;
|
||||
// myA.buff[0] = 1;
|
||||
// }
|
||||
public void testTemplatedAliasDefaultArguments() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPField buff = (ICPPField) collector.getName(4).resolveBinding();
|
||||
ICPPAliasTemplateInstance myA = (ICPPAliasTemplateInstance) collector.getName(14).resolveBinding();
|
||||
ICPPSpecialization buffRef = (ICPPSpecialization) collector.getName(18).resolveBinding();
|
||||
|
||||
assertEquals(buff, buffRef.getSpecializedBinding());
|
||||
assertSameType(buffRef.getTemplateParameterMap().getArgument(0).getTypeValue(), new CPPBasicType(IBasicType.Kind.eInt, 0));
|
||||
assertEquals(buffRef.getTemplateParameterMap().getArgument(1).getNonTypeValue().numericalValue(), new Long(5));
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename A, typename A2>
|
||||
// using TAlias = S<S<A2> >;
|
||||
// void foo() {
|
||||
// TAlias<float, int> myA;
|
||||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasTemplateArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(17).resolveBinding();
|
||||
ICPPClassSpecialization Sint = (ICPPClassSpecialization) collector.getName(18).resolveBinding();
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename A>
|
||||
// using TAlias = S<A>;
|
||||
// void bar(TAlias<int> arg){
|
||||
// }
|
||||
// void foo() {
|
||||
// TAlias<int> myA;
|
||||
// bar(myA);
|
||||
// S<int> myS;
|
||||
// bar(myS);
|
||||
// }
|
||||
public void testTemplatedAliasAsFunctionParameter() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPFunction bar = (ICPPFunction) collector.getName(9).resolveBinding();
|
||||
ICPPFunction barRefAlias = (ICPPFunction) collector.getName(17).resolveBinding();
|
||||
ICPPFunction barRefSInt = (ICPPFunction) collector.getName(22).resolveBinding();
|
||||
|
||||
assertEquals(bar, barRefAlias);
|
||||
assertEquals(bar, barRefSInt);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename A>
|
||||
// using TAlias = S<A>;
|
||||
// void bar(S<int> arg){
|
||||
// }
|
||||
// void foo() {
|
||||
// TAlias<int> myA;
|
||||
// bar(myA);
|
||||
// }
|
||||
public void testTemplatedAliasAsFunctionArgument() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPFunction bar = (ICPPFunction) collector.getName(9).resolveBinding();
|
||||
ICPPFunction barRefAlias = (ICPPFunction) collector.getName(17).resolveBinding();
|
||||
|
||||
assertEquals(bar, barRefAlias);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename A>
|
||||
// using TAlias = S<A>;
|
||||
// void bar(S<int> arg){
|
||||
// }
|
||||
// void bar(TAlias<int> arg){
|
||||
// }
|
||||
public void testTemplatedAliasRedefinitionOfSameFunction() throws Exception {
|
||||
BindingAssertionHelper bh= getAssertionHelper();
|
||||
bh.assertNonProblem("bar(S", "bar", ICPPFunction.class);
|
||||
bh.assertProblem("bar(TAlias", "bar", ISemanticProblem.BINDING_INVALID_REDEFINITION);
|
||||
}
|
||||
|
||||
// template<typename VT, typename Allocator> struct vector{};
|
||||
// template<typename AT> struct Alloc{};
|
||||
// template<typename T> using Vec = vector<T, Alloc<T> >;
|
||||
// template<template<typename> class TT>
|
||||
// void f(TT<int>);
|
||||
// template<template<typename, typename> class TT>
|
||||
// void g(TT<int, Alloc<int> >);
|
||||
// void foo(){
|
||||
// Vec<int> v;
|
||||
// g(v);
|
||||
// f(v);
|
||||
// }
|
||||
public void testTemplatedAliasDeduction() throws Exception {
|
||||
BindingAssertionHelper bh= getAssertionHelper();
|
||||
bh.assertNonProblem("g(v)", "g", ICPPFunction.class);
|
||||
bh.assertProblem("f(v)", "f", ISemanticProblem.BINDING_NOT_FOUND);
|
||||
}
|
||||
|
||||
// using function = void (&)(int);
|
||||
// void foo(int) {
|
||||
// function f = &foo;
|
||||
// }
|
||||
public void testSimpleFunctionAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ITypedef function = (ITypedef) collector.getName(0).resolveBinding();
|
||||
ICPPFunction foo = (ICPPFunction) collector.getName(2).resolveBinding();
|
||||
|
||||
assertInstances(collector, function, 2);
|
||||
assertInstances(collector, foo, 2);
|
||||
assertSameType(((ICPPReferenceType)function.getType()).getType(), foo.getType());
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename T>
|
||||
// using TAlias = S<T>&;
|
||||
// void foo() {
|
||||
// S<int> myS;
|
||||
// TAlias<int> myA = myS;
|
||||
// myA.t = 42;
|
||||
// }
|
||||
public void testTemplatedAliasForTemplateReference() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
ICPPClassSpecialization SInt = (ICPPClassSpecialization) collector.getName(10).resolveBinding();
|
||||
ICPPAliasTemplateInstance TAliasInt = (ICPPAliasTemplateInstance) collector.getName(13).resolveBinding();
|
||||
assertSameType(new CPPReferenceType(SInt, false), TAliasInt);
|
||||
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// using function = void (int);
|
||||
// void foo(int) {
|
||||
// function<int> f = &foo;
|
||||
// }
|
||||
public void testSimpleFunctionTemplateAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPAliasTemplate function = (ICPPAliasTemplate) collector.getName(1).resolveBinding();
|
||||
ICPPFunction foo = (ICPPFunction) collector.getName(3).resolveBinding();
|
||||
ICPPAliasTemplateInstance functionInt = (ICPPAliasTemplateInstance) collector.getName(5).resolveBinding();
|
||||
|
||||
assertInstances(collector, function, 2);
|
||||
assertInstances(collector, foo, 2);
|
||||
assertSameType(foo.getType(),functionInt);
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// using function = void (&)(int);
|
||||
// void foo(int) {
|
||||
// function<int> f = &foo;
|
||||
// }
|
||||
public void testSimpleFunctionReferenceTemplateAliasDeclaration() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPAliasTemplate function = (ICPPAliasTemplate) collector.getName(1).resolveBinding();
|
||||
ICPPFunction foo = (ICPPFunction) collector.getName(3).resolveBinding();
|
||||
ICPPAliasTemplateInstance functionInt = (ICPPAliasTemplateInstance) collector.getName(5).resolveBinding();
|
||||
|
||||
assertInstances(collector, function, 2);
|
||||
assertInstances(collector, foo, 2);
|
||||
assertSameType(new CPPReferenceType(foo.getType(), false),functionInt.getType());
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<template<typename> class TA>
|
||||
// using TAlias = S<TA>;
|
||||
// void foo() {
|
||||
// TAlias<S<int> > myA;
|
||||
// myA.t = S<int>();
|
||||
// }
|
||||
public void testTemplatedAliasTemplateParameter() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPField t = (ICPPField) collector.getName(3).resolveBinding();
|
||||
ICPPSpecialization tRef = (ICPPSpecialization) collector.getName(17).resolveBinding();
|
||||
ICPPClassSpecialization Sint = (ICPPClassSpecialization) collector.getName(18).resolveBinding();
|
||||
|
||||
assertEquals(t, tRef.getSpecializedBinding());
|
||||
assertSameType(tRef.getTemplateParameterMap().getArgument(0).getTypeValue(), Sint);
|
||||
}
|
||||
|
||||
// namespace NS {
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename T>
|
||||
// using Alias = S<T>;
|
||||
// }
|
||||
// using namespace NS;
|
||||
// Alias<int> intAlias;
|
||||
public void testAliasDeclarationContext() throws Exception {
|
||||
final String code = getAboveComment();
|
||||
IASTTranslationUnit ast = parseAndCheckBindings(code);
|
||||
CPPNameCollector collector = new CPPNameCollector();
|
||||
ast.accept(collector);
|
||||
|
||||
ICPPAliasTemplateInstance AliasInt = (ICPPAliasTemplateInstance) collector.getName(11).resolveBinding();
|
||||
assertEquals("Alias<int>", AliasInt.getName());
|
||||
assertEquals("NS", AliasInt.getQualifiedName()[0]);
|
||||
assertEquals("Alias<int>", AliasInt.getQualifiedName()[1]);
|
||||
|
||||
ICPPNamespace namespaceNS = (ICPPNamespace) collector.getName(0).resolveBinding();
|
||||
assertEquals(namespaceNS, AliasInt.getOwner());
|
||||
|
||||
assertTrue(AliasInt.getScope() instanceof ICPPTemplateScope);
|
||||
}
|
||||
|
||||
// template<typename U>
|
||||
// struct A {
|
||||
// template<typename V>
|
||||
// struct rebind {
|
||||
// typedef A<V> other;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename T, typename U>
|
||||
// struct B {
|
||||
// typedef typename T::template rebind<U>::other type1;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct C {
|
||||
// template<typename U>
|
||||
// using rebind2 = typename B<T, U>::type1;
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct D : C<T> {
|
||||
// typedef int type0;
|
||||
//
|
||||
// template<typename U>
|
||||
// struct rebind {
|
||||
// typedef typename C<T>::template rebind2<U> other2;
|
||||
// };
|
||||
// };
|
||||
//
|
||||
// template<typename T>
|
||||
// struct E {
|
||||
// typedef typename D<T>::template rebind<int>::other2 type2;
|
||||
// typedef D<type2> type3;
|
||||
// typedef typename type3::type0 type;
|
||||
// };
|
||||
//
|
||||
// void f(int x);
|
||||
//
|
||||
// void test(E<A<int>>::type v) {
|
||||
// f(v);
|
||||
// }
|
||||
public void testAliasTemplate_395026() throws Exception {
|
||||
parseAndCheckBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -425,4 +425,11 @@ public class GCCCompleteParseExtensionsTest extends AST2BaseTest {
|
|||
parseGCC(code);
|
||||
parseGPP(code);
|
||||
}
|
||||
|
||||
// __float128 f;
|
||||
public void test__float128() throws Exception {
|
||||
String code= getAboveComment();
|
||||
parseGCC(code);
|
||||
parseGPP(code);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2046,4 +2046,19 @@ public class IndexCPPTemplateResolutionTest extends IndexBindingResolutionTestBa
|
|||
public void testMemberOfTemplateTemplateParameter_Bug381824() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<typename T>
|
||||
// using TAlias = S<T>;
|
||||
|
||||
// void foo() {
|
||||
// TAlias<int> myA;
|
||||
// myA.t = 42;
|
||||
// }
|
||||
public void testAliasTemplate() throws Exception {
|
||||
checkBindings();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.pdom.tests;
|
||||
|
||||
|
@ -21,10 +22,16 @@ import org.eclipse.cdt.core.dom.ast.IField;
|
|||
import org.eclipse.cdt.core.dom.ast.IFunctionType;
|
||||
import org.eclipse.cdt.core.dom.ast.IPointerType;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateTypeParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPVariable;
|
||||
import org.eclipse.cdt.core.index.IndexFilter;
|
||||
|
@ -34,7 +41,9 @@ import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
|||
import org.eclipse.cdt.core.testplugin.CTestPlugin;
|
||||
import org.eclipse.cdt.core.testplugin.util.TestSourceReader;
|
||||
import org.eclipse.cdt.internal.core.CCoreInternals;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPDeferredClassInstance;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexFragmentBinding;
|
||||
import org.eclipse.cdt.internal.core.pdom.PDOM;
|
||||
import org.eclipse.cdt.internal.core.pdom.indexer.IndexerPreferences;
|
||||
|
@ -316,6 +325,245 @@ public class CPPClassTemplateTests extends PDOMTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
// template<typename xT>
|
||||
// struct S {
|
||||
// xT x;
|
||||
// };
|
||||
// template<typename aT>
|
||||
// using A = S<aT>;
|
||||
public void testSimpleAliasDefinition() throws Exception {
|
||||
assertDeclarationCount(pdom, "A", 1);
|
||||
IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingA.length);
|
||||
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
|
||||
ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
|
||||
ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
|
||||
assertEquals(1, aliasParameters.length);
|
||||
|
||||
assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter);
|
||||
ICPPTemplateTypeParameter templateParameterAT= (ICPPTemplateTypeParameter) aliasParameters[0];
|
||||
assertEquals("aT", templateParameterAT.getName());
|
||||
assertNull(templateParameterAT.getDefault());
|
||||
assertEquals(0, templateParameterAT.getTemplateNestingLevel());
|
||||
|
||||
assertDeclarationCount(pdom, "S", 1);
|
||||
IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
IType aliasedType = aliasA.getType();
|
||||
assertTrue(aliasedType instanceof ICPPDeferredClassInstance);
|
||||
ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType;
|
||||
assertEquals(1, bindingA.length);
|
||||
assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding());
|
||||
}
|
||||
|
||||
// struct D {
|
||||
// };
|
||||
// template<typename sT1, typename sT2>
|
||||
// struct S {
|
||||
// xT x;
|
||||
// };
|
||||
// template<typename aT1, typename aT2 = D>
|
||||
// using A = S<aT1, aT2>;
|
||||
public void testSimpleAliasDefinitionDefaultTemplateArgument() throws Exception {
|
||||
assertDeclarationCount(pdom, "A", 1);
|
||||
IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingA.length);
|
||||
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
|
||||
ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
|
||||
ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
|
||||
assertEquals(2, aliasParameters.length);
|
||||
|
||||
assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter);
|
||||
ICPPTemplateTypeParameter templateParameterAT1= (ICPPTemplateTypeParameter) aliasParameters[0];
|
||||
assertEquals("aT1", templateParameterAT1.getName());
|
||||
assertNull(templateParameterAT1.getDefault());
|
||||
assertEquals(0, templateParameterAT1.getTemplateNestingLevel());
|
||||
|
||||
assertTrue(aliasParameters[1] instanceof ICPPTemplateTypeParameter);
|
||||
ICPPTemplateTypeParameter templateParameterAT2= (ICPPTemplateTypeParameter) aliasParameters[1];
|
||||
assertEquals("aT2", templateParameterAT2.getName());
|
||||
IType aT2DefaultArgument = templateParameterAT2.getDefault();
|
||||
assertNotNull(aT2DefaultArgument);
|
||||
assertDeclarationCount(pdom, "D", 1);
|
||||
IIndexFragmentBinding[] bindingD= pdom.findBindings(new char[][] {{'D'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingD.length);
|
||||
assertTrue(bindingD[0] instanceof IType);
|
||||
assertTrue(((IType)bindingD[0]).isSameType(aT2DefaultArgument));
|
||||
assertEquals(0, templateParameterAT2.getTemplateNestingLevel());
|
||||
|
||||
assertDeclarationCount(pdom, "S", 1);
|
||||
IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
IType aliasedType = aliasA.getType();
|
||||
assertTrue(aliasedType instanceof ICPPDeferredClassInstance);
|
||||
ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType;
|
||||
assertEquals(1, bindingS.length);
|
||||
assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding());
|
||||
}
|
||||
|
||||
// template<boolean sT1, int sT2>
|
||||
// struct S {
|
||||
// xT x;
|
||||
// };
|
||||
// template<boolean aT1, int aT2 = 5>
|
||||
// using A = S<aT1, aT2>;
|
||||
public void testSimpleAliasDefinitionValueTemplateArguments() throws Exception {
|
||||
assertDeclarationCount(pdom, "A", 1);
|
||||
IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingA.length);
|
||||
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
|
||||
ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
|
||||
ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
|
||||
assertEquals(2, aliasParameters.length);
|
||||
|
||||
assertTrue(aliasParameters[0] instanceof ICPPTemplateNonTypeParameter);
|
||||
ICPPTemplateNonTypeParameter templateParameterAT1= (ICPPTemplateNonTypeParameter) aliasParameters[0];
|
||||
assertEquals("aT1", templateParameterAT1.getName());
|
||||
assertNull(templateParameterAT1.getDefaultValue());
|
||||
assertEquals(0, templateParameterAT1.getTemplateNestingLevel());
|
||||
|
||||
assertTrue(aliasParameters[1] instanceof ICPPTemplateNonTypeParameter);
|
||||
ICPPTemplateNonTypeParameter templateParameterAT2= (ICPPTemplateNonTypeParameter) aliasParameters[1];
|
||||
assertEquals("aT2", templateParameterAT2.getName());
|
||||
ICPPTemplateArgument aT2DefaultArgument = templateParameterAT2.getDefaultValue();
|
||||
assertNotNull(aT2DefaultArgument);
|
||||
assertTrue(new CPPBasicType(IBasicType.Kind.eInt, 0).isSameType(aT2DefaultArgument.getTypeOfNonTypeValue()));
|
||||
assertEquals(5, aT2DefaultArgument.getNonTypeValue().numericalValue().longValue());
|
||||
assertEquals(0, templateParameterAT2.getTemplateNestingLevel());
|
||||
|
||||
assertDeclarationCount(pdom, "S", 1);
|
||||
IIndexFragmentBinding[] bindingS= pdom.findBindings(new char[][] {{'S'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
IType aliasedType = aliasA.getType();
|
||||
assertTrue(aliasedType instanceof ICPPDeferredClassInstance);
|
||||
ICPPDeferredClassInstance deferredClassInstanceS= (ICPPDeferredClassInstance) aliasedType;
|
||||
assertEquals(1, bindingS.length);
|
||||
assertEquals(bindingS[0], deferredClassInstanceS.getSpecializedBinding());
|
||||
}
|
||||
|
||||
// template<typename T>
|
||||
// struct S {
|
||||
// T t;
|
||||
// };
|
||||
// template<template<typename> class TT>
|
||||
// using A = S<TT>;
|
||||
public void testSimpleAliasTemplateParameter() throws Exception {
|
||||
assertDeclarationCount(pdom, "A", 1);
|
||||
IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingA.length);
|
||||
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
|
||||
ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
|
||||
ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
|
||||
assertEquals(1, aliasParameters.length);
|
||||
|
||||
assertTrue(aliasParameters[0] instanceof ICPPTemplateTemplateParameter);
|
||||
ICPPTemplateTemplateParameter templateParameterTT= (ICPPTemplateTemplateParameter) aliasParameters[0];
|
||||
assertEquals("TT", templateParameterTT.getName());
|
||||
assertNull(templateParameterTT.getDefaultValue());
|
||||
assertEquals(0, templateParameterTT.getTemplateNestingLevel());
|
||||
}
|
||||
|
||||
// struct B{};
|
||||
// template<typename xT>
|
||||
// struct S {
|
||||
// xT x;
|
||||
// };
|
||||
// template<typename aT>
|
||||
// using A = S<aT>;
|
||||
// A<B> aB;
|
||||
// S<B> sB;
|
||||
public void testSimpleAliasReference() throws Exception {
|
||||
assertDeclarationCount(pdom, "A", 1);
|
||||
IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingA.length);
|
||||
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
|
||||
ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
|
||||
ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
|
||||
assertEquals(1, aliasParameters.length);
|
||||
|
||||
assertReferenceCount(pdom, "S", 2);
|
||||
assertReferenceCount(pdom, "A", 1);
|
||||
assertDeclarationCount(pdom, "aB", 1);
|
||||
assertDeclarationCount(pdom, "sB", 1);
|
||||
|
||||
IIndexFragmentBinding[] bindingVarSB= pdom.findBindings(new char[][] {"sB".toCharArray()}, IndexFilter.ALL, npm());
|
||||
assertEquals(1, bindingVarSB.length);
|
||||
assertTrue(bindingVarSB[0] instanceof ICPPVariable);
|
||||
ICPPVariable variableSB = (ICPPVariable) bindingVarSB[0];
|
||||
IType varSBType = variableSB.getType();
|
||||
assertTrue(varSBType instanceof ICPPClassSpecialization);
|
||||
ICPPClassSpecialization templateInstanceSB = (ICPPClassSpecialization) varSBType;
|
||||
|
||||
IIndexFragmentBinding[] bindingVarAB= pdom.findBindings(new char[][] {"aB".toCharArray()}, IndexFilter.ALL, npm());
|
||||
assertEquals(1, bindingVarAB.length);
|
||||
assertTrue(bindingVarAB[0] instanceof ICPPVariable);
|
||||
ICPPVariable variableAB = (ICPPVariable) bindingVarAB[0];
|
||||
IType varABType = variableAB.getType();
|
||||
assertTrue(varABType instanceof ICPPAliasTemplateInstance);
|
||||
ICPPAliasTemplateInstance aliasInstanceAB = (ICPPAliasTemplateInstance) varABType;
|
||||
assertTrue(varABType.isSameType(templateInstanceSB));
|
||||
assertTrue(aliasInstanceAB.getTemplateDefinition().isSameType(aliasA));
|
||||
assertEquals("A<B>", aliasInstanceAB.getName());
|
||||
}
|
||||
|
||||
// template<typename T> class CT {
|
||||
// template<typename T> using A= T; // nesting level 1
|
||||
// A<int> x;
|
||||
// };
|
||||
public void testPDOMNestedAliasDeclarationNestingLevel() throws Exception {
|
||||
IIndexFragmentBinding[] bindingCT = pdom.findBindings(new char[][] { "CT".toCharArray() }, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingCT.length);
|
||||
assertTrue(bindingCT[0] instanceof ICPPClassTemplate);
|
||||
ICPPClassTemplate templateCT = (ICPPClassTemplate) bindingCT[0];
|
||||
|
||||
IField[] fields = templateCT.getFields();
|
||||
assertEquals(1, fields.length);
|
||||
IField x = fields[0];
|
||||
IType xType = x.getType();
|
||||
assertTrue(xType instanceof ICPPAliasTemplateInstance);
|
||||
|
||||
ICPPAliasTemplateInstance aliasInstance = (ICPPAliasTemplateInstance) xType;
|
||||
ICPPAliasTemplate alias = aliasInstance.getTemplateDefinition();
|
||||
ICPPTemplateParameter[] aliasParameters = alias.getTemplateParameters();
|
||||
assertEquals(1, aliasParameters.length);
|
||||
ICPPTemplateParameter aliasParameterT = aliasParameters[0];
|
||||
assertEquals(1, aliasParameterT.getTemplateNestingLevel());
|
||||
}
|
||||
|
||||
// template<typename T> class CT;
|
||||
// template<typename T> using A= CT<T>; // nesting level 0
|
||||
// template<typename T> class CT { // nesting level 0
|
||||
// typedef Alias<T> TYPE;
|
||||
// };
|
||||
public void testPDOMAliasDeclarationNestingLevel() throws Exception {
|
||||
assertDeclarationCount(pdom, "A", 1);
|
||||
IIndexFragmentBinding[] bindingA= pdom.findBindings(new char[][] {{'A'}}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingA.length);
|
||||
assertTrue(bindingA[0] instanceof ICPPAliasTemplate);
|
||||
ICPPAliasTemplate aliasA= (ICPPAliasTemplate) bindingA[0];
|
||||
ICPPTemplateParameter[] aliasParameters= aliasA.getTemplateParameters();
|
||||
assertEquals(1, aliasParameters.length);
|
||||
|
||||
assertTrue(aliasParameters[0] instanceof ICPPTemplateTypeParameter);
|
||||
ICPPTemplateTypeParameter templateParameterT= (ICPPTemplateTypeParameter) aliasParameters[0];
|
||||
assertEquals("T", templateParameterT.getName());
|
||||
assertNull(templateParameterT.getDefault());
|
||||
assertEquals(0, templateParameterT.getTemplateNestingLevel());
|
||||
|
||||
assertDeclarationCount(pdom, "CT", 2);
|
||||
IIndexFragmentBinding[] bindingCT= pdom.findBindings(new char[][] {"CT".toCharArray()}, IndexFilter.ALL_DECLARED, npm());
|
||||
assertEquals(1, bindingCT.length);
|
||||
assertTrue(bindingCT[0] instanceof ICPPClassTemplate);
|
||||
ICPPClassTemplate templateCT= (ICPPClassTemplate) bindingCT[0];
|
||||
ICPPTemplateParameter[] ctParameters= templateCT.getTemplateParameters();
|
||||
assertEquals(1, ctParameters.length);
|
||||
|
||||
assertTrue(ctParameters[0] instanceof ICPPTemplateTypeParameter);
|
||||
ICPPTemplateTypeParameter templateParameterTofCT= (ICPPTemplateTypeParameter) ctParameters[0];
|
||||
assertEquals("T", templateParameterTofCT.getName());
|
||||
assertNull(templateParameterTofCT.getDefault());
|
||||
assertEquals(0, templateParameterTofCT.getTemplateNestingLevel());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void assertInstance(Object o, Class c) {
|
||||
assertNotNull(o);
|
||||
|
|
|
@ -10,4 +10,10 @@ void f(T* p)
|
|||
T::template adjust<100>();
|
||||
}
|
||||
|
||||
|
||||
//![temp.alias] Template alias declaration
|
||||
//%CPP
|
||||
template<typename T> struct S
|
||||
{
|
||||
};
|
||||
template<typename T> using Alias = S<T>;
|
||||
Alias<int> sInt;
|
||||
|
|
|
@ -635,6 +635,9 @@ public class ASTStringUtil {
|
|||
case IASTSimpleDeclSpecifier.t_double:
|
||||
buffer.append(Keywords.DOUBLE).append(' ');
|
||||
break;
|
||||
case IASTSimpleDeclSpecifier.t_float128:
|
||||
buffer.append(GCCKeywords.cp__float128).append(' ');
|
||||
break;
|
||||
case IASTSimpleDeclSpecifier.t_bool:
|
||||
if (simpleDeclSpec instanceof ICASTSimpleDeclSpecifier) {
|
||||
buffer.append(Keywords.cBOOL).append(' ');
|
||||
|
|
|
@ -784,6 +784,14 @@ public class ASTSignatureUtil {
|
|||
result.append(GCCKeywords.__INT128);
|
||||
needSpace = true;
|
||||
break;
|
||||
case IASTSimpleDeclSpecifier.t_float128:
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
needSpace = false;
|
||||
}
|
||||
result.append(GCCKeywords.__FLOAT128);
|
||||
needSpace = true;
|
||||
break;
|
||||
case IASTSimpleDeclSpecifier.t_void:
|
||||
if (needSpace) {
|
||||
result.append(SPACE);
|
||||
|
|
|
@ -106,6 +106,12 @@ public interface IASTSimpleDeclSpecifier extends IASTDeclSpecifier {
|
|||
*/
|
||||
public static final int t_int128 = 13;
|
||||
|
||||
/**
|
||||
* <code>__float128 i;</code>
|
||||
* @since 5.5
|
||||
*/
|
||||
public static final int t_float128 = 14;
|
||||
|
||||
/**
|
||||
* @since 5.1
|
||||
*/
|
||||
|
|
|
@ -23,7 +23,8 @@ public interface IBasicType extends IType {
|
|||
*/
|
||||
enum Kind {
|
||||
eUnspecified, eVoid, eChar, eWChar, eInt, eFloat, eDouble,
|
||||
eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr, /** @since 5.5 */ eInt128
|
||||
eBoolean, eChar16, eChar32, /** @since 5.4 */ eNullPtr,
|
||||
/** @since 5.5 */ eInt128, /** @since 5.5 */ eFloat128
|
||||
}
|
||||
|
||||
/** @since 5.2 */
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTNodeProperty;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
||||
|
||||
/**
|
||||
* Represents a C++ alias declaration.
|
||||
* e.g. struct Type {}; using Alias = Type;
|
||||
* @since 5.5
|
||||
*
|
||||
* @noextend This interface is not intended to be extended by clients.
|
||||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTAliasDeclaration extends IASTDeclaration, IASTNameOwner {
|
||||
public static final ICPPASTAliasDeclaration[] EMPTY_ALIAS_DECLARATION_ARRAY = {};
|
||||
|
||||
/**
|
||||
* <code>ALIAS_NAME</code> is the name that is brought into the local scope.
|
||||
*/
|
||||
public static final ASTNodeProperty ALIAS_NAME = new ASTNodeProperty(
|
||||
"ICPPASTAliasDeclaration.ALIAS_NAME - Introduced alias name"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* <code>MAPPING_TYPE<ID/code> represents the pre-existing type id which
|
||||
* the new symbol aliases.
|
||||
*/
|
||||
public static final ASTNodeProperty TARGET_TYPEID = new ASTNodeProperty(
|
||||
"ICPPASTAliasDeclaration.TARGET_TYPEID - Pre-existing type ID the new symbol aliases"); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* Returns the alias name.
|
||||
*
|
||||
* @return <code>IASTName</code>
|
||||
*/
|
||||
public IASTName getAlias();
|
||||
|
||||
/**
|
||||
* Sets the alias name.
|
||||
*
|
||||
* @param aliasName <code>IASTName</code>
|
||||
*/
|
||||
public void setAlias(IASTName aliasName);
|
||||
|
||||
/**
|
||||
* Returns the mapping type id.
|
||||
*
|
||||
* @return <code>ICPPASTTypeId</code>
|
||||
*/
|
||||
public ICPPASTTypeId getMappingTypeId();
|
||||
|
||||
/**
|
||||
* Sets the mapping type id.
|
||||
*
|
||||
* @param mappingTypeId <code>ICPPASTTypeId</code>
|
||||
*/
|
||||
public void setMappingTypeId(ICPPASTTypeId mappingTypeId);
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration copy();
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration copy(CopyStyle style);
|
||||
}
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Thomas Corbat (IFS) - Added copy methods
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -20,4 +21,15 @@ import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
|||
* @since 5.2
|
||||
*/
|
||||
public interface ICPPASTTypeId extends IASTTypeId, ICPPASTPackExpandable {
|
||||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
@Override
|
||||
public ICPPASTTypeId copy();
|
||||
|
||||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
@Override
|
||||
public ICPPASTTypeId copy(CopyStyle style);
|
||||
}
|
||||
|
|
|
@ -24,7 +24,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNameOwner;
|
|||
* @noimplement This interface is not intended to be implemented by clients.
|
||||
*/
|
||||
public interface ICPPASTUsingDirective extends IASTDeclaration, IASTNameOwner, IASTAttributeOwner {
|
||||
public static final ICPPASTUsingDirective[] EMPTY_USINGDIRECTIVE_ARRAY = new ICPPASTUsingDirective[0];
|
||||
public static final ICPPASTUsingDirective[] EMPTY_USINGDIRECTIVE_ARRAY = {};
|
||||
|
||||
/**
|
||||
* <code>QUALIFIED_NAME</code> is the name that is brought into local
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
|
||||
/**
|
||||
* Represents an alias template (14.5.7).
|
||||
* @since 5.5
|
||||
*/
|
||||
public interface ICPPAliasTemplate extends IType, ICPPTemplateDefinition {
|
||||
/**
|
||||
* Returns the aliased type.
|
||||
*/
|
||||
public IType getType();
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
|
||||
/**
|
||||
* Represents an instance of an alias template (14.5.7).
|
||||
* @since 5.5
|
||||
*/
|
||||
public interface ICPPAliasTemplateInstance extends ITypedef, ICPPBinding {
|
||||
/**
|
||||
* Returns the alias template specialized by this instance.
|
||||
*/
|
||||
public ICPPAliasTemplate getTemplateDefinition();
|
||||
}
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Mike Kucera (IBM Corporation) - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||
|
||||
|
@ -354,4 +355,9 @@ public interface ICPPNodeFactory extends INodeFactory {
|
|||
|
||||
@Override
|
||||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body);
|
||||
|
||||
/**
|
||||
* @since 5.5
|
||||
*/
|
||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId aliasedType);
|
||||
}
|
||||
|
|
|
@ -68,6 +68,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
|||
addMacro("__builtin_offsetof(T,m)", "((size_t) &((T *)0)->m)");
|
||||
|
||||
if (version >= VERSION_4_7) {
|
||||
addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128);
|
||||
addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -104,6 +104,7 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu
|
|||
addKeyword(GCCKeywords.cp__is_trivial, IGCCToken.tTT_is_trivial);
|
||||
}
|
||||
if (version >= VERSION_4_7) {
|
||||
addKeyword(GCCKeywords.cp__float128, IGCCToken.t__float128);
|
||||
addKeyword(GCCKeywords.cp__int128, IGCCToken.t__int128);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ public class GCCKeywords {
|
|||
public static final String __DECLSPEC = "__declspec";
|
||||
/** @since 5.5 */
|
||||
public static final String __INT128 = "__int128";
|
||||
/** @since 5.5 */
|
||||
public static final String __FLOAT128 = "__float128";
|
||||
|
||||
public static final char[]
|
||||
cpTYPEOF = TYPEOF.toCharArray(),
|
||||
|
@ -69,6 +71,7 @@ public class GCCKeywords {
|
|||
|
||||
/** @since 5.5 */
|
||||
public static final char[]
|
||||
cp__float128= __FLOAT128.toCharArray(),
|
||||
cp__int128= __INT128.toCharArray(),
|
||||
cp__is_literal_type= "__is_literal_type".toCharArray(),
|
||||
cp__is_standard_layout= "__is_standard_layout".toCharArray(),
|
||||
|
|
|
@ -45,5 +45,6 @@ public interface IGCCToken extends IToken {
|
|||
/** @since 5.5 */ int tTT_is_standard_layout= FIRST_RESERVED_IGCCToken + 23;
|
||||
/** @since 5.5 */ int tTT_is_trivial= FIRST_RESERVED_IGCCToken + 24;
|
||||
|
||||
/** @since 5.5 */ int t__int128 = FIRST_RESERVED_IGCCToken + 25;
|
||||
/** @since 5.5 */ int t__int128= FIRST_RESERVED_IGCCToken + 25;
|
||||
/** @since 5.5 */ int t__float128= FIRST_RESERVED_IGCCToken + 26;
|
||||
}
|
||||
|
|
|
@ -2591,12 +2591,13 @@ public abstract class AbstractGNUSourceCodeParser implements ISourceCodeParser {
|
|||
case IToken.t_short:
|
||||
case IToken.t_int:
|
||||
case IToken.t_long:
|
||||
case IGCCToken.t__int128:
|
||||
case IToken.t_float:
|
||||
case IToken.t_double:
|
||||
case IToken.t__Bool:
|
||||
case IToken.t__Complex:
|
||||
case IToken.t__Imaginary:
|
||||
case IGCCToken.t__int128:
|
||||
case IGCCToken.t__float128:
|
||||
case IToken.t_signed:
|
||||
case IToken.t_unsigned:
|
||||
case IToken.t_decltype:
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
*
|
||||
* Contributors:
|
||||
* Markus Schorn - initial API and implementation
|
||||
* Thomas Corbat
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser;
|
||||
|
||||
|
@ -34,6 +35,7 @@ public interface ITypeMarshalBuffer {
|
|||
final static byte UNKNOWN_MEMBER= 12;
|
||||
final static byte UNKNOWN_MEMBER_CLASS_INSTANCE= 13;
|
||||
final static byte DEFERRED_CLASS_INSTANCE= 14;
|
||||
final static byte ALIAS_TEMPLATE = 15;
|
||||
|
||||
final static byte
|
||||
EVAL_BINARY= 1,
|
||||
|
|
|
@ -73,6 +73,8 @@ public class SizeofCalculator {
|
|||
public final SizeAndAlignment sizeof_complex_double;
|
||||
public final SizeAndAlignment sizeof_long_double;
|
||||
public final SizeAndAlignment sizeof_complex_long_double;
|
||||
public final SizeAndAlignment sizeof_float128;
|
||||
public final SizeAndAlignment sizeof_complex_float128;
|
||||
|
||||
private final IASTTranslationUnit ast;
|
||||
|
||||
|
@ -135,6 +137,8 @@ public class SizeofCalculator {
|
|||
sizeof_complex_double = getSizeOfPair(sizeof_double);
|
||||
sizeof_long_double = getSize(sizeofMacros, "__SIZEOF_LONG_DOUBLE__", maxAlignment); //$NON-NLS-1$
|
||||
sizeof_complex_long_double = getSizeOfPair(sizeof_long_double);
|
||||
sizeof_float128 = size_16; // GCC does not define __SIZEOF_FLOAT128__
|
||||
sizeof_complex_float128 = getSizeOfPair(sizeof_float128);
|
||||
}
|
||||
|
||||
private SizeofCalculator() {
|
||||
|
@ -156,6 +160,8 @@ public class SizeofCalculator {
|
|||
sizeof_complex_double = null;
|
||||
sizeof_long_double = null;
|
||||
sizeof_complex_long_double = null;
|
||||
sizeof_float128 = size_16;
|
||||
sizeof_complex_float128 = getSizeOfPair(sizeof_float128);
|
||||
ast = null;
|
||||
}
|
||||
|
||||
|
@ -215,6 +221,8 @@ public class SizeofCalculator {
|
|||
return type.isComplex() ?
|
||||
(type.isLong() ? sizeof_long_double : sizeof_double) :
|
||||
(type.isLong() ? sizeof_complex_long_double : sizeof_complex_double);
|
||||
case eFloat128:
|
||||
return type.isComplex() ? sizeof_complex_float128 : sizeof_float128;
|
||||
case eWChar:
|
||||
return sizeof_wchar_t;
|
||||
case eChar16:
|
||||
|
|
|
@ -6,9 +6,9 @@
|
|||
* http://www.eclipse.org/legal/epl-v10.html
|
||||
*
|
||||
* Contributors:
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* John Camelon (IBM Rational Software) - Initial API and implementation
|
||||
* Yuan Zhang / Beth Tibbitts (IBM Research)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -19,17 +19,16 @@ import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
|||
import org.eclipse.cdt.core.dom.ast.c.ICASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.IASTAmbiguityParent;
|
||||
|
||||
public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements ICASTSimpleDeclSpecifier,
|
||||
IASTAmbiguityParent {
|
||||
|
||||
public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier
|
||||
implements ICASTSimpleDeclSpecifier, IASTAmbiguityParent {
|
||||
private int simpleType;
|
||||
private boolean isSigned;
|
||||
private boolean isUnsigned;
|
||||
private boolean isShort;
|
||||
private boolean isLong;
|
||||
private boolean longlong;
|
||||
private boolean complex=false;
|
||||
private boolean imaginary=false;
|
||||
private boolean complex;
|
||||
private boolean imaginary;
|
||||
private IASTExpression fDeclTypeExpression;
|
||||
|
||||
@Override
|
||||
|
@ -110,6 +109,8 @@ public class CASTSimpleDeclSpecifier extends CASTBaseDeclSpecifier implements IC
|
|||
return t_double;
|
||||
case eFloat:
|
||||
return t_float;
|
||||
case eFloat128:
|
||||
return t_float;
|
||||
case eInt:
|
||||
return t_int;
|
||||
case eInt128:
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2005, 2010 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
|
||||
* Copyright (c) 2005, 2010 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:
|
||||
* Devin Steffler (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Contributors:
|
||||
* Devin Steffler (IBM Rational Software) - Initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.c;
|
||||
|
||||
|
@ -24,8 +24,8 @@ import org.eclipse.core.runtime.CoreException;
|
|||
|
||||
public class CBasicType implements ICBasicType, ISerializableType {
|
||||
private final Kind fKind;
|
||||
private int fModifiers = 0;
|
||||
private IASTExpression value = null;
|
||||
private int fModifiers;
|
||||
private IASTExpression value;
|
||||
|
||||
public CBasicType(Kind kind, int modifiers, IASTExpression value) {
|
||||
if (kind == Kind.eUnspecified) {
|
||||
|
@ -69,6 +69,8 @@ public class CBasicType implements ICBasicType, ISerializableType {
|
|||
return Kind.eDouble;
|
||||
case IASTSimpleDeclSpecifier.t_float:
|
||||
return Kind.eFloat;
|
||||
case IASTSimpleDeclSpecifier.t_float128:
|
||||
return Kind.eFloat128;
|
||||
case IASTSimpleDeclSpecifier.t_int:
|
||||
return Kind.eInt;
|
||||
case IASTSimpleDeclSpecifier.t_int128:
|
||||
|
@ -122,16 +124,16 @@ public class CBasicType implements ICBasicType, ISerializableType {
|
|||
if (obj instanceof ITypedef)
|
||||
return obj.isSameType(this);
|
||||
|
||||
if (!(obj instanceof ICBasicType)) return false;
|
||||
if (!(obj instanceof ICBasicType))
|
||||
return false;
|
||||
|
||||
ICBasicType cObj = (ICBasicType)obj;
|
||||
|
||||
if (fKind != cObj.getKind()) {
|
||||
if (fKind != cObj.getKind())
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fKind == Kind.eInt) {
|
||||
//signed int and int are equivalent
|
||||
// Signed int and int are equivalent
|
||||
return (fModifiers & ~IS_SIGNED) == (cObj.getModifiers() & ~IS_SIGNED);
|
||||
} else {
|
||||
return (fModifiers == cObj.getModifiers());
|
||||
|
@ -144,7 +146,7 @@ public class CBasicType implements ICBasicType, ISerializableType {
|
|||
try {
|
||||
t = (IType) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
//not going to happen
|
||||
// Not going to happen
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
@ -155,17 +157,11 @@ public class CBasicType implements ICBasicType, ISerializableType {
|
|||
return value;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICBasicType#isComplex()
|
||||
*/
|
||||
@Override
|
||||
public boolean isComplex() {
|
||||
return (fModifiers & IS_COMPLEX) != 0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.c.ICBasicType#isImaginary()
|
||||
*/
|
||||
@Override
|
||||
public boolean isImaginary() {
|
||||
return (fModifiers & IS_IMAGINARY) != 0;
|
||||
|
@ -220,6 +216,8 @@ public class CBasicType implements ICBasicType, ISerializableType {
|
|||
case eUnspecified:
|
||||
return t_unspecified;
|
||||
case eNullPtr:
|
||||
case eInt128:
|
||||
case eFloat128:
|
||||
// Null pointer type cannot be expressed wit ha simple decl specifier.
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -1030,6 +1030,13 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
|
|||
encounteredRawType= true;
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
case IGCCToken.t__float128:
|
||||
if (encounteredTypename)
|
||||
break declSpecifiers;
|
||||
simpleType = IASTSimpleDeclSpecifier.t_float128;
|
||||
encounteredRawType= true;
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
case IToken.t_signed:
|
||||
if (encounteredTypename)
|
||||
break declSpecifiers;
|
||||
|
|
|
@ -0,0 +1,105 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.ASTVisitor;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
|
||||
|
||||
public class CPPASTAliasDeclaration extends ASTNode implements ICPPASTAliasDeclaration {
|
||||
private IASTName aliasName;
|
||||
private ICPPASTTypeId mappingTypeId;
|
||||
|
||||
public CPPASTAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId){
|
||||
setAlias(aliasName);
|
||||
setMappingTypeId(mappingTypeId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRoleForName(IASTName name) {
|
||||
if (aliasName == name) return r_definition;
|
||||
if (mappingTypeId == name) return r_reference;
|
||||
return r_unclear;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IASTName getAlias() {
|
||||
return aliasName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlias(IASTName aliasName) {
|
||||
assertNotFrozen();
|
||||
this.aliasName = aliasName;
|
||||
if (aliasName != null) {
|
||||
aliasName.setParent(this);
|
||||
aliasName.setPropertyInParent(ALIAS_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTTypeId getMappingTypeId() {
|
||||
return mappingTypeId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMappingTypeId(ICPPASTTypeId mappingTypeId) {
|
||||
assertNotFrozen();
|
||||
this.mappingTypeId = mappingTypeId;
|
||||
if (mappingTypeId != null) {
|
||||
mappingTypeId.setParent(this);
|
||||
mappingTypeId.setPropertyInParent(TARGET_TYPEID);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration copy(CopyStyle style) {
|
||||
CPPASTAliasDeclaration copy = new CPPASTAliasDeclaration(
|
||||
aliasName == null ? null : aliasName.copy(style),
|
||||
mappingTypeId == null ? null : mappingTypeId.copy(style));
|
||||
copy.setOffsetAndLength(this);
|
||||
if (style == CopyStyle.withLocations) {
|
||||
copy.setCopyLocation(this);
|
||||
}
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept(ASTVisitor action) {
|
||||
if (action.shouldVisitDeclarations) {
|
||||
switch (action.visit(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
|
||||
if (aliasName != null && !aliasName.accept(action)) return false;
|
||||
if (mappingTypeId != null && !mappingTypeId.accept(action)) return false;
|
||||
|
||||
if (action.shouldVisitDeclarations) {
|
||||
switch (action.leave(this)) {
|
||||
case ASTVisitor.PROCESS_ABORT: return false;
|
||||
case ASTVisitor.PROCESS_SKIP: return true;
|
||||
default: break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
|
@ -90,6 +90,8 @@ public class CPPASTSimpleDeclSpecifier extends CPPASTBaseDeclSpecifier
|
|||
return t_double;
|
||||
case eFloat:
|
||||
return t_float;
|
||||
case eFloat128:
|
||||
return t_float128;
|
||||
case eInt:
|
||||
return t_int;
|
||||
case eInt128:
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class CPPAliasTemplate extends PlatformObject implements ICPPAliasTemplate {
|
||||
private final IASTName aliasName;
|
||||
private final IType aliasedType;
|
||||
private ICPPTemplateParameter[] templateParameters;
|
||||
|
||||
public CPPAliasTemplate(IASTName aliasName, IType aliasedType) {
|
||||
this.aliasName = aliasName;
|
||||
this.aliasedType = aliasedType;
|
||||
aliasName.setBinding(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return aliasedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNameCharArray() {
|
||||
return aliasName.getSimpleID();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getOwner() {
|
||||
return CPPVisitor.findDeclarationOwner(aliasName, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getScope() throws DOMException {
|
||||
return CPPVisitor.getContainingScope(aliasName.getParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
if (type == null) {
|
||||
return false;
|
||||
}
|
||||
IType aliasedType = getType();
|
||||
return type.isSameType(aliasedType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
IType t = null;
|
||||
try {
|
||||
t = (IType) super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
// Not going to happen
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQualifiedName() throws DOMException {
|
||||
return CPPVisitor.getQualifiedName(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[][] getQualifiedNameCharArray() throws DOMException {
|
||||
return CPPVisitor.getQualifiedNameCharArray(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateParameter[] getTemplateParameters() {
|
||||
if (templateParameters == null) {
|
||||
ICPPASTTemplateDeclaration template = CPPTemplates.getTemplateDeclaration(aliasName);
|
||||
if (template == null)
|
||||
return ICPPTemplateParameter.EMPTY_TEMPLATE_PARAMETER_ARRAY;
|
||||
ICPPASTTemplateParameter[] params = template.getTemplateParameters();
|
||||
IBinding p = null;
|
||||
ICPPTemplateParameter[] result = null;
|
||||
for (ICPPASTTemplateParameter param : params) {
|
||||
p= CPPTemplates.getTemplateParameterName(param).resolveBinding();
|
||||
if (p instanceof ICPPTemplateParameter) {
|
||||
result = ArrayUtil.append(ICPPTemplateParameter.class, result, (ICPPTemplateParameter) p);
|
||||
}
|
||||
}
|
||||
templateParameters = ArrayUtil.trim(ICPPTemplateParameter.class, result);
|
||||
}
|
||||
return templateParameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
|
||||
}
|
||||
}
|
|
@ -0,0 +1,140 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.ASTTypeUtil;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ISerializableType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.ITypeMarshalBuffer;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
import org.eclipse.core.runtime.PlatformObject;
|
||||
|
||||
public class CPPAliasTemplateInstance extends PlatformObject
|
||||
implements ICPPAliasTemplateInstance, ISerializableType {
|
||||
private final char[] name;
|
||||
private final IType aliasedType;
|
||||
private final ICPPAliasTemplate aliasTemplate;
|
||||
|
||||
public CPPAliasTemplateInstance(char[] name, IType aliasedType, ICPPAliasTemplate aliasTemplate) {
|
||||
this.name = name;
|
||||
this.aliasedType = aliasedType;
|
||||
this.aliasTemplate = aliasTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPAliasTemplate getTemplateDefinition() {
|
||||
return aliasTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType other) {
|
||||
if (other == aliasedType)
|
||||
return true;
|
||||
if (aliasedType != null) {
|
||||
return aliasedType.isSameType(other);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
return aliasedType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return new String(getNameCharArray());
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getNameCharArray() {
|
||||
if (name != null) {
|
||||
return name;
|
||||
}
|
||||
return new char[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding getOwner() {
|
||||
if (aliasTemplate != null) {
|
||||
return aliasTemplate.getOwner();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IScope getScope() throws DOMException {
|
||||
if (aliasTemplate != null) {
|
||||
return aliasTemplate.getScope();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void marshal(ITypeMarshalBuffer buffer) throws CoreException {
|
||||
int firstByte = ITypeMarshalBuffer.ALIAS_TEMPLATE;
|
||||
buffer.putByte((byte) firstByte);
|
||||
buffer.putCharArray(name);
|
||||
buffer.marshalType(aliasedType);
|
||||
buffer.marshalBinding(aliasTemplate);
|
||||
}
|
||||
|
||||
public static IType unmarshal(int firstByte, ITypeMarshalBuffer buffer) throws CoreException {
|
||||
char[] name = buffer.getCharArray();
|
||||
IType unmarshalledAliasedTypeInstance = buffer.unmarshalType();
|
||||
ICPPAliasTemplate unmarshalledAlias = (ICPPAliasTemplate)buffer.unmarshalBinding();
|
||||
return new CPPAliasTemplateInstance(name, unmarshalledAliasedTypeInstance, unmarshalledAlias);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ASTTypeUtil.getQualifiedName(this) + " -> " + ASTTypeUtil.getType(aliasedType, true); //$NON-NLS-1$
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getQualifiedName() {
|
||||
return CPPVisitor.getQualifiedName(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[][] getQualifiedNameCharArray() {
|
||||
return CPPVisitor.getQualifiedNameCharArray(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGloballyQualified() throws DOMException {
|
||||
return ((ICPPBinding) aliasTemplate).isGloballyQualified();
|
||||
}
|
||||
}
|
|
@ -100,6 +100,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
|
|||
return Kind.eDouble;
|
||||
case IASTSimpleDeclSpecifier.t_float:
|
||||
return Kind.eFloat;
|
||||
case IASTSimpleDeclSpecifier.t_float128:
|
||||
return Kind.eFloat128;
|
||||
case IASTSimpleDeclSpecifier.t_int:
|
||||
return Kind.eInt;
|
||||
case IASTSimpleDeclSpecifier.t_int128:
|
||||
|
@ -275,6 +277,8 @@ public class CPPBasicType implements ICPPBasicType, ISerializableType {
|
|||
case eUnspecified:
|
||||
return t_unspecified;
|
||||
case eNullPtr:
|
||||
case eInt128:
|
||||
case eFloat128:
|
||||
// Null pointer type cannot be expressed wit ha simple decl specifier.
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ import org.eclipse.cdt.core.dom.ast.IASTToken;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTTokenList;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeIdInitializerExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArraySubscriptExpression;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTBinaryExpression;
|
||||
|
@ -747,4 +748,9 @@ public class CPPNodeFactory extends NodeFactory implements ICPPNodeFactory {
|
|||
public ICPPASTWhileStatement newWhileStatement(IASTExpression condition, IASTStatement body) {
|
||||
return new CPPASTWhileStatement(condition, body);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPASTAliasDeclaration newAliasDeclaration(IASTName aliasName, ICPPASTTypeId mappingTypeId) {
|
||||
return new CPPASTAliasDeclaration(aliasName, mappingTypeId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -66,6 +66,7 @@ import org.eclipse.cdt.core.dom.ast.IASTUnaryExpression;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTWhileStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAmbiguousTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTArrayDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCapture;
|
||||
|
@ -1891,7 +1892,6 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
default:
|
||||
throw backtrack;
|
||||
}
|
||||
|
||||
ICPPASTUsingDirective astUD = nodeFactory.newUsingDirective(name);
|
||||
if (attributes != null) {
|
||||
for (IASTAttribute attribute : attributes) {
|
||||
|
@ -1902,10 +1902,33 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
return astUD;
|
||||
}
|
||||
|
||||
if(LT(1) == IToken.tIDENTIFIER && LT(2) == IToken.tASSIGN){
|
||||
return aliasDeclaration(offset);
|
||||
|
||||
}
|
||||
ICPPASTUsingDeclaration result = usingDeclaration(offset);
|
||||
return result;
|
||||
}
|
||||
|
||||
private IASTDeclaration aliasDeclaration(final int offset) throws EndOfFileException,
|
||||
BacktrackException {
|
||||
IToken identifierToken = consume();
|
||||
IASTName aliasName = buildName(-1, identifierToken);
|
||||
|
||||
consume();
|
||||
|
||||
ICPPASTTypeId aliasedType = typeId(DeclarationOptions.TYPEID);
|
||||
|
||||
if(LT(1) != IToken.tSEMI){
|
||||
throw backtrack;
|
||||
}
|
||||
int endOffset = consume().getEndOffset();
|
||||
|
||||
ICPPASTAliasDeclaration aliasDeclaration = nodeFactory.newAliasDeclaration(aliasName, aliasedType);
|
||||
setRange(aliasDeclaration, offset, endOffset);
|
||||
return aliasDeclaration;
|
||||
}
|
||||
|
||||
private ICPPASTUsingDeclaration usingDeclaration(final int offset) throws EndOfFileException, BacktrackException {
|
||||
boolean typeName = false;
|
||||
if (LT(1) == IToken.t_typename) {
|
||||
|
@ -2851,6 +2874,13 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
|||
encounteredRawType= true;
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
case IGCCToken.t__float128:
|
||||
if (encounteredTypename)
|
||||
break declSpecifiers;
|
||||
simpleType = IASTSimpleDeclSpecifier.t_float128;
|
||||
encounteredRawType= true;
|
||||
endOffset= consume().getEndOffset();
|
||||
break;
|
||||
case IToken.t_void:
|
||||
if (encounteredTypename)
|
||||
break declSpecifiers;
|
||||
|
|
|
@ -586,22 +586,24 @@ class BuiltinOperators {
|
|||
return type instanceof ICPPPointerToMemberType;
|
||||
}
|
||||
|
||||
private boolean isBoolean(IType type) {
|
||||
private static boolean isBoolean(IType type) {
|
||||
return type instanceof IBasicType && ((IBasicType) type).getKind() == Kind.eBoolean;
|
||||
}
|
||||
|
||||
private boolean isFloatingPoint(IType type) {
|
||||
private static boolean isFloatingPoint(IType type) {
|
||||
if (type instanceof IBasicType) {
|
||||
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
||||
switch (kind) {
|
||||
case eDouble:
|
||||
case eFloat:
|
||||
case eFloat128:
|
||||
return true;
|
||||
case eBoolean:
|
||||
case eChar:
|
||||
case eChar16:
|
||||
case eChar32:
|
||||
case eInt:
|
||||
case eInt128:
|
||||
case eWChar:
|
||||
case eUnspecified:
|
||||
case eVoid:
|
||||
|
@ -612,7 +614,7 @@ class BuiltinOperators {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean isArithmetic(IType type) {
|
||||
private static boolean isArithmetic(IType type) {
|
||||
if (type instanceof IBasicType) {
|
||||
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
||||
switch (kind) {
|
||||
|
@ -622,7 +624,9 @@ class BuiltinOperators {
|
|||
case eChar32:
|
||||
case eDouble:
|
||||
case eFloat:
|
||||
case eFloat128:
|
||||
case eInt:
|
||||
case eInt128:
|
||||
case eWChar:
|
||||
return true;
|
||||
case eUnspecified:
|
||||
|
@ -634,7 +638,7 @@ class BuiltinOperators {
|
|||
return false;
|
||||
}
|
||||
|
||||
private boolean isIntegral(IType type) {
|
||||
private static boolean isIntegral(IType type) {
|
||||
if (type instanceof IBasicType) {
|
||||
IBasicType.Kind kind= ((IBasicType) type).getKind();
|
||||
switch (kind) {
|
||||
|
@ -643,10 +647,12 @@ class BuiltinOperators {
|
|||
case eChar16:
|
||||
case eChar32:
|
||||
case eInt:
|
||||
case eInt128:
|
||||
case eWChar:
|
||||
return true;
|
||||
case eDouble:
|
||||
case eFloat:
|
||||
case eFloat128:
|
||||
case eUnspecified:
|
||||
case eVoid:
|
||||
case eNullPtr:
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Mike Kucera (IBM)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -92,6 +93,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
|
@ -1668,6 +1670,9 @@ public class CPPSemantics {
|
|||
} else if (declaration instanceof ICPPASTNamespaceAlias) {
|
||||
IASTName alias = ((ICPPASTNamespaceAlias) declaration).getAlias();
|
||||
ASTInternal.addName(scope, alias);
|
||||
} else if (declaration instanceof ICPPASTAliasDeclaration) {
|
||||
IASTName alias = ((ICPPASTAliasDeclaration) declaration).getAlias();
|
||||
ASTInternal.addName(scope, alias);
|
||||
} else if (declaration instanceof IASTFunctionDefinition) {
|
||||
IASTFunctionDefinition functionDef = (IASTFunctionDefinition) declaration;
|
||||
final IASTDeclSpecifier declSpec = functionDef.getDeclSpecifier();
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Bryan Wilkinson (QNX)
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -66,6 +67,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateId;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
|
@ -103,6 +105,7 @@ import org.eclipse.cdt.internal.core.dom.parser.ProblemBinding;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.ProblemType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.Value;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassSpecialization;
|
||||
|
@ -393,7 +396,7 @@ public class CPPTemplates {
|
|||
return instance;
|
||||
}
|
||||
|
||||
private static ICPPTemplateArgument[] addDefaultArguments(ICPPClassTemplate template,
|
||||
private static ICPPTemplateArgument[] addDefaultArguments(ICPPTemplateDefinition template,
|
||||
ICPPTemplateArgument[] arguments, IASTNode point) throws DOMException {
|
||||
if (template instanceof ICPPClassTemplatePartialSpecialization)
|
||||
return arguments;
|
||||
|
@ -642,17 +645,30 @@ public class CPPTemplates {
|
|||
}
|
||||
}
|
||||
try {
|
||||
// Class template instance.
|
||||
IBinding result= null;
|
||||
IASTName templateName = id.getTemplateName();
|
||||
IBinding template = templateName.resolvePreBinding();
|
||||
|
||||
// Alias Template.
|
||||
if (template instanceof ICPPAliasTemplate) {
|
||||
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) template;
|
||||
IType aliasedType = aliasTemplate.getType();
|
||||
ICPPTemplateArgument[] args = createTemplateArgumentArray(id);
|
||||
args = addDefaultArguments(aliasTemplate, args, id);
|
||||
ICPPTemplateParameterMap parameterMap = createParameterMap(aliasTemplate, args);
|
||||
IBinding owner = template.getOwner();
|
||||
ICPPClassSpecialization within = getSpecializationContext(owner);
|
||||
IType instantiatedType = instantiateType(aliasedType, parameterMap, -1, within, id);
|
||||
return new CPPAliasTemplateInstance(id.toCharArray(), instantiatedType, aliasTemplate);
|
||||
}
|
||||
|
||||
// Class template.
|
||||
if (template instanceof ICPPConstructor) {
|
||||
template= template.getOwner();
|
||||
}
|
||||
|
||||
if (template instanceof ICPPUnknownMemberClass) {
|
||||
IType owner= ((ICPPUnknownMemberClass)template).getOwnerType();
|
||||
IType owner= ((ICPPUnknownMemberClass) template).getOwnerType();
|
||||
ICPPTemplateArgument[] args= createTemplateArgumentArray(id);
|
||||
args= SemanticUtil.getSimplifiedArguments(args);
|
||||
return new CPPUnknownClassInstance(owner, id.getSimpleID(), args);
|
||||
|
@ -716,8 +732,9 @@ public class CPPTemplates {
|
|||
if (parentOfName instanceof ICPPASTElaboratedTypeSpecifier ||
|
||||
parentOfName instanceof ICPPASTCompositeTypeSpecifier ||
|
||||
parentOfName instanceof ICPPASTNamedTypeSpecifier ||
|
||||
parentOfName instanceof ICPPASTBaseSpecifier)
|
||||
parentOfName instanceof ICPPASTBaseSpecifier) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (parentOfName instanceof IASTDeclarator) {
|
||||
IASTDeclarator rel= ASTQueries.findTypeRelevantDeclarator((IASTDeclarator) parentOfName);
|
||||
|
@ -726,7 +743,6 @@ public class CPPTemplates {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
public static ICPPTemplateInstance createInstance(IBinding owner, ICPPTemplateDefinition template,
|
||||
CPPTemplateParameterMap tpMap, ICPPTemplateArgument[] args, IASTNode point) {
|
||||
if (owner instanceof ICPPSpecialization) {
|
||||
|
@ -811,6 +827,10 @@ public class CPPTemplates {
|
|||
} else if (decl instanceof ITypedef) {
|
||||
IType type= instantiateType(((ITypedef) decl).getType(), tpMap, -1, getSpecializationContext(owner), point);
|
||||
spec = new CPPTypedefSpecialization(decl, owner, tpMap, type);
|
||||
} else if (decl instanceof ICPPAliasTemplate) {
|
||||
ICPPAliasTemplate aliasTemplate = (ICPPAliasTemplate) decl;
|
||||
IType type= instantiateType(aliasTemplate.getType(), tpMap, -1, getSpecializationContext(owner), point);
|
||||
spec = new CPPAliasTemplateInstance(decl.getNameCharArray(), type, aliasTemplate);
|
||||
} else if (decl instanceof IEnumeration || decl instanceof IEnumerator) {
|
||||
// TODO(sprigogin): Deal with a case when an enumerator value depends on a template parameter.
|
||||
spec = decl;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.parser.cpp.semantics;
|
||||
|
||||
|
@ -93,6 +94,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IVariable;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCompositeTypeSpecifier.ICPPASTBaseSpecifier;
|
||||
|
@ -172,6 +174,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTIdExpression;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTName;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTranslationUnit;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTUnaryExpression;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplate;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPArrayType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPBasicType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPClassTemplate;
|
||||
|
@ -654,10 +657,32 @@ public class CPPVisitor extends ASTQueries {
|
|||
binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
|
||||
return binding;
|
||||
} else if (declaration instanceof ICPPASTAliasDeclaration) {
|
||||
ICPPASTAliasDeclaration alias = (ICPPASTAliasDeclaration) declaration;
|
||||
ICPPScope scope = (ICPPScope) getContainingScope(declaration);
|
||||
IBinding binding = scope.getBinding(alias.getAlias(), false);
|
||||
if (!(binding instanceof ICPPInternalBinding)) {
|
||||
IType type = createType(alias.getMappingTypeId());
|
||||
if (type instanceof IProblemBinding) {
|
||||
IProblemBinding problem = (IProblemBinding) type;
|
||||
type = new CPPClassType.CPPClassTypeProblem(problem.getASTNode(), problem.getID(),
|
||||
alias.getMappingTypeId().getAbstractDeclarator().getName().toCharArray());
|
||||
}
|
||||
if (type != null) {
|
||||
if (alias.getParent() instanceof ICPPASTTemplateDeclaration) {
|
||||
binding = new CPPAliasTemplate(alias.getAlias(), type);
|
||||
} else {
|
||||
CPPTypedef typedef = new CPPTypedef(alias.getAlias());
|
||||
typedef.setType(type);
|
||||
binding = typedef;
|
||||
}
|
||||
} else {
|
||||
binding = new ProblemBinding(alias.getAlias(), IProblemBinding.SEMANTIC_NAME_NOT_FOUND);
|
||||
}
|
||||
}
|
||||
return binding;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -1766,7 +1791,7 @@ public class CPPVisitor extends ASTQueries {
|
|||
if (pDtor != null) {
|
||||
pt = createType(pt, pDtor);
|
||||
}
|
||||
pt= adjustParameterType(pt, forFuncType);
|
||||
pt= adjustParameterType(pt, forFuncType);
|
||||
|
||||
if (pDtor != null && CPPVisitor.findInnermostDeclarator(pDtor).declaresParameterPack()) {
|
||||
pt= new CPPParameterPackType(pt);
|
||||
|
@ -1810,13 +1835,12 @@ public class CPPVisitor extends ASTQueries {
|
|||
return pTypes;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Adjusts the parameter type according to 8.3.5-3:
|
||||
* cv-qualifiers are deleted, arrays and function types are converted to pointers.
|
||||
*/
|
||||
static IType adjustParameterType(final IType pt, boolean forFunctionType) {
|
||||
// bug 239975
|
||||
// Bug 239975
|
||||
IType t= SemanticUtil.getNestedType(pt, TDEF);
|
||||
if (t instanceof IArrayType) {
|
||||
IArrayType at = (IArrayType) t;
|
||||
|
|
|
@ -183,7 +183,7 @@ public class Conversions {
|
|||
return cost;
|
||||
}
|
||||
}
|
||||
// � otherwise, the program is ill-formed.
|
||||
// otherwise, the program is ill-formed.
|
||||
return Cost.NO_CONVERSION;
|
||||
}
|
||||
|
||||
|
|
|
@ -336,7 +336,7 @@ public class EvalID extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public int determinePackSize(ICPPTemplateParameterMap tpMap) {
|
||||
int r = fFieldOwner.determinePackSize(tpMap);
|
||||
int r = fFieldOwner != null ? fFieldOwner.determinePackSize(tpMap) : CPPTemplates.PACK_SIZE_NOT_FOUND;
|
||||
for (ICPPTemplateArgument arg : fTemplateArgs) {
|
||||
r = CPPTemplates.combinePackSize(r, CPPTemplates.determinePackSize(arg, tpMap));
|
||||
}
|
||||
|
@ -345,6 +345,6 @@ public class EvalID extends CPPEvaluation {
|
|||
|
||||
@Override
|
||||
public boolean referencesTemplateParameter() {
|
||||
return fFieldOwner.referencesTemplateParameter();
|
||||
return fFieldOwner != null && fFieldOwner.referencesTemplateParameter();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -87,6 +87,8 @@ public class DeclSpecWriter extends NodeWriter {
|
|||
return Keywords.FLOAT;
|
||||
case IASTSimpleDeclSpecifier.t_double:
|
||||
return Keywords.DOUBLE;
|
||||
case IASTSimpleDeclSpecifier.t_float128:
|
||||
return GCCKeywords.__FLOAT128;
|
||||
|
||||
case IASTSimpleDeclSpecifier.t_bool:
|
||||
return isCpp ? Keywords.BOOL : Keywords._BOOL;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
* Institute for Software - initial API and implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||
|
||||
|
@ -18,9 +19,11 @@ import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblemDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclSpecifier;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTAliasDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTCatchHandler;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConstructorChainInitializer;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTExplicitTemplateInstantiation;
|
||||
|
@ -32,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamespaceDefinition;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDeclaration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUsingDirective;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTVisibilityLabel;
|
||||
|
@ -93,6 +97,8 @@ public class DeclarationWriter extends NodeWriter {
|
|||
writeUsingDirective((ICPPASTUsingDirective) declaration);
|
||||
} else if (declaration instanceof ICPPASTVisibilityLabel) {
|
||||
writeVisibilityLabel((ICPPASTVisibilityLabel) declaration);
|
||||
} else if (declaration instanceof ICPPASTAliasDeclaration) {
|
||||
writeAliasDeclaration((ICPPASTAliasDeclaration) declaration);
|
||||
}
|
||||
|
||||
writeTrailingComments(declaration, addNewLine);
|
||||
|
@ -104,6 +110,20 @@ public class DeclarationWriter extends NodeWriter {
|
|||
}
|
||||
}
|
||||
|
||||
private void writeAliasDeclaration(ICPPASTAliasDeclaration aliasDeclaration) {
|
||||
scribe.printStringSpace(Keywords.USING);
|
||||
IASTName alias = aliasDeclaration.getAlias();
|
||||
if (alias != null) {
|
||||
alias.accept(visitor);
|
||||
}
|
||||
scribe.print(EQUALS);
|
||||
ICPPASTTypeId aliasedType = aliasDeclaration.getMappingTypeId();
|
||||
if (aliasedType != null) {
|
||||
aliasedType.accept(visitor);
|
||||
}
|
||||
scribe.printSemicolon();
|
||||
}
|
||||
|
||||
private void writeVisibilityLabel(ICPPASTVisibilityLabel visiblityLabel) {
|
||||
scribe.decrementIndentationLevel();
|
||||
switch (visiblityLabel.getVisibility()) {
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
* Contributors:
|
||||
* Andrew Ferguson (Symbian) - Initial implementation
|
||||
* Markus Schorn (Wind River Systems)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index;
|
||||
|
||||
|
@ -60,4 +61,5 @@ public interface IIndexCPPBindingConstants {
|
|||
int CPP_UNKNOWN_FIELD = IIndexBindingConstants.LAST_CONSTANT + 48;
|
||||
int CPP_USING_DECLARATION_SPECIALIZATION= IIndexBindingConstants.LAST_CONSTANT + 49;
|
||||
int CPP_UNKNOWN_METHOD = IIndexBindingConstants.LAST_CONSTANT + 50;
|
||||
int CPP_TEMPLATE_ALIAS = IIndexBindingConstants.LAST_CONSTANT + 51;
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import org.eclipse.cdt.core.dom.ast.ISemanticProblem;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.ITypedef;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassScope;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassTemplate;
|
||||
|
@ -129,9 +130,9 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
return new CompositeCPPNamespaceScope(this, namespaces);
|
||||
}
|
||||
throw new CompositingNotImplementedError(rscope.getClass().getName());
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
throw new CompositingNotImplementedError(ce.getMessage());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
throw new CompositingNotImplementedError(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -482,7 +483,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof ICPPFunction) {
|
||||
return new CompositeCPPFunctionInstance(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateDefinition) {
|
||||
|
@ -499,7 +500,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof ICPPFunctionType) {
|
||||
return new CompositeCPPFunctionTemplateSpecialization(this, (ICPPFunction) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else {
|
||||
if (binding instanceof ICPPClassType) {
|
||||
|
@ -519,10 +520,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof ICPPUsingDeclaration) {
|
||||
return new CompositeCPPUsingDeclarationSpecialization(this, (ICPPUsingDeclaration) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
}
|
||||
} else if(binding instanceof ICPPTemplateParameter) {
|
||||
} else if (binding instanceof ICPPTemplateParameter) {
|
||||
if (binding instanceof ICPPTemplateTypeParameter) {
|
||||
result = new CompositeCPPTemplateTypeParameter(this, (ICPPTemplateTypeParameter) binding);
|
||||
} else if (binding instanceof ICPPTemplateNonTypeParameter) {
|
||||
|
@ -530,7 +531,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof ICPPTemplateTemplateParameter) {
|
||||
result = new CompositeCPPTemplateTemplateParameter(this, (ICPPTemplateTemplateParameter) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else if (binding instanceof ICPPTemplateDefinition) {
|
||||
if (binding instanceof ICPPClassTemplate) {
|
||||
|
@ -542,8 +543,10 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
return new CompositeCPPMethodTemplate(this, (ICPPMethod) binding);
|
||||
} else if (binding instanceof ICPPFunctionTemplate) {
|
||||
return new CompositeCPPFunctionTemplate(this, (ICPPFunction) binding);
|
||||
} else if (binding instanceof ICPPAliasTemplate) {
|
||||
return new CompositeCPPAliasTemplate(this, (ICPPBinding) binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} else if (binding instanceof ICPPParameter) {
|
||||
result = new CompositeCPPParameter(this, (ICPPParameter) binding);
|
||||
|
@ -569,7 +572,7 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
return new CompositeCPPUnknownMethod(b, def.getNameCharArray());
|
||||
}
|
||||
}
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
} else if (binding instanceof ICPPClassType) {
|
||||
ICPPClassType def = (ICPPClassType) findOneBinding(binding);
|
||||
result = def == null ? null : new CompositeCPPClassType(this, def);
|
||||
|
@ -596,11 +599,11 @@ public class CPPCompositesFactory extends AbstractCompositeFactory {
|
|||
} else if (binding instanceof IIndexMacroContainer) {
|
||||
result= new CompositeMacroContainer(this, binding);
|
||||
} else {
|
||||
throw new CompositingNotImplementedError("composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
throw new CompositingNotImplementedError("Composite binding unavailable for " + binding + " " + binding.getClass()); //$NON-NLS-1$ //$NON-NLS-2$
|
||||
}
|
||||
} catch(CoreException ce) {
|
||||
CCorePlugin.log(ce);
|
||||
throw new CompositingNotImplementedError(ce.getMessage());
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
throw new CompositingNotImplementedError(e.getMessage());
|
||||
}
|
||||
|
||||
return result;
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Google, Inc 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:
|
||||
* Sergey Prigogin (Google) - initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.index.composite.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.index.composite.ICompositesFactory;
|
||||
|
||||
class CompositeCPPAliasTemplate extends CompositeCPPBinding implements ICPPAliasTemplate {
|
||||
public CompositeCPPAliasTemplate(ICompositesFactory cf, ICPPBinding delegate) {
|
||||
super(cf, delegate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
fail(); return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
IType type = ((ICPPAliasTemplate) rbinding).getType();
|
||||
return cf.getCompositeType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
return ((ICPPAliasTemplate) rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateParameter[] getTemplateParameters() {
|
||||
return TemplateInstanceUtil.convert(cf, ((ICPPAliasTemplate) rbinding).getTemplateParameters());
|
||||
}
|
||||
}
|
|
@ -36,7 +36,7 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera
|
|||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
return ((IEnumeration)rbinding).isSameType(type);
|
||||
return ((IEnumeration) rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,17 +48,17 @@ class CompositeCPPEnumeration extends CompositeCPPBinding implements ICPPEnumera
|
|||
}
|
||||
@Override
|
||||
public long getMinValue() {
|
||||
return ((IEnumeration)rbinding).getMinValue();
|
||||
return ((IEnumeration) rbinding).getMinValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxValue() {
|
||||
return ((IEnumeration)rbinding).getMaxValue();
|
||||
return ((IEnumeration) rbinding).getMaxValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isScoped() {
|
||||
return ((ICPPEnumeration)rbinding).isScoped();
|
||||
return ((ICPPEnumeration) rbinding).isScoped();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -25,13 +25,13 @@ class CompositeCPPTypedef extends CompositeCPPBinding implements ITypedef, IInde
|
|||
|
||||
@Override
|
||||
public IType getType() {
|
||||
IType type = ((ITypedef)rbinding).getType();
|
||||
IType type = ((ITypedef) rbinding).getType();
|
||||
return cf.getCompositeType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
return ((ITypedef)rbinding).isSameType(type);
|
||||
return ((ITypedef) rbinding).isSameType(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -0,0 +1,118 @@
|
|||
/*******************************************************************************
|
||||
* Copyright (c) 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||
* Rapperswil, University of applied sciences.
|
||||
* 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:
|
||||
* Thomas Corbat (IFS) - Initial API and implementation
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
import org.eclipse.cdt.core.CCorePlugin;
|
||||
import org.eclipse.cdt.core.dom.ast.DOMException;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameter;
|
||||
import org.eclipse.cdt.internal.core.index.IIndexCPPBindingConstants;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.Database;
|
||||
import org.eclipse.cdt.internal.core.pdom.dom.PDOMNode;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
/**
|
||||
* PDOM binding for alias template.
|
||||
*/
|
||||
class PDOMCPPAliasTemplate extends PDOMCPPBinding implements ICPPAliasTemplate {
|
||||
private static final int ALIASED_TYPE_SIZE = Database.TYPE_SIZE;
|
||||
private static final int TEMPLATE_PARAMS_SIZE = PDOMCPPTemplateTemplateParameter.RECORD_SIZE;
|
||||
@SuppressWarnings("hiding")
|
||||
protected static final int RECORD_SIZE = PDOMCPPBinding.RECORD_SIZE + ALIASED_TYPE_SIZE + TEMPLATE_PARAMS_SIZE;
|
||||
|
||||
private static final int ALIASED_TYPE_OFFSET = PDOMCPPBinding.RECORD_SIZE + 0;
|
||||
private static final int TEMPLATE_PARAMS_OFFSET = ALIASED_TYPE_OFFSET + ALIASED_TYPE_SIZE;
|
||||
|
||||
private volatile IPDOMCPPTemplateParameter[] parameters;
|
||||
|
||||
public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, PDOMNode parent,
|
||||
ICPPAliasTemplate templateAlias) throws CoreException, DOMException {
|
||||
super(linkage, parent, templateAlias.getNameCharArray());
|
||||
setTemplateParameters(linkage, templateAlias.getTemplateParameters());
|
||||
setType(linkage, templateAlias.getType());
|
||||
}
|
||||
|
||||
public PDOMCPPAliasTemplate(PDOMCPPLinkage linkage, long record) {
|
||||
super(linkage, record);
|
||||
}
|
||||
|
||||
private void setTemplateParameters(PDOMCPPLinkage linkage,
|
||||
final ICPPTemplateParameter[] origParams) throws CoreException, DOMException {
|
||||
parameters = PDOMTemplateParameterArray.createPDOMTemplateParameters(linkage, this, origParams);
|
||||
final Database db = getDB();
|
||||
long rec= PDOMTemplateParameterArray.putArray(db, parameters);
|
||||
db.putRecPtr(record + TEMPLATE_PARAMS_OFFSET, rec);
|
||||
linkage.new ConfigureTemplateParameters(origParams, parameters);
|
||||
}
|
||||
|
||||
private void setType(PDOMCPPLinkage linkage, IType aliasedType) throws CoreException {
|
||||
linkage.storeType(record + ALIASED_TYPE_OFFSET, aliasedType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNodeType() {
|
||||
return IIndexCPPBindingConstants.CPP_TEMPLATE_ALIAS;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSameType(IType type) {
|
||||
if(type == null){
|
||||
return false;
|
||||
}
|
||||
IType aliasedType = getType();
|
||||
return type.isSameType(aliasedType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ICPPTemplateParameter[] getTemplateParameters() {
|
||||
if (parameters == null) {
|
||||
try {
|
||||
Database db = getDB();
|
||||
long rec= db.getRecPtr(record + TEMPLATE_PARAMS_OFFSET);
|
||||
if (rec == 0) {
|
||||
parameters= IPDOMCPPTemplateParameter.EMPTY_ARRAY;
|
||||
} else {
|
||||
parameters= PDOMTemplateParameterArray.getArray(this, rec);
|
||||
}
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
parameters = IPDOMCPPTemplateParameter.EMPTY_ARRAY;
|
||||
}
|
||||
}
|
||||
return parameters;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IType getType() {
|
||||
try {
|
||||
return getLinkage().loadType(record + ALIASED_TYPE_OFFSET);
|
||||
} catch (CoreException e) {
|
||||
CCorePlugin.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRecordSize() {
|
||||
return RECORD_SIZE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() {
|
||||
try {
|
||||
return super.clone();
|
||||
} catch (CloneNotSupportedException e) {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
* Markus Schorn (Wind River Systems)
|
||||
* Andrew Ferguson (Symbian)
|
||||
* Sergey Prigogin (Google)
|
||||
* Thomas Corbat (IFS)
|
||||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
|
||||
|
||||
|
@ -60,6 +61,8 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespace;
|
|||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPNamespaceAlias;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPSpecialization;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplate;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateArgument;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateInstance;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateNonTypeParameter;
|
||||
|
@ -86,6 +89,7 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerToMemberType;
|
|||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPPointerType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPQualifierType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPReferenceType;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPAliasTemplateInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownClassInstance;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPUnknownMember;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ClassTypeHelper;
|
||||
|
@ -409,6 +413,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
}
|
||||
} else if (binding instanceof ITypedef) {
|
||||
pdomBinding = new PDOMCPPTypedef(this, parent, (ITypedef) binding);
|
||||
} else if (binding instanceof ICPPAliasTemplate) {
|
||||
pdomBinding = new PDOMCPPAliasTemplate(this, parent, (ICPPAliasTemplate) binding);
|
||||
}
|
||||
|
||||
if (pdomBinding != null) {
|
||||
|
@ -601,11 +607,18 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return CPPENUMERATOR;
|
||||
} else if (binding instanceof ITypedef) {
|
||||
return CPPTYPEDEF;
|
||||
} else if (binding instanceof ICPPAliasTemplate) {
|
||||
return CPP_TEMPLATE_ALIAS;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean cannotAdapt(final IBinding inputBinding) throws CoreException {
|
||||
return super.cannotAdapt(inputBinding) || inputBinding instanceof ICPPAliasTemplateInstance;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final PDOMBinding adaptBinding(final IBinding inputBinding, boolean includeLocal) throws CoreException {
|
||||
return adaptBinding(null, inputBinding, includeLocal ? FILE_LOCAL_REC_DUMMY : null);
|
||||
|
@ -825,6 +838,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return new PDOMCPPTypedefSpecialization(this, record);
|
||||
case CPP_USING_DECLARATION_SPECIALIZATION:
|
||||
return new PDOMCPPUsingDeclarationSpecialization(this, record);
|
||||
case CPP_TEMPLATE_ALIAS:
|
||||
return new PDOMCPPAliasTemplate(this, record);
|
||||
}
|
||||
assert false : "nodeid= " + nodeType; //$NON-NLS-1$
|
||||
return null;
|
||||
|
@ -1044,6 +1059,8 @@ class PDOMCPPLinkage extends PDOMLinkage implements IIndexCPPBindingConstants {
|
|||
return CPPUnknownClassInstance.unmarshal(getPDOM(), firstByte, buffer);
|
||||
case ITypeMarshalBuffer.DEFERRED_CLASS_INSTANCE:
|
||||
return CPPDeferredClassInstance.unmarshal(getPDOM(), firstByte, buffer);
|
||||
case ITypeMarshalBuffer.ALIAS_TEMPLATE:
|
||||
return CPPAliasTemplateInstance.unmarshal(firstByte, buffer);
|
||||
}
|
||||
|
||||
throw new CoreException(CCorePlugin.createStatus("Cannot unmarshal a type, first byte=" + firstByte)); //$NON-NLS-1$
|
||||
|
|
|
@ -91,10 +91,12 @@ public class EnvironmentVariableManager implements IEnvironmentVariableManager {
|
|||
protected int getVarMacroSupplierNum(EnvVarDescriptor var, IVariableContextInfo varMacroInfo) {
|
||||
int varSupplierNum = -1;
|
||||
ICdtVariableSupplier macroSuppliers[] = varMacroInfo.getSuppliers();
|
||||
for(int i = 0; i < macroSuppliers.length; i++) {
|
||||
if (macroSuppliers[i] instanceof EnvironmentVariableSupplier) {
|
||||
varSupplierNum = i;
|
||||
break;
|
||||
if (macroSuppliers != null) {
|
||||
for(int i = 0; i < macroSuppliers.length; i++) {
|
||||
if (macroSuppliers[i] instanceof EnvironmentVariableSupplier) {
|
||||
varSupplierNum = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return varSupplierNum;
|
||||
|
|
Loading…
Add table
Reference in a new issue