fix #90, dastworx issue under win32 + rework dastworx main()

This commit is contained in:
Basile Burg 2016-08-23 07:18:53 +02:00
parent a41fbd6271
commit e0fa57d8b6
3 changed files with 18 additions and 14 deletions

View File

@ -35,6 +35,8 @@ void main(string[] args)
version(devel) version(devel)
{ {
mixin(logCall); mixin(logCall);
config = LexerConfig("", StringBehavior.source, WhitespaceBehavior.skip);
cache = construct!(StringCache)(StringCache.defaultBucketCount);
File f = File(__FILE__, "r"); File f = File(__FILE__, "r");
foreach(ref buffer; f.byChunk(4096)) foreach(ref buffer; f.byChunk(4096))
source.put(buffer); source.put(buffer);
@ -42,23 +44,29 @@ void main(string[] args)
} }
else else
{ {
// get the source to process.
// even when files are passed, the std input has to be closed by the IDE
foreach(ref buffer; stdin.byChunk(4096)) foreach(ref buffer; stdin.byChunk(4096))
source.put(buffer); source.put(buffer);
} if (!source.data.length)
if (args.length > 2)
{ {
files = args[1].splitter(pathSeparator).array; files = args[1].splitter(pathSeparator).array;
version(devel) writeln(files); version(devel) writeln(files);
} }
// when files are passed, the global cache & config cant be used
else
{
config = LexerConfig("", StringBehavior.source, WhitespaceBehavior.skip); config = LexerConfig("", StringBehavior.source, WhitespaceBehavior.skip);
cache = construct!(StringCache)(StringCache.defaultBucketCount); cache = construct!(StringCache)(StringCache.defaultBucketCount);
}
}
// options for the worxs
getopt(args, std.getopt.config.passThrough, getopt(args, std.getopt.config.passThrough,
"d", &deepSymList "d", &deepSymList
); );
// launch a worx directly
getopt(args, std.getopt.config.passThrough, getopt(args, std.getopt.config.passThrough,
"i", &handleImportsOption, "i", &handleImportsOption,
"m", &handleMainfunOption, "m", &handleMainfunOption,

View File

@ -50,8 +50,6 @@ begin
str := source.Text; str := source.Text;
prc.Input.Write(str[1], str.length); prc.Input.Write(str[1], str.length);
prc.CloseInput; prc.CloseInput;
while prc.Running do
sleep(1);
processOutputToStrings(prc, imports); processOutputToStrings(prc, imports);
finally finally
prc.free; prc.free;
@ -75,8 +73,6 @@ begin
prc.ShowWindow := swoHIDE; prc.ShowWindow := swoHIDE;
prc.Execute; prc.Execute;
prc.CloseInput; prc.CloseInput;
while prc.Running do
sleep(1);
processOutputToStrings(prc, results); processOutputToStrings(prc, results);
finally finally
prc.free; prc.free;

View File

@ -6,7 +6,7 @@ interface
uses uses
Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, LazFileUtils, Classes, SysUtils, FileUtil, ce_common, ce_writableComponent, LazFileUtils,
ghashmap, ghashset, process, ghashmap, ghashset,
ce_dcd, ce_dialogs, ce_projutils, ce_interfaces, ce_dlang, ce_dastworx; ce_dcd, ce_dialogs, ce_projutils, ce_interfaces, ce_dlang, ce_dastworx;
type type