[Mono-list] perl script -- alternative?

Daniel Carrera dcarrera@math.toronto.edu
Thu, 18 Apr 2002 04:41:45 -0400 (EDT)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---2140912637-914566036-1019119305=:173346
Content-Type: TEXT/PLAIN; charset=US-ASCII

> 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
>

---2140912637-914566036-1019119305=:173346
Content-Type: APPLICATION/x-perl; name="autogen.pl"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.A41.4.30.0204180441450.173346@coxeter.math.toronto.edu>
Content-Description: Create stubbs from markup
Content-Disposition: attachment; filename="autogen.pl"

IyEvdXNyL2Jpbi9wZXJsIC13CnVzZSBHZXRvcHQ6Okxvbmc7CgoKIwojIENv
bW1hbmQtbGluZSBvcHRpb25zLgojCm15ICRUT0RPID0gMTsgIyBEZWZhdWx0
cyB0byAndHJ1ZScuCkdldE9wdGlvbnMgKCAnVE9ETyEnICA9PiBcJFRPRE8g
KTsKCiMKIyAgT2J0YWluIHRoZSBhdXRob3IsIGNsYXNzIGFuZCBuYW1lc3Bh
Y2UuCiMKd2hpbGUoIGNob21wKCRhdXRob3IgPSA8PikgKSB7IGxhc3QgaWYg
JGF1dGhvciA9fiAvXFMvIH0Kd2hpbGUoIGNob21wKCRjbGFzcyAgPSA8Pikg
KSB7IGxhc3QgaWYgJGNsYXNzICA9fiAvXFMvIH0KCiRjbGFzc19kZWZpbml0
aW9uID0gJGNsYXNzOwokY2xhc3MgPX4gcy9ccyo6LiovLzsKQGNsYXNzX2Zp
ZWxkcyA9IHNwbGl0KCAvIC8sICRjbGFzcyk7CiRjbGFzcyA9IHBvcCBAY2xh
c3NfZmllbGRzOwoKQHB3ZCA9IHNwbGl0KCIvIiwgJEVOVntQV0R9KTsKJG5h
bWVzcGFjZSA9IHBvcCBAcHdkOwoKJGFwc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