[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]
Hiding Ugly Opaque Class Declarations: X++ S&I #2
- To: <xtech@xxxxxxxxxxx>
- Subject: Hiding Ugly Opaque Class Declarations: X++ S&I #2
- From: Chris Hibbert <hibbert@evilotto>
- Date: Fri, 27 Jul 90 17:52:07 PDT
Despite our goal of having the translated to C++ code be
(approximately) as readable as C++ source would have been, all our
.hxx files now begin with a ton of opaque class declarations. In
addition, because of garbage collection support & cpp inadequacies,
each such declaration is four lines long. We can hide all this stuff
as follows. Given that classes Foo, Bar, and Baz are declared in
foox.hxx, we in addition have (i.e., generate from the translator) a
file foox.oxx:
#ifndef FOOX_OXX
#define FOOX_OXX
CHECKED_CLASS(Foo);
CHECKED_CLASS(Bar);
CHECKED_CLASS(Baz);
#endif /* FOOX_OXX */
In foox.hxx, where we used to have the many 4 line opaque declarations
for Foo, Bar, and Baz, we instead say:
#include "foox.oxx"
The foox.hxx file is also reduced. It only needs to include a few
*x.oxx files, instead of many lines of declarations. If glubx.hxx
declares the Glub, Flub, and Blub classes, and foox.hxx needs Glub and
Flub, then the old way required foox.hxx to say
#ifndef CHECKED_Glub
CHECKED_CLASS(Glub);
#define CHECKED_Glub
#endif /* CHECKED_Glub */
#ifndef CHECKED_Flub
CHECKED_CLASS(Flub);
#define CHECKED_Flub
#endif /* CHECKED_Flub */
it now gets them both by saying
#include "glubx.oxx"
The general rule is that .hxx files include .oxx files (except for
their direct superclasses for which they include the .hxx versions)
while .ixx and .cxx files include .hxx files.
Thanks to Michael for suggesting we call it "foox.oxx" instead of
"fooo.hxx" so that we can apply it symmetrically to "foop.oxx" and
"foot.oxx". Note that these latter applications aren't strictly
needed, as the only file that will see "foop.oxx" is "foox.cxx" which
also sees "foop.hxx". Similarly for "foot.oxx", "foot.cxx", and
"foot.hxx". The benefits of doing the same for all are: 1) it makes
the ".hxx"s more readable (and the ".oxx"s safely ignorable), and 2)
it makes the translator's job easier.
-- MarkM & Chris