Changeset 149

Show
Ignore:
Timestamp:
05/14/06 11:43:30 (3 years ago)
Author:
Ant
Message:

Added Makefile.Duit (completly useless for now)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/demos/gtk/SpawnTests.d

    r148 r149  
    8383        } 
    8484        Spawn spawn = new Spawn(args[0]); 
     85        spawn.addChildWatch(&childEnded); 
    8586        if (args.length > 1 ) 
    8687        { 
    8788            for( int i=1 ; i<args.length ; i++ ) 
    8889            { 
     90                writefln("SpawnTests.exec adding parameter [%s] %s",i,args[i]); 
    8991                spawn.addParm(args[i]); 
    9092            } 
    9193        } 
    92         spawn.addParm(null); 
     94        //spawn.addParm(null); 
    9395        return exec(spawn); 
     96    } 
     97     
     98    void childEnded(int process, int status) 
     99    { 
     100        writefln("process %s ended with status %s", process, status); 
    94101    } 
    95102     
  • trunk/src/glib/Spawn.d

    r148 r149  
    6363private import std.c.string;; 
    6464 
     65private import std.thread; 
     66 
    6567/** 
    6668 * Description 
     
    110112    } 
    111113     
     114    /** 
     115     * Adds a delegate to be notified on the end of the child process. 
     116     * Params: 
     117     *      delegate(int =   
     118     *      dlg =    
     119     */ 
    112120    public void addChildWatch(void delegate(int,int) dlg) 
    113121    { 
     
    166174     * Executes the prepared process 
    167175     */ 
    168     public int execAsyncWithPipes() 
    169     { 
     176    public int execAsyncWithPipes( 
     177        void delegate(int, int, char[], char[])endChild=null, 
     178        bool delegate(char[])outReader=null, 
     179        bool delegate(char[])errReader=null, 
     180        ) 
     181    { 
     182        writefln("Spawn.execAsyncWithPipes 1"); 
     183        writefln("Spawn.execAsyncWithPipes argv.length = %s",argv.length); 
    170184        char** command = Str.toStringzArray(argv); 
    171185        char* parm = *command; 
     
    198212            standardOutput = fdopen(stdOut, "r"); 
    199213            standardError = fdopen(stdErr, "r"); 
     214             
     215            if ( outReader !is null ) 
     216            { 
     217                //(new SpawnOutRead(outReader)).start(); 
     218                readLoop(outReader); 
     219            } 
    200220        } 
    201221         
    202222        return result; 
    203223    } 
     224     
     225    int readLoop(bool delegate(char[])outReader) 
     226    { 
     227        writefln("SpawnOutRead.run 1"); 
     228        while ( !endOfOutput() ) 
     229        { 
     230            writefln("SpawnOutRead.run 2"); 
     231            char[] line = readLine(); 
     232            writefln("\t%s", line); 
     233            outReader(line); 
     234            writefln("SpawnOutRead.run 3"); 
     235        } 
     236        writefln("SpawnOutRead.readLoop 4"); 
     237        if ( externalWatch !is null ) 
     238        { 
     239            writefln("Spawn.readLoop 2"); 
     240            externalWatch(childPid, 0); 
     241        } 
     242        return 0; 
     243    } 
     244     
     245//  class SpawnOutRead : Thread 
     246//  { 
     247//      bool delegate(char[])outReader; 
     248//      this(bool delegate(char[])outReader) 
     249//      { 
     250//          this.outReader = outReader; 
     251//      } 
     252//       
     253//      int run() 
     254//      { 
     255//          return readLoop(outReader); 
     256//      } 
     257//  } 
     258     
     259     
     260 
    204261     
    205262    public char[] readLine(int max=4096) 
     
    231288    extern(C) static void childWatchCallback(int pid, int status, Spawn spawn) 
    232289    { 
     290        writefln("Spawn.childWatchCallback 1"); 
    233291        if ( spawn.externalWatch !is null ) 
    234292        { 
     293        writefln("Spawn.childWatchCallback 2"); 
    235294            spawn.externalWatch(pid, status); 
    236295        } 
     296        writefln("Spawn.childWatchCallback 3"); 
    237297        spawn.close(); 
    238298    } 
  • trunk/src/glib/Str.d

    r148 r149  
    140140        foreach ( int i, char[] arg ; args) 
    141141        { 
    142             writefln("Stro.toStringArray [%s] >%s<", i, arg); 
     142            writefln("Str.toStringArray [%s] >%s<", i, arg); 
    143143        } 
    144144 
     
    149149        foreach (char[] p; args) 
    150150        { 
    151             writefln("Str.toStringzArray put .%s.", p); 
     151            writefln("Str.toStringzArray put \"%s\"", p); 
    152152            argv[argc++] = toStringz(p); 
    153153        } 
  • trunk/wrap/APILookupGLib.txt

    r147 r149  
    675675    } 
    676676     
     677    /** 
     678     * Adds a delegate to be notified on the end of the child process. 
     679     * Params: 
     680     *      delegate(int =   
     681     *      dlg =    
     682     */ 
    677683    public void addChildWatch(void delegate(int,int) dlg) 
    678684    {