Changeset 7160 for trunk/tools
- Timestamp:
- Oct 23, 2001, 4:14:02 AM (24 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/vslick/odin32.e
r7150 r7160 1 /* $Id: odin32.e,v 1. 8 2001-10-22 04:11:08bird Exp $1 /* $Id: odin32.e,v 1.9 2001-10-23 02:14:02 bird Exp $ 2 2 * 3 3 * Visual SlickEdit Documentation Macros. … … 312 312 if (file_eq(p_extension, 'asm')) 313 313 { 314 _insert_text("; $Id: odin32.e,v 1. 8 2001-10-22 04:11:08bird Exp $\n");314 _insert_text("; $Id: odin32.e,v 1.9 2001-10-23 02:14:02 bird Exp $\n"); 315 315 _insert_text("; \n"); 316 316 _insert_text("; \n"); … … 325 325 else 326 326 { 327 _insert_text("/* $Id: odin32.e,v 1. 8 2001-10-22 04:11:08bird Exp $\n");327 _insert_text("/* $Id: odin32.e,v 1.9 2001-10-23 02:14:02 bird Exp $\n"); 328 328 _insert_text(" * \n"); 329 329 _insert_text(" * \n"); … … 376 376 if (sParams) 377 377 { 378 _str sRetType = odin32_getreturntype(true); 379 if (!sRetType || sRetType == "") 380 sRetType = "void"; /* paranoia! */ 381 378 382 /* 379 383 * Insert text. 380 384 */ 381 if (! search("{"))385 if (!odin32_searchcode("{")) 382 386 { 383 387 p_col++; … … 393 397 } 394 398 395 _insert_text("\n KLOGENTRY"cArgs"(\""s Params"\""sArgs");"); /* todo tab size.. or smart indent */399 _insert_text("\n KLOGENTRY"cArgs"(\""sRetType"\",\""sParams"\""sArgs");"); /* todo tab size.. or smart indent */ 396 400 } 397 401 else 398 _insert_text("\n KLOGENTRY0( );"); /* todo tab size.. or smart indent */402 _insert_text("\n KLOGENTRY0(\""sRetType"\");"); /* todo tab size.. or smart indent */ 399 403 400 404 /* … … 439 443 if (sType) 440 444 { 445 boolean fReturn = true; /* true if an return statment is following the KLOGEXIT statement. */ 446 441 447 /* 442 448 * Insert text. … … 444 450 cur_col = p_col; 445 451 if (sType == 'void' || sType == 'VOID') 446 { 447 while (p_col <= p_SyntaxIndent) 448 keyin(" "); 449 _insert_text("KLOGEXITVOID();"); 452 { /* procedure */ 453 fReturn = cur_word(iIgnorePos) == 'return'; 454 if (!fReturn) 455 { 456 while (p_col <= p_SyntaxIndent) 457 keyin(" "); 458 } 459 460 _insert_text("KLOGEXITVOID();\n"); 461 462 if (fReturn) 463 { 464 for (i = 1; i < cur_col; i++) 465 _insert_text(" "); 466 } 467 search(")","E-"); 450 468 } 451 469 else 452 { 453 if (sType == 'unsigned' || sType == 'UNSIGNED' || sType == 'UINT') 454 _insert_text("KLOGEXITUINT();"); 455 else if (sType == 'int' || sType == 'INT') 456 _insert_text("KLOGEXITINT();"); 457 else if (sType == 'void *' || sType == 'VOID *' || sType == 'PVOID' || sType == 'LPVOID') 458 _insert_text("KLOGEXITHEX();"); 459 else 460 _insert_text("KLOGEXIT(\""sType"\", );"); 461 _insert_text("\n"); 470 { /* function */ 471 _insert_text("KLOGEXIT();\n"); 462 472 for (i = 1; i < cur_col; i++) 463 473 _insert_text(" "); … … 465 475 466 476 /* 467 * Check if it's a simple return statement.477 * Insert value if possible. 468 478 */ 469 479 _save_pos2(valuepos); … … 476 486 _save_pos2(posStart); 477 487 offStart = _QROffset(); 478 if (! search(";", "E+"))488 if (!odin32_searchcode(";", "E+")) 479 489 { 480 490 offEnd = _QROffset(); 481 491 _restore_pos2(posStart); 482 492 _str sValue = strip(get_text(offEnd - offStart)); 483 if (substr(sValue, 1, 1) == '(' && substr(sValue, length(sValue), 1) == ')') 484 sValue = strip(substr(sValue, 2, length(sValue) - 2)); 493 //say 'sValue = 'sValue; 485 494 _restore_pos2(valuepos); 486 495 _save_pos2(valuepos); … … 489 498 } 490 499 _restore_pos2(valuepos); 491 492 /* 493 * Remove old KLOGEXIT statement on previous line if any. 494 */ 500 } 501 502 /* 503 * Remove old KLOGEXIT statement on previous line if any. 504 */ 505 _save_pos2(valuepos); 506 newexitline = p_line; 507 p_line--; p_col = 1; 508 next_word(); 509 if (def_next_word_style == 'E') 510 prev_word(); 511 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT') 512 delete_line(); 513 _restore_pos2(valuepos); 514 515 /* 516 * Check for missing '{...}'. 517 */ 518 if (fReturn) 519 { 520 boolean fFound = false; 495 521 _save_pos2(valuepos); 496 newexitline = p_line; 497 p_line--; p_col = 1; 498 next_word(); 499 if (def_next_word_style == 'E') 522 p_col--; find_matching_paren(); p_col += 2; 523 odin32_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */ 524 525 _str ch = odin32_get_next_code_text(); 526 if (ch != '}') 527 { 528 _restore_pos2(valuepos); 529 _save_pos2(valuepos); 530 p_col--; find_matching_paren(); p_col += 2; 531 odin32_searchcode(';', 'E+'); /* places us at the ';' of the return. (hopefully) */ 532 p_col++; 533 if (odin32_more_code_on_line()) 534 _insert_text(' }'); 535 else 536 { 537 _save_pos2(returnget); 538 odin32_searchcode("return", "E-"); 539 return_col = p_col; 540 _restore_pos2(returnget); 541 542 end_line(); 543 _insert_text("\n"); 544 while (p_col < return_col - p_SyntaxIndent) 545 _insert_text(' '); 546 _insert_text('}'); 547 } 548 549 _restore_pos2(valuepos); 550 _save_pos2(valuepos); 500 551 prev_word(); 501 if (p_line == newexitline - 1 && substr(cur_word(iIgnorePos), 1, 8) == 'KLOGEXIT') 502 delete_line(); 552 p_col -= p_SyntaxIndent; 553 codecol = p_col; 554 _insert_text("{\n"); 555 while (p_col < codecol) 556 _insert_text(' '); 557 } 558 503 559 _restore_pos2(valuepos); 504 560 } 505 561 } 506 562 else 507 message("odin32_get paramsfailed, sType=" sType);563 message("odin32_getreturntype failed, sType=" sType); 508 564 return; 509 565 } … … 597 653 * Select procedure. 598 654 */ 599 while (!search("return", "WE<+") && odin32_getfunction() == sCurFunction) 655 while ( !odin32_searchcode("return", "WE<+") 656 && odin32_getfunction() == sCurFunction) 600 657 { 601 658 //say 'exit sub loop: ' p_line … … 631 688 if (!fUserCancel && sType && (sType == 'void' || sType == 'VOID')) 632 689 { 633 if ( ! search("{", "E+")690 if ( !odin32_searchcode("{", "E+") 634 691 && !find_matching_paren()) 635 692 { … … 667 724 668 725 669 670 726 /** 671 727 * Moves cursor to nearest function start. … … 678 734 _save_pos2(org_pos); 679 735 736 if (!next_proc(1)) 737 { 738 next_line = p_line; 739 if (!prev_proc(1) && p_line == cur_line) 740 { 741 _restore_pos2(org_pos); 742 return 0; 743 } 744 _restore_pos2(org_pos); 745 _save_pos2(org_pos); 746 } 747 else 748 p_col++; /* fixes problem with single function files. */ 749 680 750 if (!prev_proc(1)) 681 751 { … … 690 760 } 691 761 692 if (!next_proc(1))693 {694 next_line = p_line;695 if (!prev_proc(1) && p_line == cur_line)696 {697 _restore_pos2(org_pos);698 return 0;699 }700 _restore_pos2(org_pos);701 _save_pos2(org_pos);702 }703 762 704 763 if (prev_line != -1 && (next_line == -1 || cur_line - prev_line <= next_line - cur_line)) … … 714 773 } 715 774 775 _restore_pos2(org_pos); 716 776 return -1; 717 777 } … … 731 791 proc_line = p_line; 732 792 733 if (! search("{", "E+"))793 if (!odin32_searchcode("{")) 734 794 { 735 795 prev_proc(); … … 752 812 static _str odin32_getfunction() 753 813 { 754 return current_proc(); 814 sFunctionName = current_proc(); 815 if (!sFunctionName) 816 sFunctionName == ""; 817 //say 'functionanme='sFunctionName; 818 return sFunctionName; 755 819 } 756 820 … … 768 832 */ 769 833 if ( !odin32_func_goto_nearest() 770 && ! search("(") /* makes some assumptions. */834 && !odin32_searchcode("(") /* makes some assumptions. */ 771 835 ) 772 836 { … … 889 953 if (iParam == iCurParam) 890 954 { /* (yeah, we did!) */ 891 sArg = strip(substr(sParams, iStartParam, i - 1));955 sArg = strip(substr(sParams, iStartParam, i - iStartParam)); 892 956 893 957 /* lazy approach, which doens't support function types */ … … 970 1034 offStart = _QROffset(); 971 1035 972 if (! search("(")) /* makes some assumptions. */1036 if (!odin32_searchcode("(")) /* makes some assumptions. */ 973 1037 { 974 1038 prev_word(); 975 1039 offEnd = _QROffset(); 976 1040 _restore_pos2(posStart); 977 _str sTypeRaw = strip(get_text(offEnd - offStart - 1)); 978 1041 _str sTypeRaw = strip(get_text(offEnd - offStart)); 1042 1043 //say 'sTypeRaw='sTypeRaw; 979 1044 /* 980 1045 * Remove static, inline, _Optlink, stdcall, EXPENTRY etc. … … 1005 1070 sTypeRaw = stranslate(sTypeRaw, "", "WIN32API", "I"); 1006 1071 sTypeRaw = stranslate(sTypeRaw, "", "WINAPI", "I"); 1072 sTypeRaw = stranslate(sTypeRaw, "", "__operator__", "I"); /* operator fix */ 1073 sTypeRaw = stranslate(sTypeRaw, "", "__operator", "I"); /* operator fix */ 1074 sTypeRaw = stranslate(sTypeRaw, "", "operator__", "I"); /* operator fix */ 1075 sTypeRaw = stranslate(sTypeRaw, "", "operator", "I"); /* operator fix */ 1007 1076 } 1008 1077 … … 1063 1132 return false; 1064 1133 } 1134 1135 1136 /** 1137 * Search for some piece of code. 1138 */ 1139 static int odin32_searchcode(_str sSearchString, _str sOptions = "E+") 1140 { 1141 int rc; 1142 rc = search(sSearchString, sOptions); 1143 while (!rc && !odin32_in_code()) 1144 { 1145 p_col++; 1146 rc = search(sSearchString, sOptions); 1147 } 1148 return rc; 1149 } 1150 1151 1152 /** 1153 * Checks if cursor is in code or in comment. 1154 */ 1155 static boolean odin32_in_code() 1156 { 1157 _save_pos2(searchsave); 1158 boolean fRc = !_in_comment(); 1159 _restore_pos2(searchsave); 1160 return fRc; 1161 } 1162 1163 1164 /* 1165 * Gets the next piece of code. 1166 */ 1167 static _str odin32_get_next_code_text() 1168 { 1169 _str ch; 1170 _save_pos2(searchsave); 1171 ch = odin32_get_next_code_text2(); 1172 _restore_pos2(searchsave); 1173 return ch; 1174 } 1175 1176 1177 /** 1178 * Checks if there is more code on the line. 1179 */ 1180 static boolean odin32_more_code_on_line() 1181 { 1182 boolean fRc; 1183 int curline = p_line; 1184 1185 _save_pos2(searchsave); 1186 odin32_get_next_code_text2(); 1187 fRc = curline == p_line; 1188 _restore_pos2(searchsave); 1189 1190 return fRc; 1191 } 1192 1193 1194 /** 1195 * Gets the next piece of code. 1196 * Doesn't preserver cursor position. 1197 */ 1198 static _str odin32_get_next_code_text2() 1199 { 1200 _str ch; 1201 do 1202 { 1203 curcol = ++p_col; 1204 end_line() 1205 if (p_col <= curcol) 1206 { 1207 p_line++; 1208 p_col = 1; 1209 } 1210 else 1211 p_col = curcol; 1212 1213 ch = get_text(); 1214 //say ch ' ('_asc(ch)')'; 1215 while (ch == "#") /* preprocessor stuff */ 1216 { 1217 p_col = 1; 1218 p_line++; 1219 ch = get_text(); 1220 //say ch ' ('_asc(ch)')'; 1221 continue; 1222 } 1223 } while (ch :== ' ' || ch :== "\t" || ch :== "\n" || ch :== "\r" || !odin32_in_code()); 1224 1225 return ch; 1226 } 1227
Note:
See TracChangeset
for help on using the changeset viewer.