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

Last change on this file since 612 was 603, checked in by dai_9181, 17 years ago

ObjectModuleに関連するクラス一式をab_commonプロジェクトに移動した。

File size: 17.3 KB
Line 
1#include "stdafx.h"
2
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}
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}
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}
179
180int GetSourceCodeIndexFromLine( const char *source, int LineNum ){
181 int i,nCount=0;
182 for(i=0;;i++){
183 if(source[i]=='\n'){
184 nCount++;
185 if(LineNum==nCount){
186 for(i++;;i++){
187 if(IsCommandDelimitation(source[i])) break;
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;
367 }
368}
369const std::string &FormatEscapeSequenceStringToDefaultString( const std::string &source )
370{
371 int maxLength = (int)source.size();
372
373 char *temporary = (char *)malloc( source.size() + 8192 );
374 lstrcpy( temporary, source.c_str() );
375
376 for( int i=0; i<maxLength-1; i++ )
377 {
378 if( temporary[i] == 1 )
379 {
380 char temp2[255];
381 GetDefaultNameFromES( temporary[i+1], temp2 );
382 if( i>0 )
383 {
384 char temp3[255];
385 wsprintf( temp3, " %s", temp2 );
386 lstrcpy( temp2, temp3 );
387 }
388 if( i<maxLength-2 )
389 {
390 lstrcat( temp2, " " );
391 }
392
393 int length = lstrlen( temp2 );
394 SlideString( temporary + i+2, length-2 );
395 memcpy( temporary + i, temp2, length );
396 maxLength = lstrlen( temporary );
397 }
398 }
399
400 static std::string resultStr = "";
401 resultStr = temporary;
402
403 free( temporary );
404
405 return resultStr;
406}
407
408bool IsFileExist(const char *path){
409 WIN32_FIND_DATA wfd;
410 HANDLE hFind;
411
412 hFind=FindFirstFile(path,&wfd);
413 if(hFind==INVALID_HANDLE_VALUE){
414 return false;
415 }
416 FindClose(hFind);
417
418 return true;
419}
420BOOL GetFolder(HWND hWnd,char *folder,char *OpenFolderTitle){
421 BROWSEINFO BrowseInfo;
422 LPITEMIDLIST pidlBrowse;
423 LPMALLOC g_pMalloc;
424 char temporary[MAX_PATH];
425
426 BrowseInfo.hwndOwner=hWnd;
427 BrowseInfo.pszDisplayName=temporary;
428 BrowseInfo.pidlRoot=NULL;
429 BrowseInfo.lpszTitle=OpenFolderTitle;
430 BrowseInfo.ulFlags=BIF_RETURNONLYFSDIRS;
431 BrowseInfo.lpfn=NULL;
432 BrowseInfo.lParam=(LPARAM)0;
433 BrowseInfo.iImage=0;
434 pidlBrowse=SHBrowseForFolder(&BrowseInfo);
435 if(pidlBrowse){
436 if(SHGetMalloc(&g_pMalloc)!=0) return 0;
437 SHGetPathFromIDList(pidlBrowse,folder);
438 g_pMalloc->Free(pidlBrowse);
439 g_pMalloc->Release();
440 return 1;
441 }
442 return 0;
443}
444
445void ShortPathToLongPath(const char *ShortPath,char *LongPath){
446 HANDLE hFind;
447 WIN32_FIND_DATA wfd;
448 int i;
449 char dummy[MAX_PATH];
450 for(i=0;i<MAX_PATH;i++){
451 LongPath[i]=ShortPath[i];
452 if((ShortPath[i-1]==':'&&ShortPath[i]=='\\')||(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\')){
453 LongPath[i+1]=0;
454 break;
455 }
456 }
457 if(ShortPath[i-1]=='\\'&&ShortPath[i]=='\\'){
458 for(i++;i<MAX_PATH;i++){
459 if(IsDBCSLeadByte(ShortPath[i])){
460 i++;
461 continue;
462 }
463 LongPath[i]=ShortPath[i];
464 if(ShortPath[i]=='\\'){
465 LongPath[i+1]=0;
466 break;
467 }
468 }
469 for(i++;i<MAX_PATH;i++){
470 if(IsDBCSLeadByte(ShortPath[i])){
471 i++;
472 continue;
473 }
474 LongPath[i]=ShortPath[i];
475 if(ShortPath[i]=='\\'){
476 LongPath[i+1]=0;
477 break;
478 }
479 }
480 }
481 for(i++;i<MAX_PATH;i++){
482 if(IsDBCSLeadByte(ShortPath[i])){
483 i++;
484 continue;
485 }
486 if(ShortPath[i]=='\\'||ShortPath[i]=='\0'){
487 strncpy(dummy,ShortPath,i);
488 dummy[i]=0;
489 if((hFind=FindFirstFile(dummy,&wfd))!=INVALID_HANDLE_VALUE) FindClose(hFind);
490 lstrcat(LongPath,wfd.cFileName);
491
492 if(ShortPath[i]=='\0') break;
493 lstrcat(LongPath,"\\");
494
495 if(ShortPath[i]=='\\'&&ShortPath[i+1]=='\0'){
496 break;
497 }
498 }
499 }
500}
501
502
503bool IsVariableTopChar(char c){
504 if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||c=='_')
505 {
506 return true;
507 }
508 return false;
509}
510bool IsVariableChar( char c, bool isGenericsChars ){
511 if((c>='A'&&c<='Z')||(c>='a'&&c<='z')||(c>='0'&&c<='9')||
512 c=='%'||c=='!'||c=='#'||c=='$'||
513 c=='_'||c=='.')
514 {
515 return true;
516 }
517
518 if( isGenericsChars )
519 {
520 if( c == '<' || c == '>' )
521 {
522 return true;
523 }
524 }
525
526 return false;
527}
528bool IsBlank(char c){
529 if(c==' '||c=='\t') return 1;
530 return 0;
531}
532int GetOneParameter(const char *Parameter,int pos,char *retAns){
533 int i,i2,i3,IsStr;
534 for(i=pos,i2=0,IsStr=0;;i++,i2++){
535 if(Parameter[i]=='\"') IsStr^=1;
536 else if(Parameter[i]=='('&&IsStr==0){
537 i3=GetStringInPare(retAns+i2,Parameter+i);
538 i+=i3-1;
539 i2+=i3-1;
540 continue;
541 }
542 else if(Parameter[i]=='['&&IsStr==0){
543 i3=GetStringInBracket(retAns+i2,Parameter+i);
544 i+=i3-1;
545 i2+=i3-1;
546 continue;
547 }
548 else if(Parameter[i]==','&&IsStr==0){
549 retAns[i2]=0;
550 i++;
551 break;
552 }
553
554 if(IsCommandDelimitation(Parameter[i])&&IsStr==0
555 || Parameter[i] == ')' && IsStr == 0 ){
556 retAns[i2]=0;
557 break;
558 }
559
560 retAns[i2]=Parameter[i];
561 }
562 return i;
563}
564int JumpOneParameter(char *Parameter,int i){
565 int i2,IsStr;
566 for(i2=0,IsStr=0;;i++,i2++){
567 if(Parameter[i]=='\"') IsStr^=1;
568 else if(Parameter[i]=='('&&IsStr==0){
569 i=JumpStringInPare(Parameter,i+1);
570 continue;
571 }
572 else if(Parameter[i]=='['&&IsStr==0){
573 i=JumpStringInBracket(Parameter,i+1);
574 continue;
575 }
576 else if(Parameter[i]==','&&IsStr==0){
577 i++;
578 break;
579 }
580 if(IsCommandDelimitation(Parameter[i])) break;
581 }
582 return i;
583}
584int GetStringInQuotation(char *buffer,char *ReadBuffer){
585 int i;
586
587 if(ReadBuffer[0]=='\"'){
588 buffer[0]=ReadBuffer[0];
589 i=1;
590 }
591 else i=0;
592
593 for(;;i++){
594 buffer[i]=ReadBuffer[i];
595 if(IsDBCSLeadByte(ReadBuffer[i])){
596 i++;
597 buffer[i]=ReadBuffer[i];
598 continue;
599 }
600 if(ReadBuffer[i]=='\"'){
601 i++;
602 buffer[i]=0;
603 break;
604 }
605 if(ReadBuffer[i]=='\0') return 0;
606 }
607 return i;
608}
609int GetStringInPare( char *buffer, const char *ReadBuffer, bool isRemovePare ){
610 int i,IsStr,PareNum;
611 for(i=0,IsStr=0,PareNum=0;;i++){
612 buffer[i]=ReadBuffer[i];
613 if(IsDBCSLeadByte(ReadBuffer[i])){
614 i++;
615 buffer[i]=ReadBuffer[i];
616 continue;
617 }
618 if(ReadBuffer[i]=='\"') IsStr^=1;
619 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
620 else if(ReadBuffer[i]==')'&&IsStr==0){
621 PareNum--;
622 if(PareNum==0){
623 i++;
624 buffer[i]=0;
625 break;
626 }
627 }
628 else if(ReadBuffer[i]=='\0') return 0;
629 }
630
631 if( isRemovePare )
632 {
633 RemoveStringPare( buffer );
634 }
635
636 return i;
637}
638int GetStringInBracket(char *buffer,const char *ReadBuffer){
639 int i,IsStr,PareNum;
640 for(i=0,IsStr=0,PareNum=0;;i++){
641 buffer[i]=ReadBuffer[i];
642 if(IsDBCSLeadByte(ReadBuffer[i])){
643 i++;
644 buffer[i]=ReadBuffer[i];
645 continue;
646 }
647 if(ReadBuffer[i]=='\"') IsStr^=1;
648 else if(ReadBuffer[i]=='['&&IsStr==0) PareNum++;
649 else if(ReadBuffer[i]==']'&&IsStr==0){
650 PareNum--;
651 if(PareNum==0){
652 i++;
653 buffer[i]=0;
654 break;
655 }
656 }
657 else if(ReadBuffer[i]=='\0') return 0;
658 }
659 return i;
660}
661int GetStringInGenericBracket(char *buffer,const char *ReadBuffer){
662 int i,IsStr,PareNum;
663 for(i=0,IsStr=0,PareNum=0;;i++){
664 buffer[i]=ReadBuffer[i];
665 if(IsDBCSLeadByte(ReadBuffer[i])){
666 i++;
667 buffer[i]=ReadBuffer[i];
668 continue;
669 }
670 if(ReadBuffer[i]=='\"') IsStr^=1;
671 else if(ReadBuffer[i]=='<'&&IsStr==0) PareNum++;
672 else if(ReadBuffer[i]=='>'&&IsStr==0){
673 PareNum--;
674 if(PareNum==0){
675 i++;
676 buffer[i]=0;
677 break;
678 }
679 }
680 else if(ReadBuffer[i]=='\0') return 0;
681 }
682 return i;
683}
684int JumpStringInPare(const char *buffer,int pos){
685 int PareNum;
686 for(PareNum=1;;pos++){
687 if(buffer[pos]=='\"'){
688 for(pos++;;pos++){
689 if(buffer[pos]=='\"') break;
690 }
691 continue;
692 }
693 else if(buffer[pos]=='(') PareNum++;
694 else if(buffer[pos]==')'){
695 PareNum--;
696 if(PareNum==0) return pos;
697 }
698 else if(buffer[pos]=='\0') break;
699 }
700 return 0;
701}
702int JumpStringInBracket(const char *buffer,int pos){
703 int PareNum;
704 for(PareNum=1;;pos++){
705 if(buffer[pos]=='\"'){
706 for(pos++;;pos++){
707 if(buffer[pos]=='\"') break;
708 }
709 continue;
710 }
711 else if(buffer[pos]=='[') PareNum++;
712 else if(buffer[pos]==']'){
713 PareNum--;
714 if(PareNum==0) return pos;
715 }
716 else if(buffer[pos]=='\0') break;
717 }
718 return 0;
719}
720bool IsCommandDelimitation( char c ){
721 if( c == '\n' || c == ':' || c == '\0' ){
722 return true;
723 }
724
725 return false;
726}
727
728int GetStringInPare_RemovePare(char *buffer,const char *ReadBuffer){
729 int i,IsStr,PareNum;
730 for(i=0,IsStr=0,PareNum=1;;i++){
731 buffer[i]=ReadBuffer[i];
732 if(IsDBCSLeadByte(ReadBuffer[i])){
733 i++;
734 buffer[i]=ReadBuffer[i];
735 continue;
736 }
737 if(ReadBuffer[i]=='\"') IsStr^=1;
738 else if(ReadBuffer[i]=='('&&IsStr==0) PareNum++;
739 else if(ReadBuffer[i]==')'&&IsStr==0){
740 PareNum--;
741 if(PareNum==0){
742 buffer[i]=0;
743 break;
744 }
745 }
746 else if(ReadBuffer[i]=='\0') return 0;
747 }
748 return i;
749}
750
751void SplitParameter( const std::string &src, Jenga::Common::Strings &dests, bool isClear )
752{
753 const char *buffer = src.c_str();
754 int i = 0;
755
756 if( isClear )
757 {
758 dests.clear();
759 }
760
761 while( buffer[i] )
762 {
763 char result[8192];
764 i = GetOneParameter( buffer, i, result );
765 dests.push_back( result );
766 }
767}
768
769
770bool SplitMemberName( const char *desc, char *object, char *member, ReferenceKind &refType ){
771 int lastIndex = -1;
772 for( int i=0; desc[i]; i++ ){
773 if( desc[i] == '(' ){
774 i=JumpStringInPare(desc,i+1);
775 continue;
776 }
777 else if( desc[i] == '[' ){
778 i=JumpStringInBracket(desc,i+1);
779 continue;
780 }
781 else if(desc[i]=='.'||(desc[i]==1&&desc[i+1]==ESC_PSMEM)){
782 lastIndex = i;
783 }
784 }
785 if( lastIndex == -1 ){
786 if( object )
787 {
788 object[0] = 0;
789 }
790 lstrcpy( member, desc );
791 return false;
792 }
793
794 if(desc[lastIndex]=='.'){
795 lstrcpy(member,desc+lastIndex+1);
796 refType = RefDot;
797 }
798 else{
799 lstrcpy(member,desc+lastIndex+2);
800 refType = RefPointer;
801 }
802
803 if( object ){
804 lstrcpy( object, desc );
805 object[lastIndex]=0;
806 }
807
808 return true;
809}
810bool SplitMemberName( const char *desc, char *object, char *member ){
811 ReferenceKind dummyRefType;
812 return SplitMemberName( desc, object, member, dummyRefType );
813}
814
815void SplitSyntacticForAs( const char *src, char *varName, char *typeName)
816{
817 int i = 0;
818 for( ; ; i++ )
819 {
820 if( src[i] == '\0' || src[i] == 1 && src[i+1] == ESC_AS )
821 {
822 varName[i] = 0;
823 break;
824 }
825 varName[i] = src[i];
826 }
827
828 if( src[i] )
829 {
830 lstrcpy( typeName, src + i + 2 );
831 }
832 else
833 {
834 typeName[i] = 0;
835 }
836}
837
838bool IsGenericTypeSourcePart( const char *buffer )
839{
840 if( buffer[0] != '<' )
841 {
842 Jenga::Throw( "意図しない文字列に対してIsGenericTypeSourcePart関数が呼ばれた" );
843 return false;
844 }
845
846 int i=1, scopeCount=1;
847 for( ; ; i++ )
848 {
849 if( buffer[i] == '\0' )
850 {
851 break;
852 }
853 if( buffer[i] == '<' )
854 {
855 scopeCount++;
856 }
857 else if( buffer[i] == '>' )
858 {
859 scopeCount--;
860
861 if( scopeCount == 0 )
862 {
863 break;
864 }
865 }
866 }
867
868 if( buffer[i] != '>' )
869 {
870 return false;
871 }
872
873
874 /////////////////////////////////////////////////////////////////
875 // '>'に続く文字を判定する
876 /////////////////////////////////////////////////////////////////
877
878 i++;
879 while( IsBlank( buffer[i] ) )
880 {
881 i++;
882 }
883
884 if( IsVariableChar( buffer[i] ) )
885 {
886 return false;
887 }
888
889 return true;
890}
Note: See TracBrowser for help on using the repository browser.