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

Last change on this file was 829, checked in by イグトランス (egtra), 13 years ago

svn:eol-styleとsvn:mime-type(文字コード指定含む)の設定

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