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

Adding a New "primitive" Method.



Suppose I wanted to write a program that looked like this:

	(define frame (make-object frame% "Example for Canvas Method" #f 300
300))

	(define canvas (make-object canvas% frame))

	(define rc (send canvas get-rc))

	(send rc draw-triangle)





OK, if you haven't guessed this has to do with OpenGL.

Here, "rc" stands for rendering context and is somewhat analogous to a
device context.
Eventually, the various OpenGL functions would be methods of the rendering
context, but for now,
I'm just going to have a single simple method "draw-triangle".

After 3 hours I've written *zero* lines of code and eventually I fell asleep
somewhere in the middle of
the xctocc documentation that I found via a google query rather than through
the PLT help desk.

What I'm trying to find out is what file, where to edit and what to write in
order to facilitate my little
sample program above. That's what motivated my little foray into the MrEd
source code. 

I've discovered that I can't actually read the MrEd source code the same way
I read other source code. The process of searching in the files for a
particular keyword/identifier seems to be leading me in circles. :-(

I did however rediscover that a lot of the files are actually generated by
this mysterious xctocc tool. It would seem then, that a good "root node" of
the complicated graph that is the MrEd source code might in fact be the .xc
file. I was, in fact, thinking that wxs_cnvs.xc might be a file that I would
need to edit and this is what lead me to the xctocc docs.

Finally, I decided that it might be worth checking to see if xctocc were
actually installed somewhere in my PLT directory.
I found a file xctocc --- no extension, but it appears to be C source code
--- and opened it up to see what it was. At the top I found this comment:

#!/usr/local/bin/perl

# Copyright (c) 1995 Matthew Flatt

# This file reads C++ class descriptsions from files ending in ".xc".
# It produces a C++ file suitable for linking with libscheme plus
# objscheme.cc.

# See xctocc.dvi for information about using this program.

# No one should write code like this. It's horrible. It's immoral.
#
# Still, it works well enough for now.

# Get the directory where this file is, and add to include path:


Oh, is it a perl script? I'v never used perl.

Observe the comment:
"
# No one should write code like this. It's horrible. It's immoral.
#
# Still, it works well enough for now.
"


That's what prompted me to post.


My main driving question: So what file do I edit, what do I write? :-)

other new questions that have come up along the way:

Should I learn this xctocc thing? (Will I go to hell if I do?)
Is there an alternative way to add a method to a primitive scheme class?

How long is "for now"?

Will there eventually be a way for moral programmers to modify/add to the
MrEd source?

Thanks.

Cheers!