Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: f469572aef162ee362d3a48a83a92e596ae888f2 (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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
/**********************************************************************
 * Copyright (c) 2004 IBM Corporation 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: 
 * IBM - Initial API and implementation
 **********************************************************************/
package org.eclipse.cdt.internal.core.index.domsourceindexer;

import org.eclipse.cdt.internal.core.index.FunctionEntry;
import org.eclipse.cdt.internal.core.index.IIndex;
import org.eclipse.cdt.internal.core.index.IIndexerOutput;
import org.eclipse.cdt.internal.core.index.NamedEntry;
import org.eclipse.cdt.internal.core.index.TypeEntry;


/**
 * Wrapper for calls to IIndexerOutput 
 * (in anticipation that the interface is going to change)
 * 
 * @author vhirsl
 */
class IndexerOutputWrapper {
    static class EntryType {
        public int toInt() {
            return type;
        }
        private EntryType(int type) {
            this.type = type;
        }
        private int type;
        
    }
	private final static int CLASS_CONST = 1;
	private final static int STRUCT_CONST = 2;
	private final static int UNION_CONST = 3;
	private final static int ENUM_CONST = 4;
	private final static int VAR_CONST = 5;
	private final static int TYPEDEF_CONST = 6;
	private final static int DERIVED_CONST = 7;
	private final static int FRIEND_CONST = 8;
	private final static int FWD_CLASS_CONST = 9;
	private final static int FWD_STRUCT_CONST = 10;
	private final static int FWD_UNION_CONST = 11;
	private final static int NAMESPACE_CONST = 12;
	private final static int ENUMERATOR_CONST = 13;
	private final static int FIELD_CONST = 14;
	private final static int METHOD_CONST = 15;
	private final static int FUNCTION_CONST = 16;
	private final static int MACRO_CONST = 17;
	private final static int INCLUDE_CONST = 18;
	
	
    // entry types
    final static EntryType CLASS = new EntryType(CLASS_CONST);
    final static EntryType STRUCT = new EntryType(STRUCT_CONST);
    final static EntryType UNION = new EntryType(UNION_CONST);
    final static EntryType ENUM = new EntryType(ENUM_CONST);
    final static EntryType VAR = new EntryType(VAR_CONST);
    final static EntryType TYPEDEF = new EntryType(TYPEDEF_CONST);
    final static EntryType DERIVED = new EntryType(DERIVED_CONST);
    final static EntryType FRIEND = new EntryType(FRIEND_CONST);
    final static EntryType FWD_CLASS = new EntryType(FWD_CLASS_CONST);
    final static EntryType FWD_STRUCT = new EntryType(FWD_STRUCT_CONST);
    final static EntryType FWD_UNION = new EntryType(FWD_UNION_CONST);
    final static EntryType NAMESPACE = new EntryType(NAMESPACE_CONST);
    final static EntryType ENUMERATOR = new EntryType(ENUMERATOR_CONST);
    final static EntryType FIELD = new EntryType(FIELD_CONST);
    final static EntryType METHOD = new EntryType(METHOD_CONST);
    final static EntryType FUNCTION = new EntryType(FUNCTION_CONST);
    final static EntryType MACRO = new EntryType(MACRO_CONST);
    final static EntryType INCLUDE = new EntryType(INCLUDE_CONST);


	private IndexerOutputWrapper() {
	}

	static void addIndexEntry (IIndexerOutput indexerOutput,
							  char[][] name,
							  EntryType entryType,
							  int entryKind,
							  int fileNumber,
							  int offset,
							  int length,
							  int offsetType) {
		//TODO temporary until all bindings are completed
		if (name == null) 
			name = new char[][] {"NPE".toCharArray()}; //$NON-NLS-1$
		
		TypeEntry typeEntry;
		NamedEntry namedEntry;
		FunctionEntry functionEntry;
		
		switch (entryType.toInt()) {
			case CLASS_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_CLASS,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				//typeEntry.setBaseTypes(getInherits());
				typeEntry.serialize(indexerOutput);
				break;
			case STRUCT_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_STRUCT,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				//typeEntry.setBaseTypes(getInherits());
				typeEntry.serialize(indexerOutput);
				break;
			case UNION_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_UNION,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				//typeEntry.setBaseTypes(getInherits());
				typeEntry.serialize(indexerOutput);
				break;
			case ENUM_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_ENUM ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case VAR_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_VAR ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case TYPEDEF_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_TYPEDEF, entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case DERIVED_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_DERIVED ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case FRIEND_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_FRIEND ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case FWD_CLASS_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_FWD_CLASS ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case FWD_STRUCT_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_FWD_STRUCT ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case FWD_UNION_CONST:
				typeEntry = new TypeEntry(IIndex.TYPE_FWD_UNION ,entryKind, name, 0 /*getModifiers()*/, fileNumber);
				typeEntry.setNameOffset(offset, length, offsetType);
				typeEntry.serialize(indexerOutput);
				break;
			case NAMESPACE_CONST:
			    namedEntry = new NamedEntry(IIndex.NAMESPACE, entryKind, name, 0 /*getModifiers()*/, fileNumber);
				namedEntry.setNameOffset(offset, length, offsetType);
				namedEntry.serialize(indexerOutput);
				break;
			case ENUMERATOR_CONST:
				 namedEntry = new NamedEntry(IIndex.ENUMTOR, entryKind, name, 0 /*getModifiers()*/, fileNumber);
				 namedEntry.setNameOffset(offset, length, offsetType);
				 namedEntry.serialize(indexerOutput);
				break;
			case FIELD_CONST:
				 namedEntry = new NamedEntry(IIndex.FIELD, entryKind, name, 0 /*getModifiers()*/, fileNumber);
				 namedEntry.setNameOffset(offset, length, offsetType);
				 namedEntry.serialize(indexerOutput);
				break;
			case METHOD_CONST:
				functionEntry = new FunctionEntry(IIndex.METHOD, entryKind,name,0 /*getModifiers()*/, fileNumber);
				//funEntry.setSignature(getFunctionSignature());
				functionEntry.setNameOffset(offset, length, offsetType);
				functionEntry.serialize(indexerOutput);
				break;
			case FUNCTION_CONST:
				functionEntry = new FunctionEntry(IIndex.FUNCTION, entryKind,name,0 /*getModifiers()*/, fileNumber);
				//funEntry.setSignature(getFunctionSignature());
				functionEntry.setNameOffset(offset, length, offsetType);
				functionEntry.serialize(indexerOutput);
				break;
			case MACRO_CONST:
				 namedEntry = new NamedEntry(IIndex.MACRO, entryKind, name, 0 /*getModifiers()*/, fileNumber);
				 namedEntry.setNameOffset(offset, length, offsetType);
				 namedEntry.serialize(indexerOutput);
				break;
		}
	}

}

Back to the top