eda: Fixes for cross-bit compiling; ecere: Took out non-sense code no longer needed
[sdk] / eda / libeda / src / idList.ec
index 92ce1c8..80fccb5 100644 (file)
@@ -41,130 +41,128 @@ public class Id : uint
 
    Window OnEdit(DataBox dataBox, void * obsolete, int x, int y, int w, int h, void * userData)
    {
-      if(this || !this) {     // FIXME
-         TableDropBox dropBox = dataBox.keepEditor ? (TableDropBox)dataBox.editor /*obsolete*/ : null;
-         if(!dropBox)
-         {
+      TableDropBox dropBox = dataBox.keepEditor ? (TableDropBox)dataBox.editor /*obsolete*/ : null;
+      if(!dropBox)
+      {
 /*
-            if(eClass_IsDerived(dataBox._class, class(FieldDropBox)))
-            {
-               FieldDropBox fieldDropBox = (FieldDropBox)dataBox;
+         if(eClass_IsDerived(dataBox._class, class(FieldDropBox)))
+         {
+            FieldDropBox fieldDropBox = (FieldDropBox)dataBox;
 
-            }
-            else if(eClass_IsDerived(dataBox._class, class(FieldBox)))
-            {
-               FieldBox fieldBox = (FieldBox)dataBox;
+         }
+         else if(eClass_IsDerived(dataBox._class, class(FieldBox)))
+         {
+            FieldBox fieldBox = (FieldBox)dataBox;
 
-            }
+         }
 */
 
-            dropBox = TableDropBox
-            {
-               dataBox, borderStyle = 0, anchor = { 0, 0, 0, 0 }, 
-               modifyVirtualArea = false, activeStipple = false;
-               showNone = true;
-               nameField = *class_data(nameField);
-               table = *class_data(table);
+         dropBox = TableDropBox
+         {
+            dataBox, borderStyle = 0, anchor = { 0, 0, 0, 0 }, 
+            modifyVirtualArea = false, activeStipple = false;
+            showNone = true;
+            nameField = *class_data(nameField);
+            table = *class_data(table);
 
-               bool DataBox::NotifySelect(DropBox control, DataRow row, Modifiers mods)
-               {
-                  uint id = row ? row.tag : 0;
-                  SetData(&id, mods.closingDropDown);
-                  return true;
-               }
+            bool DataBox::NotifySelect(DropBox control, DataRow row, Modifiers mods)
+            {
+               // TOFIX: Id is still 32 bit
+               uint id = (uint)(row ? row.tag : 0);
+               SetData(&id, mods.closingDropDown);
+               return true;
+            }
 
-               bool DataBox::NotifyTextEntry(DropBox _dropBox, char * string, bool confirmed)
+            bool DataBox::NotifyTextEntry(DropBox _dropBox, char * string, bool confirmed)
+            {
+               TableDropBox dropBox = (TableDropBox)_dropBox;
+               //Table tbl = dropBox.table.db.OpenTable(dropBox.table.name, { tableRows });
+               //if(tbl)
                {
-                  TableDropBox dropBox = (TableDropBox)_dropBox;
-                  //Table tbl = dropBox.table.db.OpenTable(dropBox.table.name, { tableRows });
-                  //if(tbl)
+                  /*FieldIndex indexedFields[1];
+                  Row r { };*/
+                  char * trimmed = new char[strlen(string) + 1];
+                  /*indexedFields[0] = { dropBox.nameField };
+                  tbl.GenerateIndex(1, indexedFields, false);
+                  r.tbl = tbl;*/
+                  DataRow row = null;
+
+                  TrimLSpaces(string, trimmed);
+                  TrimRSpaces(trimmed, trimmed);
+
+                  /*if(r.Find(dropBox.nameField, middle, nil, trimmed))
                   {
-                     /*FieldIndex indexedFields[1];
-                     Row r { };*/
-                     char * trimmed = new char[strlen(string) + 1];
-                     /*indexedFields[0] = { dropBox.nameField };
-                     tbl.GenerateIndex(1, indexedFields, false);
-                     r.tbl = tbl;*/
-                     DataRow row = null;
-
-                     TrimLSpaces(string, trimmed);
-                     TrimRSpaces(trimmed, trimmed);
-
-                     /*if(r.Find(dropBox.nameField, middle, nil, trimmed))
+                     if(dropBox.filterField)
                      {
-                        if(dropBox.filterField)
-                        {
-                           // TODO: Improve this... Multi field?
-                           while(true)
-                           {
-                              DataRow row;
-                              Id id = 0;
-                              Field fldId = dropBox.table.FindField(defaultIdField);
-                              r.GetData(fldId, id);
-                              row = dropBox.FindSubRow(id);
-                              if(row)
-                              {
-                                 dropBox.SelectRow(row);
-                                 break;
-                              }
-                              //if(!r.Find(dropBox.nameField, next, nil, trimmed))
-                              if(!r.Next())
-                                 break;
-                           }
-                        }
-                        else
+                        // TODO: Improve this... Multi field?
+                        while(true)
                         {
+                           DataRow row;
                            Id id = 0;
                            Field fldId = dropBox.table.FindField(defaultIdField);
                            r.GetData(fldId, id);
-                           dropBox.SelectRow(dropBox.FindSubRow(id));
-                        }
-                     }
-                     */
-
-                     {
-                        for(row = dropBox.firstRow; row; row = row.next)
-                        {
-                           char * string = row.string;
-                           if(string && !strcmp(trimmed, string))
+                           row = dropBox.FindSubRow(id);
+                           if(row)
+                           {
+                              dropBox.SelectRow(row);
+                              break;
+                           }
+                           //if(!r.Find(dropBox.nameField, next, nil, trimmed))
+                           if(!r.Next())
                               break;
                         }
                      }
-                     if(row)
+                     else
                      {
-                        dropBox.SelectRow(row);
+                        Id id = 0;
+                        Field fldId = dropBox.table.FindField(defaultIdField);
+                        r.GetData(fldId, id);
+                        dropBox.SelectRow(dropBox.FindSubRow(id));
                      }
-                     else
+                  }
+                  */
+
+                  {
+                     for(row = dropBox.firstRow; row; row = row.next)
                      {
-                        dropBox.changeContents = false;
-                        dropBox.contents = trimmed;
-                        dropBox.SelectRow(null);
-                        dropBox.changeContents = true;
+                        char * string = row.string;
+                        if(string && !strcmp(trimmed, string))
+                           break;
                      }
-                     //delete r;
                   }
-                  return true;
+                  if(row)
+                  {
+                     dropBox.SelectRow(row);
+                  }
+                  else
+                  {
+                     dropBox.changeContents = false;
+                     dropBox.contents = trimmed;
+                     dropBox.SelectRow(null);
+                     dropBox.changeContents = true;
+                  }
+                  //delete r;
                }
-            };
-            if(class_data(Refill))
-               dropBox.Refill = class_data(Refill);
+               return true;
+            }
+         };
+         if(class_data(Refill))
+            dropBox.Refill = class_data(Refill);
 
-            // dropBox.Refill();
-         }
-         dataBox.OnConfigure(dropBox);
-         dropBox.Create();
-         dropBox.currentRow = dropBox.FindSubRow(this);
-         if(!dropBox.currentRow && this)
-            dataBox.SetData((uint *)&this, false);
-         {
-            DataRow r = dropBox.currentRow;
-            if(r)
-               for(r = r.parent; r; r = r.parent)
-                  r.collapsed = false;
-         }
-         return dropBox;
+         // dropBox.Refill();
+      }
+      dataBox.OnConfigure(dropBox);
+      dropBox.Create();
+      dropBox.currentRow = dropBox.FindSubRow(this);
+      if(!dropBox.currentRow && this)
+         dataBox.SetData((uint *)&this, false);
+      {
+         DataRow r = dropBox.currentRow;
+         if(r)
+            for(r = r.parent; r; r = r.parent)
+               r.collapsed = false;
       }
-      return null;
+      return dropBox;
    }
 
    char * OnGetString(char * tempString, void * fieldData, bool * needClass)
@@ -208,13 +206,14 @@ public class Id : uint
                   ((bool (*)())(void *)r.GetData)(r, *nameField, type, (type.type == structClass) ? (void *)data : &data);
 
                   if(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass)
-                     name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)&data, tempString, null, null);
+                     name = ((char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, (void *)&data, tempString, null, null);
                   else
-                     name = (String)type._vTbl[__ecereVMethodID_class_OnGetString](type, (void *)data, tempString, null, null);
+                     name = ((char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, (void *)data, tempString, null, null);
 
-                  strcpy(tempString, name ? name : "");
+                  if(name && name != tempString)
+                     strcpy(tempString, name ? name : "");
                   if(!(type.type == systemClass || type.type == unitClass || type.type == bitClass || type.type == enumClass))
-                     type._vTbl[__ecereVMethodID_class_OnFree](type, data);
+                     ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, (void *)data);
                }
                else
                {
@@ -247,7 +246,7 @@ public:
       get { return class_data(type); }
    };
 
-   public void Clear()
+   void Clear()
    {
       if(this)
       {
@@ -256,7 +255,7 @@ public:
       }
    }
    
-   public bool Includes(Id id)
+   bool Includes(Id id)
    {
       if(this)
       {
@@ -268,7 +267,7 @@ public:
       return false;
    }
 
-   public bool Add(Id id)
+   bool Add(Id id)
    {
       int c;
       for(c = 0; c < count; c++)
@@ -283,7 +282,7 @@ public:
       return false;
    }
 
-   public bool Delete(Id id)
+   bool Delete(Id id)
    {
       int c;
       for(c = 0; c < count; c++)
@@ -353,12 +352,13 @@ public:
          {
             char tempString[256];
             Class type = class_data(type);
+            String s;
             if(c) strcat(stringOutput, ", ");
 
             if(type)
-               type._vTbl[__ecereVMethodID_class_OnGetString](type, &ids[c], tempString, null, null);
+               s = ((char *(*)(void *, void *, char *, void *, bool *))(void *)type._vTbl[__ecereVMethodID_class_OnGetString])(type, &ids[c], tempString, null, null);
             // strcatf(stringOutput, "%d", ids[c]);
-            strcat(stringOutput, tempString);
+            strcat(stringOutput, s);
          }
       }
       return stringOutput;
@@ -432,7 +432,6 @@ public:
       /*if(!this)
          this = eInstance_New(_class);
          */
-      if(this || !this)    // FIXME
       {
          Class type = class_data(type);
          list.AddField({ type, editable = true });
@@ -500,7 +499,7 @@ public class StringList
 
    bool Add(String string)
    {
-      BTNode node { key = (uint)CopyString(string) };
+      BTNode node { key = (uintptr)CopyString(string) };
       if(strings.Add(node))
          return true;
       else
@@ -645,10 +644,7 @@ public class StringList
       }
       */
 
-      if(this || !this)    // FIXME
-      {
       list.AddField({ class(char *), editable = true });
-      }
       for(node = strings.first; node; node = node.next)
       {
          r = list.AddRow();
@@ -864,7 +860,7 @@ public struct DataList : OldList
          {
             if(type.type == structClass)
                link.data = new0 byte[type.structSize];
-            type._vTbl[__ecereVMethodID_class_OnUnserialize](type, (type.type == structClass) ? link.data : &link.data, channel);
+            ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnUnserialize])(type, (type.type == structClass) ? link.data : &link.data, channel);
          }
          Add(link);
       }
@@ -885,9 +881,9 @@ public struct DataList : OldList
          {
             channel.Serialize(truth);
             if(type.type == bitClass || type.type == unitClass || (type.type == systemClass && type.typeSize))
-               type._vTbl[__ecereVMethodID_class_OnSerialize](type, &node.data, channel);
+               ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnSerialize])(type, &node.data, channel);
             else
-               type._vTbl[__ecereVMethodID_class_OnSerialize](type, node.data, channel);
+               ((void (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnSerialize])(type, node.data, channel);
             node = node.next;
          }
          else
@@ -911,7 +907,7 @@ public struct DataList : OldList
          else
          {
             Class type = class_data(type);
-            result = type._vTbl[__ecereVMethodID_class_OnCompare](type, 
+            result = ((int (*)(void *, void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnCompare])(type, 
                (type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &nodeA.data : (void *)nodeA.data,
                (type.type == systemClass || type.type == bitClass || type.type == enumClass || type.type == unitClass) ? &nodeB.data : (void *)nodeB.data);
             if(result) return result;
@@ -1166,7 +1162,7 @@ public struct DataList : OldList
             else if(type.type == structClass)
                delete node.data;
             else
-               type._vTbl[__ecereVMethodID_class_OnFree](type, node.data);
+               ((void (*)(void *, void *))(void *)type._vTbl[__ecereVMethodID_class_OnFree])(type, node.data);
          }
          Delete(node);
       }