1 (* Copyright (C) DooM 2D:Forever Developers
2 *
3 * This program is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
6 * (at your option) any later version.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 *)
16 {$INCLUDE a_modes.inc}
19 interface
21 uses
22 Classes,
26 // ////////////////////////////////////////////////////////////////////////// //
27 type
37 // this is base type for all scalars (and arrays)
39 public
40 type
41 TType = (TBool, TChar, TByte, TUByte, TShort, TUShort, TInt, TUInt, TString, TPoint, TSize, TList, TTrigData);
42 // TPoint: pair of Integers
43 // TSize: pair of UShorts
44 // TList: actually, array of records
45 // TTrigData: array of mMaxDim bytes, but internally a record (mRecRef)
46 // arrays of chars are pascal shortstrings (with counter in the first byte)
48 private
49 type
52 private
73 mAsMonsterId: Boolean; // special hack for triggers: monster record number+1 in binary (so 0 means "none")
74 // default value
81 mEBSType: TObject; // either TDynRecord or TDynEBS; nil means "simple type"; nil for `TTrigData` too
83 // for binary parser
86 private
91 procedure parseDefaultValue (); // parse `mDefUnparsed` to `mDefSVal`, `mDefIVal`, `mDefIVal2`, `mDefRecRef`
95 public
113 // won't work for lists
118 public
140 // "value" header record contains TList fields, with name equal to record type
142 private
152 mHeaderRec: TDynRecord; // for "value" records this is header record with data, for "type" records this is header type record
154 private
164 protected
169 public
187 // find field with `TriggerType` type
190 // number of records of the given instance
193 public
208 private
217 private
226 public
233 // return empty string if not found
236 public
245 public
250 private
255 public
265 // creates new header record
268 // creates new header record
271 public
276 implementation
278 uses
282 // ////////////////////////////////////////////////////////////////////////// //
286 // ////////////////////////////////////////////////////////////////////////// //
288 begin
299 begin
306 begin
313 begin
348 var
350 begin
361 begin
364 end
365 else
366 begin
394 // won't work for lists
396 begin
414 begin
424 var
426 begin
428 try
430 finally
437 var
443 begin
445 begin
450 end
451 else
452 begin
458 try
465 finally
477 // default value should be parsed
479 begin
482 begin
484 raise Exception.Create(Format('field ''%s'' in record ''%s'' of record type ''%s'' is not set', [mName, mOwner.mId, mOwner.mName]));
494 // default value should be parsed
496 begin
509 begin
530 begin
539 TEBS.TBitSet: begin result += ' bitset '; if mBitSetUnique then result += 'unique '; result += mEBSTypeName; end;
544 begin
545 if (mType = TType.TPoint) then begin if (mAsT) then result += ' as txy' else result += ' as xy'; end
546 else if (mType = TType.TSize) then begin if (mAsT) then result += ' as twh' else result += ' as wh'; end;
554 begin
558 TType.TChar: if (mMaxDim > 0) then result += formatstrf('Char%d;', [mMaxDim]) else result += 'Char;';
582 var
600 begin
631 begin
633 if (lmaxdim < 1) then raise Exception.Create(Format('invalid field ''%s'' array size', [fldname]));
635 end;
638 begin
640 begin
641 if (fldofs >= 0) then raise Exception.Create(Format('duplicate field ''%s'' offset', [fldname]));
644 continue;
648 begin
655 continue;
656 end;
659 begin
661 if (Length(fldrecname) <> 0) then raise Exception.Create(Format('field ''%s'' already typed as ''%s''', [fldname, fldrecname]));
663 continue;
667 begin
669 if (Length(fldrecname) <> 0) then raise Exception.Create(Format('field ''%s'' already typed as ''%s''', [fldname, fldrecname]));
672 continue;
676 begin
677 if hasdefStr or hasdefInt or hasdefId then raise Exception.Create(Format('field ''%s'' has duplicate default', [fldname]));
680 begin
685 begin
690 begin
694 else
697 continue;
701 begin
703 continue;
707 begin
709 continue;
712 if (pr.tokType <> pr.TTId) then raise Exception.Create(Format('field ''%s'' has something unexpected in definition', [fldname]));
714 if (Length(fldrecname) <> 0) then raise Exception.Create(Format('field ''%s'' already typed as ''%s''', [fldname, fldrecname]));
721 // create field
736 else raise Exception.Create(Format('field ''%s'' has invalid type ''%s''', [fldname, fldtype]));
738 if (lmaxdim > 0) and (mType <> TType.TChar) and (mType <> TType.TTrigData) then raise Exception.Create(Format('field ''%s'' of type ''%s'' cannot be array', [fldname, fldtype]));
740 begin
741 if (lmaxdim < 1) then raise Exception.Create(Format('field ''%s'' of type ''%s'' cannot be array', [fldname, fldtype]));
742 if (Length(fldrecname) > 0) then raise Exception.Create(Format('field ''%s'' of type ''%s'' cannot have another type', [fldname, fldtype]));
763 end;
767 var
773 begin
777 begin
779 begin
780 // this must be triggerdata
782 begin
783 raise Exception.Create(Format('record reference type ''%s'' in field ''%s'' cannot be written', [mEBSTypeName, mName]));
785 // write triggerdata
787 if (buf = nil) then raise Exception.Create(Format('record reference type ''%s'' in field ''%s'' cannot be written', [mEBSTypeName, mName]));
788 try
791 begin
796 finally
800 exit;
802 // record reference
810 else raise Exception.Create(Format('record reference type ''%s'' in field ''%s'' cannot be written', [mEBSTypeName, mName]));
812 // find record number
814 begin
816 if (f < 0) then raise Exception.Create(Format('record reference type ''%s'' in field ''%s'' not found in record list', [mEBSTypeName, mName]));
818 if (f > maxv) then raise Exception.Create(Format('record reference type ''%s'' in field ''%s'' has too big index', [mEBSTypeName, mName]));
819 end
820 else
821 begin
828 else raise Exception.Create(Format('record reference type ''%s'' in field ''%s'' cannot be written', [mEBSTypeName, mName]));
830 exit;
839 begin
841 begin
843 end
844 else
845 begin
848 exit;
851 begin
852 if (mMaxDim = 0) then raise Exception.Create(Format('invalid string size definition for field ''%s''', [mName]));
854 begin
855 if (Length(mSVal) <> 1) then raise Exception.Create(Format('invalid string size definition for field ''%s''', [mName]));
857 end
858 else
859 begin
860 if (Length(mSVal) > mMaxDim) then raise Exception.Create(Format('invalid string size definition for field ''%s''', [mName]));
865 exit;
869 begin
870 // triggerdata array was processed earlier
871 if (mMaxDim >= 0) then Exception.Create(Format('byte array in field ''%s'' cannot be written', [mName]));
873 exit;
877 begin
878 if (mMaxDim >= 0) then raise Exception.Create(Format('short array in field ''%s'' cannot be written', [mName]));
880 exit;
884 begin
885 if (mMaxDim >= 0) then raise Exception.Create(Format('int array in field ''%s'' cannot be written', [mName]));
887 exit;
890 begin
894 begin
895 if (mMaxDim >= 0) then raise Exception.Create(Format('pos/size array in field ''%s'' cannot be written', [mName]));
898 exit;
901 begin
902 if (mMaxDim >= 0) then raise Exception.Create(Format('pos/size array in field ''%s'' cannot be written', [mName]));
905 exit;
908 begin
910 exit;
913 begin
915 exit;
923 var
927 begin
933 begin
935 begin
937 end
939 begin
941 end
942 else
943 begin
947 exit;
950 begin
951 //def := mOwner.mOwner;
952 //es := def.findEBSType(mEBSTypeName);
955 if (es = nil) or (not es.mIsEnum) then raise Exception.Create(Format('record enum type ''%s'' for field ''%s'' not found', [mEBSTypeName, mName]));
957 begin
959 begin
962 exit;
965 raise Exception.Create(Format('value %d in record enum type ''%s'' for field ''%s'' not found', [mIVal, mEBSTypeName, mName]));
968 begin
969 //def := mOwner.mOwner;
970 //es := def.findEBSType(mEBSTypeName);
973 if (es = nil) or es.mIsEnum then raise Exception.Create(Format('record bitset type ''%s'' for field ''%s'' not found', [mEBSTypeName, mName]));
974 // none?
976 begin
978 begin
980 begin
983 exit;
986 raise Exception.Create(Format('value %d in record bitset type ''%s'' for field ''%s'' not found', [0, mEBSTypeName, mName]));
988 // not none
992 begin
994 begin
997 begin
999 begin
1003 break;
1006 if not found then raise Exception.Create(Format('value %d in record bitset type ''%s'' for field ''%s'' not found', [mask, mEBSTypeName, mName]));
1011 exit;
1018 begin
1020 exit;
1023 begin
1024 if (mMaxDim = 0) then raise Exception.Create(Format('invalid string size definition for field ''%s''', [mName]));
1027 exit;
1035 begin
1037 exit;
1040 begin
1043 exit;
1047 begin
1049 exit;
1052 begin
1054 exit;
1057 begin
1059 exit;
1067 var
1074 begin
1078 begin
1079 // this must be triggerdata
1081 begin
1084 // find trigger definition
1086 if (tfld = nil) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' without TriggerType field', [mName, rec.mName]));
1088 if (rc = nil) then raise Exception.Create(Format('triggerdata definition for field ''%s'' in record ''%s'' with type ''%s'' not found', [mName, rec.mName, tfld.mSVal]));
1091 try
1095 finally
1099 exit;
1100 end
1101 else
1102 begin
1103 // not a trigger data
1111 else raise Exception.Create(Format('invalid non-numeric type ''%s'' for field ''%s'' of record ''%s''', [getTypeName(mType), mName, mEBSTypeName]));
1117 exit;
1121 begin
1130 else raise Exception.Create(Format('invalid non-numeric type ''%s'' for field ''%s'' of record ''%s''', [getTypeName(mType), mName, mEBSTypeName]));
1134 if (es = nil) or (es.mIsEnum <> (mEBS = TEBS.TEnum)) then raise Exception.Create(Format('record enum type ''%s'' for field ''%s'' not found', [mEBSTypeName, mName]));
1136 // build enum/bitfield values
1138 begin
1140 if (Length(mSVal) = 0) then raise Exception.Create(Format('record enum type ''%s'' for field ''%s'' has invalid value %d', [mEBSTypeName, mName, mIVal]));
1141 end
1142 else
1143 begin
1144 // special for 'none'
1146 begin
1148 if (Length(mSVal) = 0) then raise Exception.Create(Format('record bitset type ''%s'' for field ''%s'' has invalid value %d', [mEBSTypeName, mName, mIVal]));
1149 end
1150 else
1151 begin
1155 begin
1157 begin
1159 if (Length(s) = 0) then raise Exception.Create(Format('record bitset type ''%s'' for field ''%s'' has invalid value %d', [mEBSTypeName, mName, mask]));
1167 //writeln('ebs <', es.mName, '>: ', mSVal);
1169 exit;
1176 begin
1182 exit;
1185 begin
1187 begin
1189 end
1190 else
1191 begin
1194 try
1199 begin
1204 finally
1209 exit;
1218 begin
1220 exit;
1223 begin
1227 exit;
1230 begin
1234 exit;
1237 begin
1239 exit;
1242 begin
1244 exit;
1255 begin
1257 if (mIVal < min) or (mIVal > max) then raise Exception.Create(Format('invalid %s value for field ''%s''', [getTypeName(mType), mName]));
1261 var
1267 begin
1268 // if this field should contain struct, convert type and parse struct
1272 begin
1273 // ugly hack. sorry.
1275 begin
1278 begin
1279 // '{}'
1282 end
1283 else
1284 begin
1286 // find trigger definition
1288 if (tfld = nil) then raise Exception.Create(Format('triggerdata value for field ''%s'' in record ''%s'' without ''type'' field', [mName, rec.mName]));
1290 if (rc = nil) then raise Exception.Create(Format('triggerdata definition for field ''%s'' in record ''%s'' with type ''%s'' not found', [mName, rec.mName, tfld.mSVal]));
1293 //writeln(rc.definition);
1294 try
1298 finally
1304 exit;
1306 // other record types
1308 begin
1310 begin
1312 end
1313 else
1314 begin
1316 if (rec = nil) then raise Exception.Create(Format('record ''%s'' (%s) value for field ''%s'' not found', [pr.tokStr, mEBSTypeName, mName]));
1322 exit;
1323 end
1325 begin
1326 //rec := mOwner.mOwner.findRecType(mEBSTypeName); // find in mapdef
1329 if (rec = nil) then raise Exception.Create(Format('record type ''%s'' for field ''%s'' not found', [mEBSTypeName, mName]));
1337 exit;
1342 begin
1343 //es := mOwner.mOwner.findEBSType(mEBSTypeName); // find in mapdef
1346 if (es = nil) or (not es.mIsEnum) then raise Exception.Create(Format('record enum type ''%s'' for field ''%s'' not found', [mEBSTypeName, mName]));
1348 if not es.has[tk] then raise Exception.Create(Format('record enum value ''%s'' of type ''%s'' for field ''%s'' not found', [tk, mEBSTypeName, mName]));
1351 //writeln('ENUM ', mEBSName, '; element <', mSVal, '> with value ', mIVal);
1354 exit;
1357 begin
1358 //es := mOwner.mOwner.findEBSType(mEBSTypeName); // find in mapdef
1361 if (es = nil) or es.mIsEnum then raise Exception.Create(Format('record bitset type ''%s'' for field ''%s'' not found', [mEBSTypeName, mName]));
1364 begin
1366 if not es.has[tk] then raise Exception.Create(Format('record bitset value ''%s'' of type ''%s'' for field ''%s'' not found', [tk, mEBSTypeName, mName]));
1370 if mBitSetUnique then raise Exception.Create(Format('record bitset of type ''%s'' for field ''%s'' expects only one value', [tk, mEBSTypeName, mName]));
1371 //pr.expectDelim('|');
1376 exit;
1383 begin
1389 exit;
1392 begin
1393 if (mMaxDim = 0) then raise Exception.Create(Format('invalid string size definition for field ''%s''', [mName]));
1396 begin
1397 // single char
1398 if (Length(mSVal) <> 1) then raise Exception.Create(Format('invalid string size for field ''%s''', [mName]));
1401 end
1402 else
1403 begin
1404 // string
1405 if (Length(mSVal) > mMaxDim) then raise Exception.Create(Format('invalid string size for field ''%s''', [mName]));
1409 exit;
1412 begin
1415 exit;
1418 begin
1421 exit;
1424 begin
1427 exit;
1430 begin
1433 exit;
1436 begin
1439 exit;
1442 begin
1445 exit;
1448 begin
1452 exit;
1456 begin
1460 begin
1461 if (mIVal < 0) or (mIVal > 32767) then raise Exception.Create(Format('invalid %s value for field ''%s''', [getTypeName(mType), mName]));
1465 begin
1466 if (mIVal2 < 0) or (mIVal2 > 32767) then raise Exception.Create(Format('invalid %s value for field ''%s''', [getTypeName(mType), mName]));
1471 exit;
1474 begin
1476 exit;
1479 begin
1481 exit;
1489 // ////////////////////////////////////////////////////////////////////////// //
1491 begin
1492 if (pr = nil) then raise Exception.Create('cannot create record type without type definition');
1506 begin
1517 begin
1528 begin
1531 begin
1540 begin
1546 var
1548 begin
1555 begin
1561 var
1563 begin
1571 var
1574 begin
1582 begin
1595 var
1598 begin
1601 // find record data
1604 if (fld.mType <> fld.TType.TList) then raise Exception.Create(Format('cannot get record of type ''%s'' due to name conflict with ordinary field', [atypename]));
1605 // find by id
1607 begin
1609 begin
1613 // alas
1617 function TDynRecord.findRecordNumByType (const atypename: AnsiString; rc: TDynRecord): Integer;
1618 var
1621 begin
1623 // find record data
1626 if (fld.mType <> fld.TType.TList) then raise Exception.Create(Format('cannot get record of type ''%s'' due to name conflict with ordinary field', [atypename]));
1627 // find by ref
1629 begin
1631 begin
1635 // alas
1640 var
1642 begin
1643 // find record data
1646 begin
1647 // first record
1652 if (fld.mType <> fld.TType.TList) then raise Exception.Create(Format('cannot append record of type ''%s'' due to name conflict with ordinary field', [atypename]));
1653 // append
1660 var
1662 begin
1668 begin
1676 var
1679 begin
1681 begin
1692 // number of records of the given instance
1694 var
1696 begin
1704 var
1707 begin
1709 begin
1712 begin
1714 begin
1718 if isForTrig[tdn] then raise Exception.Create(Format('duplicate trigdata ''%s'' trigtype ''%s''', [mName, tdn]));
1722 end
1723 else
1724 begin
1730 end
1731 else
1732 begin
1737 begin
1740 begin
1741 if (mSize > 0) then raise Exception.Create(Format('duplicate `size` in record ''%s''', [mName]));
1743 if (mSize < 1) then raise Exception.Create(Format('invalid record ''%s'' size: %d', [mName, mSize]));
1745 continue;
1748 begin
1749 if (mBinBlock >= 0) then raise Exception.Create(Format('duplicate `binblock` in record ''%s''', [mName]));
1751 if (mBinBlock < 1) then raise Exception.Create(Format('invalid record ''%s'' binblock: %d', [mName, mBinBlock]));
1752 continue;
1758 // load fields
1760 begin
1762 if hasByName(fld.name) then begin fld.Free(); raise Exception.Create(Format('duplicate field ''%s''', [fld.name])); end;
1763 // append
1766 // done with field
1773 var
1775 begin
1777 begin
1780 end
1781 else
1782 begin
1783 // record
1787 begin
1797 var
1799 begin
1801 begin
1802 // trigger data
1805 begin
1808 begin
1813 end
1814 else
1815 begin
1818 end
1819 else
1820 begin
1821 // record
1828 begin
1838 var
1850 var
1853 begin
1854 //writeln('*** rec: ', rec.mName, '.', rec.mId, ' (', rec.mFields.count, ')');
1856 begin
1858 begin
1860 continue;
1866 begin
1867 e_LogWritefln('record of type ''%s'' with id ''%s'' links to inexistant record of type ''%s'' with id ''%s''', [rec.mName, rec.mId, fld.mEBSTypeName, fld.mRecRefId], MSG_WARNING);
1868 //raise Exception.Create(Format('record of type ''%s'' with id ''%s'' links to inexistant record of type ''%s'' with id ''%s''', [rec.mName, rec.mId, fld.mEBSTypeName, fld.mRecRefId]));
1870 //writeln(' ', rec.mName, '.', rec.mId, ':', fld.mName, ' -> ', rt.mName, '.', rt.mId, ' (', fld.mEBSTypeName, '.', fld.mRecRefId, ')');
1876 begin
1877 //writeln(' ', fld.mName);
1882 begin
1885 try
1887 begin
1888 // parse map file as sequence of blocks
1892 // parse blocks
1894 begin
1900 if (bsize < 0) or (bsize > $1fffffff) then raise Exception.Create(Format('block of type %d has invalid size %d', [btype, bsize]));
1901 if loaded[btype] then raise Exception.Create(Format('block of type %d already loaded', [btype]));
1903 // find record type for this block
1906 if (rect = nil) then raise Exception.Create(Format('block of type %d has no corresponding record', [btype]));
1907 //writeln('found type ''', rec.mName, ''' for block type ', btype);
1908 if (rec.mSize = 0) or ((bsize mod rec.mSize) <> 0) then raise Exception.Create(Format('block of type %d has invalid number of records', [btype]));
1909 // header?
1911 begin
1912 if (bsize <> mSize) then raise Exception.Create(Format('header block of type %d has invalid number of records', [btype]));
1917 end
1918 else
1919 begin
1920 // create list for this type
1925 begin
1929 begin
1936 //writeln('parsed ''', rec.mId, '''...');
1942 //st.position := st.position+bsize;
1944 // link fields
1946 begin
1950 exit;
1953 // read fields
1955 if (mSize < 1) then raise Exception.Create(Format('cannot read record of type ''%s'' with unknown size', [mName]));
1959 begin
1962 if (fld.mBinOfs >= st.size) then raise Exception.Create(Format('record of type ''%s'' has invalid field ''%s''', [fld.mName]));
1964 //writeln('parsing ''', mName, '.', fld.mName, '''...');
1967 finally
1974 procedure TDynRecord.writeBinTo (st: TStream; trigbufsz: Integer=-1; onlyFields: Boolean=false);
1975 var
1981 //f, c: Integer;
1984 begin
1986 begin
1987 if (mBinBlock < 1) then raise Exception.Create('cannot write binary record without block number');
1990 end
1991 else
1992 begin
1995 try
2000 // write normal fields
2002 begin
2003 // record list?
2007 if (fld.mBinOfs >= bufsz) then raise Exception.Create('binary value offset is outside of the buffer');
2009 //writeln('writing field <', fld.mName, '>');
2013 // write block with normal fields
2015 begin
2016 //writeln('writing header...');
2017 // signature and version
2028 // write other blocks, if any
2030 begin
2031 // calculate blkmax
2034 begin
2035 // record list?
2037 begin
2045 // write blocks
2047 begin
2051 begin
2052 // record list?
2054 begin
2063 // flush block
2065 begin
2076 // write end marker
2081 finally
2089 var
2092 begin
2094 begin
2101 try
2103 begin
2104 // record list?
2106 begin
2109 begin
2111 begin
2117 continue;
2124 finally
2133 var
2136 begin
2137 if (mOwner = nil) then raise Exception.Create(Format('can''t parse record ''%s'' value without owner', [mName]));
2139 // not a header?
2141 begin
2142 // id?
2144 end
2145 else
2146 begin
2150 //writeln('parsing record <', mName, '>');
2153 begin
2155 //writeln('<', mName, '.', pr.tokStr, '>');
2157 // records
2159 begin
2160 // add records with this type (if any)
2163 begin
2166 try
2170 begin
2173 begin
2175 begin
2176 if (Length(rv.mId) > 0) and StrEqu(rv.mId, rec.mId) then raise Exception.Create(Format('duplicate thing ''%s'' in record ''%s''', [fld.mName, mName]));
2182 finally
2185 continue;
2189 // fields
2192 begin
2193 if fld.defined then raise Exception.Create(Format('duplicate field ''%s'' in record ''%s''', [fld.mName, mName]));
2194 if fld.internal then raise Exception.Create(Format('internal field ''%s'' in record ''%s''', [fld.mName, mName]));
2197 continue;
2200 // something is wrong
2204 // fix field defaults
2206 //writeln('done parsing record <', mName, '>');
2210 // ////////////////////////////////////////////////////////////////////////// //
2212 begin
2219 begin
2226 begin
2237 begin
2240 begin
2249 begin
2255 var
2257 begin
2264 var
2266 begin
2270 // fields
2273 begin
2277 begin
2281 end
2282 else
2283 begin
2288 // max field
2295 var
2297 begin
2299 // fields
2301 begin
2308 var
2310 begin
2312 begin
2320 var
2326 begin
2335 begin
2338 begin
2339 if StrEqu(mIds[f], idname) then raise Exception.Create(Format('duplicate field ''%s'' in enum/bitset ''%s''', [idname, mName]));
2341 if StrEqu(mMaxName, idname) then raise Exception.Create(Format('duplicate field ''%s'' in enum/bitset ''%s''', [idname, mName]));
2345 // has value?
2347 begin
2349 begin
2350 if (Length(mMaxName) > 0) then raise Exception.Create(Format('duplicate max field ''%s'' in enum/bitset ''%s''', [idname, mName]));
2353 end
2354 else
2355 begin
2361 // append it?
2363 begin
2364 // fix maxvalue
2366 begin
2373 // next cv
2375 begin
2384 // add max field
2386 begin
2395 // ////////////////////////////////////////////////////////////////////////// //
2397 begin
2406 var
2409 begin
2424 begin
2431 var
2433 begin
2435 begin
2443 var
2445 begin
2447 begin
2455 var
2457 begin
2459 begin
2467 var
2472 // setup header links and type links
2474 var
2476 begin
2479 begin
2484 begin
2486 if (fld.mEBSType = nil) then raise Exception.Create(Format('field ''%s'' of type ''%s'' has no correcponding record definition', [fld.mName, fld.mEBSTypeName]));
2490 begin
2492 if (fld.mEBSType = nil) then raise Exception.Create(Format('field ''%s'' of type ''%s'' has no correcponding enum/bitset', [fld.mName, fld.mEBSTypeName]));
2493 if ((fld.mEBS = TDynField.TEBS.TEnum) <> (fld.mEBSType as TDynEBS).mIsEnum) then raise Exception.Create(Format('field ''%s'' of type ''%s'' enum/bitset type conflict', [fld.mName, fld.mEBSTypeName]));
2499 // setup default values
2501 var
2503 begin
2507 begin
2510 begin
2515 begin
2518 begin
2524 //writeln(eb.definition); writeln;
2525 continue;
2529 begin
2532 begin
2534 begin
2541 //writeln(dr.definition); writeln;
2542 continue;
2546 //writeln(dr.definition); writeln;
2547 if (findRecType(rec.name) <> nil) then begin rec.Free(); raise Exception.Create(Format('duplicate record ''%s''', [rec.name])); end;
2548 if (hdr <> nil) and StrEqu(rec.name, hdr.name) then begin rec.Free(); raise Exception.Create(Format('duplicate record ''%s''', [rec.name])); end;
2551 begin
2552 if (hdr <> nil) then begin rec.Free(); raise Exception.Create(Format('duplicate header record ''%s'' (previous is ''%s'')', [rec.name, hdr.name])); end;
2554 end
2555 else
2556 begin
2561 // put header record to top
2567 // setup header links and type links
2571 // setup default values
2577 // ////////////////////////////////////////////////////////////////////////// //
2579 var
2581 begin
2583 try
2591 begin
2600 var
2602 begin
2604 try
2611 begin
2620 var
2626 begin
2628 result += '// ////////////////////////////////////////////////////////////////////////// //'#10;
2631 result += #10#10'// ////////////////////////////////////////////////////////////////////////// //'#10;
2634 begin
2639 result += #10#10'// ////////////////////////////////////////////////////////////////////////// //'#10;
2645 begin
2649 begin
2655 begin