[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: Adding a New "primitive" Method.



In the instructions below, Matthew said this:

> If you're using Windows, then in plt/src/mred/wxs
> yuo want to run
> 
>   perl ../../mzscheme/utils/xctocc -cxx wxs_cnvs.xc


OK, I know nothing about perl. I found "ActivePerl" or something or the
other on the web. It made me jump through an anoying hoop to install, but I
have perl now.

I type in the gunk above, and shortly following, I get this output:

The name specified is not recognized as an
internal or external command, operable program or batch file.
Can't locate parse.pl in @INC (@INC contains: D:/Perl/lib D:/Perl/site/lib .
) at ..\..\mzscheme\uti
ls\xctocc line 34.


I tracked down the "The name specified is not recognized..." garbage (When
the asshole at MS who came up with this particular error message dies he's
going to hell. Whenever he asks anyone why he's there, or anything else for
that matter, they're going to tell him "The name specified is not
recognized..." and nothing else --- that will be his eternal punishment.)

Anyway, I tracked down the offending line in the script. It happens early
on:

{$0 =~ /^(.*)\/.*$/;  $my_dir = $1; 
 if ($my_dir !~ ?^/?) {
	 open(DIRNAME, "pwd | ");

#Greg Pettyjohn					it doesn't like the
following line:
     $pwd = <DIRNAME>;


	 close(DIRNAME);
	 chop($pwd);
     $my_dir = $pwd . "/" . $my_dir;}
 if ($my_dir =~ ?/$?) {chop ($my_dir);}}
push(@INC, $my_dir);


With the extra whitespace my line 34 (with some context):
...
 if ($my_dir =~ ?/$?) {chop ($my_dir);}}
push(@INC, $my_dir);



require "parse.pl";       <---- line 34
require "common.pl";

$cc_suffix = "cc";

if ($ARGV[0] eq '-cxx') {
...


I'm guessing that $my_dir didn't have the the right value when it got
"push"'d into @INC. Where @INC is a whatever the fuck some sort of stack or
something? (when whoever it is that decided it was a neat idea to put @$?/#
and other profanity into a programming language goes to hell, I'll be happy
to find out that someone pushes a $my_dir into his @INC for eternity)


For now I'm going to go play rampart until I've overcome my initial "perl
syntax shock" and then I'll give the perl docs a go.(really didn't want to
start learning perl today).


> -----Original Message-----
> From: Matthew Flatt [mailto:mflatt@cs.utah.edu]
> Sent: Tuesday, October 10, 2000 6:08 AM
> To: Greg Pettyjohn
> Cc: plt-scheme@fast.cs.utah.edu
> Subject: Re: Adding a New "primitive" Method.
> 
> 
> I've long dreaded the day that someone wants to modify MrEd
> significantly. The MrEd-MzScheme glue is one of the oldest, trickiest,
> grossest parts of the system. It's long overdue for an 
> overhaul, but we
> have a few other things to overhaul first.
> 
> Anyway, to answer the meta-questions:
> 
> > # No one should write code like this. It's horrible. It's immoral.
> 
> This is the only line in the source code for xctocc that I'm happy to
> defend. :) 
> 
> Of course, if I did it over again, I'd turn MzScheme in a compentent
> scripting language before creating MrEd, instead of the other way
> around. Then there'd be no perl code in the build process.
> 
> > Should I learn this xctocc thing?
> 
> No.
> 
> > (Will I go to hell if I do?)
> 
> You shouldn't take any chances.
> 
> > Is there an alternative way to add a method to a primitive 
> scheme class?
> 
> Not really. :(
> 
> > How long is "for now"?
> 
> Probably a good while longer.
> 
> I'm gradually cleaning up the source code to make it readable, but
> currently I'm working in plt/src/mzscheme/src and the wxWindows code.
> It's a long-term project.
> 
> Meanwhile, I predict significant upheaval in the implementation of
> MzScheme and MrEd over the coming months. Nothing that will make MrEd
> easier to modify, though.
> 
> > Will there eventually be a way for moral programmers to 
> modify/add to
> > the MrEd source?
> 
> Eventually.
> 
> ----------------------------------------
> 
> Now, the painful answer to the main question:
> 
> Quoting Greg Pettyjohn:
> > Suppose I wanted to write a program that looked like this:
> > 
> > [...]
> > 
> > 	(define rc (send canvas get-rc))
> 
> If you really want to add a method to the primitive canvas%, you have
> correctly deduced that you want to modify some .xc[i] file in
> plt/src/mred/wxs. In this case, it's wxs_cnvs.xc. Somewhere near
> 
>  @ "get-dc" : wxDC! GetDC();
> 
> add:
> 
>  @ m "get-rc" : void[]/CastToSO//spAnything GetRC();
> 
> Somewhere at the top, near
> 
>  static void FillZero(int *a, int *b) {
>    *a = *b = 0;
>  }
> 
> add:
> 
>  @MACRO CastToSO = (Scheme_Object*){x}
>  @MACRO spAnything = _
> 
>  void *GetRC(wxDC *dc) {
>     ... implement it, returning a Scheme_Object* ...
>  }
> 
> If you're using some form of Unix, wxs_cnvs.cxx will get generated by
> the make process. If you're using Windows, then in plt/src/mred/wxs
> yuo want to run
> 
>   perl ../../mzscheme/utils/xctocc -cxx wxs_cnvs.xc
> 
> But wait --- there's more! In plt/src/mred/wrap/mred.ss, you need to
> add `get-rc' to yet another wrapping layer. Look for `basic-canvas%',
> and add `get-rc' in the same way as `get-dc' is already 
> there. Then, if
> you're in Unix, go to mred/wrap in your build area and run 
> `make'. (The
> normal make won't do that unless you;ve done it once before.) Using
> Windows, run plt/src/mred/wrap/makewrap.bat.
> 
> 
> For the implementation of `rc', avoid xctocc. Some other 
> tool, like the
> one described at www.dia.uniroma3.it/~scorzell might be the right
> thing. Or see the "tree.cxx" example in plt/collects/mzscheme/example
> and figure out how to generate the glue you want.
> 
> Matthew
>