From de4adf5084c3c41987bb4e959505de57b9066c0a Mon Sep 17 00:00:00 2001 From: Jerome St-Louis Date: Sat, 5 Dec 2015 18:46:20 -0500 Subject: [PATCH] EDA/idList: Fixed remaining issues with 64 bit Id - Also moved in IdListIncludes custom SQL function definition --- eda/libeda/src/idList.ec | 88 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 79 insertions(+), 9 deletions(-) diff --git a/eda/libeda/src/idList.ec b/eda/libeda/src/idList.ec index 1293680..50425a0 100644 --- a/eda/libeda/src/idList.ec +++ b/eda/libeda/src/idList.ec @@ -168,6 +168,7 @@ public class Id : uint64 { if(&this) { + Id thisID = this; // FIXME Table tbl = class_data(table) ? *class_data(table) : null; if(tbl) @@ -182,9 +183,9 @@ public class Id : uint64 } r = tbl.cachedIdRow; - if(this) + if(thisID) { - if(r.Find(idField, middle, nil, this)) + if(r.Find(idField, middle, nil, thisID)) { String name = null; Field * nameField = class_data(nameField); @@ -222,7 +223,15 @@ public class Id : uint64 } } else - sprintf(tempString, "(Invalid %s entry: %d)", tbl.name, this); + { + sprintf(tempString, "(Invalid %s entry: " + #if defined(__WIN32__) + "%I64d" + #else + "%lld" + #endif + ")", tbl.name, thisID); + } } else { @@ -233,7 +242,7 @@ public class Id : uint64 } else { - Id id = this; + Id id = thisID; id.OnGetString(tempString, null, null); } } @@ -424,7 +433,7 @@ public: if(row == listBox.lastRow) { row = listBox.AddRow(); - row.SetData(null, 0); + row.SetData(null, (Id)0); listBox.scroll.y = listBox.scrollArea.h; } else if(row.next == listBox.lastRow) @@ -450,7 +459,7 @@ public: r.SetData(null, ids[c]); } r = list.AddRow(); - r.SetData(null, 0); + r.SetData(null, (Id)0); list.Create(); list.modifiedDocument = false; return list; @@ -482,6 +491,67 @@ public: } } +public class IdList32 : IdList +{ + void OnUnserialize(IOChannel channel) + { + int c, count; + + this = null; + + channel.Unserialize(count); + if(count != MAXDWORD) + { + IdList idList = eInstance_New(_class); + idList.count = count; + idList.ids = new Id[count]; + for(c = 0; c < count; c++) + { + uint32 id; + channel.Unserialize(id); + idList.ids[c] = id; + } + this = idList; + } + } + + void OnSerialize(IOChannel channel) + { + if(this) + { + int c; + channel.Serialize(count); + for(c = 0; c < count; c++) + channel.Serialize((uint32)ids[c]); + } + else + { + Id none = MAXDWORD; + channel.Serialize((uint32)none); + } + } +} + +public class IdListIncludes : SQLCustomFunction +{ + // Should private methods be added to the component system? +public: + bool function(IdList list, Id id) + { + return list.Includes(id); + } +} + +public class IdList32Includes : SQLCustomFunction +{ + // Should private methods be added to the component system? +public: + bool function(IdList32 list, Id id) + { + return list.Includes(id); + } +} + static void FreeString(String string) { delete string; @@ -950,7 +1020,7 @@ public struct DataList : OldList if(type.type == normalClass || type.type == structClass || type.type == noHeadClass) listBox.AddRow().SetData(null, null); else - listBox.AddRow().SetData(null, 0); + listBox.AddRow().SetData(null, (Id)0); listBox.scroll.y = listBox.scrollArea.h; listBox.alwaysEdit = true; } @@ -998,7 +1068,7 @@ public struct DataList : OldList if(type.type == normalClass || type.type == structClass || type.type == noHeadClass) lastRow.SetData(null, null); else - lastRow.SetData(null, 0); + lastRow.SetData(null, (Id)0); } } }; @@ -1026,7 +1096,7 @@ public struct DataList : OldList if(type.type == normalClass || type.type == structClass || type.type == noHeadClass) r.SetData(null, null); else - r.SetData(null, 0); + r.SetData(null, (Id)0); list.Create(); list.modifiedDocument = false; return list; -- 1.8.3.1