Bug 36545 - [Chromium] Add an ASSERT macro to the Chromium WebKit API
Summary: [Chromium] Add an ASSERT macro to the Chromium WebKit API
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Jeremy Orlow
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-03-24 10:39 PDT by Jeremy Orlow
Modified: 2010-03-25 16:48 PDT (History)
2 users (show)

See Also:


Attachments
Patch (4.86 KB, patch)
2010-03-24 10:45 PDT, Jeremy Orlow
fishd: review-
Details | Formatted Diff | Diff
fix issues (4.85 KB, patch)
2010-03-25 03:42 PDT, Jeremy Orlow
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jeremy Orlow 2010-03-24 10:39:36 PDT
[Chromium] Add an ASSERT macro to the Chromium WebKit API
Comment 1 Jeremy Orlow 2010-03-24 10:45:34 PDT
Created attachment 51522 [details]
Patch
Comment 2 Darin Fisher (:fishd, Google) 2010-03-24 21:07:58 PDT
Comment on attachment 51522 [details]
Patch

> +++ b/WebKit/chromium/public/WebCommon.h
...
>  } // namespace WebKit
>  
> +// -----------------------------------------------------------------------------
> +// Assertions
> +
> +namespace WebKit {
> +
> +void failedAssertion(const char* file, int line, const char* function, const char* assertion);
> +
> +} // namespace WebKit

Why close and then re-open the WebKit namespace?

Please annotate WebKit API entry points with WEBKIT_API.


> +// Only use inside the public directory but outside of WEBKIT_IMPLEMENTATION blocks.  Otherwise use WTF's ASSERT.

There is actually no problem using this outside of WEBKIT_IMPLEMENTATION blocks.


> +#if defined(NDEBUG)
> +#define WEBKIT_ASSERT(assertion) ((void)0)
> +#else
> +#define WEBKIT_ASSERT(assertion) do \
> +    if (!(assertion)) { \
> +        WebKit::failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \
> +    } \

^^^ nit: webkit style says no brackets around single line statements.
Comment 3 Jeremy Orlow 2010-03-25 03:35:53 PDT
> > +// Only use inside the public directory but outside of WEBKIT_IMPLEMENTATION blocks.  Otherwise use WTF's ASSERT.
> 
> There is actually no problem using this outside of WEBKIT_IMPLEMENTATION
> blocks.

I know, but the WebCore asserts are more robust and have extra logic for turning them on/off.  Just seemed like a good idea to point people in that direction primarily.

> > +#if defined(NDEBUG)
> > +#define WEBKIT_ASSERT(assertion) ((void)0)
> > +#else
> > +#define WEBKIT_ASSERT(assertion) do \
> > +    if (!(assertion)) { \
> > +        WebKit::failedAssertion(__FILE__, __LINE__, __FUNCTION__, #assertion); \
> > +    } \
> 
> ^^^ nit: webkit style says no brackets around single line statements.

Just copied what was in Assertions (and then removed a line).  I suppose brackets should be around the do/while tho.
Comment 4 Jeremy Orlow 2010-03-25 03:42:36 PDT
Created attachment 51618 [details]
fix issues
Comment 5 WebKit Commit Bot 2010-03-25 16:48:40 PDT
Comment on attachment 51618 [details]
fix issues

Clearing flags on attachment: 51618

Committed r56579: <http://trac.webkit.org/changeset/56579>
Comment 6 WebKit Commit Bot 2010-03-25 16:48:46 PDT
All reviewed patches have been landed.  Closing bug.