Compare commits

..

11 Commits

Author SHA1 Message Date
Juraj Kirchheim
a77aedb458 Partial workaround for https://github.com/benmerckx/genes/issues/6 2020-01-02 19:44:41 +01:00
Juraj Kirchheim
b4fa5f4fe0 Update lix version to download correct nightly. 2019-09-13 09:45:24 +02:00
Juraj Kirchheim
e59fab499d Release 0.18.0 2019-09-13 09:40:22 +02:00
Juraj Kirchheim
3356172b7f Update to newest haxe version. 2019-09-13 09:39:24 +02:00
Juraj Kirchheim
4fd03ed667 Release 0.17.7 2019-06-29 11:27:39 +02:00
Juraj Kirchheim
4cb5ee4196 Use @:persistent as necessary. 2019-06-22 15:16:04 +02:00
Kevin Leung
888481094a Pin lix version 2019-05-14 11:33:28 +08:00
Kevin Leung
7686fe3e35 Use xenial 2019-05-14 11:10:52 +08:00
Kevin Leung
747d07bfc5 Revert "Better type comparison (closes #25)"
This reverts commit 00640d8328.
2019-05-13 18:53:42 +08:00
Kevin Leung
00640d8328 Better type comparison (closes #25) 2019-05-13 17:01:54 +08:00
Kevin Leung
77973f6007 print metadata 2019-05-13 17:00:54 +08:00
11 changed files with 89 additions and 58 deletions

View File

@@ -1,4 +1,4 @@
{
"version": "4.0.0-rc.1",
"version": "e552bdc",
"resolveLibs": "scoped"
}

View File

@@ -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.5.4
- lix install haxe $HAXE_VERSION
- lix download

View File

@@ -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.16.1
-cp ${HAXESHIM_LIBCACHE}/tink_core/1.16.1/haxelib/src
-D tink_core=1.24.0
# @install: lix --silent download "haxelib:/tink_core#1.24.0" into tink_core/1.24.0/haxelib
-cp ${HAXE_LIBCACHE}/tink_core/1.24.0/haxelib/src

View File

@@ -1,20 +1,20 @@
{
"name": "tink_macro",
"description": "The macro toolkit ;)",
"classPath": "src",
"dependencies": {
"tink_core": ""
},
"url": "http://haxetink.org/tink_macro",
"contributors": [
"back2dos"
],
"version": "0.17.6",
"releasenote": "Add call to find main class.",
"license": "MIT",
"tags": [
"tink",
"macro",
"utility"
],
"license": "MIT"
"classPath": "src",
"description": "The macro toolkit ;)",
"contributors": [
"back2dos"
],
"releasenote": "Compat with haxe 4 rc4 onward.",
"version": "0.18.0",
"url": "http://haxetink.org/tink_macro",
"dependencies": {
"tink_core": ""
}
}

View File

@@ -42,7 +42,7 @@ class MacroApi {
return None;
}
static var idCounter = 0;
@:persistent static var idCounter = 0;
@:noUsing static public inline function tempName(?prefix:String = 'tmp'):String
return '__tink_' + prefix + Std.string(idCounter++);

View File

@@ -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)

View File

@@ -21,7 +21,7 @@ class Constructor {
var afterArgs:Array<FunctionArg>;
var pos:Position;
var onGenerateHooks:Array<Function->Void>;
var superCall:Expr;
var superCall:Array<Expr>;
var owner:ClassBuilder;
var meta:Metadata;
public var isPublic:Null<Bool>;
@@ -57,12 +57,17 @@ class Constructor {
default: oldStatements = [f.expr];
}
}
superCall =
if (oldStatements.length == 0) [].toBlock();
else switch oldStatements[0] {
case macro super($a{_}): oldStatements.shift();
default: [].toBlock();
for (i in 0...oldStatements.length)
switch oldStatements[i] {
case macro super($a{_}):
superCall = oldStatements.splice(0, i + 1);
break;
default:
}
if (superCall == null)
superCall = [];
}
public function getArgList():Array<FunctionArg>
@@ -148,7 +153,7 @@ class Constructor {
isPublic = true;
function toBlock()
return [superCall]
return superCall
.concat(nuStatements)
.concat(oldStatements)
.toBlock(pos);

View File

@@ -4,9 +4,18 @@ import haxe.macro.Expr;
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 {
static public inline function asExpr(f:Function, ?name, ?pos)
return EFunction(name, f).at(pos);
static public inline function asExpr(f:Function, ?kind:Kind, ?pos)
return EFunction(kind, f).at(pos);
static public inline function toArg(name:String, ?t, ?opt = false, ?value = null):FunctionArg {
return {

View File

@@ -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);
}
}

11
tests/Functions.hx Normal file
View 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);
}
}

View File

@@ -12,6 +12,7 @@ class Run {
new Types(),
new Positions(),
new TypeMapTest(),
new Functions(),
new Misc(),
];
#end