Article

From:
To:
Vladimir Ulchenko
Subject:
Re: Delphi Project X Cross GUI
Newsgroup:
embarcadero.public.delphi.non-technical

Re: Delphi Project X Cross GUI

Hello,

Vladimir Ulchenko wrote:

> > obviously you haven't seen my macro collection :)
> 
> that would be quite interesting to see those macros you use to work
> with bcb

that was a joke. I have written numerous macros which would easily
resist being ported to Delphi, but I don't really use them in
production code :)


> I personally have lots of one-liners such as
> BEGIN_END_UPDATE(SomeObject)
> SAVE_RESTORE_PROPERTY(PropName,TObject*,SetValue)
> SHOW_HIDE_BUSY(BusyMessage,ProgressMin,ProgressMax)
> SAVE_RESTORE_CURSOR
> DISABLE_ENABLE_CONTROLS(DataSet)
> SAVE_RESTORE_BOOKMARK(DataSet)
> etc. not to mention numerous ON_BLOCK_EXIT, ON_BLOCK_EXIT_OBJ and
> other scopeguards created from variadic macros

They all sound reasonable.

The only one I'm using regularly is a generic scopeguard macro:
// ----- #define UCL_PP_EXPAND(...) __VA_ARGS__ #define UCL_PP_CAT2_(a,...) UCL_PP_EXPAND(a ## __VA_ARGS__) #define UCL_PP_CAT2(a,...) UCL_PP_CAT2_(a, __VA_ARGS__) #define UCL_SAFEGUARD(arg, init, exit) \     class UCL_PP_CAT2(_SG_, __LINE__) \     { \         typedef decltype (arg) ArgType; /* should be a pointer type */ \         ArgType object; \     public: \         UCL_PP_CAT2(_SG_, __LINE__) (ArgType _object) \          : object (_object) \         { init; } \         ~UCL_PP_CAT2(_SG_, __LINE__) (void) { exit; } \     } UCL_PP_CAT2(_vSG_, __LINE__) (arg) // -----
Usage: // ----- void __fastcall TMyForm::SomeButtonClick(TObject* Sender) {   UCL_SAFEGUARD (MyListView->Items,     object->BeginUpdate (), object->EndUpdate ());   ... } // -----
Works in C++Builder 2009 onwards (it relies on decltype()).
-- Moritz
"Hey, it compiles! Ship it!"
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Mon, 25 Nov 2024 11:19:50 UTC
Copyright © 2009-2024
HREF Tools Corp.