buildsystem, ide, ecere, ecs; (#906) added runtime option to ecere's memory manager...
[sdk] / ide / src / project / Workspace.ec
index 017247d..9e67fe6 100644 (file)
@@ -22,6 +22,29 @@ import "ide"
 }*/
 
 enum OpenedFileState { unknown, opened, closed };
+enum ValgrindLeakCheck
+{
+   no, summary, yes, full;
+
+   property char *
+   {
+      get { return OnGetString(null, null, null); }
+   }
+
+   char * OnGetString(char * tempString, void * fieldData, bool * needClass)
+   {
+      if(this >= no && this <= full)
+      {
+         if(tempString)
+            strcpy(tempString, valgrindLeakCheckNames[this]);
+         return valgrindLeakCheckNames[this];
+      }
+      if(tempString && tempString[0])
+         tempString[0] = '\0';
+      return null;
+   }
+};
+static const char * valgrindLeakCheckNames[ValgrindLeakCheck] = { "no", "summary", "yes", "full" };
 
 class OpenedFileInfo
 {
@@ -177,6 +200,15 @@ public:
 
 private:
    String compiler;
+   int bitDepth;
+   // TODO: save these new settings when json format is ready
+   bool useValgrind;
+   ValgrindLeakCheck vgLeakCheck;
+   bool vgTrackOrigins;
+   int vgRedzoneSize;
+
+   vgRedzoneSize = -1;
+   vgLeakCheck = summary;
 
 public:
    void Save()
@@ -220,6 +252,7 @@ public:
          file.Printf("\nVersion 0.02\n");
          file.Printf("\nWorkspace\n");
          file.Printf("\n   Active Compiler = %s\n", compiler ? compiler : defaultCompilerName);
+         file.Printf("\n   Active Bit Depth = %d\n", bitDepth);
          
          if(projects.first)
          {
@@ -258,7 +291,13 @@ public:
          {
             file.Printf("\n      Environment Variables\n\n");
             for(v : environmentVars)
-               file.Printf("       ~ %s = %s\n", v.name, v.string);
+            {
+               file.Printf("       ~ ");
+               file.Puts(v.name);
+               file.Printf(" = ");
+               file.Puts(v.string);
+               file.Printf("\n");
+            }
          }
 
          file.Printf("\n   Debugger Data\n");
@@ -324,11 +363,12 @@ public:
       char name[MAX_LOCATION];
       char absolute[MAX_LOCATION];
       Project prj = null;
+      ProjectNode node = null;
 
       GetLastDirectory(relative, name);
       for(p : projects)
       {
-         if(p.topNode.Find(name, false))
+         if(node = p.topNode.Find(name, false))
          {
             prj = p;
             break;
@@ -336,8 +376,7 @@ public:
       }
       if(prj)
       {
-         strcpy(absolute, prj.topNode.path);
-         PathCatSlash(absolute, relative);
+         node.GetFullFilePath(absolute);
          return CopyString(absolute);
       }
 
@@ -444,11 +483,36 @@ public:
       DropInvalidBreakpoints();
       modified = true;
       ide.findInFilesDialog.RemoveProjectItem(project);
+      ide.UpdateToolBarActiveConfigs(false);
       Save();
 
       delete project;
    }
 
+   void SelectActiveConfig(char * configName)
+   {
+      bool change = false;
+      for(prj : ide.workspace.projects)
+      {
+         for(cfg : prj.configurations)
+         {
+            if(cfg.name && !strcmp(cfg.name, configName))
+            {
+               prj.config = cfg;
+               change = true;
+               break;
+            }
+         }
+      }
+      if(change)
+      {
+         modified = true;
+         ide.UpdateToolBarActiveConfigs(true);
+         ide.projectView.Update(null);
+         Save();
+      }
+   }
+
    bool FindPath(ProjectNode node, char * path)
    {
       if(node.type == file)
@@ -478,7 +542,7 @@ public:
       Breakpoint bp = (Breakpoint)row.tag;
       if(bp)
       {
-         char * currentLoc = bp.LocationToString();
+         char * currentLoc = bp.CopyUserLocationString();
          if(strcmp(location, currentLoc))
          {
             // todo, parse location
@@ -496,7 +560,7 @@ public:
          //  else
          //     ...
          //bp = Breakpoint { };
-         //row.tag = (int)bp;
+         //row.tag = (int64)bp;
          //breakpoints.Add(bp);
          //bp.row = row;
          Save();
@@ -691,6 +755,9 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
    if(file)
    {
       OldList openedFilesNotFound { };
+      double version = 0;
+      char section[128];
+      char subSection[128];
 
       workspace = Workspace { compiler = ideSettings.defaultCompiler, workspaceFile = filePath };
 
@@ -698,10 +765,6 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
       while(!file.Eof())
       {
          char buffer[65536];
-         char section[128];
-         char subSection[128];
-         //char version[16];
-         float version;
          char * equal;
          int len;
          
@@ -810,7 +873,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
 
                      bp = { type = user, enabled = enabled, ignore = ignore, level = level, line = line };
                      workspace.breakpoints.Add(bp);
-                     bp.relativeFilePath = CopyString(strFile);
+                     bp.relativeFilePath = strFile;
                      bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(strFile);
                      if(!bp.absoluteFilePath)
                         bp.absoluteFilePath = CopyString("");
@@ -832,7 +895,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                   Point scroll { };
                   char absolutePath[MAX_LOCATION];
                   strcpy(absolutePath, workspace.workspaceDir);
-                  if(version == 0.01f)
+                  if(version == 0.01)
                   {
                      char * comma = strchr(equal, ',');
                      if(comma)
@@ -842,7 +905,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                         equal = comma + 1;
                      }
                   }
-                  else if(version >= 0.02f)
+                  else if(version >= 0.02)
                   {
                      char * column = strchr(equal, ':');
                      if(column)
@@ -899,7 +962,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                   Project newProject;
                   strcpy(projectFilePath, workspace.workspaceDir);
                   PathCatSlash(projectFilePath, equal);
-                  newProject = LoadProject(projectFilePath);
+                  newProject = LoadProject(projectFilePath, null);
                   if(newProject)
                   {
                      workspace.projects.Add(newProject);
@@ -919,7 +982,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
             }
             else if(!strcmpi(buffer, "ECERE Workspace File"));
             else if(!strcmpi(buffer, "Version 0a"))
-               version = 0.0f;
+               version = 0;
             else if(!strncmp(buffer, "Version ", 8))
                version = atof(&buffer[8]);
             else if(!strcmpi(buffer, "Workspace"))
@@ -962,6 +1025,14 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                            workspace.compiler = equal;
                         delete compiler;
                      }
+                     if(!strcmpi(buffer, "Active Bit Depth"))
+                     {
+                        int bitDepth = atoi(equal);
+                        if(!(bitDepth == 32 || bitDepth == 64))
+                           bitDepth = 0;
+                        workspace.bitDepth = bitDepth;
+                        ide.toolBar.activeBitDepth.SelectRow(ide.toolBar.activeBitDepth.FindRow(bitDepth));
+                     }
                   }
                   else if(!strcmpi(section, "Execution Data"))
                   {
@@ -974,6 +1045,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
 
                      if(!strcmpi(buffer, "Environment Variables"))
                      {
+                        workspace.environmentVars.Free();
                         delete workspace.environmentVars;
                         workspace.environmentVars = { };
                      }
@@ -1062,10 +1134,10 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
                                           bp = { type = user, enabled = enabled, level = -1 };
                                           workspace.breakpoints.Add(bp);
                                           bp.line = atoi(lineNum);
-                                          bp.relativeFilePath = CopyString(relPath);
+                                          bp.relativeFilePath = relPath;
                                           bp.absoluteFilePath = workspace.GetAbsolutePathFromRelative(relPath);
                                           if(!bp.absoluteFilePath)
-                                             bp.absoluteFilePath = CopyString("");
+                                             bp.absoluteFilePath = "";
                                        }
                                     }
                                  }
@@ -1101,13 +1173,13 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
          {
             Project project;
             if(fromProjectFile)
-               project = LoadProject(fromProjectFile /*projectFilePath*/);
+               project = LoadProject(fromProjectFile /*projectFilePath*/, null);
             else
             {
                char projectFilePath[MAX_LOCATION];
                strcpy(projectFilePath, workspace.workspaceFile);
                ChangeExtension(projectFilePath, ProjectExtension, projectFilePath);
-               project = LoadProject(projectFilePath);
+               project = LoadProject(projectFilePath, null);
             }
             if(project)
             {
@@ -1171,7 +1243,7 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
       
       //strcpy(projectFile, filePath);
       //ChangeExtension(projectFile, ProjectExtension, projectFile);
-      newProject = LoadProject(fromProjectFile /*projectFile*/);
+      newProject = LoadProject(fromProjectFile /*projectFile*/, null);
 
       if(newProject)
       {
@@ -1190,6 +1262,5 @@ Workspace LoadWorkspace(char * filePath, char * fromProjectFile)
       if(!workspace.compiler || !workspace.compiler[0])
          workspace.compiler = defaultCompilerName;
    }
-
    return workspace;
 }