Compare commits
9 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
4fd03ed667 | ||
![]() |
4cb5ee4196 | ||
![]() |
888481094a | ||
![]() |
7686fe3e35 | ||
![]() |
747d07bfc5 | ||
![]() |
00640d8328 | ||
![]() |
77973f6007 | ||
![]() |
0df9c28ace | ||
![]() |
d90fb966d2 |
2
.haxerc
2
.haxerc
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "4.0.0-rc.1",
|
"version": "4.0.0-rc.3",
|
||||||
"resolveLibs": "scoped"
|
"resolveLibs": "scoped"
|
||||||
}
|
}
|
@@ -1,5 +1,5 @@
|
|||||||
sudo: required
|
sudo: required
|
||||||
dist: trusty
|
dist: xenial
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- test
|
- test
|
||||||
@@ -17,7 +17,7 @@ env:
|
|||||||
- HAXE_VERSION=edge
|
- HAXE_VERSION=edge
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- npm i -g lix
|
- npm i -g lix@15.3.13
|
||||||
- lix install haxe $HAXE_VERSION
|
- lix install haxe $HAXE_VERSION
|
||||||
- lix download
|
- lix download
|
||||||
|
|
||||||
|
24
haxelib.json
24
haxelib.json
@@ -1,20 +1,20 @@
|
|||||||
{
|
{
|
||||||
"name": "tink_macro",
|
"name": "tink_macro",
|
||||||
"license": "MIT",
|
"description": "The macro toolkit ;)",
|
||||||
|
"classPath": "src",
|
||||||
|
"dependencies": {
|
||||||
|
"tink_core": ""
|
||||||
|
},
|
||||||
|
"url": "http://haxetink.org/tink_macro",
|
||||||
|
"contributors": [
|
||||||
|
"back2dos"
|
||||||
|
],
|
||||||
|
"version": "0.17.7",
|
||||||
|
"releasenote": "Use @:persistent as necessary.",
|
||||||
"tags": [
|
"tags": [
|
||||||
"tink",
|
"tink",
|
||||||
"macro",
|
"macro",
|
||||||
"utility"
|
"utility"
|
||||||
],
|
],
|
||||||
"classPath": "src",
|
"license": "MIT"
|
||||||
"description": "The macro toolkit ;)",
|
|
||||||
"contributors": [
|
|
||||||
"back2dos"
|
|
||||||
],
|
|
||||||
"releasenote": "Various fixes",
|
|
||||||
"version": "0.17.5",
|
|
||||||
"url": "http://haxetink.org/tink_macro",
|
|
||||||
"dependencies": {
|
|
||||||
"tink_core": ""
|
|
||||||
}
|
|
||||||
}
|
}
|
@@ -29,7 +29,20 @@ typedef TypeResolution = Ref<Either<String, TypeDefinition>>;
|
|||||||
|
|
||||||
class MacroApi {
|
class MacroApi {
|
||||||
|
|
||||||
static var idCounter = 0;
|
static var MAIN_CANDIDATES = ['-main', '-x', '--run'];
|
||||||
|
static public function getMainClass():Option<String> {
|
||||||
|
var args = Sys.args();
|
||||||
|
|
||||||
|
for (c in MAIN_CANDIDATES)
|
||||||
|
switch args.indexOf(c) {
|
||||||
|
case -1:
|
||||||
|
case v: return Some(args[v+1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
|
||||||
|
@:persistent static var idCounter = 0;
|
||||||
|
|
||||||
@:noUsing static public inline function tempName(?prefix:String = 'tmp'):String
|
@:noUsing static public inline function tempName(?prefix:String = 'tmp'):String
|
||||||
return '__tink_' + prefix + Std.string(idCounter++);
|
return '__tink_' + prefix + Std.string(idCounter++);
|
||||||
|
@@ -33,7 +33,7 @@ typedef BuildContext3 = {>BuildContext2,
|
|||||||
|
|
||||||
class BuildCache {
|
class BuildCache {
|
||||||
|
|
||||||
static var cache = new Map();
|
@:persistent static var cache = new Map();
|
||||||
|
|
||||||
static public function getType3(name, ?types, ?pos:Position, build:BuildContext3->TypeDefinition) {
|
static public function getType3(name, ?types, ?pos:Position, build:BuildContext3->TypeDefinition) {
|
||||||
if (types == null)
|
if (types == null)
|
||||||
|
@@ -3,6 +3,7 @@ package tink.macro;
|
|||||||
import haxe.macro.Expr;
|
import haxe.macro.Expr;
|
||||||
|
|
||||||
class Metadatas {
|
class Metadatas {
|
||||||
|
static var printer = new haxe.macro.Printer();
|
||||||
static public function toMap(m:Metadata) {
|
static public function toMap(m:Metadata) {
|
||||||
var ret = new Map<String,Array<Array<Expr>>>();
|
var ret = new Map<String,Array<Array<Expr>>>();
|
||||||
if (m != null)
|
if (m != null)
|
||||||
@@ -18,4 +19,8 @@ class Metadatas {
|
|||||||
return
|
return
|
||||||
if (m == null) [];
|
if (m == null) [];
|
||||||
else [for (meta in m) if (meta.name == name) meta.params];
|
else [for (meta in m) if (meta.name == name) meta.params];
|
||||||
|
|
||||||
|
static public inline function toString(m:MetadataEntry) {
|
||||||
|
return printer.printMetadata(m);
|
||||||
|
}
|
||||||
}
|
}
|
10
tests/Misc.hx
Normal file
10
tests/Misc.hx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import tink.MacroApi;
|
||||||
|
import haxe.unit.TestCase;
|
||||||
|
|
||||||
|
using tink.CoreApi;
|
||||||
|
|
||||||
|
class Misc extends TestCase {
|
||||||
|
function testMain() {
|
||||||
|
assertEquals('Run', MacroApi.getMainClass().force());
|
||||||
|
}
|
||||||
|
}
|
@@ -12,6 +12,7 @@ class Run {
|
|||||||
new Types(),
|
new Types(),
|
||||||
new Positions(),
|
new Positions(),
|
||||||
new TypeMapTest(),
|
new TypeMapTest(),
|
||||||
|
new Misc(),
|
||||||
];
|
];
|
||||||
#end
|
#end
|
||||||
macro static function test() {
|
macro static function test() {
|
||||||
|
Reference in New Issue
Block a user