Compare commits
19 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
08249260f9 | ||
![]() |
e24941880a | ||
![]() |
bdf78197db | ||
![]() |
635e64ebf1 | ||
![]() |
990096cfd5 | ||
![]() |
1df0dd6d6c | ||
![]() |
6b8be33832 | ||
![]() |
8b769e5938 | ||
![]() |
0ca2e371d4 | ||
![]() |
472916f2af | ||
![]() |
2471637905 | ||
![]() |
c400f5af51 | ||
![]() |
32d711cd71 | ||
![]() |
0947d1b916 | ||
![]() |
aa186a1ec2 | ||
![]() |
40d7c2fbde | ||
![]() |
f1010a518f | ||
![]() |
54f592f14c | ||
![]() |
e01bf6912a |
95
.github/workflows/ci.yml
vendored
Normal file
95
.github/workflows/ci.yml
vendored
Normal file
@@ -0,0 +1,95 @@
|
||||
name: CI
|
||||
|
||||
on:
|
||||
push:
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
haxe-version:
|
||||
- stable
|
||||
- nightly
|
||||
target:
|
||||
- node
|
||||
|
||||
steps:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- name: Cache Yarn
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Cache Haxe
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/haxe
|
||||
key: haxe
|
||||
|
||||
- name: Install Lix
|
||||
uses: lix-pm/setup-lix@master
|
||||
|
||||
- name: Install Haxe
|
||||
run: lix install haxe ${{ matrix.haxe-version }}
|
||||
|
||||
- name: Install Haxe Libraries
|
||||
run: lix download
|
||||
|
||||
- name: Run Test
|
||||
run: lix run travix ${{ matrix.target }}
|
||||
|
||||
release:
|
||||
runs-on: ubuntu-latest
|
||||
needs: test
|
||||
if: startsWith(github.ref, 'refs/tags/') # consider using the "release" event. see: https://docs.github.com/en/actions/reference/events-that-trigger-workflows#release
|
||||
|
||||
steps:
|
||||
- name: Check out repo
|
||||
uses: actions/checkout@v2
|
||||
|
||||
- name: Get yarn cache directory path
|
||||
id: yarn-cache-dir-path
|
||||
run: echo "::set-output name=dir::$(yarn cache dir)"
|
||||
|
||||
- name: Cache Yarn
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
|
||||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-yarn-
|
||||
|
||||
- name: Cache Haxe
|
||||
uses: actions/cache@v1
|
||||
with:
|
||||
path: ~/haxe
|
||||
key: haxe
|
||||
|
||||
- name: Install Lix
|
||||
uses: lix-pm/setup-lix@master
|
||||
|
||||
- name: Install Haxe
|
||||
run: lix install haxe stable
|
||||
|
||||
- name: Install Haxe Libraries
|
||||
run: lix download
|
||||
|
||||
- name: Release to Haxelib
|
||||
run: lix run travix release
|
||||
env:
|
||||
HAXELIB_AUTH: ${{ secrets.HAXELIB_AUTH }}
|
||||
|
2
.haxerc
2
.haxerc
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"version": "4.0.5",
|
||||
"version": "4.2.1",
|
||||
"resolveLibs": "scoped"
|
||||
}
|
17
.vscode/tasks.json
vendored
17
.vscode/tasks.json
vendored
@@ -1,6 +1,19 @@
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"version": "2.0.0",
|
||||
"command": "haxelib",
|
||||
"args": ["run", "travix", "node"],
|
||||
"problemMatcher": "$haxe"
|
||||
"problemMatcher": "$haxe",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "haxelib",
|
||||
"command": "haxelib",
|
||||
"args": [
|
||||
"run",
|
||||
"travix",
|
||||
"node"
|
||||
],
|
||||
"problemMatcher": "$haxe",
|
||||
"group": "build"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
@@ -1,7 +1,9 @@
|
||||
# Tinkerbell Macro Library
|
||||
|
||||
[](https://travis-ci.org/haxetink/tink_macro)
|
||||
[](https://gitter.im/haxetink/public)
|
||||
[](https://github.com/haxetink/tink_macro/actions)
|
||||
[](https://gitter.im/haxetink/public)
|
||||
[](https://discord.com/channels/162395145352904705/579634919576436736)
|
||||
|
||||
|
||||
Explained in current marketing speak, `tink_macro` is *the* macro toolkit ;)
|
||||
|
||||
|
3
haxe_libraries/tink_chunk.hxml
Normal file
3
haxe_libraries/tink_chunk.hxml
Normal file
@@ -0,0 +1,3 @@
|
||||
# @install: lix --silent download "gh://github.com/haxetink/tink_chunk#f095072a029f1f50ce5f2cc0a690c3e834298d96" into tink_chunk/0.3.1/github/f095072a029f1f50ce5f2cc0a690c3e834298d96
|
||||
-cp ${HAXE_LIBCACHE}/tink_chunk/0.3.1/github/f095072a029f1f50ce5f2cc0a690c3e834298d96/src
|
||||
-D tink_chunk=0.3.1
|
@@ -1,8 +1,8 @@
|
||||
-D tink_cli=0.3.1
|
||||
# @install: lix --silent download "haxelib:/tink_cli#0.3.1" into tink_cli/0.3.1/haxelib
|
||||
# @install: lix --silent download "gh://github.com/haxetink/tink_cli#1278ad2a34fd5e2403e414aefe09bb938d0c8825" into tink_cli/0.5.1/github/1278ad2a34fd5e2403e414aefe09bb938d0c8825
|
||||
-lib tink_io
|
||||
-lib tink_stringly
|
||||
-lib tink_macro
|
||||
-cp ${HAXE_LIBCACHE}/tink_cli/0.3.1/haxelib/src
|
||||
-lib tink_stringly
|
||||
-cp ${HAXE_LIBCACHE}/tink_cli/0.5.1/github/1278ad2a34fd5e2403e414aefe09bb938d0c8825/src
|
||||
-D tink_cli=0.5.1
|
||||
# Make sure docs are generated
|
||||
-D use-rtti-doc
|
@@ -1,3 +1,3 @@
|
||||
-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
|
||||
# @install: lix --silent download "haxelib:/tink_core#2.1.0" into tink_core/2.1.0/haxelib
|
||||
-cp ${HAXE_LIBCACHE}/tink_core/2.1.0/haxelib/src
|
||||
-D tink_core=2.1.0
|
@@ -1,5 +1,5 @@
|
||||
-D tink_io=0.5.0
|
||||
# @install: lix --silent download "haxelib:/tink_io#0.5.0" into tink_io/0.5.0/haxelib
|
||||
# @install: lix --silent download "gh://github.com/haxetink/tink_io#e4a92421865adfd7037474937cffacaa1abd4338" into tink_io/0.8.0/github/e4a92421865adfd7037474937cffacaa1abd4338
|
||||
-lib tink_chunk
|
||||
-lib tink_streams
|
||||
-lib tink_core
|
||||
-cp ${HAXE_LIBCACHE}/tink_io/0.5.0/haxelib/src
|
||||
-cp ${HAXE_LIBCACHE}/tink_io/0.8.0/github/e4a92421865adfd7037474937cffacaa1abd4338/src
|
||||
-D tink_io=0.8.0
|
@@ -1,4 +1,6 @@
|
||||
-D tink_streams=0.2.1
|
||||
# @install: lix --silent download "haxelib:/tink_streams#0.2.1" into tink_streams/0.2.1/haxelib
|
||||
# @install: lix --silent download "gh://github.com/haxetink/tink_streams#aa006c354e742164c4f7bc8ec4532bc9154fb0d0" into tink_streams/0.3.3/github/aa006c354e742164c4f7bc8ec4532bc9154fb0d0
|
||||
-lib tink_core
|
||||
-cp ${HAXE_LIBCACHE}/tink_streams/0.2.1/haxelib/src
|
||||
-cp ${HAXE_LIBCACHE}/tink_streams/0.3.3/github/aa006c354e742164c4f7bc8ec4532bc9154fb0d0/src
|
||||
-D tink_streams=0.3.3
|
||||
# temp for development, delete this file when pure branch merged
|
||||
-D pure
|
@@ -1,6 +1,7 @@
|
||||
-D travix=0.12.2
|
||||
# @install: lix --silent download "gh://github.com/back2dos/travix#7da3bf96717b52bf3c7e5d2273bf927a8cd7aeb5" into travix/0.12.2/github/7da3bf96717b52bf3c7e5d2273bf927a8cd7aeb5
|
||||
# @post-install: cd ${HAXE_LIBCACHE}/travix/0.12.2/github/7da3bf96717b52bf3c7e5d2273bf927a8cd7aeb5 && haxe -cp src --run travix.PostDownload
|
||||
# @run: haxelib run-dir travix ${HAXE_LIBCACHE}/travix/0.12.2/github/7da3bf96717b52bf3c7e5d2273bf927a8cd7aeb5
|
||||
# @install: lix --silent download "haxelib:/travix#0.15.3" into travix/0.15.3/haxelib
|
||||
# @post-install: cd ${HAXE_LIBCACHE}/travix/0.15.3/haxelib && haxe -cp src --run travix.PostDownload
|
||||
# @run: haxelib run-dir travix "${HAXE_LIBCACHE}/travix/0.15.3/haxelib"
|
||||
-lib tink_cli
|
||||
-cp ${HAXE_LIBCACHE}/travix/0.12.2/github/7da3bf96717b52bf3c7e5d2273bf927a8cd7aeb5/src
|
||||
-cp ${HAXE_LIBCACHE}/travix/0.15.3/haxelib/src
|
||||
-D travix=0.15.3
|
||||
--macro travix.Macro.setup()
|
@@ -9,8 +9,8 @@
|
||||
"contributors": [
|
||||
"back2dos"
|
||||
],
|
||||
"version": "0.23.0",
|
||||
"releasenote": "Make TypeMap work exacly with anons.",
|
||||
"version": "1.0.4",
|
||||
"releasenote": "Haxe 5 compat",
|
||||
"tags": [
|
||||
"tink",
|
||||
"macro",
|
||||
|
@@ -21,7 +21,7 @@ typedef TypeMap<T> = tink.macro.TypeMap<T>;
|
||||
|
||||
//TODO: consider adding stuff from haxe.macro.Expr here
|
||||
typedef MacroOutcome<D, F> = tink.core.Outcome<D, F>;
|
||||
typedef MacroOutcomeTools = tink.OutcomeTools;
|
||||
typedef MacroOutcomeTools = tink.core.Outcome.OutcomeTools;
|
||||
|
||||
typedef Member = tink.macro.Member;
|
||||
typedef Constructor = tink.macro.Constructor;
|
||||
@@ -33,6 +33,12 @@ class MacroApi {
|
||||
|
||||
static var MAIN_CANDIDATES = ['-main', '-x', '--run'];
|
||||
static public function getMainClass():Option<String> {
|
||||
#if (haxe_ver >= 4.3)
|
||||
return switch haxe.macro.Compiler.getConfiguration().mainClass {
|
||||
case null: None;
|
||||
case p: Some(p.pack.concat([p.name]).join('.'));
|
||||
}
|
||||
#else
|
||||
var args = Sys.args();
|
||||
|
||||
for (c in MAIN_CANDIDATES)
|
||||
@@ -42,6 +48,7 @@ class MacroApi {
|
||||
}
|
||||
|
||||
return None;
|
||||
#end
|
||||
}
|
||||
|
||||
@:persistent static var idCounter = 0;
|
||||
|
@@ -44,6 +44,7 @@ package tink.macro;
|
||||
else
|
||||
Context.currentPos().error('unknown id ' + id);
|
||||
}
|
||||
static public var lastEvaled(default, null):Dynamic;
|
||||
#else
|
||||
@:noUsing static public function makeOuter<A>(a:A):Bouncer
|
||||
return null;
|
||||
@@ -55,6 +56,11 @@ package tink.macro;
|
||||
default: ethis.reject();
|
||||
}
|
||||
|
||||
@:noUsing static public macro function eval(f:Void->Dynamic) {
|
||||
lastEvaled = f();
|
||||
return macro null;
|
||||
}
|
||||
|
||||
@:noUsing macro static public function catchBounce(id:Int)
|
||||
return doBounce(id);
|
||||
|
||||
|
@@ -48,6 +48,11 @@ class Exprs {
|
||||
static public inline function as(e:Expr, c:ComplexType)
|
||||
return ECheckType(e, c).at(e.pos);
|
||||
|
||||
static public function eval(e:Expr):Dynamic {
|
||||
Context.typeof(macro tink.macro.Bouncer.eval(function () return $e));
|
||||
return Bouncer.lastEvaled;
|
||||
}
|
||||
|
||||
static public function finalize(e:Expr, ?nuPos:Position, ?rules:Dict<String>, ?skipFields = false, ?callPos:PosInfos) {
|
||||
if (nuPos == null)
|
||||
nuPos = Context.currentPos();
|
||||
@@ -352,7 +357,7 @@ class Exprs {
|
||||
expr = [EVars(locals).at(expr.pos), expr].toMBlock(expr.pos);
|
||||
Success(Context.typeof(expr));
|
||||
}
|
||||
catch (e:haxe.macro.Error) {
|
||||
catch (e:haxe.macro.Expr.Error) {
|
||||
e.pos.makeFailure(e.message);
|
||||
}
|
||||
catch (e:Dynamic) {
|
||||
|
@@ -99,6 +99,15 @@ abstract Member(Field) from Field to Field {
|
||||
if (this.meta == null) [];
|
||||
else [for (tag in this.meta) if (tag.name == name) tag];
|
||||
|
||||
public function hasMeta(name)
|
||||
return switch this.meta {
|
||||
case null | []: false;
|
||||
case meta:
|
||||
for (m in meta)
|
||||
if (m.name == name) return true;
|
||||
false;
|
||||
}
|
||||
|
||||
public inline function asField():Field return this;
|
||||
public function publish()
|
||||
if (this.access == null) this.access = [APublic];
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package tink.macro;
|
||||
|
||||
import haxe.macro.Context;
|
||||
import haxe.macro.Type;
|
||||
import haxe.ds.Option;
|
||||
using haxe.macro.Tools;
|
||||
@@ -31,6 +32,9 @@ class TypedExprs {
|
||||
return None;
|
||||
}
|
||||
|
||||
static public function eval(t:TypedExpr)
|
||||
return Exprs.eval(Context.storeTypedExpr(t));
|
||||
|
||||
static public function isThis(t:TypedExpr):Bool
|
||||
return switch t {
|
||||
case null: false;
|
||||
|
@@ -41,9 +41,10 @@ class Types {
|
||||
static public function accessToName(v:VarAccess, ?read = true)
|
||||
return
|
||||
switch (v) {
|
||||
case AccNormal, AccInline: 'default';
|
||||
case AccNormal: 'default';
|
||||
case AccInline: if (read) 'default' else 'never';
|
||||
case AccNo: 'null';
|
||||
case AccNever: 'never';
|
||||
case AccNever #if haxe4 | AccCtor #end: 'never';
|
||||
case AccCall: if (read) 'get' else 'set';
|
||||
default:
|
||||
throw 'not implemented';
|
||||
@@ -213,7 +214,7 @@ class Types {
|
||||
static public function deduceCommonType(types:Array<Type>):Outcome<Type, Error> {
|
||||
var exprs = types.map(function(t) {
|
||||
var ct = t.toComplex();
|
||||
return macro (null:$ct);
|
||||
return macro (cast null:$ct);
|
||||
});
|
||||
|
||||
return switch (macro $a{exprs}).typeof() {
|
||||
|
@@ -29,6 +29,8 @@ abstract PhysicalType<T>(Either<Class<T>, Enum<T>>) {
|
||||
}
|
||||
//TODO: this helper should go somewhere
|
||||
class Base extends TestCase {
|
||||
function stringCompare<A>(v1:A, v2:A, ?pos)
|
||||
assertEquals(Std.string(v1), Std.string(v2), pos);
|
||||
|
||||
function fail(msg:String, ?c : PosInfos) {
|
||||
currentTest.done = true;
|
||||
|
@@ -16,6 +16,15 @@ class Exprs extends Base {
|
||||
assertTrue(id.length <= 3);
|
||||
}
|
||||
}
|
||||
|
||||
function testEval() {
|
||||
var expr = macro (untyped {foo:[{bar:234},'bar']});
|
||||
var str = Std.string(untyped {foo:[{bar:234},'bar']});
|
||||
assertEquals(Std.string(expr.eval()), Std.string(untyped {foo:[{bar:234},'bar']}));
|
||||
|
||||
// This doesn't work in Haxe 4.3, which is correct, because typeExpr types an expression into target context, rather than macro context
|
||||
// assertEquals(Std.string(Context.typeExpr(expr).eval()), Std.string(untyped {foo:[{bar:234},'bar']}));
|
||||
}
|
||||
function testGet() {
|
||||
assertEquals('foo', (macro foo).getIdent().sure());
|
||||
assertEquals('foo', (macro "foo").getString().sure());
|
||||
|
@@ -6,8 +6,6 @@ import haxe.macro.Expr;
|
||||
using tink.MacroApi;
|
||||
|
||||
class Positions extends Base {
|
||||
function stringCompare<A>(v1:A, v2:A)
|
||||
assertEquals(Std.string(v1), Std.string(v2));
|
||||
|
||||
function testSanitize() {
|
||||
var p:Position = null;
|
||||
@@ -19,6 +17,6 @@ class Positions extends Base {
|
||||
function testBlank() {
|
||||
var p:Position = null;
|
||||
var t = p.makeBlankType();
|
||||
stringCompare('TMono(<mono>)', cast t.toType().sure());
|
||||
stringCompare('TMono(<mono>)', cast t.toType().sure().reduce());
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user