From 93dcaaad4b712b6561c42a32becf750541ce60d1 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Fri, 18 Sep 2015 06:21:56 +0200 Subject: [PATCH] project interface, set conf index --- src/ce_dubproject.pas | 38 ++++++++++++++++++++++---------------- src/ce_interfaces.pas | 4 +++- src/ce_nativeproject.pas | 10 ++++++++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/ce_dubproject.pas b/src/ce_dubproject.pas index 619496fe..032395d7 100644 --- a/src/ce_dubproject.pas +++ b/src/ce_dubproject.pas @@ -66,7 +66,8 @@ type function importPath(index: integer): string; // function configurationCount: integer; - procedure setActiveConfiguration(index: integer); + function getActiveConfigurationIndex: integer; + procedure setActiveConfigurationIndex(index: integer); function configurationName(index: integer): string; // function compile: boolean; @@ -266,11 +267,16 @@ begin exit(fConfigsCount); end; -procedure TCEDubProject.setActiveConfiguration(index: integer); +function TCEDubProject.getActiveConfigurationIndex: integer; +begin + exit(fBuiltTypeIx * fConfigs.Count + fConfigIx); +end; + +procedure TCEDubProject.setActiveConfigurationIndex(index: integer); begin fBuiltTypeIx := index div fConfigs.Count; fConfigIx := index mod fConfigs.Count; - updateSourcesFromJson; + doModified; end; function TCEDubProject.configurationName(index: integer): string; @@ -373,7 +379,7 @@ begin if fConfigIx = 0 then exit; // item := fJSON.Find('configurations'); - if item = nil then exit; + if not assigned(item) then exit; // confs := TJSONArray(item); if fConfigIx > confs.Count -1 then exit; @@ -386,8 +392,8 @@ var value: TJSONData; begin value := fJSON.Find('name'); - if value <> nil then fPackageName := value.AsString - else fPackageName := ''; + if not assigned(value) then fPackageName := '' + else fPackageName := value.AsString; end; procedure TCEDubProject.udpateConfigsFromJson; @@ -460,13 +466,13 @@ begin try // auto folders & files item := fJSON.Find('mainSourceFile'); - if item <> nil then + if assigned(item) then fSrcs.Add(ExtractRelativepath(fBasePath, item.AsString)); tryAddFromFolder(fBasePath + 'src'); tryAddFromFolder(fBasePath + 'source'); // custom folders item := fJSON.Find('sourcePaths'); - if item <> nil then + if assigned(item) then begin arr := TJSONArray(item); for i := 0 to arr.Count-1 do @@ -477,21 +483,21 @@ begin end; // custom files item := fJSON.Find('sourceFiles'); - if item <> nil then + if assigned(item) then begin arr := TJSONArray(item); for i := 0 to arr.Count-1 do fSrcs.Add(ExtractRelativepath(fBasePath, arr.Strings[i])); end; conf := getCurrentCustomConfig; - if conf <> nil then + if assigned(conf) then begin item := conf.Find('mainSourceFile'); - if item <> nil then + if assigned(item) then fSrcs.Add(ExtractRelativepath(fBasePath, item.AsString)); // custom folders in current config item := conf.Find('sourcePaths'); - if item <> nil then + if assigned(item) then begin arr := TJSONArray(item); for i := 0 to arr.Count-1 do @@ -502,7 +508,7 @@ begin end; // custom files in current config item := conf.Find('sourceFiles'); - if item <> nil then + if assigned(item) then begin arr := TJSONArray(item); for i := 0 to arr.Count-1 do @@ -547,11 +553,11 @@ var src: string; begin fBinKind := executable; - if fJSON = nil then exit; + if not assigned(fJSON) then exit; // note: in Coedit this is only used to known if output can be launched found := findTargetKindInd(fJSON); conf := getCurrentCustomConfig; - if conf <> nil then + if assigned(conf) then found := found or findTargetKindInd(conf); if not found then begin @@ -589,7 +595,7 @@ procedure TCEDubProject.updateImportPathsFromJson; var conf: TJSONObject; begin - if fJSON = nil then exit; + if not assigned(fJSON) then exit; // addFrom(fJSON); conf := getCurrentCustomConfig; diff --git a/src/ce_interfaces.pas b/src/ce_interfaces.pas index 4775ee82..e5ac445c 100644 --- a/src/ce_interfaces.pas +++ b/src/ce_interfaces.pas @@ -53,9 +53,11 @@ type // returns the count of configuration function configurationCount: integer; // sets the active configuration - procedure setActiveConfiguration(index: integer); + procedure setActiveConfigurationIndex(index: integer); // returns the name of the index-th configuration function configurationName(index: integer): string; + // return the index of the active configration index + function getActiveConfigurationIndex: integer; // project sources --------------------------------------------------------- diff --git a/src/ce_nativeproject.pas b/src/ce_nativeproject.pas index cb050f71..63d8c1e8 100644 --- a/src/ce_nativeproject.pas +++ b/src/ce_nativeproject.pas @@ -90,8 +90,9 @@ type function modified: boolean; // function configurationCount: integer; - procedure setActiveConfiguration(index: integer); + procedure setActiveConfigurationIndex(index: integer); function configurationName(index: integer): string; + function getActiveConfigurationIndex: integer; // function sourcesCount: integer; function sourceRelative(index: integer): string; @@ -838,11 +839,16 @@ begin exit(fConfigs.Count); end; -procedure TCENativeProject.setActiveConfiguration(index: integer); +procedure TCENativeProject.setActiveConfigurationIndex(index: integer); begin setConfIx(index); end; +function TCENativeProject.getActiveConfigurationIndex: integer; +begin + exit(fConfIx); +end; + function TCENativeProject.configurationName(index: integer): string; begin if index > fConfigs.Count -1 then index := fConfigs.Count -1;