public static FField loadField(FStruct fs, String fname, List <String> parms) { FField f = null; //check for loaded struct FEntry ftype = fs.format.structs.getEntry(parms[0].ToLower()); if (ftype != null) { f = new StructField(fs, fname, (FStruct)ftype); } //else is a predefined struct else { switch (parms[0]) { case "int": f = IntField.loadEntry(fs, fname, parms); break; case "fixedstr": f = FixedString.loadEntry(fs, fname, parms); break; case "fixedbuf": f = FixedBuffer.loadEntry(fs, fname, parms); break; case "varbuf": f = VariableBuffer.loadEntry(fs, fname, parms); break; case "vartable": f = VariableTable.loadEntry(fs, fname, parms); break; case "sizebuftable": f = SizeBufferTable.loadEntry(fs, fname, parms); break; default: break; } } return(f); }
public override void formatEntry(SourceFile src, List <string> lines) { lines.Add(""); lines.Add("//" + name); FField delimf = (FField)structure.format.vars.getEntry(delim); uint count = delimf.value; for (int i = 0; i < count; i++) { if (i > 0) { lines.Add(""); } lines.Add("[" + i + "]"); fs.formatEntry(src, lines); } }
//use hard coded fields for now public static Format loadFormatFile(string filepath) { Format format = new Format(); EnamlData gosling = EnamlData.loadFromFile(filepath); string gosVersion = gosling.getStringValue("Gosling.version", ""); //read in structure data List <String> structs = gosling.getPathKeys("structs"); foreach (String structname in structs) { FStruct fs = new FStruct(format, structname); List <String> fields = gosling.getPathKeys("structs." + structname); String fieldpath = "structs." + structname + "."; foreach (String fieldname in fields) { String fline = gosling.getStringValue(fieldpath + fieldname, ""); List <String> parms = getParams(fline); FField f = loadField(fs, fieldname, parms); fs.fields.Add(f); fs.symTable.addEntry(fieldname, f); } format.structs.addEntry(structname, fs); } //read in file structure data format.fyle = new FStruct(format, "file"); List <String> ffields = gosling.getPathKeys("file"); foreach (String fieldname in ffields) { String fline = gosling.getStringValue("file." + fieldname, "").Trim(); List <String> parms = getParams(fline); FField f = loadField(format.fyle, fieldname, parms); format.fyle.fields.Add(f); format.fyle.symTable.addEntry(fieldname, f); } return(format); }
public override void formatEntry(SourceFile src, List <string> lines) { uint pos = src.getPos(); FField delimf = (FField)format.vars.getEntry(delim); uint width = delimf.getValue() - pos; string s = pos.ToString("X6"); int count = 0; for (int i = 1; i <= width; i++) { uint v = src.getOne(); s = s + ':' + v.ToString("X2"); count++; if ((count == 16) && (i != width)) { lines.Add(s); s = src.getPos().ToString("X6"); count = 0; } } lines.Add(s); }