private PyRep analyse(PyRep obj) { try { if (obj is PyObjectEx) { bool usedList, usedDict; PyRep res = obj; PyObjectEx ex = obj as PyObjectEx; if (!ex.IsType2) { res = analyseType1(ex, out usedList, out usedDict); } else { res = analyseType2(ex, out usedList, out usedDict); } if (res != obj) { if (!usedList) { if (ex.List != null && ex.List.Count > 0) { unknown.AppendLine("Unused List item in " + res.GetType()); } } if (!usedDict) { if (ex.Dictionary != null && ex.Dictionary.Count > 0) { unknown.AppendLine("Unused dictionary item in " + res.GetType()); } } } return(res); } } catch (InvalidDataException) { return(obj); } return(obj); }
private PyRep analyseType2(PyObjectEx obj, out bool usedList, out bool usedDict) { usedDict = false; usedList = false; // type 2 PyTuple headerTuple = obj.Header as PyTuple; if (headerTuple != null && headerTuple.Items.Count > 1) { int headerCount = headerTuple.Items.Count; PyDict dict = headerTuple.Items[1] as PyDict; PyToken token = null; PyTuple tokenTuple = headerTuple.Items[0] as PyTuple; if (tokenTuple != null && tokenTuple.Items.Count == 1) { token = tokenTuple.Items[0] as PyToken; } if (token != null) { if (headerCount != 2) { unknown.AppendLine("PyObjectEx Type2: headerCount=" + headerCount + " token: " + token.Token); } if (headerCount == 2 && token.Token == "carbon.common.script.sys.crowset.CRowset") { usedList = true; if (dict.Dictionary.Count > 1) { unknown.AppendLine("PyObjectEx Type2: Extra parameters in dict for CRowset"); } return(new CRowSet(dict, obj.List)); } if (headerCount == 2 && token.Token == "carbon.common.script.sys.crowset.CIndexedRowset") { usedDict = true; if (dict.Dictionary.Count > 2) { unknown.AppendLine("PyObjectEx Type2: Extra parameters in dict for CIndexedRowset"); } return(new CIndexedRowset(dict, obj.Dictionary)); } if (token.Token == "eve.common.script.dogma.effect.BrainEffect") { return(obj); } if (token.Token == "industry.job.Location") { return(obj); } if (token.Token == "eve.common.script.sys.rowset.RowDict") { return(obj); } if (token.Token == "carbon.common.script.sys.crowset.CFilterRowset") { return(obj); } if (token.Token == "eve.common.script.sys.rowset.RowList") { return(obj); } if (token.Token == "eve.common.script.util.pagedCollection.PagedResultSet") { return(obj); } if (token.Token == "shipskins.storage.LicensedSkin") { return(obj); } if (token.Token == "seasons.common.challenge.Challenge") { return(obj); } unknown.AppendLine("Unknown Token type 2: " + token.Token); } } return(obj); }
private PyRep analyseType1(PyObjectEx obj, out bool usedList, out bool usedDict) { usedDict = false; usedList = false; // Type1 PyTuple headerTuple = obj.Header as PyTuple; if (headerTuple != null && headerTuple.Items.Count > 1) { int headerCount = headerTuple.Items.Count; PyToken token = headerTuple.Items[0] as PyToken; if (token != null) { PyTuple tuple1 = null; int tuple1Count = 0; if (headerCount > 1) { tuple1 = headerTuple.Items[1] as PyTuple; if (tuple1 != null) { if (headerCount == 3 && token.Token == "eveexceptions.UserError") { return(new UserError(tuple1, headerTuple.Items[2] as PyDict)); } tuple1Count = tuple1.Items.Count; if (tuple1Count == 0) { if (headerCount == 3 && token.Token == "carbon.common.script.net.machoNetExceptions.WrongMachoNode") { return(new WrongMachoNode(headerTuple.Items[2] as PyDict)); } } if (tuple1Count == 1) { if (token.Token == "blue.DBRowDescriptor") { return(new DBRowDescriptor(headerTuple)); } PyRep item1 = tuple1.Items[0]; if (item1 != null) { if (token.Token == "__builtin__.set") { return(new BuiltinSet(item1 as PyList)); } if (headerCount == 2 && token.Token == "collections.defaultdict") { PyToken tupleToken = item1 as PyToken; if (tupleToken.Token == "__builtin__.set") { usedDict = true; return(new DefaultDict(obj.Dictionary)); } } if (token.Token == "carbon.common.script.net.objectCaching.CacheOK") { if (item1.StringValue == "CacheOK") { return(new CacheOK()); } } } } } } if (token.Token == "carbon.common.script.net.GPSExceptions.GPSTransportClosed") { return(obj); } unknown.AppendLine("Unknown or malformed token: " + token.Token); } } return(obj); }
private static string PrintObjectEx(PyObjectEx obj) { return "[PyObjectEx " + (obj.IsType2 ? "Type2" : "Normal") + "]"; }