Article View: gnu.g++
Article #155Re: problems with genclass
From: T.Day
Date: Tue, 03 Oct 1989 17:03
Date: Tue, 03 Oct 1989 17:03
86 lines
3653 bytes
3653 bytes
From: Tim Day <T.Day@uk.ac.ucl.cs>
You can take a lot of the pain out of genclass with makefile rules
e.g from my own setup for bags: (works OK on Gnu make 3.54)
Note that
$(GDEP) is the name of a file which can be touched to cause all genclassed
code to be rebuilt.
$(Gcomp) is the g++ compile macro (= $(C++) $(C++FLAGS) etc)
Bags/Lists of Ptrs are pass by value (created by $(genclassV)).
Anything else is pass by reference (created by $(genclassR)).
useful.h is included everywhere
The $(genclass ) macros...
genclass the required class
Insert a #include for the name of the ``contained'' class
Insert a #include "useful.h"
Touch a .cc file in case genclass didn't produce one
The result is that you can get all the .SLList, .Bag and .SLBag files generated
just by mentioning a .SLBag.h dependency. (Of course you still have to
remember to archive or link all three .o files)
define genclassR
genclass $(basename $(basename $(notdir $@))) ref $(suffix $(basename $(notdir $@)))
prepend '#include "$(basename $(basename $(notdir $@))).h"' $(basename $(notdir $@)).h
prepend '#include "useful.h"' $(basename $(notdir $@)).h
touch $(basename $(notdir $@)).cc
endef
define genclassV
genclass $(basename $(basename $(notdir $@))) val $(suffix $(basename $(notdir $@)))
prepend '#include "$(basename $(basename $(notdir $@))).h"' $(basename $(notdir $@)).h
prepend '#include "useful.h"' $(basename $(notdir $@)).h
touch $(basename $(notdir $@)).cc
endef
%Ptr.SLList.h %Ptr.SLList.cc: $(GDEP)
$(genclassV)
%Ptr.SLList.o: useful.h %Ptr.h %Ptr.defs.h %Ptr.SLList.h %Ptr.SLList.cc
$(Gcomp)
%Ptr.Bag.h %Ptr.Bag.cc: $(GDEP)
$(genclassV)
%Ptr.Bag.o: useful.h %Ptr.h %Ptr.defs.h %Ptr.Bag.h %Ptr.Bag.cc
$(Gcomp)
%Ptr.SLBag.h %Ptr.SLBag.cc: $(GDEP) %Ptr.SLList.h %Ptr.Bag.h
$(genclassV)
%Ptr.SLBag.o: $(GDEP) useful.h %Ptr.h %Ptr.defs.h %Ptr.SLList.h %Ptr.Bag.h %Ptr.SLBag.h %Ptr.SLBag.cc
$(Gcomp)
%.SLList.h %.SLList.cc: $(GDEP)
$(genclassR)
%.SLList.o: useful.h %.h %.defs.h %.SLList.h %.SLList.cc
$(Gcomp)
%.Bag.h %.Bag.cc: $(GDEP)
$(genclassR)
%.Bag.o: useful.h %.h %.defs.h %.Bag.h %.Bag.cc
$(Gcomp)
%.SLBag.h %.SLBag.cc: $(GDEP) %.SLList.h %.Bag.h
$(genclassR)
%.SLBag.o: $(GDEP) useful.h %.h %.defs.h %.SLList.h %.Bag.h %.SLBag.h %.SLBag.cc
$(Gcomp)
You'll probably have to declare all the .h files you create as precious,
otherwise make regards them as intermediate and deletes them after its built
the .o... not much use for libraries. I think make can also get a little
confused by genclass creating two files at once. You need slightly
different versions of the genclass macros for bags of builtins (e.g int) or
supplied classes (e.g String).
My favourite class ? String.%Ptr.SplayMap, v. useful for writing parser type
things
+-----------------------------------------------------------------------------+
Tim Day | Meet every second in life as challenge;
Department of Photogrammetry | Respond fully to whatever happens
UCL, Gower St., London WC1E 6BT | without anxiety, or complaint, or clinging
+-----------------------------------------------------------------------------+
Technical Details
Message-ID:
<413@ucl-cs.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!wuarchive!wugate!uunet!mcsun!ukc!strath-cs!nott-cs!ucl-cs!T.DayShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!wuarchive!wugate!uunet!mcsun!ukc!strath-cs!nott-cs!ucl-cs!T.Day From: T.Day@ucl-cs.UUCP Newsgroups: gnu.g++ Subject: Re: problems with genclass Message-ID: <413@ucl-cs.UUCP> Date: 3 Oct 89 17:03:12 GMT Sender: T.Day@ucl-cs.UUCP Lines: 86