Hi, all.

> >Hrmm.. I've written an Object Pascal template/macro processor
> which we use
> >here at Profax.
>
> Is there a hook in Delphi to get your preprocessor automatically
> called prior
> to compiling any *.pas file?

Hrm.. I don't think so. I'd have to check in Hidden Paths of Delphi 3 but I
don't believe there is a 'BeforeCompile' hook that I could grab and use. At
present, it's a stand alone executable which needs to be kicked up manually
although I did toy with the idea of turning it into a Delphi Wizard/Expert
(not that it would actually help much).

Still, I find I just kick it up and fire out a specific template
instantiation whenever I find I need one I haven't built yet. We have
'standard' instantiations of our templates built for TObject and string
which I use a fair bit. The only other instantiations I've needed were
specific String/Integer and String/TObject beasts to plug into the Red-Black
Tree template for on-the-fly balanced binary tree indexes in memory for our
MemoryTable (ISAM in ram) and ProfaxTable (ISAM on network files) TDataset
derivatives.

> > I have considered offering the processor as a public domain
> >utility and 'donating' the executable to the Delphi community since
> >Templates are pretty damn handy for efficient type-safe
> containers and are
> >the one thing I actually miss from C++.
>
> I miss it... It basically gives you a very simple subclassing
> engine so you
> don't have to compromise on Typesafety...

Yep, exactly the reason I built it :-)

> >The Template Processor is a Delphi executable which reads a template
> >specification unit (.nlt) and prompts for the paramater values
> and an output
> >unit name (.pas) which it then produces. The processor is a single pass
> >lexer/tokenizer/macro processor engine working largely upon
> memory streams
> >so it seems pretty quick. It actually depends upon itself now
> since the code
> >now uses a uDList<string> template  internally rather than TStringLists
> >which gave a nice order of magnitude speed improvement for inserts and
> >deletes which macro engines by their nature do quite a bit off.
> >If anyone is interested, I can email them the .EXE and the complete
> >uDList.nlt as a sample. If lots of people end up asking, I'll
> put it up on
> >the 'NewLook Free Stuff' page at http://www.newlook.co.nz/freestuff.htm
> >instead.
>
> Definitely interested... Have you posted it and suggestions for
> inclusion in
> D5... Seems that the preprocessor functions are the only big thing missing
> in Delphi (apart from fixing the degrading quality of online help)...

Actually, I hadn't thought of doing that. Good idea. I had asked Anders
about adding Templates to Delphi a few BorCon's back and he said 'yes, it
would be nice but we haven't had many Delphi user ask for it' so I figured I
was better to build what I needed myself. I guess it's only if you've used
templates in C++ or Eiffel that you are likely to know and want them but now
that Delphi is acquiring more features from the C++ compiler, maybe
templates might get done but I wouldn't hold your breath since the C++
implementation of templates is god-awfully complicated - you know,
committees and camels.

> It'd be nice to see a few other features available on some C
> compilers too...
> like compiletime defined constants for current_source_line,
> current_source_file
> compilation_datestamp, Method_Name, ... I'll pass on the #defines though,
> that got pretty messy in C... ;)

Yes, I agree. The irritating thing is that the built-in Assert functionality
in D3 already uses those but they didn't surface the tokens up for 'general
developer use'. <mutter mutter>

I did write my own Assert unit for Delphi 2 and did most of the above (File,
Line, and Function) by parsing a detailed MAP files to get out the info. I
still have uAssert.pas and uMapFile.pas lurking around here in the
repository. I did wonder if I could hook my version under the hood of the
Delphi builtin support in D3. Hrrmm.. time to go read through System.pas and
SysUtils.pas again...

TTFN,
  Paul.


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz

Reply via email to