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"
|
||||
}
|
@@ -1,5 +1,5 @@
|
||||
sudo: required
|
||||
dist: trusty
|
||||
dist: xenial
|
||||
|
||||
stages:
|
||||
- test
|
||||
@@ -17,7 +17,7 @@ env:
|
||||
- HAXE_VERSION=edge
|
||||
|
||||
install:
|
||||
- npm i -g lix
|
||||
- npm i -g lix@15.3.13
|
||||
- lix install haxe $HAXE_VERSION
|
||||
- lix download
|
||||
|
||||
|
24
haxelib.json
24
haxelib.json
@@ -1,20 +1,20 @@
|
||||
{
|
||||
"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": [
|
||||
"tink",
|
||||
"macro",
|
||||
"utility"
|
||||
],
|
||||
"classPath": "src",
|
||||
"description": "The macro toolkit ;)",
|
||||
"contributors": [
|
||||
"back2dos"
|
||||
],
|
||||
"releasenote": "Various fixes",
|
||||
"version": "0.17.5",
|
||||
"url": "http://haxetink.org/tink_macro",
|
||||
"dependencies": {
|
||||
"tink_core": ""
|
||||
}
|
||||
"license": "MIT"
|
||||
}
|
@@ -29,7 +29,20 @@ typedef TypeResolution = Ref<Either<String, TypeDefinition>>;
|
||||
|
||||
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
|
||||
return '__tink_' + prefix + Std.string(idCounter++);
|
||||
|
@@ -33,7 +33,7 @@ typedef BuildContext3 = {>BuildContext2,
|
||||
|
||||
class BuildCache {
|
||||
|
||||
static var cache = new Map();
|
||||
@:persistent static var cache = new Map();
|
||||
|
||||
static public function getType3(name, ?types, ?pos:Position, build:BuildContext3->TypeDefinition) {
|
||||
if (types == null)
|
||||
|
@@ -3,6 +3,7 @@ package tink.macro;
|
||||
import haxe.macro.Expr;
|
||||
|
||||
class Metadatas {
|
||||
static var printer = new haxe.macro.Printer();
|
||||
static public function toMap(m:Metadata) {
|
||||
var ret = new Map<String,Array<Array<Expr>>>();
|
||||
if (m != null)
|
||||
@@ -18,4 +19,8 @@ class Metadatas {
|
||||
return
|
||||
if (m == null) [];
|
||||
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 Positions(),
|
||||
new TypeMapTest(),
|
||||
new Misc(),
|
||||
];
|
||||
#end
|
||||
macro static function test() {
|
||||
|
Reference in New Issue
Block a user