source: dev/ProjectEditor/CClassInfo.cpp@ 27

Last change on this file since 27 was 3, checked in by dai_9181, 18 years ago
File size: 6.0 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 DWORD dwProc;
87 if(memicmp(pBuf+i,"Abstract",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')||
88 memicmp(pBuf+i,"Virtual",7)==0&&(pBuf[i+7]==' '||pBuf[i+7]=='\t')||
89 memicmp(pBuf+i,"Override",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')||
90 memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')||
91 memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')){
92 //メンバ関数のとき
93 if(pBuf[i]=='a'||pBuf[i]=='A'){
94 i+=9;
95 dwProc=ESC_ABSTRACT;
96
97 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
98 if(memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')) i+=9;
99 else if(memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')) i+=4;
100 }
101 else if(pBuf[i]=='v'||pBuf[i]=='V'){
102 i+=8;
103 dwProc=ESC_VIRTUAL;
104
105 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
106 if(memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')) i+=9;
107 else if(memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')) i+=4;
108 }
109 else if(pBuf[i]=='o'||pBuf[i]=='O'){
110 i+=9;
111 dwProc=ESC_OVERRIDE;
112
113 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
114 if(memicmp(pBuf+i,"Function",8)==0&&(pBuf[i+8]==' '||pBuf[i+8]=='\t')) i+=9;
115 else if(memicmp(pBuf+i,"Sub",3)==0&&(pBuf[i+3]==' '||pBuf[i+3]=='\t')) i+=4;
116 }
117 else if(pBuf[i]=='f'||pBuf[i]=='F'){
118 i+=9;
119 dwProc=ESC_FUNCTION;
120 }
121 else if(pBuf[i]=='s'||pBuf[i]=='S'){
122 i+=4;
123 dwProc=ESC_SUB;
124 }
125
126 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
127 }
128 else{
129 //メンバ変数のとき
130 dwProc=0;
131 }
132
133 int code_pos;
134 code_pos=i;
135
136 //変数名または関数名を取得
137 if(pBuf[i]=='~'){
138 temporary[0]='~';
139 i2=1;
140 i++;
141 }
142 else i2=0;
143 for(;;i++,i2++){
144 if(!IsVariableChar(pBuf[i])){
145 temporary[i2]=0;
146 break;
147 }
148 temporary[i2]=pBuf[i];
149 }
150
151 //次の行をサーチ
152 for(;;i++){
153 if(pBuf[i]=='\0') break;
154 if(pBuf[i]=='\''||(pBuf[i]=='/'&&pBuf[i+1]=='*')){
155 //コメント中
156 JumpBlank(pBuf,&i);
157 break;
158 }
159 i2=IsCommandDelimitation(pBuf,i);
160 if(i2){
161 i+=i2;
162 break;
163 }
164 }
165 JumpBlank(pBuf,&i);
166
167 if(lstrcmpi(temporary,"Inherits")==0){
168 //継承指定の場合(ツリーに反映すべきデータはないので無視する)
169 continue;
170 }
171
172 //アクセスを変更
173 if(lstrcmpi(temporary,"Private")==0){
174 dwAccess=ACCESS_PRIVATE;
175 continue;
176 }
177 if(lstrcmpi(temporary,"Public")==0){
178 dwAccess=ACCESS_PUBLIC;
179 continue;
180 }
181 if(lstrcmpi(temporary,"Protected")==0){
182 dwAccess=ACCESS_PROTECTED;
183 continue;
184 }
185
186 //重複チェック(オーバーライド関数を考慮)
187 for(i2=0;i2<MemberNum;i2++){
188 if(lstrcmp(pMemberInfo[i2].pName,temporary)==0){
189 lstrcat(temporary," ");
190 break;
191 }
192 }
193
194 pMemberInfo=
195 (MEMBERINFO *)HeapReAlloc(hHeap,
196 0,
197 pMemberInfo,
198 (MemberNum+1)*sizeof(MEMBERINFO));
199
200 //メンバ名
201 pMemberInfo[MemberNum].pName=
202 (char *)HeapAlloc(hHeap,0,lstrlen(temporary)+1);
203 lstrcpy(pMemberInfo[MemberNum].pName,
204 temporary);
205
206 //メンバの種類(変数、Virtual、Sub、Function)
207 pMemberInfo[MemberNum].dwProc=dwProc;
208
209 //アクセシビリティ
210 pMemberInfo[MemberNum].dwAccess=dwAccess;
211
212 //コードの位置
213 pMemberInfo[MemberNum].code_pos=code_pos;
214
215 MemberNum++;
216
217 if(dwProc){
218 //Abstract定義以外はEnd Sub、End Functionをサーチする
219 if(dwProc==ESC_ABSTRACT) continue;
220 if(dwClassType==ESC_INTERFACE) continue;
221
222 while(1){
223 if(pBuf[i]=='\0'){
224 i2=0;
225 break;
226 }
227
228 if(memicmp(pBuf+i,"End",3)==0){
229 /* End Sub
230 End Function
231 の検出 */
232 i+=3;
233 while(pBuf[i]==' '||pBuf[i]=='\t') i++;
234
235 if(memicmp(pBuf+i,"Sub",3)==0&&(!IsVariableChar(pBuf[i+3]))||
236 memicmp(pBuf+i,"Function",8)==0&&(!IsVariableChar(pBuf[i+8]))){
237 i2=1;
238 break;
239 }
240
241 if(memicmp(pBuf+i,"Class",5)==0&&(!IsVariableChar(pBuf[i+5]))||
242 memicmp(pBuf+i,"Interface",9)==0&&(!IsVariableChar(pBuf[i+9]))||
243 memicmp(pBuf+i,"Type",4)==0&&(!IsVariableChar(pBuf[i+4]))){
244 i2=0;
245 break;
246 }
247 }
248
249 //次の行をサーチ
250 for(;;i++){
251 if(pBuf[i]=='\0') break;
252 i2=IsCommandDelimitation(pBuf,i);
253 if(i2){
254 i+=i2;
255 break;
256 }
257 }
258 JumpBlank(pBuf,&i);
259 }
260
261 if(i2==0){
262 //コード解析が不正に終了
263 *p=i;
264 return 0;
265 }
266
267 //次の行をサーチ
268 for(;;i++){
269 if(pBuf[i]=='\0') break;
270 i2=IsCommandDelimitation(pBuf,i);
271 if(i2){
272 i+=i2;
273 break;
274 }
275 }
276 JumpBlank(pBuf,&i);
277 }
278 }
279
280 *p=i;
281
282 return 1;
283}
284
Note: See TracBrowser for help on using the repository browser.