Closed Bug 1300511 Opened 9 years ago Closed 6 months ago

[meta] Replace union OptionalType usages with Maybe<Type> in ipdls

Categories

(Core :: IPC, task, P3)

task

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: kanru, Unassigned)

References

Details

(Keywords: meta)

Currently some IPDL headers define optional type of Type as union OptionalType { void_t; Type; }; or union OptionalType { null_t; Type; }; I intend to replace these with using Maybe<Type> from "mozilla/Maybe.h" and use Maybe<Type> directly in IPDL methods. The rationale is it is clearer how to check the nullness of Maybe<T> and we don't need to define extra optional types in ipdl. This could also avoid uninitialized optional types (it will be OptionalType::T__None, I think it's very confusing) Maybe we can also make the IPDL parser output a warning or error when such usage is detected.
Depends on: 1300512
Priority: -- → P3
Severity: normal → S3

I cannot find OptionalType in any ipdl these days? Am I overlooking something?

Flags: needinfo?(jld)
Type: defect → task

(In reply to Jens Stutte [:jstutte] from comment #1)

I cannot find OptionalType in any ipdl these days? Am I overlooking something?

OptionalType is just an example. The idea here is that people were making their own Maybe-style types with IPDL unions, and the proposal was to use Maybe instead. Nowadays, we have the nicer syntax ? for these kinds of optional types. I see a bunch of places where people have done the conversion in the intervening decade, and if we see further places where this is happening we'd want to replace it, but this is a meta bug with only one blocking bug, so let's just close it.

Status: NEW → RESOLVED
Closed: 6 months ago
Flags: needinfo?(jld)
Resolution: --- → WORKSFORME

That being said, if somebody does want to look for these, looking for union maybe or union opt does turn up a handful of these.

It would also be possible to hack up the IPDL compiler to yell if somebody created a union where one option is null_t or void_t to dredge up more, although there are likely false positives there. You could restrict it to places where there are only two cases, but then you'd miss things like MaybeInputData where A || B || void_t could perhaps be changed to InputData? defined as A || B.

You need to log in before you can comment on or make changes to this bug.