Changeset 96
- Timestamp:
- 03/19/06 16:15:13 (3 years ago)
- Location:
- trunk/orca
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/orca/boot.c
r82 r96 71 71 "mold: native [\n" 72 72 " value\n" 73 " /only\n" 73 74 "]\n" 74 75 "not: native [value]\n" … … 517 518 " [insert tail series reduce :value]\n" 518 519 "]\n" 520 "save: func [\n" 521 " file [file!]\n" 522 " data\n" 523 "] [\n" 524 " write file mold/only data\n" 525 "]\n" 519 526 "dirize: func [path [file! string!] /local end]\n" 520 527 "[\n" -
trunk/orca/boot.r
r82 r96 98 98 mold: native [ 99 99 value 100 ;/only "Omit outer braces of a block value"101 ;/all "Mold in serialized format"102 ;/flat "Don't indent"100 /only 101 ;/all 102 ;/flat 103 103 ] 104 104 … … 695 695 ] 696 696 697 save: func [ 698 file [file!] 699 data 700 ][ 701 write file mold/only data 702 ] 703 697 704 dirize: func [path [file! string!] /local end] 698 705 [ -
trunk/orca/print.c
r94 r96 23 23 #include "ovalue.h" 24 24 #include "internal.h" 25 26 27 #define MOLD_NO_BRACES 1 28 29 30 static void form( OString* out, const OValue* val, int depth ); 31 static void mold( OString* out, const OValue* val, int depth, int flags ); 32 25 33 26 34 … … 60 68 static void indent( OString* str, int depth ) 61 69 { 62 while( depth-- ) 70 while( depth > 0 ) 71 { 63 72 append(str," ",4); 64 } 65 66 67 static void form( OString* out, const OValue* val, int depth ); 68 static void mold( OString* out, const OValue* val, int depth ); 73 --depth; 74 } 75 } 69 76 70 77 … … 248 255 else 249 256 append1( ' ', out ); 250 mold( out, it + 1, 0 );257 mold( out, it + 1, 0, 0 ); 251 258 252 259 orListNextNode( blk, it ); … … 398 405 // Mold gives us quotes around empty strings. 399 406 // Need to check correct behavior of nested objects. 400 mold( out, it, depth );407 mold( out, it, depth, 0 ); 401 408 402 409 append1( '\n', out ); … … 429 436 { 430 437 append1( ' ', out ); 431 mold( out, it, 0 );438 mold( out, it, 0, 0 ); 432 439 ++it; 433 440 if( it == end ) … … 674 681 675 682 676 static void mold( OString* out, const OValue* val, int depth )683 static void mold( OString* out, const OValue* val, int depth, int mflags ) 677 684 { 678 685 /* … … 928 935 if( vp != path->values ) 929 936 append1( '/', out ); 930 mold( out, vp, 0 );937 mold( out, vp, 0, 0 ); 931 938 } 932 939 if( val->type == OT_SETPATH ) … … 947 954 bval.index = val->func.specBlk; 948 955 bval.series.it = 0; 949 mold( out, &bval, depth );956 mold( out, &bval, depth, 0 ); 950 957 } 951 958 break; … … 964 971 { 965 972 bval.series.n = val->func.specBlk; 966 mold( out, &bval, depth );973 mold( out, &bval, depth, 0 ); 967 974 } 968 975 else … … 972 979 973 980 bval.index = val->func.bodyBlk; 974 mold( out, &bval, depth );981 mold( out, &bval, depth, 0 ); 975 982 } 976 983 break; … … 987 994 // append1( '\n', out ); 988 995 989 append1( (val->type == OT_BLOCK) ? '[' : '(', out ); 996 if( ! (mflags & MOLD_NO_BRACES) ) 997 { 998 append1( (val->type == OT_BLOCK) ? '[' : '(', out ); 999 ++depth; 1000 } 990 1001 991 1002 if( vp != end ) 992 1003 { 993 ++depth;994 1004 for( ; vp != end; ++vp ) 995 1005 { … … 1003 1013 append1( ' ', out ); 1004 1014 } 1005 mold( out, vp, depth );1015 mold( out, vp, depth, 0 ); 1006 1016 } 1017 } 1018 1019 if( ! (mflags & MOLD_NO_BRACES) ) 1020 { 1007 1021 --depth; 1008 } 1009 1010 if( val->flags & OR_FLAG_BEOL ) 1011 { 1012 append1( '\n', out ); 1013 indent(out, depth); 1014 } 1015 1016 append1( (val->type == OT_BLOCK) ? ']' : ')', out ); 1022 if( val->flags & OR_FLAG_BEOL ) 1023 { 1024 append1( '\n', out ); 1025 indent(out, depth); 1026 } 1027 append1( (val->type == OT_BLOCK) ? ']' : ')', out ); 1028 } 1017 1029 } 1018 1030 break; … … 1051 1063 orAtomStr( orAtom(it), out ); 1052 1064 append( out, ": ", 2 ); 1053 mold( out, vit, depth + 1 );1065 mold( out, vit, depth + 1, 0 ); 1054 1066 append1( '\n', out ); 1055 1067 } … … 1110 1122 void orMold( OString* out, const OValue* val ) 1111 1123 { 1112 mold( out, val, 0 );1124 mold( out, val, 0, 0 ); 1113 1125 if( out->used ) 1114 1126 { … … 1134 1146 OR_NATIVE_PUB( orMoldNative ) 1135 1147 { 1148 #define REF_MOLD_ONLY a1+1 1136 1149 OString* str = orMakeString( 0 ); 1137 orMold( str, a1 ); 1150 mold( str, a1, 0, orRefineSet(REF_MOLD_ONLY) ? MOLD_NO_BRACES : 0 ); 1151 if( str->used ) 1152 { 1153 orTermCStr( str ); 1154 } 1138 1155 orResultSTRING( orStringN(str) ); 1139 1156 }
