From ebfaf3ad9111729c152304cbc03f0d6c32b926c8 Mon Sep 17 00:00:00 2001 From: Basile Burg Date: Mon, 22 Feb 2016 07:18:57 +0100 Subject: [PATCH] cetodo, use a static array and not an aa --- cesetup/readme.md | 8 +++---- cetodo/cetodo.d | 56 +++++++++++++++++++++-------------------------- 2 files changed, 29 insertions(+), 35 deletions(-) diff --git a/cesetup/readme.md b/cesetup/readme.md index d197cc47..801ff116 100644 --- a/cesetup/readme.md +++ b/cesetup/readme.md @@ -5,10 +5,10 @@ Coedit setup program === This coedit project (_cesetup.coedit_) creates the coedit setup program. -The project contains 4 configurations: +The project contains 3 configurations named _win32_, _nux32_, _nux64. +Each takes the content of the matching sub-folder and puts it in the output folder, as an extractor program, +at compile time (using the `import(file)` expression). -- _devel-win32_: it does not takes part in the release process. -- _win32_, _nux32_, _nux64_: they take the content of their matching sub-folder and put it in the output folder, as an extractor program, at compile time (using the `import(file)` expression). The extractor program is then compressed by the post-build process, using the scripts named `setupzip-`. Raw Zip @@ -20,7 +20,7 @@ They are proposed alternatively to the setup program. The scripts are launched a Todo by hand for each release === -- change the setup program _outputFilename_ for each configuration as well as the text printed to the console, according to the new version. - change the text in the _version.txt_ file. +- change the setup program _outputFilename_ for each configuration, according to the new version. - put the content (programs, icon, license, etc.) in each of the nux32/nux64/win32 folders. - compile on each platform with the right project configuration. \ No newline at end of file diff --git a/cetodo/cetodo.d b/cetodo/cetodo.d index 19266aff..0f3f65f4 100644 --- a/cetodo/cetodo.d +++ b/cetodo/cetodo.d @@ -59,16 +59,16 @@ import std.array, std.conv, std.traits, std.ascii; import std.file, std.path, std.range; import dparse.lexer; -/// Encapsulates the fields of a _TODO comment_. +/// Encapsulates the fields of a TODO comment_. private struct TodoItem { /** * Enumerates the possible fields of _a TODO comment_. * They must match the published member of the widget-side class TTodoItem. */ - private static enum TodoField {filename, line, text, category, assignee, priority, status} + private enum TodoField: ubyte {filename, line, text, category, assignee, priority, status} private __gshared static string[TodoField] fFieldNames; - private string[TodoField] fFields; + private string[TodoField.max+1] fFields; static this() { @@ -79,20 +79,17 @@ private struct TodoItem /** * Constructs a TODO item with its fields. * Params: - * fname = the file where the _TODO comment_ is located. mandatory. - * line = the line where the _TODO comment_ is located. mandatory. - * text = the _TODO comment_ main text. mandatory. - * cat = the _TODO comment_ category, optional. - * ass = the _TODO comment_ assignee, optional. - * prior = the _TODO comment_ priority, as an integer litteral, optional. - * status = the _TODO comment_ status, optional. + * fname = the file where the _TODO comment is located. mandatory. + * line = the line where the _TODO comment_is located. mandatory. + * text = the _TODO comment main text. mandatory. + * cat = the _TODO comment category, optional. + * ass = the _TODO comment assignee, optional. + * prior = the _TODO comment priority, as an integer litteral, optional. + * status= the _TODO comment status, optional. */ - @safe public this(string fname, string line, string text, string cat = "", + @safe this(string fname, string line, string text, string cat = "", string ass = "", string prior = "", string status = "") - { - // fname must really be valid - if (!fname.exists) throw new Exception("TodoItem exception, the file name is invalid"); - + { // priority must be convertible to int if (prior.length) try to!long(prior); catch(Exception e) prior = ""; @@ -102,13 +99,13 @@ private struct TodoItem else immutable glue = "'#10'"; text = text.splitLines.join(glue); - fFields[TodoField.filename] = fname.idup; - fFields[TodoField.line] = line.idup; - fFields[TodoField.text] = text.idup; - fFields[TodoField.category] = cat.idup; - fFields[TodoField.assignee] = ass.idup; - fFields[TodoField.priority] = prior.idup; - fFields[TodoField.status] = status.idup; + fFields[TodoField.filename] = fname; + fFields[TodoField.line] = line; + fFields[TodoField.text] = text; + fFields[TodoField.category] = cat; + fFields[TodoField.assignee] = ass; + fFields[TodoField.priority] = prior; + fFields[TodoField.status] = status; } /** @@ -116,7 +113,7 @@ private struct TodoItem * Params: * LfmString = the string containing the LFM script. */ - public void serialize(ref Appender!string lfmApp) + void serialize(ref Appender!string lfmApp) { lfmApp.put(" \r item\r"); foreach(member; EnumMembers!TodoField) @@ -179,10 +176,9 @@ void main(string[] args) @safe private void token2TodoItem(const(Token) atok, string fname, ref TodoItems todoItems) { if (atok.type != (tok!"comment")) return; - auto text = atok.text.strip; + string text = atok.text.strip; string identifier; - // always comment text.popFrontN(2); if (text.empty) @@ -216,8 +212,7 @@ void main(string[] args) } if (!isTodoComment) return; identifier = ""; - - + // splits "fields" and "description" bool isWellFormed; string fields; @@ -235,8 +230,7 @@ void main(string[] args) } if (!isWellFormed) return; identifier = ""; - - + // parses "fields" string a, c, p, s; while (!fields.empty) @@ -269,9 +263,9 @@ void main(string[] args) todoItems ~= new TodoItem(fname, line, text, c, a, p, s); } -// samples for testing the program as a runnable ('Compile and run file ...') with '' +// samples for testing the program as a runnable ('Compile file and run ...') with '' -// fixme-p8: èuèuuè``u`èuùè é ^ç +// fixme-p8: èuèuuè``u`èuùè é ^çßßðđææ«€¶ // fixme-p8: fixme also handled // TODO-cINVALID_because_no_content: ////TODO:set this property as const() to set it read only.