mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-08 18:26:01 +02:00
Bug 363234. Support for thread_local storage class specifier.
This commit is contained in:
parent
68c99e9441
commit
d8fa087eec
13 changed files with 137 additions and 119 deletions
|
@ -1077,6 +1077,13 @@ public class AST2CPPSpecTest extends AST2SpecBaseTest {
|
||||||
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// thread_local int e;
|
||||||
|
// static thread_local int f;
|
||||||
|
// extern thread_local int g;
|
||||||
|
public void test7_1_1s1() throws Exception {
|
||||||
|
parse(getAboveComment(), ParserLanguage.CPP, true, 0);
|
||||||
|
}
|
||||||
|
|
||||||
// static char* f(); // f() has internal linkage
|
// static char* f(); // f() has internal linkage
|
||||||
// char* f() // f() still has internal linkage
|
// char* f() // f() still has internal linkage
|
||||||
// { //
|
// { //
|
||||||
|
|
|
@ -511,6 +511,14 @@ public class ASTSignatureUtil {
|
||||||
|
|
||||||
if (declSpec instanceof ICPPASTDeclSpecifier) {
|
if (declSpec instanceof ICPPASTDeclSpecifier) {
|
||||||
ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec;
|
ICPPASTDeclSpecifier cppDeclSpec = (ICPPASTDeclSpecifier) declSpec;
|
||||||
|
if (cppDeclSpec.isThreadLocal()) {
|
||||||
|
if (needSpace) {
|
||||||
|
result.append(SPACE);
|
||||||
|
needSpace = false;
|
||||||
|
}
|
||||||
|
result.append(Keywords.THREAD_LOCAL);
|
||||||
|
needSpace = true;
|
||||||
|
}
|
||||||
if (cppDeclSpec.isConstexpr()) {
|
if (cppDeclSpec.isConstexpr()) {
|
||||||
if (needSpace) {
|
if (needSpace) {
|
||||||
result.append(SPACE);
|
result.append(SPACE);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2004, 2011 IBM Corporation and others.
|
* Copyright (c) 2004, 2012 IBM Corporation and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Doug Schaefer (IBM) - Initial API and implementation
|
* Doug Schaefer (IBM) - Initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.core.dom.ast.cpp;
|
package org.eclipse.cdt.core.dom.ast.cpp;
|
||||||
|
|
||||||
|
@ -79,6 +80,22 @@ public interface ICPPASTDeclSpecifier extends IASTDeclSpecifier {
|
||||||
*/
|
*/
|
||||||
public void setConstexpr(boolean value);
|
public void setConstexpr(boolean value);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this thread_local
|
||||||
|
*
|
||||||
|
* @return boolean
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public boolean isThreadLocal();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets this to be thread_local.
|
||||||
|
*
|
||||||
|
* @param value the new value
|
||||||
|
* @since 5.4
|
||||||
|
*/
|
||||||
|
public void setThreadLocal(boolean value);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @since 5.1
|
* @since 5.1
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -26,6 +26,7 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
|
||||||
private boolean isVolatile;
|
private boolean isVolatile;
|
||||||
private boolean isRestrict;
|
private boolean isRestrict;
|
||||||
private int sc;
|
private int sc;
|
||||||
|
private boolean isThreadLocal;
|
||||||
private boolean virtual;
|
private boolean virtual;
|
||||||
private boolean explicit;
|
private boolean explicit;
|
||||||
|
|
||||||
|
@ -45,6 +46,17 @@ public abstract class CPPASTBaseDeclSpecifier extends ASTNode implements ICPPAST
|
||||||
sc = storageClass;
|
sc = storageClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isThreadLocal() {
|
||||||
|
return isThreadLocal;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setThreadLocal(boolean value) {
|
||||||
|
assertNotFrozen();
|
||||||
|
isThreadLocal = value;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isConst() {
|
public boolean isConst() {
|
||||||
return isConst;
|
return isConst;
|
||||||
|
|
|
@ -2595,9 +2595,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
|
|
||||||
private final static int INLINE= 0x1, CONST= 0x2, CONSTEXPR= 0x4, RESTRICT= 0x8, VOLATILE= 0x10,
|
private final static int INLINE= 0x1, CONST= 0x2, CONSTEXPR= 0x4, RESTRICT= 0x8, VOLATILE= 0x10,
|
||||||
SHORT= 0x20, UNSIGNED= 0x40, SIGNED= 0x80, COMPLEX= 0x100, IMAGINARY= 0x200,
|
SHORT= 0x20, UNSIGNED= 0x40, SIGNED= 0x80, COMPLEX= 0x100, IMAGINARY= 0x200,
|
||||||
VIRTUAL= 0x400, EXPLICIT= 0x800, FRIEND= 0x1000;
|
VIRTUAL= 0x400, EXPLICIT= 0x800, FRIEND= 0x1000, THREAD_LOCAL= 0x2000;
|
||||||
private static final int FORBID_IN_EMPTY_DECLSPEC =
|
private static final int FORBID_IN_EMPTY_DECLSPEC =
|
||||||
CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND;
|
CONST | RESTRICT | VOLATILE | SHORT | UNSIGNED | SIGNED | COMPLEX | IMAGINARY | FRIEND | THREAD_LOCAL;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2682,6 +2682,10 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
storageClass = IASTDeclSpecifier.sc_extern;
|
storageClass = IASTDeclSpecifier.sc_extern;
|
||||||
endOffset= consume().getEndOffset();
|
endOffset= consume().getEndOffset();
|
||||||
break;
|
break;
|
||||||
|
case IToken.t_thread_local:
|
||||||
|
options |= THREAD_LOCAL; // thread_local may appear with static or extern
|
||||||
|
endOffset= consume().getEndOffset();
|
||||||
|
break;
|
||||||
case IToken.t_mutable:
|
case IToken.t_mutable:
|
||||||
storageClass = IASTDeclSpecifier.sc_mutable;
|
storageClass = IASTDeclSpecifier.sc_mutable;
|
||||||
endOffset= consume().getEndOffset();
|
endOffset= consume().getEndOffset();
|
||||||
|
@ -3018,6 +3022,7 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
|
||||||
declSpec.setVirtual((options & VIRTUAL) != 0);
|
declSpec.setVirtual((options & VIRTUAL) != 0);
|
||||||
declSpec.setExplicit((options & EXPLICIT) != 0);
|
declSpec.setExplicit((options & EXPLICIT) != 0);
|
||||||
declSpec.setRestrict((options & RESTRICT) != 0);
|
declSpec.setRestrict((options & RESTRICT) != 0);
|
||||||
|
declSpec.setThreadLocal((options & THREAD_LOCAL) != 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ICPPASTDeclSpecifier enumDeclaration(boolean allowOpaque) throws BacktrackException, EndOfFileException {
|
private ICPPASTDeclSpecifier enumDeclaration(boolean allowOpaque) throws BacktrackException, EndOfFileException {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2008, 2010 Institute for Software, HSR Hochschule fuer Technik
|
* Copyright (c) 2008, 2012 Institute for Software, HSR Hochschule fuer Technik
|
||||||
* Rapperswil, University of applied sciences and others
|
* Rapperswil, University of applied sciences and others
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
|
@ -8,6 +8,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
|
@ -44,23 +45,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
* @author Emanuel Graf IFS
|
* @author Emanuel Graf IFS
|
||||||
*/
|
*/
|
||||||
public class DeclSpecWriter extends NodeWriter {
|
public class DeclSpecWriter extends NodeWriter {
|
||||||
private static final String MUTABLE = "mutable "; //$NON-NLS-1$
|
|
||||||
private static final String _COMPLEX = "_Complex "; //$NON-NLS-1$
|
|
||||||
private static final String LONG_LONG = "long long "; //$NON-NLS-1$
|
|
||||||
private static final String REGISTER = "register "; //$NON-NLS-1$
|
|
||||||
private static final String AUTO = "auto "; //$NON-NLS-1$
|
|
||||||
private static final String TYPEDEF = "typedef "; //$NON-NLS-1$
|
|
||||||
private static final String UNION = "union"; //$NON-NLS-1$
|
|
||||||
private static final String STRUCT = "struct"; //$NON-NLS-1$
|
|
||||||
private static final String CLASS = "class"; //$NON-NLS-1$
|
|
||||||
private static final String FRIEND = "friend "; //$NON-NLS-1$
|
|
||||||
private static final String CONSTEXPR = "constexpr "; //$NON-NLS-1$
|
|
||||||
private static final String EXPLICIT = "explicit "; //$NON-NLS-1$
|
|
||||||
private static final String VIRTUAL = "virtual "; //$NON-NLS-1$
|
|
||||||
private static final String UNION_SPACE = "union "; //$NON-NLS-1$
|
|
||||||
private static final String STRUCT_SPACE = "struct "; //$NON-NLS-1$
|
|
||||||
private static final String ENUM_SPACE = "enum "; //$NON-NLS-1$
|
|
||||||
private static final String _BOOL = "_Bool"; //$NON-NLS-1$
|
|
||||||
|
|
||||||
public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
public DeclSpecWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
||||||
super(scribe, visitor, commentMap);
|
super(scribe, visitor, commentMap);
|
||||||
|
@ -89,23 +73,23 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
case IASTSimpleDeclSpecifier.t_unspecified:
|
case IASTSimpleDeclSpecifier.t_unspecified:
|
||||||
return ""; //$NON-NLS-1$
|
return ""; //$NON-NLS-1$
|
||||||
case IASTSimpleDeclSpecifier.t_void:
|
case IASTSimpleDeclSpecifier.t_void:
|
||||||
return VOID;
|
return Keywords.VOID;
|
||||||
case IASTSimpleDeclSpecifier.t_char:
|
case IASTSimpleDeclSpecifier.t_char:
|
||||||
return CHAR;
|
return Keywords.CHAR;
|
||||||
case IASTSimpleDeclSpecifier.t_int:
|
case IASTSimpleDeclSpecifier.t_int:
|
||||||
return INT;
|
return Keywords.INT;
|
||||||
|
|
||||||
case IASTSimpleDeclSpecifier.t_float:
|
case IASTSimpleDeclSpecifier.t_float:
|
||||||
return FLOAT;
|
return Keywords.FLOAT;
|
||||||
case IASTSimpleDeclSpecifier.t_double:
|
case IASTSimpleDeclSpecifier.t_double:
|
||||||
return DOUBLE;
|
return Keywords.DOUBLE;
|
||||||
|
|
||||||
case IASTSimpleDeclSpecifier.t_bool:
|
case IASTSimpleDeclSpecifier.t_bool:
|
||||||
return isCpp ? CPP_BOOL : _BOOL;
|
return isCpp ? Keywords.BOOL : Keywords._BOOL;
|
||||||
|
|
||||||
case IASTSimpleDeclSpecifier.t_wchar_t:
|
case IASTSimpleDeclSpecifier.t_wchar_t:
|
||||||
if (isCpp)
|
if (isCpp)
|
||||||
return WCHAR_T;
|
return Keywords.WCHAR_T;
|
||||||
break;
|
break;
|
||||||
case IASTSimpleDeclSpecifier.t_char16_t:
|
case IASTSimpleDeclSpecifier.t_char16_t:
|
||||||
if (isCpp)
|
if (isCpp)
|
||||||
|
@ -134,7 +118,7 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
|
|
||||||
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
|
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
|
||||||
if (cDeclSpec.isRestrict()) {
|
if (cDeclSpec.isRestrict()) {
|
||||||
scribe.print(RESTRICT);
|
scribe.printStringSpace(Keywords.RESTRICT);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cDeclSpec instanceof ICASTCompositeTypeSpecifier) {
|
if (cDeclSpec instanceof ICASTCompositeTypeSpecifier) {
|
||||||
|
@ -152,7 +136,7 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
|
|
||||||
private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) {
|
private void writeNamedTypeSpecifier(ICPPASTNamedTypeSpecifier namedSpc) {
|
||||||
if (namedSpc.isTypename()) {
|
if (namedSpc.isTypename()) {
|
||||||
scribe.print(TYPENAME);
|
scribe.printStringSpace(Keywords.TYPENAME);
|
||||||
}
|
}
|
||||||
namedSpc.getName().accept(visitor);
|
namedSpc.getName().accept(visitor);
|
||||||
}
|
}
|
||||||
|
@ -162,20 +146,20 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeElaboratedTypeSec(IASTElaboratedTypeSpecifier elabType) {
|
private void writeElaboratedTypeSec(IASTElaboratedTypeSpecifier elabType) {
|
||||||
scribe.print(getElabTypeString(elabType.getKind()));
|
scribe.printStringSpace(getElabTypeString(elabType.getKind()));
|
||||||
elabType.getName().accept(visitor);
|
elabType.getName().accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getElabTypeString(int kind) {
|
private String getElabTypeString(int kind) {
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case IASTElaboratedTypeSpecifier.k_enum:
|
case IASTElaboratedTypeSpecifier.k_enum:
|
||||||
return ENUM_SPACE;
|
return Keywords.ENUM;
|
||||||
case IASTElaboratedTypeSpecifier.k_struct:
|
case IASTElaboratedTypeSpecifier.k_struct:
|
||||||
return STRUCT_SPACE;
|
return Keywords.STRUCT;
|
||||||
case IASTElaboratedTypeSpecifier.k_union:
|
case IASTElaboratedTypeSpecifier.k_union:
|
||||||
return UNION_SPACE;
|
return Keywords.UNION;
|
||||||
case ICPPASTElaboratedTypeSpecifier.k_class:
|
case ICPPASTElaboratedTypeSpecifier.k_class:
|
||||||
return CLASS_SPACE;
|
return Keywords.CLASS;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$
|
throw new IllegalArgumentException("Unknown elaborated type: " + kind); //$NON-NLS-1$
|
||||||
|
@ -184,19 +168,22 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
|
|
||||||
private void writeCPPDeclSpec(ICPPASTDeclSpecifier cppDelcSpec) {
|
private void writeCPPDeclSpec(ICPPASTDeclSpecifier cppDelcSpec) {
|
||||||
if (cppDelcSpec.isVirtual()) {
|
if (cppDelcSpec.isVirtual()) {
|
||||||
scribe.print(VIRTUAL);
|
scribe.printStringSpace(Keywords.VIRTUAL);
|
||||||
}
|
}
|
||||||
if (cppDelcSpec.isConstexpr()) {
|
if (cppDelcSpec.isConstexpr()) {
|
||||||
scribe.print(CONSTEXPR);
|
scribe.printStringSpace(Keywords.CONSTEXPR);
|
||||||
}
|
}
|
||||||
if (cppDelcSpec.isExplicit()) {
|
if (cppDelcSpec.isExplicit()) {
|
||||||
scribe.print(EXPLICIT);
|
scribe.printStringSpace(Keywords.EXPLICIT);
|
||||||
}
|
}
|
||||||
if (cppDelcSpec.isFriend()) {
|
if (cppDelcSpec.isFriend()) {
|
||||||
scribe.print(FRIEND);
|
scribe.printStringSpace(Keywords.FRIEND);
|
||||||
|
}
|
||||||
|
if (cppDelcSpec.isThreadLocal()) {
|
||||||
|
scribe.printStringSpace(Keywords.THREAD_LOCAL);
|
||||||
}
|
}
|
||||||
if (cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
|
if (cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
|
||||||
scribe.print(MUTABLE);
|
scribe.printStringSpace(Keywords.MUTABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (cppDelcSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
if (cppDelcSpec instanceof ICPPASTCompositeTypeSpecifier) {
|
||||||
|
@ -213,7 +200,7 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) {
|
private void writeEnumSpec(IASTEnumerationSpecifier enumSpec) {
|
||||||
scribe.print(ENUM_SPACE);
|
scribe.printStringSpace(Keywords.ENUM);
|
||||||
enumSpec.getName().accept(visitor);
|
enumSpec.getName().accept(visitor);
|
||||||
scribe.print('{');
|
scribe.print('{');
|
||||||
scribe.printSpace();
|
scribe.printSpace();
|
||||||
|
@ -288,13 +275,13 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
private void writeBaseSpecifiers(ICPPASTBaseSpecifier specifier) {
|
private void writeBaseSpecifiers(ICPPASTBaseSpecifier specifier) {
|
||||||
switch (specifier.getVisibility()) {
|
switch (specifier.getVisibility()) {
|
||||||
case ICPPASTBaseSpecifier.v_public:
|
case ICPPASTBaseSpecifier.v_public:
|
||||||
scribe.printStringSpace(PUBLIC);
|
scribe.printStringSpace(Keywords.PUBLIC);
|
||||||
break;
|
break;
|
||||||
case ICPPASTBaseSpecifier.v_protected:
|
case ICPPASTBaseSpecifier.v_protected:
|
||||||
scribe.printStringSpace(PROTECTED);
|
scribe.printStringSpace(Keywords.PROTECTED);
|
||||||
break;
|
break;
|
||||||
case ICPPASTBaseSpecifier.v_private:
|
case ICPPASTBaseSpecifier.v_private:
|
||||||
scribe.printStringSpace(PRIVATE);
|
scribe.printStringSpace(Keywords.PRIVATE);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
specifier.getName().accept(visitor);
|
specifier.getName().accept(visitor);
|
||||||
|
@ -306,7 +293,7 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case ICPPASTCompositeTypeSpecifier.k_class:
|
case ICPPASTCompositeTypeSpecifier.k_class:
|
||||||
return CLASS;
|
return Keywords.CLASS;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
|
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -315,9 +302,9 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
private String getCompositeTypeString(int key) {
|
private String getCompositeTypeString(int key) {
|
||||||
switch (key) {
|
switch (key) {
|
||||||
case IASTCompositeTypeSpecifier.k_struct:
|
case IASTCompositeTypeSpecifier.k_struct:
|
||||||
return STRUCT;
|
return Keywords.STRUCT;
|
||||||
case IASTCompositeTypeSpecifier.k_union:
|
case IASTCompositeTypeSpecifier.k_union:
|
||||||
return UNION;
|
return Keywords.UNION;
|
||||||
default:
|
default:
|
||||||
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
|
throw new IllegalArgumentException("Unknown type specifier: " + key); //$NON-NLS-1$
|
||||||
}
|
}
|
||||||
|
@ -325,30 +312,30 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
|
|
||||||
private void writeDeclSpec(IASTDeclSpecifier declSpec) {
|
private void writeDeclSpec(IASTDeclSpecifier declSpec) {
|
||||||
if (declSpec.isInline()) {
|
if (declSpec.isInline()) {
|
||||||
scribe.print(INLINE);
|
scribe.printStringSpace(Keywords.INLINE);
|
||||||
}
|
}
|
||||||
switch (declSpec.getStorageClass()) {
|
switch (declSpec.getStorageClass()) {
|
||||||
case IASTDeclSpecifier.sc_typedef:
|
case IASTDeclSpecifier.sc_typedef:
|
||||||
scribe.print(TYPEDEF);
|
scribe.printStringSpace(Keywords.TYPEDEF);
|
||||||
break;
|
break;
|
||||||
case IASTDeclSpecifier.sc_extern:
|
case IASTDeclSpecifier.sc_extern:
|
||||||
scribe.print(EXTERN);
|
scribe.printStringSpace(Keywords.EXTERN);
|
||||||
break;
|
break;
|
||||||
case IASTDeclSpecifier.sc_static:
|
case IASTDeclSpecifier.sc_static:
|
||||||
scribe.print(STATIC);
|
scribe.printStringSpace(Keywords.STATIC);
|
||||||
break;
|
break;
|
||||||
case IASTDeclSpecifier.sc_auto:
|
case IASTDeclSpecifier.sc_auto:
|
||||||
scribe.print(AUTO);
|
scribe.printStringSpace(Keywords.AUTO);
|
||||||
break;
|
break;
|
||||||
case IASTDeclSpecifier.sc_register:
|
case IASTDeclSpecifier.sc_register:
|
||||||
scribe.print(REGISTER);
|
scribe.printStringSpace(Keywords.REGISTER);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (declSpec.isConst()) {
|
if (declSpec.isConst()) {
|
||||||
scribe.printStringSpace(CONST);
|
scribe.printStringSpace(Keywords.CONST);
|
||||||
}
|
}
|
||||||
if (declSpec.isVolatile()) {
|
if (declSpec.isVolatile()) {
|
||||||
scribe.printStringSpace(VOLATILE);
|
scribe.printStringSpace(Keywords.VOLATILE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -367,22 +354,23 @@ public class DeclSpecWriter extends NodeWriter {
|
||||||
|
|
||||||
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
|
private void printQualifiers(IASTSimpleDeclSpecifier simpDeclSpec) {
|
||||||
if (simpDeclSpec.isSigned()) {
|
if (simpDeclSpec.isSigned()) {
|
||||||
scribe.printStringSpace(SIGNED);
|
scribe.printStringSpace(Keywords.SIGNED);
|
||||||
} else if (simpDeclSpec.isUnsigned()) {
|
} else if (simpDeclSpec.isUnsigned()) {
|
||||||
scribe.printStringSpace(UNSIGNED);
|
scribe.printStringSpace(Keywords.UNSIGNED);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (simpDeclSpec.isShort()) {
|
if (simpDeclSpec.isShort()) {
|
||||||
scribe.printStringSpace(SHORT);
|
scribe.printStringSpace(Keywords.SHORT);
|
||||||
} else if (simpDeclSpec.isLong()) {
|
} else if (simpDeclSpec.isLong()) {
|
||||||
scribe.printStringSpace(LONG);
|
scribe.printStringSpace(Keywords.LONG);
|
||||||
} else if (simpDeclSpec.isLongLong()) {
|
} else if (simpDeclSpec.isLongLong()) {
|
||||||
scribe.print(LONG_LONG);
|
scribe.printStringSpace(Keywords.LONG);
|
||||||
|
scribe.printStringSpace(Keywords.LONG);
|
||||||
}
|
}
|
||||||
if (simpDeclSpec instanceof ICASTSimpleDeclSpecifier) {
|
if (simpDeclSpec instanceof ICASTSimpleDeclSpecifier) {
|
||||||
ICASTSimpleDeclSpecifier cSimpDeclSpec = (ICASTSimpleDeclSpecifier) simpDeclSpec;
|
ICASTSimpleDeclSpecifier cSimpDeclSpec = (ICASTSimpleDeclSpecifier) simpDeclSpec;
|
||||||
if (cSimpDeclSpec.isComplex()) {
|
if (cSimpDeclSpec.isComplex()) {
|
||||||
scribe.print(_COMPLEX);
|
scribe.printStringSpace(Keywords._COMPLEX);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,10 +51,7 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
private static final String ASM_END = ")"; //$NON-NLS-1$
|
private static final String ASM_END = ")"; //$NON-NLS-1$
|
||||||
private static final String ASM_START = "asm("; //$NON-NLS-1$
|
private static final String ASM_START = "asm("; //$NON-NLS-1$
|
||||||
private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$
|
private static final String TEMPLATE_DECLARATION = "template<"; //$NON-NLS-1$
|
||||||
private static final String EXPORT = "export "; //$NON-NLS-1$
|
|
||||||
private static final String TEMPLATE_SPECIALIZATION = "template <> "; //$NON-NLS-1$
|
private static final String TEMPLATE_SPECIALIZATION = "template <> "; //$NON-NLS-1$
|
||||||
private static final String NAMESPACE = "namespace "; //$NON-NLS-1$
|
|
||||||
private static final String USING = "using "; //$NON-NLS-1$
|
|
||||||
private boolean printSemicolon;
|
private boolean printSemicolon;
|
||||||
|
|
||||||
public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
public DeclarationWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
||||||
|
@ -111,15 +108,15 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
scribe.decrementIndentationLevel();
|
scribe.decrementIndentationLevel();
|
||||||
switch (visiblityLabel.getVisibility()) {
|
switch (visiblityLabel.getVisibility()) {
|
||||||
case ICPPASTVisibilityLabel.v_private:
|
case ICPPASTVisibilityLabel.v_private:
|
||||||
scribe.print(PRIVATE);
|
scribe.print(Keywords.PRIVATE);
|
||||||
scribe.print(':');
|
scribe.print(':');
|
||||||
break;
|
break;
|
||||||
case ICPPASTVisibilityLabel.v_protected:
|
case ICPPASTVisibilityLabel.v_protected:
|
||||||
scribe.print(PROTECTED);
|
scribe.print(Keywords.PROTECTED);
|
||||||
scribe.print(':');
|
scribe.print(':');
|
||||||
break;
|
break;
|
||||||
case ICPPASTVisibilityLabel.v_public:
|
case ICPPASTVisibilityLabel.v_public:
|
||||||
scribe.print(PUBLIC);
|
scribe.print(Keywords.PUBLIC);
|
||||||
scribe.print(':');
|
scribe.print(':');
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -129,15 +126,16 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeUsingDirective(ICPPASTUsingDirective usingDirective) {
|
private void writeUsingDirective(ICPPASTUsingDirective usingDirective) {
|
||||||
scribe.print(USING + NAMESPACE);
|
scribe.printStringSpace(Keywords.USING);
|
||||||
|
scribe.printStringSpace(Keywords.NAMESPACE);
|
||||||
usingDirective.getQualifiedName().accept(visitor);
|
usingDirective.getQualifiedName().accept(visitor);
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeUsingDeclaration(ICPPASTUsingDeclaration usingDeclaration) {
|
private void writeUsingDeclaration(ICPPASTUsingDeclaration usingDeclaration) {
|
||||||
scribe.print(USING);
|
scribe.printStringSpace(Keywords.USING);
|
||||||
if (usingDeclaration.isTypename()) {
|
if (usingDeclaration.isTypename()) {
|
||||||
scribe.print(TYPENAME);
|
scribe.printStringSpace(Keywords.TYPENAME);
|
||||||
}
|
}
|
||||||
usingDeclaration.getName().accept(visitor);
|
usingDeclaration.getName().accept(visitor);
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
|
@ -150,7 +148,7 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
|
|
||||||
protected void writeTemplateDeclaration(ICPPASTTemplateDeclaration templateDeclaration) {
|
protected void writeTemplateDeclaration(ICPPASTTemplateDeclaration templateDeclaration) {
|
||||||
if (templateDeclaration.isExported()) {
|
if (templateDeclaration.isExported()) {
|
||||||
scribe.print(EXPORT);
|
scribe.printStringSpace(Keywords.EXPORT);
|
||||||
}
|
}
|
||||||
scribe.print(TEMPLATE_DECLARATION);
|
scribe.print(TEMPLATE_DECLARATION);
|
||||||
ICPPASTTemplateParameter[] paraDecls = templateDeclaration.getTemplateParameters();
|
ICPPASTTemplateParameter[] paraDecls = templateDeclaration.getTemplateParameters();
|
||||||
|
@ -172,7 +170,7 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) {
|
private void writeNamespaceDefinition(ICPPASTNamespaceDefinition namespaceDefinition) {
|
||||||
scribe.print(NAMESPACE);
|
scribe.printStringSpace(Keywords.NAMESPACE);
|
||||||
namespaceDefinition.getName().accept(visitor);
|
namespaceDefinition.getName().accept(visitor);
|
||||||
if (!hasTrailingComments(namespaceDefinition.getName())) {
|
if (!hasTrailingComments(namespaceDefinition.getName())) {
|
||||||
scribe.newLine();
|
scribe.newLine();
|
||||||
|
@ -200,7 +198,7 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNamespaceAlias(ICPPASTNamespaceAlias namespaceAliasDefinition) {
|
private void writeNamespaceAlias(ICPPASTNamespaceAlias namespaceAliasDefinition) {
|
||||||
scribe.print(NAMESPACE);
|
scribe.printStringSpace(Keywords.NAMESPACE);
|
||||||
namespaceAliasDefinition.getAlias().accept(visitor);
|
namespaceAliasDefinition.getAlias().accept(visitor);
|
||||||
scribe.print(EQUALS);
|
scribe.print(EQUALS);
|
||||||
namespaceAliasDefinition.getMappingName().accept(visitor);
|
namespaceAliasDefinition.getMappingName().accept(visitor);
|
||||||
|
@ -208,9 +206,8 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) {
|
private void writeLinkageSpecification(ICPPASTLinkageSpecification linkageSpecification) {
|
||||||
scribe.print(EXTERN);
|
scribe.printStringSpace(Keywords.EXTERN);
|
||||||
scribe.print(linkageSpecification.getLiteral());
|
scribe.printStringSpace(linkageSpecification.getLiteral());
|
||||||
scribe.printSpaces(1);
|
|
||||||
|
|
||||||
IASTDeclaration[] declarations = linkageSpecification.getDeclarations();
|
IASTDeclaration[] declarations = linkageSpecification.getDeclarations();
|
||||||
if (declarations.length > 1) {
|
if (declarations.length > 1) {
|
||||||
|
@ -230,17 +227,17 @@ public class DeclarationWriter extends NodeWriter {
|
||||||
private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) {
|
private void writeExplicitTemplateInstantiation(ICPPASTExplicitTemplateInstantiation explicitTemplateInstantiation) {
|
||||||
switch(explicitTemplateInstantiation.getModifier()) {
|
switch(explicitTemplateInstantiation.getModifier()) {
|
||||||
case ICPPASTExplicitTemplateInstantiation.EXTERN:
|
case ICPPASTExplicitTemplateInstantiation.EXTERN:
|
||||||
scribe.print(EXTERN);
|
scribe.printStringSpace(Keywords.EXTERN);
|
||||||
break;
|
break;
|
||||||
case ICPPASTExplicitTemplateInstantiation.INLINE:
|
case ICPPASTExplicitTemplateInstantiation.INLINE:
|
||||||
scribe.print(INLINE);
|
scribe.printStringSpace(Keywords.INLINE);
|
||||||
break;
|
break;
|
||||||
case ICPPASTExplicitTemplateInstantiation.STATIC:
|
case ICPPASTExplicitTemplateInstantiation.STATIC:
|
||||||
scribe.print(STATIC);
|
scribe.printStringSpace(Keywords.STATIC);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
scribe.print(TEMPLATE);
|
scribe.printStringSpace(Keywords.TEMPLATE);
|
||||||
explicitTemplateInstantiation.getDeclaration().accept(visitor);
|
explicitTemplateInstantiation.getDeclaration().accept(visitor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* Institute for Software - initial API and implementation
|
* Institute for Software - initial API and implementation
|
||||||
* Markus Schorn (Wind River Systems)
|
* Markus Schorn (Wind River Systems)
|
||||||
|
* Sergey Prigogin (Google)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
package org.eclipse.cdt.internal.core.dom.rewrite.astwriter;
|
||||||
|
|
||||||
|
@ -29,6 +30,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTPointerToMember;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTReferenceOperator;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -41,7 +43,6 @@ import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
public class DeclaratorWriter extends NodeWriter {
|
public class DeclaratorWriter extends NodeWriter {
|
||||||
private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$
|
private static final String AMPERSAND_AMPERSAND = "&&"; //$NON-NLS-1$
|
||||||
private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$
|
private static final String PURE_VIRTUAL = " = 0"; //$NON-NLS-1$
|
||||||
private static final String MUTABLE = "mutable"; //$NON-NLS-1$
|
|
||||||
private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$
|
private static final String ARROW_OPERATOR = "->"; //$NON-NLS-1$
|
||||||
|
|
||||||
public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
public DeclaratorWriter(Scribe scribe, ASTWriterVisitor visitor, NodeCommentMap commentMap) {
|
||||||
|
@ -128,15 +129,15 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
private void writeCppFunctionDeclarator(ICPPASTFunctionDeclarator funcDec) {
|
private void writeCppFunctionDeclarator(ICPPASTFunctionDeclarator funcDec) {
|
||||||
if (funcDec.isConst()) {
|
if (funcDec.isConst()) {
|
||||||
scribe.printSpace();
|
scribe.printSpace();
|
||||||
scribe.print(CONST);
|
scribe.print(Keywords.CONST);
|
||||||
}
|
}
|
||||||
if (funcDec.isVolatile()) {
|
if (funcDec.isVolatile()) {
|
||||||
scribe.printSpace();
|
scribe.printSpace();
|
||||||
scribe.print(VOLATILE);
|
scribe.print(Keywords.VOLATILE);
|
||||||
}
|
}
|
||||||
if (funcDec.isMutable()) {
|
if (funcDec.isMutable()) {
|
||||||
scribe.printSpace();
|
scribe.printSpace();
|
||||||
scribe.print(MUTABLE);
|
scribe.print(Keywords.MUTABLE);
|
||||||
}
|
}
|
||||||
if (funcDec.isPureVirtual()) {
|
if (funcDec.isPureVirtual()) {
|
||||||
scribe.print(PURE_VIRTUAL);
|
scribe.print(PURE_VIRTUAL);
|
||||||
|
@ -153,7 +154,7 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions) {
|
protected void writeExceptionSpecification(ICPPASTFunctionDeclarator funcDec, IASTTypeId[] exceptions) {
|
||||||
if (exceptions != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) {
|
if (exceptions != ICPPASTFunctionDeclarator.NO_EXCEPTION_SPECIFICATION) {
|
||||||
scribe.printSpace();
|
scribe.printSpace();
|
||||||
scribe.print(THROW);
|
scribe.printStringSpace(Keywords.THROW);
|
||||||
scribe.print('(');
|
scribe.print('(');
|
||||||
writeNodeList(exceptions);
|
writeNodeList(exceptions);
|
||||||
scribe.print(')');
|
scribe.print(')');
|
||||||
|
@ -182,13 +183,13 @@ public class DeclaratorWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (operator.isConst()) {
|
if (operator.isConst()) {
|
||||||
scribe.printStringSpace(CONST);
|
scribe.printStringSpace(Keywords.CONST);
|
||||||
}
|
}
|
||||||
if (operator.isVolatile()) {
|
if (operator.isVolatile()) {
|
||||||
scribe.printStringSpace(VOLATILE);
|
scribe.printStringSpace(Keywords.VOLATILE);
|
||||||
}
|
}
|
||||||
if (operator.isRestrict()) {
|
if (operator.isRestrict()) {
|
||||||
scribe.print(RESTRICT);
|
scribe.printStringSpace(Keywords.RESTRICT);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,6 +39,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
|
||||||
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
|
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -112,6 +113,7 @@ public class ExpressionWriter extends NodeWriter{
|
||||||
private static final String OPENING_SQUARE_BRACKET = "["; //$NON-NLS-1$
|
private static final String OPENING_SQUARE_BRACKET = "["; //$NON-NLS-1$
|
||||||
private static final String CLOSING_SQUARE_BRACKET = "]"; //$NON-NLS-1$
|
private static final String CLOSING_SQUARE_BRACKET = "]"; //$NON-NLS-1$
|
||||||
private static final String THIS = "this"; //$NON-NLS-1$
|
private static final String THIS = "this"; //$NON-NLS-1$
|
||||||
|
private static final String THROW = "throw "; //$NON-NLS-1$
|
||||||
private final MacroExpansionHandler macroHandler;
|
private final MacroExpansionHandler macroHandler;
|
||||||
|
|
||||||
public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
|
public ExpressionWriter(Scribe scribe, ASTWriterVisitor visitor, MacroExpansionHandler macroHandler, NodeCommentMap commentMap) {
|
||||||
|
@ -423,7 +425,7 @@ public class ExpressionWriter extends NodeWriter{
|
||||||
if (fieldRef instanceof ICPPASTFieldReference) {
|
if (fieldRef instanceof ICPPASTFieldReference) {
|
||||||
ICPPASTFieldReference cppFieldRef = (ICPPASTFieldReference) fieldRef;
|
ICPPASTFieldReference cppFieldRef = (ICPPASTFieldReference) fieldRef;
|
||||||
if (cppFieldRef.isTemplate()) {
|
if (cppFieldRef.isTemplate()) {
|
||||||
scribe.print(TEMPLATE);
|
scribe.printStringSpace(Keywords.TEMPLATE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fieldRef.getFieldName().accept(visitor);
|
fieldRef.getFieldName().accept(visitor);
|
||||||
|
|
|
@ -17,6 +17,7 @@ import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTConversionName;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTQualifiedName;
|
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.ICPPASTTemplateId;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
|
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPTemplateTypeParameter;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
|
||||||
|
@ -58,7 +59,7 @@ public class NameWriter extends NodeWriter {
|
||||||
|
|
||||||
private void writeTempalteId(ICPPASTTemplateId tempId) {
|
private void writeTempalteId(ICPPASTTemplateId tempId) {
|
||||||
if (needsTemplateQualifier(tempId)) {
|
if (needsTemplateQualifier(tempId)) {
|
||||||
scribe.print(TEMPLATE);
|
scribe.printStringSpace(Keywords.TEMPLATE);
|
||||||
}
|
}
|
||||||
scribe.print(tempId.getTemplateName().toString());
|
scribe.print(tempId.getTemplateName().toString());
|
||||||
scribe.print('<');
|
scribe.print('<');
|
||||||
|
|
|
@ -30,31 +30,7 @@ public class NodeWriter {
|
||||||
protected NodeCommentMap commentMap;
|
protected NodeCommentMap commentMap;
|
||||||
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
|
protected static final String COMMA_SPACE = ", "; //$NON-NLS-1$
|
||||||
protected static final String EQUALS = " = "; //$NON-NLS-1$
|
protected static final String EQUALS = " = "; //$NON-NLS-1$
|
||||||
protected static final String RESTRICT = "restrict "; //$NON-NLS-1$
|
|
||||||
protected static final String TYPENAME = "typename "; //$NON-NLS-1$
|
|
||||||
protected static final String PUBLIC = "public"; //$NON-NLS-1$
|
|
||||||
protected static final String PRIVATE = "private"; //$NON-NLS-1$
|
|
||||||
protected static final String PROTECTED = "protected"; //$NON-NLS-1$
|
|
||||||
protected static final String CONST = "const"; //$NON-NLS-1$
|
|
||||||
protected static final String VOLATILE = "volatile"; //$NON-NLS-1$
|
|
||||||
protected static final String INLINE = "inline "; //$NON-NLS-1$
|
|
||||||
protected static final String EXTERN = "extern "; //$NON-NLS-1$
|
|
||||||
protected static final String STATIC = "static "; //$NON-NLS-1$
|
|
||||||
protected static final String THROW = "throw "; //$NON-NLS-1$
|
|
||||||
protected static final String SPACE_COLON_SPACE = " : "; //$NON-NLS-1$
|
protected static final String SPACE_COLON_SPACE = " : "; //$NON-NLS-1$
|
||||||
protected static final String TEMPLATE = "template "; //$NON-NLS-1$
|
|
||||||
protected static final String DOUBLE = "double"; //$NON-NLS-1$
|
|
||||||
protected static final String FLOAT = "float"; //$NON-NLS-1$
|
|
||||||
protected static final String INT = "int"; //$NON-NLS-1$
|
|
||||||
protected static final String CHAR = "char"; //$NON-NLS-1$
|
|
||||||
protected static final String VOID = "void"; //$NON-NLS-1$
|
|
||||||
protected static final String WCHAR_T = "wchar_t"; //$NON-NLS-1$
|
|
||||||
protected static final String CPP_BOOL = "bool"; //$NON-NLS-1$
|
|
||||||
protected static final String LONG = "long"; //$NON-NLS-1$
|
|
||||||
protected static final String SHORT = "short"; //$NON-NLS-1$
|
|
||||||
protected static final String UNSIGNED = "unsigned"; //$NON-NLS-1$
|
|
||||||
protected static final String SIGNED = "signed"; //$NON-NLS-1$
|
|
||||||
protected static final String CLASS_SPACE = "class "; //$NON-NLS-1$
|
|
||||||
protected static final String VAR_ARGS = "..."; //$NON-NLS-1$
|
protected static final String VAR_ARGS = "..."; //$NON-NLS-1$
|
||||||
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
|
protected static final String COLON_COLON = "::"; //$NON-NLS-1$
|
||||||
protected static final String COLON_SPACE = ": "; //$NON-NLS-1$
|
protected static final String COLON_SPACE = ": "; //$NON-NLS-1$
|
||||||
|
|
|
@ -16,6 +16,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTParameterDeclaration;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplateParameter;
|
||||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTemplatedTypeTemplateParameter;
|
||||||
|
import org.eclipse.cdt.core.parser.Keywords;
|
||||||
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
import org.eclipse.cdt.internal.core.dom.rewrite.commenthandler.NodeCommentMap;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,10 +70,10 @@ public class TemplateParameterWriter extends NodeWriter {
|
||||||
private void writeSimpleTypeTemplateParameter(ICPPASTSimpleTypeTemplateParameter simple) {
|
private void writeSimpleTypeTemplateParameter(ICPPASTSimpleTypeTemplateParameter simple) {
|
||||||
switch (simple.getParameterType()) {
|
switch (simple.getParameterType()) {
|
||||||
case ICPPASTSimpleTypeTemplateParameter.st_class:
|
case ICPPASTSimpleTypeTemplateParameter.st_class:
|
||||||
scribe.print(CLASS_SPACE);
|
scribe.printStringSpace(Keywords.CLASS);
|
||||||
break;
|
break;
|
||||||
case ICPPASTSimpleTypeTemplateParameter.st_typename:
|
case ICPPASTSimpleTypeTemplateParameter.st_typename:
|
||||||
scribe.print(TYPENAME);
|
scribe.printStringSpace(Keywords.TYPENAME);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -138,10 +138,11 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
|
ICPPASTNamedTypeSpecifier decl = (ICPPASTNamedTypeSpecifier) node;
|
||||||
return isDeclSpecifierEqual(trailDecl, decl)
|
return isDeclSpecifierEqual(trailDecl, decl)
|
||||||
&& isSameNamedTypeSpecifierName(trailDecl, decl)
|
&& isSameNamedTypeSpecifierName(trailDecl, decl)
|
||||||
&& trailDecl.isTypename() == decl.isTypename()
|
|
||||||
&& trailDecl.isConstexpr() == decl.isConstexpr()
|
&& trailDecl.isConstexpr() == decl.isConstexpr()
|
||||||
&& trailDecl.isExplicit() == decl.isExplicit()
|
&& trailDecl.isExplicit() == decl.isExplicit()
|
||||||
&& trailDecl.isFriend() == decl.isFriend()
|
&& trailDecl.isFriend() == decl.isFriend()
|
||||||
|
&& trailDecl.isThreadLocal() == decl.isThreadLocal()
|
||||||
|
&& trailDecl.isTypename() == decl.isTypename()
|
||||||
&& trailDecl.isVirtual() == decl.isVirtual();
|
&& trailDecl.isVirtual() == decl.isVirtual();
|
||||||
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
|
} else if (trailNode instanceof IASTNamedTypeSpecifier) {
|
||||||
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
|
IASTNamedTypeSpecifier trailDecl = (IASTNamedTypeSpecifier) trailNode;
|
||||||
|
@ -165,6 +166,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
&& trailDecl.isConstexpr() == decl.isConstexpr()
|
&& trailDecl.isConstexpr() == decl.isConstexpr()
|
||||||
&& trailDecl.isExplicit() == decl.isExplicit()
|
&& trailDecl.isExplicit() == decl.isExplicit()
|
||||||
&& trailDecl.isFriend() == decl.isFriend()
|
&& trailDecl.isFriend() == decl.isFriend()
|
||||||
|
&& trailDecl.isThreadLocal() == decl.isThreadLocal()
|
||||||
&& trailDecl.isVirtual() == decl.isVirtual();
|
&& trailDecl.isVirtual() == decl.isVirtual();
|
||||||
} else if (trailNode instanceof ICASTDeclSpecifier) {
|
} else if (trailNode instanceof ICASTDeclSpecifier) {
|
||||||
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
|
ICASTDeclSpecifier trailDecl = (ICASTDeclSpecifier) trailNode;
|
||||||
|
@ -318,6 +320,7 @@ public class TrailNodeEqualityChecker implements EqualityChecker<IASTNode> {
|
||||||
if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr()
|
if (trailCppDecl.isConstexpr() != cppDecl.isConstexpr()
|
||||||
|| trailCppDecl.isExplicit() != cppDecl.isExplicit()
|
|| trailCppDecl.isExplicit() != cppDecl.isExplicit()
|
||||||
|| trailCppDecl.isFriend() != cppDecl.isFriend()
|
|| trailCppDecl.isFriend() != cppDecl.isFriend()
|
||||||
|
|| trailCppDecl.isThreadLocal() != cppDecl.isThreadLocal()
|
||||||
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
|
|| trailCppDecl.isVirtual() != cppDecl.isVirtual()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue