make kiss implement write output to a log
This commit is contained in:
@@ -792,6 +792,13 @@ class Macros {
|
|||||||
// Maybe the NEW wildest code in Kiss?
|
// Maybe the NEW wildest code in Kiss?
|
||||||
macros["#extern"] = (wholeExp:ReaderExp, exps:Array<ReaderExp>, k:KissState) -> {
|
macros["#extern"] = (wholeExp:ReaderExp, exps:Array<ReaderExp>, k:KissState) -> {
|
||||||
wholeExp.checkNumArgs(4, null, "(#extern <BodyType> <lang> <?compileArgs object> [<typed bindings...>] <body...>)");
|
wholeExp.checkNumArgs(4, null, "(#extern <BodyType> <lang> <?compileArgs object> [<typed bindings...>] <body...>)");
|
||||||
|
var b = wholeExp.expBuilder();
|
||||||
|
|
||||||
|
// Skip all extern code generation if -D null-extern is provided to the compiler
|
||||||
|
if (Context.defined("null-extern")) {
|
||||||
|
return b.symbol("null");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var bodyType = exps.shift();
|
var bodyType = exps.shift();
|
||||||
var langExp = exps.shift();
|
var langExp = exps.shift();
|
||||||
@@ -834,9 +841,6 @@ class Macros {
|
|||||||
{};
|
{};
|
||||||
}
|
}
|
||||||
|
|
||||||
var b = wholeExp.expBuilder();
|
|
||||||
|
|
||||||
// TODO generate tink_json writers and parsers for this
|
|
||||||
var bindingList = bindingListExp.bindingList("#extern", true);
|
var bindingList = bindingListExp.bindingList("#extern", true);
|
||||||
|
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
|
@@ -37,7 +37,7 @@ class Main {
|
|||||||
// kiss implement [type] [fromLib]
|
// kiss implement [type] [fromLib]
|
||||||
var _pwd = args.pop();
|
var _pwd = args.pop();
|
||||||
var theInterface = args.shift();
|
var theInterface = args.shift();
|
||||||
var pArgs = ["build-scripts/common-args.hxml", "-lib", "kiss"];
|
var pArgs = ["-D", "null-extern", "build-scripts/common-args.hxml", "-lib", "kiss"];
|
||||||
// pass --lib and the lib containing the interface as specified
|
// pass --lib and the lib containing the interface as specified
|
||||||
if (args.length > 0) {
|
if (args.length > 0) {
|
||||||
pArgs = pArgs.concat(["-lib", args.shift()]);
|
pArgs = pArgs.concat(["-lib", args.shift()]);
|
||||||
@@ -175,10 +175,29 @@ class Main {
|
|||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// edge cases for this:
|
||||||
|
// TODO interfaces that extend other interfaces
|
||||||
|
// TODO generic interfaces
|
||||||
|
// TODO this could be useful for typedefs as well
|
||||||
|
// TODO merging a generated implementation with a Kiss file that already has some functions implemented
|
||||||
static function implement(theInterface:String) {
|
static function implement(theInterface:String) {
|
||||||
|
// This runs in a subprocess whose stdout output can only be read all at once,
|
||||||
|
// so re-implement trace to write to a file:
|
||||||
|
haxe.Log.trace = (v, ?infos) -> {
|
||||||
|
File.saveContent("implementLog.txt", "");
|
||||||
|
File.saveContent("implementLog.txt", File.getContent("implementLog.txt") + "\n" + Std.string(v));
|
||||||
|
v;
|
||||||
|
}
|
||||||
#if macro
|
#if macro
|
||||||
var type = Context.resolveType(Helpers.parseComplexType(theInterface), Context.currentPos());
|
var type = Context.resolveType(Helpers.parseComplexType(theInterface), Context.currentPos());
|
||||||
trace(type);
|
switch (type) {
|
||||||
|
case TInst(classTypeRef, params):
|
||||||
|
var classType = classTypeRef.get();
|
||||||
|
var fields = classType.fields.get();
|
||||||
|
trace(fields);
|
||||||
|
default:
|
||||||
|
throw 'Unexpected result from resolveType of $theInterface';
|
||||||
|
}
|
||||||
#end
|
#end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user