source: dev/trunk/ab5.0/abdev/ProjectEditor/CClassInfo.cpp@ 477

Last change on this file since 477 was 475, checked in by dai_9181, 17 years ago

構成管理を変更中・・・(いったんコミット)

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