[Mono-list] perl script -- alternative?
Daniel Carrera
dcarrera@math.toronto.edu
Thu, 18 Apr 2002 13:57:07 -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-697035782-1019152311=:173346
Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
Content-ID: <Pine.A41.4.30.0204181352401.173346@coxeter.math.toronto.edu>
Done.
1) $ENV{PWD}
You can override that now with the '-n' or '--namespace' flag.
2) tee
The 'tee' part is just eye-candy and not necessary.
Now the program does not use tee by default. You can optionally add it to
get the output also sent to STDOUT.
Therefore, on a Linux/Unix system you could type:
autogen.pl SomeClass.def -n Some.Namespace
And that would generate the .cs file.
BTW, the file name 'SomeClass.def' is inconsecuential. The name if the
file will be 'ClassName.cs', as it should be.
I don't know how if ActiveState Perl allows for flags to Perl programs.
It should. If the flag doesn't work we'll try something else.
Cheers,
Daniel.
On Thu, 18 Apr 2002, Jaak Simm wrote:
> 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
>
---2140912637-697035782-1019152311=:173346
Content-Type: APPLICATION/X-PERL; NAME="autogen.pl"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.A41.4.30.0204181351510.173346@coxeter.math.toronto.edu>
Content-Description: version 0.0.2
Content-Disposition: ATTACHMENT; FILENAME="autogen.pl"
IyEvdXNyL2Jpbi9wZXJsIC13CnVzZSBHZXRvcHQ6Okxvbmc7CgoKIwojIENv
bW1hbmQtbGluZSBvcHRpb25zLgojCm15ICRUT0RPICAgID0gMTsgIyBEZWZh
dWx0cyB0byAndHJ1ZScuCm15ICR2ZXJib3NlID0gMDsgIyBEZWZhdWx0cyB0
byAnZmxhc2UnLgpteSAkbmFtZXNwYWNlID0nJzsKR2V0T3B0aW9ucyAoICdU
T0RPIScgID0+IFwkVE9ETywgJ3Z8dmVyYm9zZScgPT4gXCR2ZXJib3NlLAoJ
CSdufG5hbWVzcGFjZT1zJyA9PiBcJG5hbWVzcGFjZSAgKTsKCiMKIyAgT2J0
YWluIHRoZSBhdXRob3IsIGNsYXNzIGFuZCBuYW1lc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