Abstract away reserved parameters in Win32 functions and COM methods #821
Labels
breaking change
Changes that break existing functionality
feature
A new feature or request
P2
Medium-priority issue
package: generator
Issue with package:generator
Milestone
In certain Win32 functions and COM methods, some parameters are designated as reserved, meaning they must be explicitly set to
NULL
ornullptr
, depending on the parameter's type. These reserved parameters often serve no functional purpose for the caller and only exist to maintain API compatibility.To improve the developer experience, these reserved parameters can be abstracted away by the
generator
, allowingNULL
ornullptr
to be passed automatically behind the scenes.Take the CoInitializeEx function as an example. Its current projection in Dart is as follows:
The first parameter,
pvReserved
, is marked as reserved and must be set tonullptr
. This results in a typical call like this:To simplify this, the function projection can be adjusted to implicitly pass
nullptr
for the reserved parameter, eliminating the need for the caller to provide it manually:With this change, calling the function becomes much cleaner and more intuitive:
The text was updated successfully, but these errors were encountered: