HaxeFoundation/haxe — pull request #2588 by nadako (2014-01-30 07:44:59+00:00)
Title: support overriding pf_ settings with command line

After discussing with @Simn on IRC, we thought that it may be a good idea to provide ways to override __some__ `pf_*` settings with command line.

One of the use cases is custom generators, like @frabbit's hx2python (see also #2367). With `-pf` settings, it possible to configure basic compiler behaviour to make it return more suited typed AST in the `onGenerate` callback.

Another one is `pf_sys` that could be overriden so compiler don't forbid the `sys` package which can be useful, for example when targeting node.js

The third use case is what I intentionally wanted for my company's code: we compile haxe to both JS and C#, but JS is the primary target, so people keep forgetting that they should mark basic types with `Null` and I often end up fixing that to make it compile on C# target. I initially wanted to fix that with overriding `pf_static` (which I renamed to `pf_nullable_basic_types` to make it more clear), however that affects compiler behaviour, so I just ended up adding `-D forbid-null-on-basic-types` to make that one check work even on targets which support nullable basic types.

This branch adds the `-pf` command line option that currently can override `sys` and `nullable_basic_types` settings and renames/inverts `pf_static` to `pf_nullable_basic_types`.
It also provides the `-D forbid-null-on-basic-types` option to forbid usage of null for basic types on platforms that support it (see the reasoning above).