HaxeFoundation / HaxeFoundation/as3hx
Support AS3 conditional compilation, aka compiler constants / variables
- Dominant language
- Haxe
- Stars
- 180
- Forks
- 52
- PR merge metrics
- No merged PRs in 30d
Description
AS3 / mxmlc supports conditional compiler variables / expressions: http://help.adobe.com/en_US/flex/using/WS2db454920e96a9e51e63e3d11c0bf69084-7abd.html
(Issue #45 mentions these but only one specific use case.)
You can use booleans to conditionally include entire blocks of code:
```
CONFIG::FOO {
...
}
```
The doc says you can tag definitions at the package-level (without curly braces):
```
CONFIG::debugging
public class MyButton extends Button {
...
CONFIG::release
public class MyButton extends Button {
...
```
I know that you can also enclose those definitions in `{}.
You can also make conditional things like import statements and inline classes, though the latter could be rare:
```
CONFIG::AIR { // This import doesn't exist for non-AIR target
import flash.desktop.NativeApplication;
}
```
You can use constants, both booleans and Strings:
```
if (CONFIG::FOO) { ... }
var host:String = CONFIG::HOSTNAME;
trace("The host is: "+host);
```
The docs state you can pass expressions "a > b", though this one seems odd, I can't think of a good use case / reason you'd do that.
Syntax: Note that I've used the prefix `CONFIG` -- but I believe any / multiple prefixes can be defined. Uppercase prefix is convention, but I'm not sure it's required. The key name case doesn't matter.
Some of the use cases translate easily, but others are more complicated:
- `PREFIX::KEY { ... }` could map to Haxe's [conditional compilation](http://haxe.org/manual/lf-condition-compilation.html) `#if PREFIX_KEY ... #end`, with perhaps a special case prefix/key mapping to `#if debug` (programmable? default?)
- Constants could be mapped to a file of Static public inlines with unknown type and value? It wouldn't compile, but it'd be tidy / obvious. Or perhaps a macro that converts Haxe `-D` definitions to static inline constants (string or boolean).
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reviewing how the converter currently handles AS3 conditional blocks, package-level definitions, imports, inline classes, and constants, then compare these cases with Haxe conditional compilation and -D definitions. Done means the listed AS3 forms have a defined, tested conversion or an explicitly documented limitation.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100