Closed Bug 1011510 Opened 8 years ago Closed 8 years ago

Codegen.py: Add EndGuard to enum generation

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla32

People

(Reporter: janv, Assigned: janv)

References

(Blocks 1 open bug)

Details

Attachments

(1 file, 1 obsolete file)

Attached patch patch (obsolete) — Splinter Review
We have this enum in webidl:
enum FileMode { "readonly", "readwrite" };

Codegen.py generates FileModeBinding.h with this content:
MOZ_BEGIN_ENUM_CLASS(FileMode, uint32_t)
  Readonly,
  Readwrite
MOZ_END_ENUM_CLASS(FileMode)

I would like to see:
MOZ_BEGIN_ENUM_CLASS(FileMode, uint32_t)
  Readonly,
  Readwrite,
  EndGuard
MOZ_END_ENUM_CLASS(FileMode)

So I can add a serialization helper for IPDL:
template <>
struct ParamTraits<mozilla::dom::FileMode> :
  public ContiguousEnumSerializer<
                          mozilla::dom::FileMode,
                          mozilla::dom::FileMode::Readonly,
                          mozilla::dom::FileMode::EndGuard>
{ };
Attachment #8423870 - Flags: review?(bzbarsky)
Blocks: 942542
Comment on attachment 8423870 [details] [diff] [review]
patch

Please call it _EndGuard and add an assert in the codegen that none of the enum values collide with it.
Attachment #8423870 - Flags: review?(bzbarsky) → review-
Attached patch patchSplinter Review
Assignee: nobody → Jan.Varga
Attachment #8423870 - Attachment is obsolete: true
Status: NEW → ASSIGNED
Attachment #8424008 - Flags: review?(bzbarsky)
Comment on attachment 8424008 [details] [diff] [review]
patch

r=me if you make it 

  'Enum value "' + value + '" cannot be used because it collides with our internal EndGuard_ value.  Please rename our internal EndGuard_ to something else'
Attachment #8424008 - Flags: review?(bzbarsky) → review+
https://hg.mozilla.org/mozilla-central/rev/d221383c1e8e
Status: ASSIGNED → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla32
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.