source: dev/ProjectEditor/CClassInfo.cpp@ 103

Last change on this file since 103 was 81, checked in by dai_9181, 18 years ago

プロジェクトを開いていないときでもクラスビューの機能を有効にした。

File size: 6.2 KB
Line 
1#include "Common.h"
2
3#if defined(JPN)
4//日本語
5#include "pj_msg_jpn.h"
6#else
7//英語
8#include "pj_msg_eng.h"
9#endif
10
11
12CClassInfo::CClassInfo(){
13 pMemberInfo=(MEMBERINFO *)HeapAlloc(hHeap,0,1);
14 MemberNum=0;
15}
16CClassInfo::~CClassInfo(){
17 int i;
18 for(i=0;i<MemberNum;i++){
19 HeapDefaultFree(pMemberInfo[i].pName);
20 }
21 HeapDefaultFree(pMemberInfo);
22}
23
24int CClassInfo::Analyze(char *pBuf,int *p){
25 int i,i2;
26 char temporary[VN_SIZE];
27
28 i=*p;
29
30 DWORD dwAccess;
31
32 //種類を取得
33 DWORD dwClassType;
34 if(memicmp(pBuf+i,"Class",5)==0){
35 dwClassType=ESC_CLASS;
36 i+=5;
37
38 dwAccess=ACCESS_PRIVATE;
39 }
40 else if(memicmp(pBuf+i,"Type",4)==0){
41 dwClassType=ESC_TYPE;
42 i+=4;
43
44 dwAccess=ACCESS_PUBLIC;
45 }
46 else if(memicmp(pBuf+i,"Interface",9)==0){
47 dwClassType=ESC_INTERFACE;
48 i+=9;
49
50 dwAccess=ACCESS_PUBLIC;
51 }
52 else return 0;
53 JumpBlank(pBuf,&i);
54
55
56 //クラス名を取得
57 for(i2=0;;i++,i2++){
58 if(!(IsVariableChar(pBuf[i])||pBuf[i]=='~')){
59 ClassName[i2]=0;
60 break;
61 }
62 ClassName[i2]=pBuf[i];
63 }
64 JumpBlank(pBuf,&i);
65
66
67 //メンバ変数、関数を取得
68 while(1){
69 if(pBuf[i]=='\0') break;
70 if(memicmp(pBuf+i,"End",3)==0){
71 /* End Class
72 End Type
73 の検出 */
74 i2=i+3;
75 while(pBuf[i2]==' '||pBuf[i2]=='\t') i2++;
76
77 if(memicmp(pBuf+i2,"Class",5)==0&&(!IsVariableChar(pBuf[i2+5]))||
78 memicmp(pBuf+i2,"Interface",9)==0&&(!IsVariableChar(pBuf[i2+9]))||
79 memicmp(pBuf+i2,"Type",4)==0&&(!IsVariableChar(pBuf[i2+4]))){
80 while(!IsCommandDelimitation(pBuf,i2)) i2++;
81 i=i2;
82 break;
83 }
84 }
85
86 // Static/Constを飛ばす
87 if( memicmp(pBuf+i,"Static",6)==0 ){
88 // Static
89 i+=6;
90 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
91 }
92 if(pBuf[i]=='c'||pBuf[i]=='C'){
93 // Const
94 i+=5;
95 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
96 }
97
98 DWORD dwProc;
99 if(memicmp(pBuf+i,"Abstract",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')||
100 memicmp(pBuf+i,"Virtual",7)==0&&(pBuf[i+7]==' '||pBuf[i+7]=='\t')||
101 memicmp(pBuf+i,"Override",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')||
102 memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')||
103 memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')){
104 //メンバ関数のとき
105
106 if(pBuf[i]=='a'||pBuf[i]=='A'){
107 i+=9;
108 dwProc=ESC_ABSTRACT;
109
110 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
111 if(memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')) i+=9;
112 else if(memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')) i+=4;
113 }
114 else if(pBuf[i]=='v'||pBuf[i]=='V'){
115 i+=8;
116 dwProc=ESC_VIRTUAL;
117
118 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
119 if(memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')) i+=9;
120 else if(memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')) i+=4;
121 }
122 else if(pBuf[i]=='o'||pBuf[i]=='O'){
123 i+=9;
124 dwProc=ESC_OVERRIDE;
125
126 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
127 if(memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')) i+=9;
128 else if(memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')) i+=4;
129 }
130 else if(pBuf[i]=='f'||pBuf[i]=='F'){
131 i+=9;
132 dwProc=ESC_FUNCTION;
133 }
134 else if(pBuf[i]=='s'||pBuf[i]=='S'){
135 i+=4;
136 dwProc=ESC_SUB;
137 }
138
139 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
140 }
141 else{
142 //メンバ変数のとき
143 dwProc=0;
144 }
145
146 int code_pos;
147 code_pos=i;
148
149 //変数名または関数名を取得
150 if(pBuf[i]=='~'){
151 temporary[0]='~';
152 i2=1;
153 i++;
154 }
155 else i2=0;
156 for(;;i++,i2++){
157 if(!IsVariableChar(pBuf[i])){
158 temporary[i2]=0;
159 break;
160 }
161 temporary[i2]=pBuf[i];
162 }
163
164 //次の行をサーチ
165 for(;;i++){
166 if(pBuf[i]=='\0') break;
167 if(pBuf[i]=='\''||(pBuf[i]=='/'&&pBuf[i+1]=='*')){
168 //コメント中
169 JumpBlank(pBuf,&i);
170 break;
171 }
172 i2=IsCommandDelimitation(pBuf,i);
173 if(i2){
174 i+=i2;
175 break;
176 }
177 }
178 JumpBlank(pBuf,&i);
179
180 if(lstrcmpi(temporary,"Inherits")==0){
181 //継承指定の場合(ツリーに反映すべきデータはないので無視する)
182 continue;
183 }
184
185 //アクセスを変更
186 if(lstrcmpi(temporary,"Private")==0){
187 dwAccess=ACCESS_PRIVATE;
188 continue;
189 }
190 if(lstrcmpi(temporary,"Public")==0){
191 dwAccess=ACCESS_PUBLIC;
192 continue;
193 }
194 if(lstrcmpi(temporary,"Protected")==0){
195 dwAccess=ACCESS_PROTECTED;
196 continue;
197 }
198
199 //重複チェック(オーバーライド関数を考慮)
200 for(i2=0;i2<MemberNum;i2++){
201 if(lstrcmp(pMemberInfo[i2].pName,temporary)==0){
202 lstrcat(temporary," ");
203 break;
204 }
205 }
206
207 pMemberInfo=
208 (MEMBERINFO *)HeapReAlloc(hHeap,
209 0,
210 pMemberInfo,
211 (MemberNum+1)*sizeof(MEMBERINFO));
212
213 //メンバ名
214 pMemberInfo[MemberNum].pName=
215 (char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
216 lstrcpy(pMemberInfo[MemberNum].pName,
217 temporary);
218
219 //メンバの種類(変数、Virtual、Sub、Function)
220 pMemberInfo[MemberNum].dwProc=dwProc;
221
222 //アクセシビリティ
223 pMemberInfo[MemberNum].dwAccess=dwAccess;
224
225 //コードの位置
226 pMemberInfo[MemberNum].code_pos=code_pos;
227
228 MemberNum++;
229
230 if(dwProc){
231 //Abstract定義以外はEnd Sub、End Functionをサーチする
232 if(dwProc==ESC_ABSTRACT) continue;
233 if(dwClassType==ESC_INTERFACE) continue;
234
235 while(1){
236 if(pBuf[i]=='\0'){
237 i2=0;
238 break;
239 }
240
241 if(memicmp(pBuf+i,"End",3)==0){
242 /* End Sub
243 End Function
244 の検出 */
245 i+=3;
246 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
247
248 if(memicmp(pBuf+i,"Sub",3)==0&&(!IsVariableChar(pBuf[i+3]))||
249 memicmp(pBuf+i,"Function",8)==0&&(!IsVariableChar(pBuf[i+8]))){
250 i2=1;
251 break;
252 }
253
254 if(memicmp(pBuf+i,"Class",5)==0&&(!IsVariableChar(pBuf[i+5]))||
255 memicmp(pBuf+i,"Interface",9)==0&&(!IsVariableChar(pBuf[i+9]))||
256 memicmp(pBuf+i,"Type",4)==0&&(!IsVariableChar(pBuf[i+4]))){
257 i2=0;
258 break;
259 }
260 }
261
262 //次の行をサーチ
263 for(;;i++){
264 if(pBuf[i]=='\0') break;
265 i2=IsCommandDelimitation(pBuf,i);
266 if(i2){
267 i+=i2;
268 break;
269 }
270 }
271 JumpBlank(pBuf,&i);
272 }
273
274 if(i2==0){
275 //コード解析が不正に終了
276 *p=i;
277 return 0;
278 }
279
280 //次の行をサーチ
281 for(;;i++){
282 if(pBuf[i]=='\0') break;
283 i2=IsCommandDelimitation(pBuf,i);
284 if(i2){
285 i+=i2;
286 break;
287 }
288 }
289 JumpBlank(pBuf,&i);
290 }
291 }
292
293 *p=i;
294
295 return 1;
296}
297
Note: See TracBrowser for help on using the repository browser.