[Mono-list] perl script -- alternative?

Piers Haken piersh@friskit.com
Thu, 18 Apr 2002 11:45:45 -0700


Both 'tee' and 'perl' are part of the cygwin distribution. I'd suggest
using those instead of the ActiveState/UnxUtils versions as they're
probably much closer to the unix versions.

Piers.

-----Original Message-----
From: Jaak Simm [mailto:jaaksimm@firm.ee] 
Sent: Thursday, April 18, 2002 11:37 AM
To: Daniel Carrera; mono-list@ximian.com
Subject: Re: [Mono-list] perl script -- alternative?


Hi Daniel,

I tried out your script on a windows xp box with ActiveState Perl 5.6.1,
but it failed. Basically, I run into 2 problems:
- Windows box does not have variable for pwd ( $ENV{PWD} ). Giving:
    > Use of uninitialized value in split at autogen.pl line 22, <> line
3.
- Windows shell does not have command 'tee', giving error:
    > 'tee' is not recognized as an internal or external command,
operable program or batch file.

The first problem was not serious and I was able to avoid it. The second
one was too tough for me as I am not very familiar with perl. Maybe you
could alter the output code so the script could be used on systems
without 'tee' command.

Cheers,
Jaak


Daniel Carrera wrote:

> > It would be smart to add following things:
> > - '[MonoTODO]' in front of the properties/methods/events
> > - public events
> > - a summary node for the class
> > - maybe a possibility to create the property/method/event without 
> > [MonoTODO] and notimplementedexception (so it is ready for 
> > implementation).
> >
> > Looking forward to try it out.
> >
> > Best,
> > Jaak
>
> Thanks Jaak, Those were very good suggestions.  I believe that I have 
> addressed them for the most part (still working on the summary part).

> I just wrote the script and I think that it works well.  I'm attaching

> it so that people can try it (and suggest changes).  I hope that 
> nobody minds the attachment.
>
> Here is a sample input file (in the directory System.Windows.Forms):
>
> /* * * * * * * * * * *   Begin Text File   * * * * * * * * */
>
> Daniel Carrera (dcarrera@math.toronto.edu)
> public class Form : ContainerControl
>
> /// <summary>
> ///    This is a summary.
> /// </summary>
>
> //
> //  --- Public Properties
> //
> =public
>
> IButtonControl AcceptButton{gs}
> static Form ActiveForm{g}
> Form ActiveMdiChild{g}
>
> =public bool
> AutoScale{gs}
> IsMidiChild{gs}
> IsMidiContainer{gs}
> KeyPreview{gs}
> MaximizeBox{gs}
> Modal{g}
>
> //
> //  --- Public Methods
> //
> void Activate()
>
> //
> //  --- Public Events
> //
> event EventHandler Activated
>
> /* * * * * * * * * * *  End Text File   * * * * * * * * * * * */
>
> A few notes:
>
> 1)  The script respects blank lines and C# comments.
>
> 2) '=some text' makes 'some text' precede every declaration until the
next
>    '='.  To stop this type a line with just an = sign and nothing 
> else.
>
> 3) '{gs}' will be replaced by the 'get' and 'set' lines (see below).
>    The script simply looks for the letters 'g' and 's' inside the
>    brackets.  Therefore, '{gs}', '{get; set}', '{GET}' will all work.
>
> 4) You can write multi-line code like-so:
> override IntPtr HookProc(       \
>         IntPtr hWnd,            \
>         int msg,                \
>         IntPtr wparam,          \
>         IntPtr lparam           \
> )
> My script will concatenate the extra white space.
>
> To produce the output type:
> ./autogen.pl Form.template
>
> This will make a file called 'Form.cs', as well as send the output to 
> STDOUT.  The filename is taken from the class name you give it.
>
> As suggested, the output contains the '[MonoTODO]' lines as well.  
> Also, as suggested, you can suppress those, as well as the 
> NotImplementedException with:
>
> ./autogen.pl --noTODO Form.template
>
> Finally, this markup also addresses the 'public events' suggestion 
> since there is no distinction for methods, properties, etc.
>
> Here is the output of the program:
>
> //
> // tmp.Form
> //
> // Author:
> //   stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
> //
> // (C) 2002 Ximian, Inc
> //
>
> namespace tmp
> {
>         public public class Form : ContainerControl
>         {
>
>                 /// <summary>
>                 /// This is a summary.
>                 /// </summary>
>
>                 //
>                 // --- Public Properties
>                 //
>
>                 [MonoTODO]
>                 public IButtonControl AcceptButton
>                 {
>                         get { throw new NotImplementedException (); }
>                         set { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public static Form ActiveForm
>                 {
>                         get { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public Form ActiveMdiChild
>                 {
>                         get { throw new NotImplementedException (); }
>                 }
>
>                 [MonoTODO]
>                 public bool AutoScale
>                 {
>                         get { throw new NotImplementedException (); }
>                         set { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public bool IsMidiChild
>                 {
>                         get { throw new NotImplementedException (); }
>                         set { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public bool IsMidiContainer
>                 {
>                         get { throw new NotImplementedException (); }
>                         set { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public bool KeyPreview
>                 {
>                         get { throw new NotImplementedException (); }
>                         set { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public bool MaximizeBox
>                 {
>                         get { throw new NotImplementedException (); }
>                         set { throw new NotImplementedException (); }
>                 }
>                 [MonoTODO]
>                 public bool Modal
>                 {
>                         get { throw new NotImplementedException (); }
>                 }
>
>                 //
>                 // --- Public Methods
>                 //
>                 [MonoTODO]
>                 public bool void Activate()
>                 {
>                         throw new NotImplementedException ();
>                 }
>
>                 //
>                 // --- Public Events
>                 //
>                 [MonoTODO]
>                 public bool event EventHandler Activated
>                 {
>                         throw new NotImplementedException ();
>                 }
>
>         }
> }
>
> Cheers,
> Daniel.
>
> On Thu, 18 Apr 2002, Jaak Simm wrote:
>
> > I like the idea.
> > It would be smart to add following things:
> > - '[MonoTODO]' in front of the properties/methods/events
> > - public events
> > - a summary node for the class
> > - maybe a possibility to create the property/method/event without 
> > [MonoTODO] and notimplementedexception (so it is ready for 
> > implementation).
> >
> > Looking forward to try it out.
> >
> > Best,
> > Jaak
> >
> > Daniel Carrera wrote:
> >
> > > I will certainly comply with whatever rules Mono sets.
> > >
> > > I have another idea.  Not as useful as the first, but I'm sure 
> > > it's
> > > legal:
> > >
> > > I can come up with some sort of "markup" that people can type the 
> > > classes into.  It'd be designed to minimize typing.  Then my 
> > > program would convert that markup to the actual stubbs.
> > >
> > > I might need help desgning an efficient markup.
> > > The markup file (in the System.Windows.Forms directory) might be 
> > > something like this:
> > >
> > > Daniel Carrera (dcarrera@math.toronto.edu)
> > > abstract class FileDialog : CommonDialog
> > >
> > > public prop [
> > > bool AddExtension {get set}
> > > virtual bool CheckFileExists {g s}
> > > ]
> > >
> > > protected methods [
> > > void Dispose()
> > > virtual object GetService(Type service)
> > > ]
> > >
> > > >From this my script would generate:
> > >
> > > //
> > > // System.Windows.Forms.FileDialog
> > > //
> > > // Author:
> > > //   stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
> > > //
> > > // (C) 2002 Ximian, Inc
> > > //
> > >
> > > namespace System.Windows.Forms
> > > {
> > >         /// <summary>
> > >         /// ToDo note:
> > >         ///  - Nothing is implemented
> > >         /// </summary>
> > >         public abstract class FileDialog : CommonDialog
> > >         {
> > >
> > >                 //
> > >                 //  --- Public Properties
> > >                 //
> > >                 public bool AddExtension
> > >                 {
> > >                        get { throw new NotImplementedException ();
}
> > >                        set { throw new NotImplementedException ();
}
> > >                 }
> > >                 public virtual bool CheckFileExists
> > >                 {
> > >                        get { throw new NotImplementedException ();
}
> > >                        set { throw new NotImplementedException ();
}
> > >                 }
> > >
> > >                 //
> > >                 //  --- Protected Methods
> > >                 //
> > >                 protected void Dispose()
> > >                 {
> > >                         throw new NotImplementedException ();
> > >                 }
> > >                 protected virtual object GetService(Type service)
> > >                 {
> > >                         throw new NotImplementedException ();
> > >                 }
> > >         }
> > > }
> > >
> > > This is much less powerful than the one I made already.  However, 
> > > I thought that if we have to do 3000 classes it might still be 
> > > worth it.
> > >
> > > Thoughts on this?
> > >
> > > Daniel.
> > >
> > > On 17 Apr 2002, Miguel de Icaza wrote:
> > >
> > > > Manually typing in the stubs, and bug fixing as we go should be 
> > > > fine.
> > > >
> > > > Do not attempt to use any automatic mechanisms.
> > > >
> > > > Miguel.
> > > ...
> > > >
> > > > We have never copy/pasted code.  I have always used one machine 
> > > > to read the prototypes, and another to type it in (logistically,

> > > > thats the only way I could do it ;-), which is why you find so 
> > > > many little mistakes in the base classes ;-)
> > > >
> > > > Miguel
> > > >
> > >
> > > _______________________________________________
> > > Mono-list maillist  -  Mono-list@ximian.com 
> > > http://lists.ximian.com/mailman/listinfo/mono-list
> >
>
>
------------------------------------------------------------------------
>                     Name: autogen.pl
>    autogen.pl       Type: Perl Program (APPLICATION/x-perl)
>                 Encoding: BASE64
>              Description: Create stubbs from markup


_______________________________________________
Mono-list maillist  -  Mono-list@ximian.com
http://lists.ximian.com/mailman/listinfo/mono-list