ecere/containers: Iterator::Index() now returning false when creating new entry
[sdk] / ide / src / designer / CodeEditor.ec
index 6fd019e..3c5becc 100644 (file)
@@ -387,6 +387,39 @@ void GetLocText(EditBox editBox, File f, int position, Location loc, char ** tex
    f.Printf(""); // Make the stream point to where the editbox is
 }
 
+static int64 GetI64EnumValue(Class dataType, DataValue dataForm)
+{
+   int64 i64Value = 0;
+   switch(dataType.typeSize)
+   {
+      case 1:
+         if(!strcmp(dataType.dataTypeString, "byte"))
+            i64Value = dataForm.uc;
+         else
+            i64Value = dataForm.c;
+         break;
+      case 2:
+         if(!strcmp(dataType.dataTypeString, "uint16"))
+            i64Value = dataForm.us;
+         else
+            i64Value = dataForm.s;
+         break;
+      case 4:
+         if(!strcmp(dataType.dataTypeString, "uint"))
+            i64Value = dataForm.ui;
+         else
+            i64Value = dataForm.i;
+         break;
+      case 8:
+         if(!strcmp(dataType.dataTypeString, "uint64"))
+            i64Value = *(int64 *)&dataForm.ui64;
+         else
+            i64Value = dataForm.i64;
+         break;
+   }
+   return i64Value;
+}
+
 void Code_FixProperty(Property prop, Instance object)
 {
    Designer::FixProperty(prop, object);
@@ -681,7 +714,7 @@ class CodeEditor : Window
 
    OldList * ast;
    Context globalContext { };
-   OldList excludedSymbols { offset = (uint)&((Symbol)0).left };
+   OldList excludedSymbols { offset = (uint)(uintptr)&((Symbol)0).left };
 
    OldList defines;
    OldList imports;
@@ -796,7 +829,6 @@ class CodeEditor : Window
                   hide = true;
                else
                {
-                  const char * buffer = membersLine.text;
                   int c;
 
                   if(charPos - 1 < membersLoc.start.charPos)
@@ -880,11 +912,11 @@ class CodeEditor : Window
          int oldLine = lastLine;
          display.FontExtent(font.font, " ", 1, null, &spaceH);
          {
-            Box box { 0, (Min(oldLine,oldLine)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(oldLine, oldLine))*spaceH-1 - editBox.scroll.y };
+            Box box { 0, (oldLine-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, oldLine*spaceH-1 - editBox.scroll.y };
             Update(box);
          }
          {
-            Box box { 0, (Min(line,line)-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, (Max(line, line))*spaceH-1 - editBox.scroll.y };
+            Box box { 0, (line-1) * spaceH - editBox.scroll.y, editBox.anchor.left.distance, line*spaceH-1 - editBox.scroll.y };
             Update(box);
          }
          lastLine = line;
@@ -2383,7 +2415,7 @@ class CodeEditor : Window
 
       if(editBox.syntaxHighlighting && fileName && ide.projectView)
       {
-         bool error, bpOnCursor, bpOnTopFrame, breakpointEnabled[128];
+         bool error, bpOnTopFrame, breakpointEnabled[128];
          int lineCursor, lineTopFrame, breakpointLines[128];
          int count, i, lineH, boxH, scrollY; //, firstLine; firstLine = editBox.firstLine;
          Debugger debugger = ide.debugger;
@@ -2393,7 +2425,7 @@ class CodeEditor : Window
          scrollY = editBox.scroll.y;
          displaySystem.FontExtent(editBox.font.font, " ", 1, null, &lineH);
 
-         bpOnCursor = bpOnTopFrame = false;
+         bpOnTopFrame = false;
          count = debugger.GetMarginIconsLineNumbers(fileName, breakpointLines, breakpointEnabled, 128, &error, &lineCursor, &lineTopFrame);
          if(count)
          {
@@ -2402,8 +2434,6 @@ class CodeEditor : Window
                if(breakpointLines[i] == lineCursor || breakpointLines[i] == lineTopFrame)
                {
                   bmpRes = breakpointEnabled[i] ? ide.bmpBpHalf : ide.bmpBpHalfDisabled;
-                  if(breakpointLines[i] == lineCursor)
-                     bpOnCursor = true;
                   if(breakpointLines[i] == lineTopFrame)
                      bpOnTopFrame = true;
                }
@@ -2548,7 +2578,6 @@ class CodeEditor : Window
    CodeEditor()
    {
       CodeObjectType c;
-      ProjectView projectView = ide.projectView;
 
       globalData.classes.CompareKey = (void *)BinaryTree::CompareString;
       globalData.defines.CompareKey = (void *)BinaryTree::CompareString;
@@ -2759,7 +2788,7 @@ class CodeEditor : Window
 
             next = _class.next;
 
-            for(;object = _class.instances.first;)
+            while((object = _class.instances.first))
             {
                if(object.instance)
                {
@@ -2838,7 +2867,7 @@ class CodeEditor : Window
          SetTargetBits(ide.workspace.bitDepth ? ide.workspace.bitDepth : GetHostBits());
          delete compiler;
       }
-      this.privateModule = __ecere_COM_Initialize(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4), 1, null);
+      this.privateModule = __ecere_COM_Initialize((bool)(false | ((GetTargetBits() == sizeof(uintptr) *8) ? 0 : GetTargetBits() == 64 ? 2 : 4)), 1, null);
 
       SetPrivateModule(privateModule);
 
@@ -2892,6 +2921,7 @@ class CodeEditor : Window
          int bitDepth = ide.workspace.bitDepth;
          DirExpression objDir = project.GetObjDir(compiler, config, bitDepth);
          SetSymbolsDir(objDir.dir);
+         SetDefaultNameSpace(project.GetDefaultNameSpace(config));
          ide.SetPath(true, compiler, config, bitDepth);
 
          delete objDir;
@@ -2901,7 +2931,7 @@ class CodeEditor : Window
       }
       else
       {
-         switch(GetRuntimePlatform())
+         switch(__runtimePlatform)
          {
             case win32: SetSymbolsDir("obj/debug.win32"); break;
             case tux:   SetSymbolsDir("obj/debug.linux"); break;
@@ -2909,6 +2939,7 @@ class CodeEditor : Window
          }
          SetIncludeDirs(null);
          SetSysIncludeDirs(null);
+         SetDefaultNameSpace(null);
       }
 
       {
@@ -3092,7 +3123,6 @@ class CodeEditor : Window
                            classDefinition = _class;
                            oClass = classObject;
                         };
-                        Symbol symbol;
                         classes.Add(classObject);
 
                         incref instance;
@@ -3559,7 +3589,6 @@ class CodeEditor : Window
          if(selectedName)
          {
             ObjectInfo check;
-            int pos = 0;
 
             for(check = this.oClass.instances.first; check; check = check.next)
             {
@@ -3778,7 +3807,7 @@ class CodeEditor : Window
                            {
                               Map<String, bool> i18nStrings = object.i18nStrings;
                               bool i18n = true;
-                              if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
+                              if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false, null))
                                  i18n = false;
 
                               f.Printf("%s\"", i18n ? "$" : "");
@@ -3806,7 +3835,7 @@ class CodeEditor : Window
 
                      if((prop.IsSet && !prop.IsSet(test)) || ((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, &dataForm, &dataTest))
                      {
-                        char * string;
+                        char * string = null;
                         char tempString[1024] = "";
                         SetProperty(prop, test, dataForm);
 
@@ -3816,13 +3845,14 @@ class CodeEditor : Window
 
                            if(dataType.type == enumClass)
                            {
-                              NamedLink value;
+                              NamedLink64 value;
                               Class enumClass = eSystem_FindClass(privateModule, "enum");
                               EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
+                              int64 i64Value = GetI64EnumValue(dataType, dataForm);
 
                               for(value = e.values.first; value; value = value.next)
                               {
-                                 if((int)value.data == dataForm.i)
+                                 if(value.data == i64Value)
                                  {
                                     string = value.name;
                                     break;
@@ -3884,9 +3914,7 @@ class CodeEditor : Window
       Window control = (Window)object.instance;
       bool prev = false;
       bool methodPresent = false;
-      Class _class;
       bool lastIsMethod = true;
-      ObjectInfo classObject = object.oClass;
 
       if(inst)
       {
@@ -3968,7 +3996,7 @@ class CodeEditor : Window
                {
                   int count = 0;
                   int toDelete = 0;
-                  int toAdd = 0;
+                  //int toAdd = 0;
 
                   f.Seek(-1, current);
                   DeleteJunkBefore(f, position, &position);
@@ -3994,8 +4022,8 @@ class CodeEditor : Window
                            toDelete += count - 6;
                            count = 6;
                         }
-                        else
-                           toAdd = 6 - count;
+                        /*else
+                           toAdd = 6 - count;*/
                         break;
                      }
                   }
@@ -4144,7 +4172,6 @@ class CodeEditor : Window
                   if(!keptMember || !members.next)
                   {
                      char ch = 0;
-                     int count = 0;
 
                      if(keptMember && lastKept != members.dataMembers->last)
                      {
@@ -4426,7 +4453,7 @@ class CodeEditor : Window
             {
                Class dataType = prop.dataTypeClass;
                char tempString[1024] = "";
-               char * string;
+               char * string = null;
                bool specify = false;
                DataMember member;
 
@@ -4487,7 +4514,7 @@ class CodeEditor : Window
                   if(((int (*)(void *, void *, void *))(void *)dataType._vTbl[__ecereVMethodID_class_OnCompare])(dataType, dataForm, dataTest))
                   {
                      char tempString[1024] = "";
-                     char * string;
+                     char * string = null;
                      ((void (*)(void *, void *))(void *)prop.Set)(test, dataForm);
 
                      if(eClass_IsDerived(classObject.instance._class, dataType) && classObject.instance == dataForm)
@@ -4505,7 +4532,7 @@ class CodeEditor : Window
                         {
                            Map<String, bool> i18nStrings = classObject.i18nStrings;
                            bool i18n = true;
-                           if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false))
+                           if(i18nStrings && i18nStrings.GetAtPosition(prop.name, false, null))
                               i18n = false;
 
                            f.Printf("\n   %s%s = %s\"", specify ? "property::" : "", prop.name, i18n ? "$" : "");
@@ -4545,13 +4572,14 @@ class CodeEditor : Window
                         bool needClass = true;
                         if(dataType.type == enumClass)
                         {
-                           NamedLink value;
+                           NamedLink64 value;
                            Class enumClass = eSystem_FindClass(privateModule, "enum");
                            EnumClassData e = ACCESS_CLASSDATA(dataType, enumClass);
+                           int64 i64Value = GetI64EnumValue(dataType, dataForm);
 
                            for(value = e.values.first; value; value = value.next)
                            {
-                              if((int)value.data == dataForm.i)
+                              if(value.data == i64Value)
                               {
                                  string = value.name;
                                  break;
@@ -4605,7 +4633,6 @@ class CodeEditor : Window
 
          for(classObject = classes.first; classObject; classObject = classObject.next)
          {
-            Class _class;
             ClassDefinition classDef = classObject.classDefinition;
             Class regClass = eSystem_FindClass(this.privateModule, ((Specifier)classDef.baseSpecs->first).name);
             Instance test;
@@ -4724,7 +4751,6 @@ class CodeEditor : Window
                      if(!keptMember)
                      {
                         char ch = 0;
-                        int count = 0;
                         f.Seek(def.loc.end.pos - position - 1, current);
                         f.Getc(&ch);
 
@@ -5686,7 +5712,7 @@ class CodeEditor : Window
 
                if(subMember.dataType && subMember.dataType.kind == classType && subMember.dataType._class)
                {
-                  char * bitmapName = (char *)eClass_GetProperty(subMember.dataType._class.registered, "icon");
+                  char * bitmapName = (char *)(intptr)eClass_GetProperty(subMember.dataType._class.registered, "icon");
                   if(bitmapName)
                   {
                      bitmap = { bitmapName };
@@ -5784,7 +5810,7 @@ class CodeEditor : Window
 
                      if(member.dataType && member.dataType.kind == classType && member.dataType._class)
                      {
-                        char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
+                        char * bitmapName = (char *)(intptr)eClass_GetProperty(member.dataType._class.registered, "icon");
                         if(bitmapName)
                         {
                            bitmap = { bitmapName };
@@ -5815,8 +5841,6 @@ class CodeEditor : Window
       for(_class = whatClass; _class && _class.type != systemClass; _class = _class.base)
       {
          Method method;
-         Property prop;
-         DataMember member;
 
          for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
          {
@@ -5854,7 +5878,6 @@ class CodeEditor : Window
       for(_class = whatClass; _class /*&& _class.type != systemClass*/; _class = _class.base)
       {
          Method method;
-         Property prop;
          DataMember member;
 
          for(method = (Method)_class.methods.first; method; method = (Method)((BTNode)method).next)
@@ -5899,7 +5922,7 @@ class CodeEditor : Window
 
                   if(member.dataType && member.dataType.kind == classType && member.dataType._class)
                   {
-                     char * bitmapName = (char *)eClass_GetProperty(member.dataType._class.registered, "icon");
+                     char * bitmapName = (char *)(intptr)eClass_GetProperty(member.dataType._class.registered, "icon");
                      if(bitmapName)
                      {
                         bitmap = { bitmapName };
@@ -5924,8 +5947,6 @@ class CodeEditor : Window
    {
       if(type && (type.kind == classType || type.kind == structType || type.kind == unionType))
       {
-         Class _class;
-
          if(type.kind == classType)
          {
             if(type._class)
@@ -5981,14 +6002,14 @@ class CodeEditor : Window
 
       for(link = (BTNamedLink)nameSpace.defines.first; link; link = (BTNamedLink)((BTNode)link).next )
       {
-         DefinedExpression definedExp = link.data;
+         //DefinedExpression definedExp = link.data;
          DataRow row = membersList.AddString(link /*definedExp*/.name);
          row.icon = icons[typeData];
       }
 
       for(link = (BTNamedLink)nameSpace.functions.first; link; link = (BTNamedLink)((BTNode)link).next)
       {
-         GlobalFunction function = link.data;
+         //GlobalFunction function = link.data;
          DataRow row = membersList.AddString(link /*function*/.name);
          row.icon = icons[typeMethod];
       }
@@ -6018,7 +6039,7 @@ class CodeEditor : Window
       for(_class : classes)
       {
          EnumClassData enumeration = (EnumClassData)_class.data;
-         NamedLink item;
+         NamedLink64 item;
          for(item = enumeration.values.first; item; item = item.next)
          {
             DataRow row = membersList.AddString(item.name);
@@ -6071,7 +6092,7 @@ class CodeEditor : Window
       for(link = (BTNamedLink)nameSpace.classes.first; link; link = (BTNamedLink)((BTNode)link).next)
       {
          Class _class = link.data;
-         if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *"))) && !dest.classObjectType)) &&
+         if(_class.type == enumClass && (dest.kind != classType || ((!dest._class || !dest._class.registered || (dest._class.registered != _class && strcmp(dest._class.registered.dataTypeString, "char *") && strcmp(dest._class.string, "bool"))) && !dest.classObjectType)) &&
             dest.kind != pointerType && dest.kind != ellipsisType)
          {
             OldList conversions { };
@@ -6182,7 +6203,7 @@ class CodeEditor : Window
       }
       else if(destType && destType.kind == enumType)
       {
-         NamedLink value;
+         NamedLink64 value;
 
          for(value = destType.members.first; value; value = value.next)
          {
@@ -6244,7 +6265,7 @@ class CodeEditor : Window
                         BitmapResource bitmap = null;
                         if(symbol.type && symbol.type.kind == classType && symbol.type._class && symbol.type._class)
                         {
-                           char * bitmapName = (char *)eClass_GetProperty(symbol.type._class.registered, "icon");
+                           char * bitmapName = (char *)(intptr)eClass_GetProperty(symbol.type._class.registered, "icon");
                            if(bitmapName)
                            {
                               bitmap = { bitmapName };
@@ -6336,7 +6357,7 @@ class CodeEditor : Window
    void OverrideVirtualFunction(ClassFunction function, Method method, Class _class, bool isInstance, bool extraIndent)
    {
       EditBoxStream f { editBox = editBox };
-      uint position = 0;
+      int position = 0;
       EditLine l1, l2;
       int x1,y1,x2,y2;
 
@@ -6444,7 +6465,6 @@ class CodeEditor : Window
    {
       bool didOverride = false;
       EditLine line = editBox.line;
-      const char * text = line.text;
       int lineNum, charPos;
       Expression exp = null;
       EditLine l1, l2;
@@ -6546,7 +6566,8 @@ class CodeEditor : Window
          int rowCount;
          char tempString[1024];
          char * string = null;
-         CodePosition idStart, idEnd;
+         CodePosition idStart { };
+         CodePosition idEnd { };
 
          if(membersListShown)
          {
@@ -6582,7 +6603,7 @@ class CodeEditor : Window
             }
             string[len] = 0;
             */
-            int x, y;
+            int x = 0, y;
             int len = 0;
             EditLine editLine = editBox.line;
             bool firstChar = true;
@@ -6821,10 +6842,7 @@ class CodeEditor : Window
 
    void InvokeParameters(bool exact, bool reposition, bool caretMove)
    {
-      EditLine line = editBox.line;
-      const char * text = line.text;
       int lineNum, charPos;
-      Expression exp = null;
       EditLine l1, l2;
       int x1,y1, x2,y2;