Compare commits
13 Commits
0.17.5
...
genes-issu
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a77aedb458 | ||
|
|
b4fa5f4fe0 | ||
|
|
e59fab499d | ||
|
|
3356172b7f | ||
|
|
4fd03ed667 | ||
|
|
4cb5ee4196 | ||
|
|
888481094a | ||
|
|
7686fe3e35 | ||
|
|
747d07bfc5 | ||
|
|
00640d8328 | ||
|
|
77973f6007 | ||
|
|
0df9c28ace | ||
|
|
d90fb966d2 |
2
.haxerc
2
.haxerc
@@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"version": "4.0.0-rc.1",
|
"version": "e552bdc",
|
||||||
"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.5.4
|
||||||
- lix install haxe $HAXE_VERSION
|
- lix install haxe $HAXE_VERSION
|
||||||
- lix download
|
- lix download
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,3 @@
|
|||||||
# @install: lix --silent download "haxelib:tink_core#1.16.1" into tink_core/1.16.1/haxelib
|
-D tink_core=1.24.0
|
||||||
-D tink_core=1.16.1
|
# @install: lix --silent download "haxelib:/tink_core#1.24.0" into tink_core/1.24.0/haxelib
|
||||||
-cp ${HAXESHIM_LIBCACHE}/tink_core/1.16.1/haxelib/src
|
-cp ${HAXE_LIBCACHE}/tink_core/1.24.0/haxelib/src
|
||||||
|
|||||||
@@ -11,8 +11,8 @@
|
|||||||
"contributors": [
|
"contributors": [
|
||||||
"back2dos"
|
"back2dos"
|
||||||
],
|
],
|
||||||
"releasenote": "Various fixes",
|
"releasenote": "Compat with haxe 4 rc4 onward.",
|
||||||
"version": "0.17.5",
|
"version": "0.18.0",
|
||||||
"url": "http://haxetink.org/tink_macro",
|
"url": "http://haxetink.org/tink_macro",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"tink_core": ""
|
"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)
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Constructor {
|
|||||||
var afterArgs:Array<FunctionArg>;
|
var afterArgs:Array<FunctionArg>;
|
||||||
var pos:Position;
|
var pos:Position;
|
||||||
var onGenerateHooks:Array<Function->Void>;
|
var onGenerateHooks:Array<Function->Void>;
|
||||||
var superCall:Expr;
|
var superCall:Array<Expr>;
|
||||||
var owner:ClassBuilder;
|
var owner:ClassBuilder;
|
||||||
var meta:Metadata;
|
var meta:Metadata;
|
||||||
public var isPublic:Null<Bool>;
|
public var isPublic:Null<Bool>;
|
||||||
@@ -57,12 +57,17 @@ class Constructor {
|
|||||||
default: oldStatements = [f.expr];
|
default: oldStatements = [f.expr];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
superCall =
|
|
||||||
if (oldStatements.length == 0) [].toBlock();
|
for (i in 0...oldStatements.length)
|
||||||
else switch oldStatements[0] {
|
switch oldStatements[i] {
|
||||||
case macro super($a{_}): oldStatements.shift();
|
case macro super($a{_}):
|
||||||
default: [].toBlock();
|
superCall = oldStatements.splice(0, i + 1);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (superCall == null)
|
||||||
|
superCall = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getArgList():Array<FunctionArg>
|
public function getArgList():Array<FunctionArg>
|
||||||
@@ -148,7 +153,7 @@ class Constructor {
|
|||||||
isPublic = true;
|
isPublic = true;
|
||||||
|
|
||||||
function toBlock()
|
function toBlock()
|
||||||
return [superCall]
|
return superCall
|
||||||
.concat(nuStatements)
|
.concat(nuStatements)
|
||||||
.concat(oldStatements)
|
.concat(oldStatements)
|
||||||
.toBlock(pos);
|
.toBlock(pos);
|
||||||
|
|||||||
@@ -4,9 +4,18 @@ import haxe.macro.Expr;
|
|||||||
|
|
||||||
using tink.macro.Exprs;
|
using tink.macro.Exprs;
|
||||||
|
|
||||||
|
#if haxe4
|
||||||
|
private abstract Kind(FunctionKind) from FunctionKind to FunctionKind {
|
||||||
|
@:from static function ofString(s:String):Kind
|
||||||
|
return FNamed(s);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
private typedef Kind = String;
|
||||||
|
#end
|
||||||
|
|
||||||
class Functions {
|
class Functions {
|
||||||
static public inline function asExpr(f:Function, ?name, ?pos)
|
static public inline function asExpr(f:Function, ?kind:Kind, ?pos)
|
||||||
return EFunction(name, f).at(pos);
|
return EFunction(kind, f).at(pos);
|
||||||
|
|
||||||
static public inline function toArg(name:String, ?t, ?opt = false, ?value = null):FunctionArg {
|
static public inline function toArg(name:String, ?t, ?opt = false, ?value = null):FunctionArg {
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
11
tests/Functions.hx
Normal file
11
tests/Functions.hx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import haxe.macro.Context;
|
||||||
|
import haxe.macro.Expr;
|
||||||
|
using tink.MacroApi;
|
||||||
|
|
||||||
|
class Functions extends Base {
|
||||||
|
function test() {
|
||||||
|
var f:Function = (macro function () {}).getFunction().sure();
|
||||||
|
f.asExpr('foo');
|
||||||
|
assertTrue(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
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,8 @@ class Run {
|
|||||||
new Types(),
|
new Types(),
|
||||||
new Positions(),
|
new Positions(),
|
||||||
new TypeMapTest(),
|
new TypeMapTest(),
|
||||||
|
new Functions(),
|
||||||
|
new Misc(),
|
||||||
];
|
];
|
||||||
#end
|
#end
|
||||||
macro static function test() {
|
macro static function test() {
|
||||||
|
|||||||
Reference in New Issue
Block a user