pass kissFile and className to conditional compiler macros
This commit is contained in:
@@ -47,6 +47,7 @@ class AsyncEmbeddedScript {
|
||||
// trace('AsyncEmbeddedScript.build $dslHaxelib $dslFile $scriptFile');
|
||||
var k = Kiss.defaultKissState();
|
||||
|
||||
k.file = scriptFile;
|
||||
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
||||
var loadingDirectory = Path.directory(classPath);
|
||||
var classFields = []; // Kiss.build() will already include Context.getBuildFields()
|
||||
|
@@ -50,6 +50,7 @@ class EmbeddedScript {
|
||||
#if macro
|
||||
public static function build(dslFile:String, scriptFile:String):Array<Field> {
|
||||
var k = Kiss.defaultKissState();
|
||||
k.file = scriptFile;
|
||||
|
||||
var classPath = Context.getPosInfos(Context.currentPos()).file;
|
||||
var loadingDirectory = Path.directory(classPath);
|
||||
|
@@ -24,6 +24,7 @@ typedef ExprConversion = (ReaderExp) -> Expr;
|
||||
|
||||
typedef KissState = {
|
||||
className:String,
|
||||
file:String,
|
||||
readTable:ReadTable,
|
||||
startOfLineReadTable:ReadTable,
|
||||
fieldForms:Map<String, FieldFormFunction>,
|
||||
@@ -51,6 +52,7 @@ class Kiss {
|
||||
|
||||
var k = {
|
||||
className: className,
|
||||
file: "",
|
||||
readTable: Reader.builtins(),
|
||||
startOfLineReadTable: new ReadTable(),
|
||||
fieldForms: FieldForms.builtins(),
|
||||
@@ -215,6 +217,8 @@ class Kiss {
|
||||
} else {
|
||||
Path.join([loadingDirectory, kissFile]);
|
||||
};
|
||||
var previousFile = k.file;
|
||||
k.file = fullPath;
|
||||
|
||||
if (k.loadedFiles.exists(fullPath)) {
|
||||
return k.loadedFiles[fullPath];
|
||||
@@ -268,6 +272,7 @@ class Kiss {
|
||||
null;
|
||||
}
|
||||
k.loadedFiles[fullPath] = exp;
|
||||
k.file = previousFile;
|
||||
return exp;
|
||||
}
|
||||
|
||||
|
@@ -121,6 +121,8 @@ class Macros {
|
||||
};
|
||||
|
||||
function prepareForConditional(i:KissInterp, k:KissState) {
|
||||
i.variables.set("kissFile", k.file);
|
||||
i.variables.set("className", k.className);
|
||||
for (flag => value in Context.getDefines()) {
|
||||
// Don't overwrite types that are put in all KissInterps, i.e. the kiss namespace
|
||||
if (!i.variables.exists(flag)) {
|
||||
|
Reference in New Issue
Block a user