source: dev/trunk/ab5.0/abdev/BasicCompiler_Common/StrOperation.cpp@ 679

Last change on this file since 679 was 644, checked in by dai_9181, 16 years ago

マイナス値として配列範囲外へのアクセスが生じてしまう不具合を修正

File size: 17.7 KB
RevLine 
[206]1#include "stdafx.h"
2
[4]3void KillSpaces(char *str1,char *str2){
4 int i,i2,i3,IsStr;
5 for(i=0,i2=0,IsStr=0;;i++,i2++){
6 if((str1[i]==' '||str1[i]=='\t')&&IsStr==0){
7 i3=i+1;
8 while(str1[i3]==' '||str1[i3]=='\t') i3++;
9 if(i!=0){
10 if(i==1){
11 if(IsVariableChar(str1[i-1])&&
12 IsVariableChar(str1[i3])){
13 //識別子間にある省略すべきでない空白
14 str2[i2++]=' ';
15 }
16 }
17 else{
18 if(str1[i-2]!=1&&IsVariableChar(str1[i-1])&&
19 IsVariableChar(str1[i3])){
20 //識別子間にある省略すべきでない空白
21 str2[i2++]=' ';
22 }
23 }
24 }
25 i=i3;
26 }
27 if(str1[i]=='\"') IsStr^=1;
28 str2[i2]=str1[i];
29 if(str1[i]=='\0') break;
30 }
31}
32void KillStringSpaces(char *str){
33 char *s2;
34
35 extern HANDLE hHeap;
36 s2=(char *)HeapAlloc(hHeap,0,lstrlen(str)+1);
37 lstrcpy(s2,str);
38 KillSpaces(s2,str);
39 HeapDefaultFree(s2);
40 return;
41}
42BOOL RemoveStringQuotes(char *str){
43 int i;
44 if(str[0]!='\"') return 0;
45 for(i=0;;i++){
46 str[i]=str[i+1];
47 if(str[i]=='\"') break;
48 }
49 str[i]=0;
50 if(str[i+2]!='\0') return 0;
51 return 1;
52}
[387]53bool RemoveStringQuotes( std::string &str )
54{
55 if( str[0] != '\"' )
56 {
57 return false;
58 }
59
60 str = str.substr( 1, str.length() - 2 );
61 return true;
62}
[4]63void RemoveStringPare(char *str){
64 int i;
65 i=lstrlen(str);
66 if(str[0]!='('||str[i-1]!=')') return;
67 SlideString(str+1,-1);
68 str[i-2]=0;
69}
70void RemoveStringBracket(char *str){
71 int i;
72 i=lstrlen(str);
73 if(str[0]!='['||str[i-1]!=']') return;
74 SlideString(str+1,-1);
75 str[i-2]=0;
76}
77void SetStringQuotes(char *str){
78 int i;
79 if(str[0]=='\"') return;
80 i=lstrlen(str);
81 SlideString(str,1);
82 str[0]='\"';
83 str[i+1]='\"';
84 str[i+2]=0;
85}
86int FormatString_EscapeSequence(char *buffer){
87 int i2,i3,i4;
88
89 for(i2=0,i3=0;;i2++,i3++){
90 if(IsDBCSLeadByte(buffer[i3])){
91 buffer[i2++]=buffer[i3++];
92 buffer[i2]=buffer[i3];
93 if(buffer[i3]=='\0') break;
94 continue;
95 }
96 if(buffer[i3]=='\\'){
97 switch(buffer[i3+1]){
98 case '\\':
99 buffer[i2]='\\';
100 i3++;
101 break;
102 case '0':
103 buffer[i2]='\0';
104 i3++;
105 break;
106 case 'n':
107 buffer[i2]='\n';
108 i3++;
109 break;
110 case 'q':
111 buffer[i2]='\"';
112 i3++;
113 break;
114 case 'r':
115 buffer[i2]='\r';
116 i3++;
117 break;
118 case 't':
119 buffer[i2]='\t';
120 i3++;
121 break;
122 case 'x':
123 //16進表記
124 char temporary[8];
125 temporary[0]=buffer[i3+2];
126 temporary[1]=buffer[i3+3];
127 temporary[2]=0;
128 CharUpper(temporary);
129
130 i4=temporary[0]-0x30;
131 if(i4<0||9<i4){
132 i4=temporary[0]-0x41+10;
133 if(i4<0xA||0xF<i4){
134 buffer[i2]=buffer[i3];
135 break;
136 }
137 }
138 temporary[0]=i4;
139
140 i4=temporary[1]-0x30;
141 if(i4<0||9<i4){
142 i4=temporary[1]-0x41+10;
143 if(i4<0xA||0xF<i4){
144 buffer[i2]=buffer[i3];
145 break;
146 }
147 }
148 temporary[1]=i4;
149
150 buffer[i2]=temporary[0]*0x10+temporary[1];
151 i3+=3;
152 break;
153 default:
154 buffer[i2]=buffer[i3];
155 break;
156 }
157 }
158 else{
159 buffer[i2]=buffer[i3];
160 if(buffer[i3]=='\0') break;
161 }
162 }
163 return i2;
164}
165void SlideString(char *buffer, int slide){
166 char *temp;
167 temp=(char *)malloc(lstrlen(buffer)+1);
168 lstrcpy(temp,buffer);
169 lstrcpy(buffer+slide,temp);
170 free(temp);
171}
172void SlideBuffer(char *buffer,int length,int slide){
173 void *temp;
174 temp=malloc(length+1);
175 memcpy(temp,buffer,length);
176 memcpy(buffer+slide,temp,length);
177 free(temp);
178}
[77]179
[313]180int GetSourceCodeIndexFromLine( const char *source, int LineNum ){
[4]181 int i,nCount=0;
182 for(i=0;;i++){
[313]183 if(source[i]=='\n'){
[4]184 nCount++;
185 if(LineNum==nCount){
186 for(i++;;i++){
[313]187 if(IsCommandDelimitation(source[i])) break;
[4]188 }
189 return i;
190 }
191 }
192 }
193}
194
195char GetEndXXXCommand(char es){
196 switch(es){
197 case ESC_SUB:
198 return ESC_ENDSUB;
199 case ESC_FUNCTION:
200 return ESC_ENDFUNCTION;
201 case ESC_MACRO:
202 return ESC_ENDMACRO;
203 case ESC_TYPE:
204 return ESC_ENDTYPE;
205 case ESC_CLASS:
206 return ESC_ENDCLASS;
207 case ESC_INTERFACE:
208 return ESC_ENDINTERFACE;
209 case ESC_ENUM:
210 return ESC_ENDENUM;
211 }
212 return 0;
213}
214void GetDefaultNameFromES(char es,char *name){
215 name[0]=0;
216 switch(es){
217 case ESC_PSMEM:
218 lstrcpy(name,"->");
219 break;
220 case ESC_MOD:
221 lstrcpy(name,"Mod");
222 break;
223 case ESC_AND:
224 lstrcpy(name,"And");
225 break;
226 case ESC_OR:
227 lstrcpy(name,"Or");
228 break;
229 case ESC_XOR:
230 lstrcpy(name,"Xor");
231 break;
232 case ESC_NOT:
233 lstrcpy(name,"Not");
234 break;
235 case ESC_AS:
236 lstrcpy(name,"As");
237 break;
238 case ESC_THEN:
239 lstrcpy(name,"Then");
240 break;
241 case ESC_ELSE:
242 lstrcpy(name,"Else");
243 break;
244 case ESC_IF:
245 lstrcpy(name,"If");
246 break;
247 case ESC_ELSEIF:
248 lstrcpy(name,"ElseIf");
249 break;
250 case ESC_ENDIF:
251 lstrcpy(name,"End If");
252 break;
253 case ESC_DEF:
254 lstrcpy(name,"Def");
255 break;
256 case ESC_DECLARE:
257 lstrcpy(name,"Declare");
258 break;
259 case ESC_ABSTRACT:
260 lstrcpy(name,"Abstract");
261 break;
262 case ESC_VIRTUAL:
263 lstrcpy(name,"Virtual");
264 break;
265 case ESC_OVERRIDE:
266 lstrcpy(name,"Override");
267 break;
268 case ESC_SUB:
269 lstrcpy(name,"Sub");
270 break;
271 case ESC_ENDSUB:
272 lstrcpy(name,"End Sub");
273 break;
274 case ESC_EXITSUB:
275 lstrcpy(name,"Exit Sub");
276 break;
277 case ESC_FUNCTION:
278 lstrcpy(name,"Function");
279 break;
280 case ESC_ENDFUNCTION:
281 lstrcpy(name,"End Function");
282 break;
283 case ESC_EXITFUNCTION:
284 lstrcpy(name,"Exit Function");
285 break;
286 case ESC_BYVAL:
287 lstrcpy(name,"ByVal ");
288 break;
289 case ESC_BYREF:
290 lstrcpy(name,"ByRef ");
291 break;
292 case ESC_TYPE:
293 lstrcpy(name,"Type");
294 break;
295 case ESC_ENDTYPE:
296 lstrcpy(name,"End Type");
297 break;
298 case ESC_EXITFOR:
299 lstrcpy(name,"Exit For");
300 break;
301 case ESC_EXITWHILE:
302 lstrcpy(name,"Exit While");
303 break;
304 case ESC_EXITDO:
305 lstrcpy(name,"Exit Do");
306 break;
307 case ESC_SELECTCASE:
308 lstrcpy(name,"Select Case");
309 break;
310 case ESC_CASE:
311 lstrcpy(name,"Case");
312 break;
313 case ESC_CASEELSE:
314 lstrcpy(name,"Case Else");
315 break;
316 case ESC_ENDSELECT:
317 lstrcpy(name,"End Select");
318 break;
319 case ESC_CONST:
320 lstrcpy(name,"Const");
321 break;
322 case ESC_TYPEDEF:
323 lstrcpy(name,"TypeDef");
324 break;
325 case ESC_WITH:
326 lstrcpy(name,"With");
327 break;
328 case ESC_ENDWITH:
329 lstrcpy(name,"End With");
330 break;
331 case ESC_CDECL:
332 lstrcpy(name,"cdecl");
333 break;
334 case ESC_MACRO:
335 lstrcpy(name,"Macro");
336 break;
337 case ESC_ENDMACRO:
338 lstrcpy(name,"End Macro");
339 break;
340 case ESC_EXITMACRO:
341 lstrcpy(name,"Exit Macro");
342 break;
343 case ESC_EXPORT:
344 lstrcpy(name,"Export");
345 break;
346 case ESC_CONTINUE:
347 lstrcpy(name,"Continue");
348 break;
349 case ESC_CLASS:
350 lstrcpy(name,"Class");
351 break;
352 case ESC_ENDCLASS:
353 lstrcpy(name,"End Class");
354 break;
355 case ESC_INTERFACE:
356 lstrcpy(name,"Interface");
357 break;
358 case ESC_ENDINTERFACE:
359 lstrcpy(name,"End Interface");
360 break;
361 case ESC_ENUM:
362 lstrcpy(name,"Enum");
363 break;
364 case ESC_ENDENUM:
365 lstrcpy(name,"End Enum");
366 break;
[632]367 case ESC_OPERATOR:
368 lstrcpy( name, "Operator" );
369 break;
[4]370 }
371}
[206]372const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source )
373{
374 int maxLength = (int)source.size();
[4]375
[206]376 char *temporary = (char *)malloc( source.size() + 8192 );
377 lstrcpy( temporary, source.c_str() );
[4]378
[206]379 for( int i=0; i<maxLength-1; i++ )
380 {
381 if( temporary[i] == 1 )
382 {
[632]383 int esc = temporary[i+1];
[206]384 char temp2[255];
[632]385 GetDefaultNameFromES( esc, temp2 );
[206]386 if( i>0 )
387 {
388 char temp3[255];
389 wsprintf( temp3, " %s", temp2 );
390 lstrcpy( temp2, temp3 );
391 }
392 if( i<maxLength-2 )
393 {
394 lstrcat( temp2, " " );
395 }
[4]396
[632]397 int slide = 2;
398
399 if( esc == ESC_OPERATOR )
400 {
401 extern char *calcNames[256];
[644]402 unsigned char calcId = temporary[i+2];
[632]403 if( calcNames[calcId] )
404 {
405 lstrcat( temp2, calcNames[calcId] );
406 }
407 slide = 3;
408 }
409
[206]410 int length = lstrlen( temp2 );
[632]411 SlideString( temporary + i+slide, length-slide );
[206]412 memcpy( temporary + i, temp2, length );
413 maxLength = lstrlen( temporary );
414 }
[4]415 }
[206]416
417 static std::string resultStr = "";
418 resultStr = temporary;
419
420 free( temporary );
421
422 return resultStr;
[4]423}
424
[279]425bool IsFileExist(const char *path){
[4]426 WIN32_FIND_DATA wfd;
427 HANDLE hFind;
428
429 hFind=FindFirstFile(path,&wfd);
430 if(hFind==INVALID_HANDLE_VALUE){
[279]431 return false;
[4]432 }
433 FindClose(hFind);
434
[279]435 return true;
[4]436}
437BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle){
438 BROWSEINFO BrowseInfo;
439 LPITEMIDLIST pidlBrowse;
440 LPMALLOC g_pMalloc;
441 char temporary[MAX_PATH];
442
443 BrowseInfo.hwndOwner=hWnd;
444 BrowseInfo.pszDisplayName=temporary;
445 BrowseInfo.pidlRoot=NULL;
446 BrowseInfo.lpszTitle=OpenFolderTitle;
447 BrowseInfo.ulFlags=BIF_RETURNONLYFSDIRS;
448 BrowseInfo.lpfn=NULL;
449 BrowseInfo.lParam=(LPARAM)0;
450 BrowseInfo.iImage=0;
451 pidlBrowse=SHBrowseForFolder(&BrowseInfo);
452 if(pidlBrowse){
453 if(SHGetMalloc(&g_pMalloc)!=0) return 0;
454 SHGetPathFromIDList(pidlBrowse,folder);
455 g_pMalloc->Free(pidlBrowse);
456 g_pMalloc->Release();
457 return 1;
458 }
459 return 0;
460}
[31]461
462void ShortPathToLongPath(const char *ShortPath,char *LongPath){
463 HANDLE hFind;
464 WIN32_FIND_DATA wfd;
465 int i;
466 char dummy[MAX_PATH];
467 for(i=0;i<MAX_PATH;i++){
468 LongPath[i]=ShortPath[i];
469 if((ShortPath[i-1]==':'&&ShortPath[i]=='\\')||(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\')){
470 LongPath[i+1]=0;
471 break;
472 }
473 }
474 if(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\'){
475 for(i++;i<MAX_PATH;i++){
476 if(IsDBCSLeadByte(ShortPath[i])){
477 i++;
478 continue;
479 }
480 LongPath[i]=ShortPath[i];
481 if(ShortPath[i]=='\\'){
482 LongPath[i+1]=0;
483 break;
484 }
485 }
486 for(i++;i<MAX_PATH;i++){
487 if(IsDBCSLeadByte(ShortPath[i])){
488 i++;
489 continue;
490 }
491 LongPath[i]=ShortPath[i];
492 if(ShortPath[i]=='\\'){
493 LongPath[i+1]=0;
494 break;
495 }
496 }
497 }
498 for(i++;i<MAX_PATH;i++){
499 if(IsDBCSLeadByte(ShortPath[i])){
500 i++;
501 continue;
502 }
503 if(ShortPath[i]=='\\'||ShortPath[i]=='\0'){
504 strncpy(dummy,ShortPath,i);
505 dummy[i]=0;
506 if((hFind=FindFirstFile(dummy,&wfd))!=INVALID_HANDLE_VALUE) FindClose(hFind);
507 lstrcat(LongPath,wfd.cFileName);
508
509 if(ShortPath[i]=='\0') break;
510 lstrcat(LongPath,"\\");
511
512 if(ShortPath[i]=='\\'&&ShortPath[i+1]=='\0'){
513 break;
514 }
515 }
516 }
517}
[400]518
519
520bool IsVariableTopChar(char c){
521 if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c=='_')
522 {
523 return true;
524 }
525 return false;
526}
527bool IsVariableChar( char c, bool isGenericsChars ){
528 if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||
529 c=='%'||c=='!'||c=='#'||c=='$'||
530 c=='_'||c=='.')
531 {
532 return true;
533 }
534
535 if( isGenericsChars )
536 {
537 if( c == '<' || c == '>' )
538 {
539 return true;
540 }
541 }
542
543 return false;
544}
545bool IsBlank(char c){
546 if(c==' '||c=='\t') return 1;
547 return 0;
548}
549int GetOneParameter(const char *Parameter,int pos,char *retAns){
550 int i,i2,i3,IsStr;
551 for(i=pos,i2=0,IsStr=0;;i++,i2++){
552 if(Parameter[i]=='\"') IsStr^=1;
553 else if(Parameter[i]=='('&&IsStr==0){
554 i3=GetStringInPare(retAns+i2,Parameter+i);
555 i+=i3-1;
556 i2+=i3-1;
557 continue;
558 }
559 else if(Parameter[i]=='['&&IsStr==0){
560 i3=GetStringInBracket(retAns+i2,Parameter+i);
561 i+=i3-1;
562 i2+=i3-1;
563 continue;
564 }
565 else if(Parameter[i]==','&&IsStr==0){
566 retAns[i2]=0;
567 i++;
568 break;
569 }
570
571 if(IsCommandDelimitation(Parameter[i])&&IsStr==0
572 || Parameter[i] == ')' && IsStr == 0 ){
573 retAns[i2]=0;
574 break;
575 }
576
577 retAns[i2]=Parameter[i];
578 }
579 return i;
580}
581int JumpOneParameter(char *Parameter,int i){
582 int i2,IsStr;
583 for(i2=0,IsStr=0;;i++,i2++){
584 if(Parameter[i]=='\"') IsStr^=1;
585 else if(Parameter[i]=='('&&IsStr==0){
586 i=JumpStringInPare(Parameter,i+1);
587 continue;
588 }
589 else if(Parameter[i]=='['&&IsStr==0){
590 i=JumpStringInBracket(Parameter,i+1);
591 continue;
592 }
593 else if(Parameter[i]==','&&IsStr==0){
594 i++;
595 break;
596 }
597 if(IsCommandDelimitation(Parameter[i])) break;
598 }
599 return i;
600}
601int GetStringInQuotation(char *buffer,char *ReadBuffer){
602 int i;
603
604 if(ReadBuffer[0]=='\"'){
605 buffer[0]=ReadBuffer[0];
606 i=1;
607 }
608 else i=0;
609
610 for(;;i++){
611 buffer[i]=ReadBuffer[i];
612 if(IsDBCSLeadByte(ReadBuffer[i])){
613 i++;
614 buffer[i]=ReadBuffer[i];
615 continue;
616 }
617 if(ReadBuffer[i]=='\"'){
618 i++;
619 buffer[i]=0;
620 break;
621 }
622 if(ReadBuffer[i]=='\0') return 0;
623 }
624 return i;
625}
626int GetStringInPare( char *buffer, const char *ReadBuffer, bool isRemovePare ){
627 int i,IsStr,PareNum;
628 for(i=0,IsStr=0,PareNum=0;;i++){
629 buffer[i]=ReadBuffer[i];
630 if(IsDBCSLeadByte(ReadBuffer[i])){
631 i++;
632 buffer[i]=ReadBuffer[i];
633 continue;
634 }
635 if(ReadBuffer[i]=='\"') IsStr^=1;
636 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
637 else if(ReadBuffer[i]==')'&&IsStr==0){
638 PareNum--;
639 if(PareNum==0){
640 i++;
641 buffer[i]=0;
642 break;
643 }
644 }
645 else if(ReadBuffer[i]=='\0') return 0;
646 }
647
648 if( isRemovePare )
649 {
650 RemoveStringPare( buffer );
651 }
652
653 return i;
654}
655int GetStringInBracket(char *buffer,const char *ReadBuffer){
656 int i,IsStr,PareNum;
657 for(i=0,IsStr=0,PareNum=0;;i++){
658 buffer[i]=ReadBuffer[i];
659 if(IsDBCSLeadByte(ReadBuffer[i])){
660 i++;
661 buffer[i]=ReadBuffer[i];
662 continue;
663 }
664 if(ReadBuffer[i]=='\"') IsStr^=1;
665 else if(ReadBuffer[i]=='['&&IsStr==0) PareNum++;
666 else if(ReadBuffer[i]==']'&&IsStr==0){
667 PareNum--;
668 if(PareNum==0){
669 i++;
670 buffer[i]=0;
671 break;
672 }
673 }
674 else if(ReadBuffer[i]=='\0') return 0;
675 }
676 return i;
677}
678int GetStringInGenericBracket(char *buffer,const char *ReadBuffer){
679 int i,IsStr,PareNum;
680 for(i=0,IsStr=0,PareNum=0;;i++){
681 buffer[i]=ReadBuffer[i];
682 if(IsDBCSLeadByte(ReadBuffer[i])){
683 i++;
684 buffer[i]=ReadBuffer[i];
685 continue;
686 }
687 if(ReadBuffer[i]=='\"') IsStr^=1;
688 else if(ReadBuffer[i]=='<'&&IsStr==0) PareNum++;
689 else if(ReadBuffer[i]=='>'&&IsStr==0){
690 PareNum--;
691 if(PareNum==0){
692 i++;
693 buffer[i]=0;
694 break;
695 }
696 }
697 else if(ReadBuffer[i]=='\0') return 0;
698 }
699 return i;
700}
701int JumpStringInPare(const char *buffer,int pos){
702 int PareNum;
703 for(PareNum=1;;pos++){
704 if(buffer[pos]=='\"'){
705 for(pos++;;pos++){
706 if(buffer[pos]=='\"') break;
707 }
708 continue;
709 }
710 else if(buffer[pos]=='(') PareNum++;
711 else if(buffer[pos]==')'){
712 PareNum--;
713 if(PareNum==0) return pos;
714 }
715 else if(buffer[pos]=='\0') break;
716 }
717 return 0;
718}
719int JumpStringInBracket(const char *buffer,int pos){
720 int PareNum;
721 for(PareNum=1;;pos++){
722 if(buffer[pos]=='\"'){
723 for(pos++;;pos++){
724 if(buffer[pos]=='\"') break;
725 }
726 continue;
727 }
728 else if(buffer[pos]=='[') PareNum++;
729 else if(buffer[pos]==']'){
730 PareNum--;
731 if(PareNum==0) return pos;
732 }
733 else if(buffer[pos]=='\0') break;
734 }
735 return 0;
736}
737bool IsCommandDelimitation( char c ){
738 if( c == '\n' || c == ':' || c == '\0' ){
739 return true;
740 }
741
742 return false;
743}
744
745int GetStringInPare_RemovePare(char *buffer,const char *ReadBuffer){
746 int i,IsStr,PareNum;
747 for(i=0,IsStr=0,PareNum=1;;i++){
748 buffer[i]=ReadBuffer[i];
749 if(IsDBCSLeadByte(ReadBuffer[i])){
750 i++;
751 buffer[i]=ReadBuffer[i];
752 continue;
753 }
754 if(ReadBuffer[i]=='\"') IsStr^=1;
755 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
756 else if(ReadBuffer[i]==')'&&IsStr==0){
757 PareNum--;
758 if(PareNum==0){
759 buffer[i]=0;
760 break;
761 }
762 }
763 else if(ReadBuffer[i]=='\0') return 0;
764 }
765 return i;
766}
767
768void SplitParameter( const std::string &src, Jenga::Common::Strings &dests, bool isClear )
769{
770 const char *buffer = src.c_str();
771 int i = 0;
772
773 if( isClear )
774 {
775 dests.clear();
776 }
777
778 while( buffer[i] )
779 {
780 char result[8192];
781 i = GetOneParameter( buffer, i, result );
782 dests.push_back( result );
783 }
784}
785
786
787bool SplitMemberName( const char *desc, char *object, char *member, ReferenceKind &refType ){
788 int lastIndex = -1;
789 for( int i=0; desc[i]; i++ ){
790 if( desc[i] == '(' ){
791 i=JumpStringInPare(desc,i+1);
792 continue;
793 }
794 else if( desc[i] == '[' ){
795 i=JumpStringInBracket(desc,i+1);
796 continue;
797 }
798 else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){
799 lastIndex = i;
800 }
801 }
802 if( lastIndex == -1 ){
803 if( object )
804 {
805 object[0] = 0;
806 }
807 lstrcpy( member, desc );
808 return false;
809 }
810
811 if(desc[lastIndex]=='.'){
812 lstrcpy(member,desc+lastIndex+1);
813 refType = RefDot;
814 }
815 else{
816 lstrcpy(member,desc+lastIndex+2);
817 refType = RefPointer;
818 }
819
820 if( object ){
821 lstrcpy( object, desc );
822 object[lastIndex]=0;
823 }
824
825 return true;
826}
827bool SplitMemberName( const char *desc, char *object, char *member ){
828 ReferenceKind dummyRefType;
829 return SplitMemberName( desc, object, member, dummyRefType );
830}
831
832void SplitSyntacticForAs( const char *src, char *varName, char *typeName)
833{
834 int i = 0;
835 for( ; ; i++ )
836 {
837 if( src[i] == '\0' || src[i] == 1 && src[i+1] == ESC_AS )
838 {
839 varName[i] = 0;
840 break;
841 }
842 varName[i] = src[i];
843 }
844
845 if( src[i] )
846 {
847 lstrcpy( typeName, src + i + 2 );
848 }
849 else
850 {
851 typeName[i] = 0;
852 }
853}
854
855bool IsGenericTypeSourcePart( const char *buffer )
856{
857 if( buffer[0] != '<' )
858 {
859 Jenga::Throw( "意図しない文字列に対してIsGenericTypeSourcePart関数が呼ばれた" );
860 return false;
861 }
862
863 int i=1, scopeCount=1;
864 for( ; ; i++ )
865 {
866 if( buffer[i] == '\0' )
867 {
868 break;
869 }
870 if( buffer[i] == '<' )
871 {
872 scopeCount++;
873 }
874 else if( buffer[i] == '>' )
875 {
876 scopeCount--;
877
878 if( scopeCount == 0 )
879 {
880 break;
881 }
882 }
883 }
884
885 if( buffer[i] != '>' )
886 {
887 return false;
888 }
889
890
891 /////////////////////////////////////////////////////////////////
892 // '>'に続く文字を判定する
893 /////////////////////////////////////////////////////////////////
894
895 i++;
896 while( IsBlank( buffer[i] ) )
897 {
898 i++;
899 }
900
901 if( IsVariableChar( buffer[i] ) )
902 {
903 return false;
904 }
905
906 return true;
907}
Note: See TracBrowser for help on using the repository browser.