Re: wxWidgets 2.9 build

From: Peter Geoghegan <peter(dot)geoghegan86(at)gmail(dot)com>
To: Dave Page <dpage(at)pgadmin(dot)org>
Cc: Magnus Hagander <magnus(at)hagander(dot)net>, pgadmin-hackers(at)postgresql(dot)org
Subject: Re: wxWidgets 2.9 build
Date: 2011-02-01 15:24:31
Message-ID: AANLkTikqkszdv+KN62R-uN4yeRUZ8i_O1b8j9NDs9jOo@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgadmin-hackers

I now use c_str() for logging variadics without casting, extending wx
logging in a way that provides the same interface as the existing 2.8
code.

There are still two areas where we still cast for variadics, where I
didn't want to copy the black magic that wx does to make the proxy
passable. Here's one:

report->XmlAddSectionTableRow(section,
column->GetColNumber(),
6,
(const wxChar*) colName,
(const wxChar*) column->GetVarTypename(),
(const wxChar*) BoolToYesNo(column->GetNotNull()),
(const wxChar*) BoolToYesNo(column->GetIsPK()),
(const wxChar*) column->GetDefault(),
(const wxChar*) column->GetComment());

I think that to copy the wx technique verbatim would be a net gain in
ugliness, because we're currently simply naive clients of it.

I've performed the changes to overloads of sysSettings::Write() and
ctlListView::AppendItem() already discussed.

Now, sysLogger.h looks like this:

#define wxLOG_Notice (wxLOG_User+1)
#define wxLOG_Sql (wxLOG_User+2)
#define wxLOG_QuietError (wxLOG_User+3)
#define wxLOG_Script (wxLOG_User+4)
#define wxLOG_ScriptVerbose (wxLOG_User+5)

#if wxCHECK_VERSION(2, 9, 0)

#define wxLogNotice wxDO_LOG(Notice)
#define wxLogSql wxDO_LOG(Sql)
#define wxLogQuietError wxDO_LOG(QuietError)
#define wxLogScript wxDO_LOG(Script)
#define wxLogScriptVerbose wxDO_LOG(ScriptVerbose)

#else
#define DECLARE_INT_LOG_FUNCTION(level) \
extern void wxVLog##level(const wxChar *szFormat, va_list argptr); \
extern void wxLog##level(const wxChar *szFormat, ...) ATTRIBUTE_PRINTF_1

DECLARE_INT_LOG_FUNCTION(Notice);
*** SNIP*** // same as before
#endif

This works fine for client TUs. However, sysLogger.cpp doesn't compile
on 2.9 . I don't know why we've provided implementations of various
logger functions there. What do you think? I've attached a patch of my
latest revisions so you can take a look yourself.

By the way, reading 2.9 log.h I learned something about the "ambiguous
else" warnings:

// work as expected, without it the second "else" would match the "if"
// inside wxLogError(). Unfortunately code like
//
// if ( cond )
// wxLogError("!!!");
//
// now provokes "suggest explicit braces to avoid ambiguous 'else'"
// warnings from g++ 4.3 and later with -Wparentheses on but they can be
// easily fixed by adding curly braces around wxLogError() and at least
// the code still does do the right thing.

I'm not sure that your suggestion about the cstr() macro is a win, but
if we do it I feel that it should be an inline function.

--
Regards,
Peter Geoghegan

Attachment Content-Type Size
variadics.patch text/x-patch 79.8 KB

In response to

Responses

Browse pgadmin-hackers by date

  From Date Subject
Next Message Dave Page 2011-02-01 16:20:35 pgAdmin III commit: Phase 1 of our wxWidgets 2.9 compatibility. For mor
Previous Message Dave Page 2011-02-01 10:21:16 Re: wxWidgets 2.9 build