https://github.com/r32/macro-aux
A collection of haxe macro utilities.
https://github.com/r32/macro-aux
Last synced: 3 months ago
JSON representation
A collection of haxe macro utilities.
- Host: GitHub
- URL: https://github.com/r32/macro-aux
- Owner: R32
- Created: 2022-09-09T05:49:37.000Z (almost 4 years ago)
- Default Branch: master
- Last Pushed: 2024-06-11T06:10:39.000Z (about 2 years ago)
- Last Synced: 2025-04-05T22:13:33.440Z (about 1 year ago)
- Language: Haxe
- Size: 18.6 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
macro aux
------
A collection of haxe macro auxiliaries
### GitVersion
Retrieves the git hash string from current directory.
```haxe
var version = maux.GitVersion.get(true);
// js output:
var version = "master@b3bc166";
```
### BitFields
A simple bit fileds build tool.
```haxe
#if !macro
@:build(maux.BitFields.build())
#end
abstract RGB(Int) {
var b : _8; // low bits
var g : _8;
var r : _8; // high bits
// The macro will automatically generate additional "name_offset", "name_mask" fields
inline function new( r : Int, g : Int, b : Int ) {
this = r << r_offset | g << g_offset | b << b_offset;
}
}
// ...
var rgb = new RGB(0x60, 0x70, 0x80);
assert(rgb.r == 0x60); // getter
rgb.r = 0xFF; // setter
assert(rgb.r == 0xFF);
```
### ModuleLevel
It's used to strip the module-level prefix of the field, to generate cleaner JavaScript code.
Main.hx :
```haxe
function foo() {
trace("hello world!");
}
function main() {
foo();
}
```
build.hxml :
```bash
-main Main
-lib macro-aux
--macro maux.ModuleLevel.strip()
--js main.js
```
Generated main.js :
```js
function foo() {
console.log("src/Main.hx:2:","hello world!");
}
function main() {
foo();
}
main();
```
### CStruct
It's used to construct a raw data block similar to the C language.
[CStruct](maux/CStruct.hx)
### ES
[Some utility functions for Javascript](maux/ES.hx)