]> git.saurik.com Git - wxWidgets.git/blob - include/wx/checkeddelete.h
Use wxWebKitCtrlNameStr to adhere to the convention used by other wx classes.
[wxWidgets.git] / include / wx / checkeddelete.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/checkeddelete.h
3 // Purpose: wxCHECKED_DELETE() macro
4 // Author: Vadim Zeitlin
5 // Created: 2009-02-03
6 // RCS-ID: $Id$
7 // Copyright: (c) 2002-2009 wxWidgets dev team
8 // Licence: wxWindows licence
9 ///////////////////////////////////////////////////////////////////////////////
10
11 #ifndef _WX_CHECKEDDELETE_H_
12 #define _WX_CHECKEDDELETE_H_
13
14 // TODO: provide wxCheckedDelete[Array]() template functions too
15
16 // ----------------------------------------------------------------------------
17 // wxCHECKED_DELETE and wxCHECKED_DELETE_ARRAY macros
18 // ----------------------------------------------------------------------------
19
20 /*
21 checked deleters are used to make sure that the type being deleted is really
22 a complete type.: otherwise sizeof() would result in a compile-time error
23
24 do { ... } while ( 0 ) construct is used to have an anonymous scope
25 (otherwise we could have name clashes between different "complete"s) but
26 still force a semicolon after the macro
27 */
28
29 #ifdef __WATCOMC__
30 #define wxFOR_ONCE(name) for(int name=0; name<1; name++)
31 #define wxPRE_NO_WARNING_SCOPE(name) wxFOR_ONCE(wxMAKE_UNIQUE_NAME(name))
32 #define wxPOST_NO_WARNING_SCOPE(name)
33 #else
34 #define wxPRE_NO_WARNING_SCOPE(name) do
35 #define wxPOST_NO_WARNING_SCOPE(name) while ( wxFalse )
36 #endif
37
38 #define wxCHECKED_DELETE(ptr) \
39 wxPRE_NO_WARNING_SCOPE(scope_var1) \
40 { \
41 typedef char complete[sizeof(*ptr)]; \
42 delete ptr; \
43 } wxPOST_NO_WARNING_SCOPE(scope_var1)
44
45 #define wxCHECKED_DELETE_ARRAY(ptr) \
46 wxPRE_NO_WARNING_SCOPE(scope_var2) \
47 { \
48 typedef char complete[sizeof(*ptr)]; \
49 delete [] ptr; \
50 } wxPOST_NO_WARNING_SCOPE(scope_var2)
51
52
53 #endif // _WX_CHECKEDDELETE_H_
54