Skip to main content
summaryrefslogtreecommitdiffstats
blob: 5df07418f1d9bbe80b0c65c78e37537a68d03872 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/*******************************************************************************
 * Copyright (c) 2000, 2004 QNX Software Systems and others.
 * All rights reserved. This program and the accompanying materials 
 * are made available under the terms of the Common Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/cpl-v10.html
 * 
 * Contributors:
 *     QNX Software Systems - Initial API and implementation
 *******************************************************************************/

package org.eclipse.cdt.debug.internal.core.model;

import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.model.ICType;

/**
 * Enter type comment.
 * 
 * @since Jun 10, 2003
 */
public class CType implements ICType
{
	private ICDIType fCDIType;

	public CType( ICDIType cdiType )
	{
		setCDIType( cdiType );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#getName()
	 */
	public String getName()
	{
		return ( fCDIType != null ) ? fCDIType.getTypeName() : null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
	 */
	public Object getAdapter( Class adapter )
	{
		if ( ICType.class.equals( adapter ) )
			return this;
		return null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#dispose()
	 */
	public void dispose()
	{
		fCDIType = null;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#getArrayDimensions()
	 */
	public int[] getArrayDimensions()
	{
		int length = 0;
		ICDIType type = getCDIType();
		while( type instanceof ICDIArrayType )
		{
			++length;
			type = ( type instanceof ICDIDerivedType ) ? ((ICDIDerivedType)type).getComponentType() : null;
		}
		int[] dims = new int[length];
		type = getCDIType();
		for ( int i = length; i > 0; --i )
		{
			dims[i - 1] = ((ICDIArrayType)type).getDimension();
			type = ((ICDIDerivedType)type).getComponentType();
		}
		return dims;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#isArray()
	 */
	public boolean isArray()
	{
		return ( getCDIType() instanceof ICDIArrayType );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#isCharacter()
	 */
	public boolean isCharacter()
	{
		return ( getCDIType() instanceof ICDICharType );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#isFloatingPointType()
	 */
	public boolean isFloatingPointType()
	{
		return ( getCDIType() instanceof ICDIFloatingPointType );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#isPointer()
	 */
	public boolean isPointer()
	{
		return ( getCDIType() instanceof ICDIPointerType );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.ICType#isReference()
	 */
	public boolean isReference()
	{
		return ( getCDIType() instanceof ICDIReferenceType );
	}

	/* (non-Javadoc)
	 * @see org.eclipse.cdt.debug.core.model.type.ICType#isStructure()
	 */
	public boolean isStructure()
	{
		return ( getCDIType() instanceof ICDIStructType );
	}

	protected ICDIType getCDIType()
	{
		return fCDIType;
	}

	protected void setCDIType( ICDIType type )
	{
		fCDIType = type;
	}

	protected boolean hasChildren()
	{
		ICDIType type = getCDIType();
		if ( type instanceof ICDIStructType || type instanceof ICDIArrayType || 
			 type instanceof ICDIPointerType || type instanceof ICDIReferenceType )
			return true;
		return false;
	}
}

Back to the top