dts2hx
Version:
Converts TypeScript definition files (d.ts) to haxe externs
1,433 lines • 542 kB
JavaScript
(function ($hx_exports, $global) { "use strict";
var $estr = function() { return js_Boot.__string_rec(this,''); },$hxEnums = $hxEnums || {},$_;
function $extend(from, fields) {
var proto = Object.create(from);
for (var name in fields) proto[name] = fields[name];
if( fields.toString !== Object.prototype.toString ) proto.toString = fields.toString;
return proto;
}
var js_node_ChildProcess = require("child_process");
var Std = function() { };
Std.__name__ = true;
Std.string = function(s) {
return js_Boot.__string_rec(s,"");
};
Std.parseInt = function(x) {
if(x != null) {
var _g = 0;
var _g1 = x.length;
while(_g < _g1) {
var i = _g++;
var c = x.charCodeAt(i);
if(c <= 8 || c >= 14 && c != 32 && c != 45) {
var nc = x.charCodeAt(i + 1);
var v = parseInt(x,nc == 120 || nc == 88 ? 16 : 10);
if(isNaN(v)) {
return null;
} else {
return v;
}
}
}
}
return null;
};
var Sys = function() { };
Sys.__name__ = true;
Sys.environment = function() {
var m = new haxe_ds_StringMap();
var _g = 0;
var _g1 = Reflect.fields(process.env);
while(_g < _g1.length) {
var key = _g1[_g];
++_g;
var v = process.env[key];
m.h[key] = v;
}
return m;
};
Sys.systemName = function() {
var _g = process.platform;
switch(_g) {
case "darwin":
return "Mac";
case "freebsd":
return "BSD";
case "linux":
return "Linux";
case "win32":
return "Windows";
default:
var other = _g;
return other;
}
};
var Reflect = function() { };
Reflect.__name__ = true;
Reflect.field = function(o,field) {
try {
return o[field];
} catch( _g ) {
return null;
}
};
Reflect.fields = function(o) {
var a = [];
if(o != null) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
for( var f in o ) {
if(f != "__id__" && f != "hx__closures__" && hasOwnProperty.call(o,f)) {
a.push(f);
}
}
}
return a;
};
var EReg = function(r,opt) {
this.r = new RegExp(r,opt.split("u").join(""));
};
EReg.__name__ = true;
EReg.prototype = {
match: function(s) {
if(this.r.global) {
this.r.lastIndex = 0;
}
this.r.m = this.r.exec(s);
this.r.s = s;
return this.r.m != null;
}
,matched: function(n) {
if(this.r.m != null && n >= 0 && n < this.r.m.length) {
return this.r.m[n];
} else {
throw haxe_Exception.thrown("EReg::matched");
}
}
,matchedLeft: function() {
if(this.r.m == null) {
throw haxe_Exception.thrown("No string matched");
}
return HxOverrides.substr(this.r.s,0,this.r.m.index);
}
,matchedRight: function() {
if(this.r.m == null) {
throw haxe_Exception.thrown("No string matched");
}
var sz = this.r.m.index + this.r.m[0].length;
return HxOverrides.substr(this.r.s,sz,this.r.s.length - sz);
}
,matchedPos: function() {
if(this.r.m == null) {
throw haxe_Exception.thrown("No string matched");
}
return { pos : this.r.m.index, len : this.r.m[0].length};
}
,matchSub: function(s,pos,len) {
if(len == null) {
len = -1;
}
if(this.r.global) {
this.r.lastIndex = pos;
this.r.m = this.r.exec(len < 0 ? s : HxOverrides.substr(s,0,pos + len));
var b = this.r.m != null;
if(b) {
this.r.s = s;
}
return b;
} else {
var b = this.match(len < 0 ? HxOverrides.substr(s,pos,null) : HxOverrides.substr(s,pos,len));
if(b) {
this.r.s = s;
this.r.m.index += pos;
}
return b;
}
}
,map: function(s,f) {
var offset = 0;
var buf_b = "";
while(true) {
if(offset >= s.length) {
break;
} else if(!this.matchSub(s,offset)) {
buf_b += Std.string(HxOverrides.substr(s,offset,null));
break;
}
var p = this.matchedPos();
buf_b += Std.string(HxOverrides.substr(s,offset,p.pos - offset));
buf_b += Std.string(f(this));
if(p.len == 0) {
buf_b += Std.string(HxOverrides.substr(s,p.pos,1));
offset = p.pos + 1;
} else {
offset = p.pos + p.len;
}
if(!this.r.global) {
break;
}
}
if(!this.r.global && offset > 0 && offset < s.length) {
buf_b += Std.string(HxOverrides.substr(s,offset,null));
}
return buf_b;
}
};
var Console = function() { };
Console.__name__ = true;
Console.format = function(s,formatMode) {
s += "<//>";
var activeFormatFlagStack = [];
var groupedProceedingTags = [];
var browserFormatArguments = [];
var result = Console.formatTagPattern.map(s,function(e) {
var escaped = e.matched(1) != null;
if(escaped) {
return e.matched(0);
}
var open = e.matched(2) == null;
var tags = e.matched(3).split(",");
if(!open && tags.length == 1) {
if(tags[0] == "") {
var last = activeFormatFlagStack[activeFormatFlagStack.length - 1];
var i = activeFormatFlagStack.indexOf(last);
if(i != -1) {
var proceedingTags = groupedProceedingTags[i];
activeFormatFlagStack.splice(i - proceedingTags,proceedingTags + 1);
groupedProceedingTags.splice(i - proceedingTags,proceedingTags + 1);
}
} else if(FormatFlag.fromString(tags[0]) == "reset") {
activeFormatFlagStack = [];
groupedProceedingTags = [];
} else {
var flag = FormatFlag.fromString(tags[0]);
if(flag != null) {
var i = activeFormatFlagStack.indexOf(flag);
if(i != -1) {
var proceedingTags = groupedProceedingTags[i];
activeFormatFlagStack.splice(i - proceedingTags,proceedingTags + 1);
groupedProceedingTags.splice(i - proceedingTags,proceedingTags + 1);
}
}
}
} else {
var proceedingTags = 0;
var _g = 0;
while(_g < tags.length) {
var tag = tags[_g];
++_g;
var flag = FormatFlag.fromString(tag);
if(flag == null) {
return e.matched(0);
}
if(open) {
activeFormatFlagStack.push(flag);
groupedProceedingTags.push(proceedingTags);
++proceedingTags;
} else {
var i = activeFormatFlagStack.indexOf(flag);
if(i != -1) {
var proceedingTags1 = groupedProceedingTags[i];
activeFormatFlagStack.splice(i - proceedingTags1,proceedingTags1 + 1);
groupedProceedingTags.splice(i - proceedingTags1,proceedingTags1 + 1);
}
}
}
}
switch(formatMode) {
case 0:
if(open) {
if(activeFormatFlagStack.length > 0) {
var lastFlagCount = groupedProceedingTags[groupedProceedingTags.length - 1] + 1;
var asciiFormatString = "";
var _g = 0;
var _g1 = lastFlagCount;
while(_g < _g1) {
var i = _g++;
var idx = groupedProceedingTags.length - 1 - i;
asciiFormatString += Console.getAsciiFormat(activeFormatFlagStack[idx]);
}
return asciiFormatString;
} else {
return "";
}
} else {
var result = Console.getAsciiFormat("reset");
var result1 = new Array(activeFormatFlagStack.length);
var _g = 0;
var _g1 = activeFormatFlagStack.length;
while(_g < _g1) {
var i = _g++;
result1[i] = Console.getAsciiFormat(activeFormatFlagStack[i]);
}
var _g = [];
var _g1 = 0;
var _g2 = result1;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v != null) {
_g.push(v);
}
}
return result + _g.join("");
}
break;
case 1:
var browserFormatArguments1 = browserFormatArguments;
var result = new Array(activeFormatFlagStack.length);
var _g = 0;
var _g1 = activeFormatFlagStack.length;
while(_g < _g1) {
var i = _g++;
result[i] = Console.getBrowserFormat(activeFormatFlagStack[i]);
}
var _g = [];
var _g1 = 0;
var _g2 = result;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v != null) {
_g.push(v);
}
}
browserFormatArguments1.push(_g.join(";"));
return "%c";
case 2:
return "";
}
});
return { formatted : result, browserFormatArguments : browserFormatArguments};
};
Console.stripFormatting = function(s) {
return Console.format(s,2).formatted;
};
Console.printFormatted = function(s,outputStream) {
if(outputStream == null) {
outputStream = 0;
}
if(s == null) {
s = "";
}
var result = Console.format(s,Console.formatMode);
if(Console.formatMode == 1) {
var logArgs = [result.formatted].concat(result.browserFormatArguments);
switch(outputStream) {
case 1:
console.warn.apply(console, logArgs);
break;
case 2:
console.error.apply(console, logArgs);
break;
case 0:case 3:
console.log.apply(console, logArgs);
break;
}
return;
}
Console.print(result.formatted,outputStream);
};
Console.print = function(s,outputStream) {
if(outputStream == null) {
outputStream = 0;
}
if(s == null) {
s = "";
}
if(Console.printIntercept != null) {
var allowDefaultPrint = Console.printIntercept(s,outputStream);
if(!allowDefaultPrint) {
return;
}
}
if(Console.unicodeCompatibilityMode == 1 && !Console.unicodeCompatibilityEnabled) {
Console.exec("chcp 65001");
Console.unicodeCompatibilityEnabled = true;
}
switch(outputStream) {
case 1:case 2:
new _$Sys_FileOutput(2).writeString(s);
break;
case 0:case 3:
new _$Sys_FileOutput(1).writeString(s);
break;
}
};
Console.getAsciiFormat = function(flag) {
if(flag.charAt(0) == "#") {
var hex = HxOverrides.substr(flag,1,null);
var r = Std.parseInt("0x" + HxOverrides.substr(hex,0,2));
var g = Std.parseInt("0x" + HxOverrides.substr(hex,2,2));
var b = Std.parseInt("0x" + HxOverrides.substr(hex,4,2));
return "\x1B[38;5;" + Console.rgbToAscii256(r,g,b) + "m";
}
if(HxOverrides.substr(flag,0,3) == "bg#") {
var hex = HxOverrides.substr(flag,3,null);
var r = Std.parseInt("0x" + HxOverrides.substr(hex,0,2));
var g = Std.parseInt("0x" + HxOverrides.substr(hex,2,2));
var b = Std.parseInt("0x" + HxOverrides.substr(hex,4,2));
return "\x1B[48;5;" + Console.rgbToAscii256(r,g,b) + "m";
}
switch(flag) {
case "bg_black":
return "\x1B[48;5;" + 0 + "m";
case "bg_blue":
return "\x1B[48;5;" + 4 + "m";
case "bg_cyan":
return "\x1B[48;5;" + 6 + "m";
case "bg_green":
return "\x1B[48;5;" + 2 + "m";
case "bg_light_black":
return "\x1B[48;5;" + 8 + "m";
case "bg_light_blue":
return "\x1B[48;5;" + 12 + "m";
case "bg_light_cyan":
return "\x1B[48;5;" + 14 + "m";
case "bg_light_green":
return "\x1B[48;5;" + 10 + "m";
case "bg_light_magenta":
return "\x1B[48;5;" + 13 + "m";
case "bg_light_red":
return "\x1B[48;5;" + 9 + "m";
case "bg_light_white":
return "\x1B[48;5;" + 15 + "m";
case "bg_light_yellow":
return "\x1B[48;5;" + 11 + "m";
case "bg_magenta":
return "\x1B[48;5;" + 5 + "m";
case "bg_red":
return "\x1B[48;5;" + 1 + "m";
case "bg_white":
return "\x1B[48;5;" + 7 + "m";
case "bg_yellow":
return "\x1B[48;5;" + 3 + "m";
case "black":
return "\x1B[38;5;" + 0 + "m";
case "blink":
return "\x1B[5m";
case "blue":
return "\x1B[38;5;" + 4 + "m";
case "bold":
return "\x1B[1m";
case "cyan":
return "\x1B[38;5;" + 6 + "m";
case "dim":
return "\x1B[2m";
case "green":
return "\x1B[38;5;" + 2 + "m";
case "hidden":
return "\x1B[8m";
case "invert":
return "\x1B[7m";
case "italic":
return "\x1B[3m";
case "light_black":
return "\x1B[38;5;" + 8 + "m";
case "light_blue":
return "\x1B[38;5;" + 12 + "m";
case "light_cyan":
return "\x1B[38;5;" + 14 + "m";
case "light_green":
return "\x1B[38;5;" + 10 + "m";
case "light_magenta":
return "\x1B[38;5;" + 13 + "m";
case "light_red":
return "\x1B[38;5;" + 9 + "m";
case "light_white":
return "\x1B[38;5;" + 15 + "m";
case "light_yellow":
return "\x1B[38;5;" + 11 + "m";
case "magenta":
return "\x1B[38;5;" + 5 + "m";
case "red":
return "\x1B[38;5;" + 1 + "m";
case "reset":
return "\x1B[m";
case "underline":
return "\x1B[4m";
case "white":
return "\x1B[38;5;" + 7 + "m";
case "yellow":
return "\x1B[38;5;" + 3 + "m";
default:
return "";
}
};
Console.rgbToAscii256 = function(r,g,b) {
var nearIdx = function(c,set) {
var delta = Infinity;
var index = -1;
var _g = 0;
var _g1 = set.length;
while(_g < _g1) {
var i = _g++;
var d = Math.abs(c - set[i]);
if(d < delta) {
delta = d;
index = i;
}
}
return index;
};
var colorSteps = [0,95,135,175,215,255];
var ir = nearIdx(r,colorSteps);
var ig = nearIdx(g,colorSteps);
var ib = nearIdx(b,colorSteps);
var ier = Math.abs(r - colorSteps[ir]);
var ieg = Math.abs(g - colorSteps[ig]);
var ieb = Math.abs(b - colorSteps[ib]);
var averageColorError = ier + ieg + ieb;
var jr = Math.round((r - 8) / 10);
var jg = Math.round((g - 8) / 10);
var jb = Math.round((b - 8) / 10);
var jer = Math.abs(r - Math.max(Math.min(jr * 10 + 8,238),8));
var jeg = Math.abs(g - Math.max(Math.min(jg * 10 + 8,238),8));
var jeb = Math.abs(b - Math.max(Math.min(jb * 10 + 8,238),8));
var averageGrayError = jer + jeg + jeb;
if(averageGrayError < averageColorError && r == g && g == b) {
var grayIndex = jr + 232;
return grayIndex;
} else {
var colorIndex = 16 + ir * 36 + ig * 6 + ib;
return colorIndex;
}
};
Console.getBrowserFormat = function(flag) {
if(flag.charAt(0) == "#") {
return "color: " + flag;
}
if(HxOverrides.substr(flag,0,3) == "bg#") {
return "background-color: " + HxOverrides.substr(flag,2,null);
}
if(flag.charAt(0) == "{") {
return HxOverrides.substr(flag,1,flag.length - 2);
}
switch(flag) {
case "bg_black":
return "background-color: black";
case "bg_blue":
return "background-color: blue";
case "bg_cyan":
return "background-color: cyan";
case "bg_green":
return "background-color: green";
case "bg_light_black":
return "background-color: gray";
case "bg_light_blue":
return "background-color: lightBlue";
case "bg_light_cyan":
return "background-color: lightCyan";
case "bg_light_green":
return "background-color: lightGreen";
case "bg_light_magenta":
return "background-color: lightPink";
case "bg_light_red":
return "background-color: salmon";
case "bg_light_white":
return "background-color: white";
case "bg_light_yellow":
return "background-color: lightYellow";
case "bg_magenta":
return "background-color: magenta";
case "bg_red":
return "background-color: red";
case "bg_white":
return "background-color: whiteSmoke";
case "bg_yellow":
return "background-color: gold";
case "black":
return "color: black";
case "blink":
return "text-decoration: blink";
case "blue":
return "color: blue";
case "bold":
return "font-weight: bold";
case "cyan":
return "color: cyan";
case "dim":
return "color: gray";
case "green":
return "color: green";
case "hidden":
return "visibility: hidden; color: white";
case "invert":
return "-webkit-filter: invert(100%); filter: invert(100%)";
case "italic":
return "font-style: italic";
case "light_black":
return "color: gray";
case "light_blue":
return "color: lightBlue";
case "light_cyan":
return "color: lightCyan";
case "light_green":
return "color: lightGreen";
case "light_magenta":
return "color: lightPink";
case "light_red":
return "color: salmon";
case "light_white":
return "color: white";
case "light_yellow":
return "color: #ffed88";
case "magenta":
return "color: magenta";
case "red":
return "color: red";
case "reset":
return "";
case "underline":
return "text-decoration: underline";
case "white":
return "color: whiteSmoke";
case "yellow":
return "color: #f5ba00";
default:
return "";
}
};
Console.determineConsoleFormatMode = function() {
var hasWindowObject = typeof(window) != "undefined";
if(hasWindowObject) {
return 1;
}
var tputColors = Console.exec("tput colors");
if(tputColors.exit == 0) {
var tputResult = Std.parseInt(tputColors.stdout);
if(tputResult != null && tputResult > 2) {
return 0;
}
}
var termEnv = Sys.environment().h["TERM"];
if(termEnv != null && new EReg("cygwin|xterm|vt100","").match(termEnv)) {
return 0;
}
return 2;
};
Console.exec = function(cmd,args) {
var p = js_node_ChildProcess.spawnSync(cmd,args != null ? args : [],{ });
var stdout = p.stdout == null ? "" : p.stdout.toString();
if(stdout == null) {
stdout = "";
}
return { exit : p.status, stdout : stdout};
};
var FormatFlag = {};
FormatFlag.fromString = function(str) {
str = str.toLowerCase();
if(str.charAt(0) == "#" || HxOverrides.substr(str,0,3) == "bg#") {
var hIdx = str.indexOf("#");
var hex = HxOverrides.substr(str,hIdx + 1,null);
if(hex.length == 3) {
var a = hex.split("");
hex = [a[0],a[0],a[1],a[1],a[2],a[2]].join("");
}
if(new EReg("[^0-9a-f]","i").match(hex) || hex.length < 6) {
return "";
}
var normalized = str.substring(0,hIdx) + "#" + hex;
return normalized;
}
switch(str) {
case "!":
return "invert";
case "/":
return "reset";
case "b":
return "bold";
case "bg_gray":
return "bg_light_black";
case "gray":
return "light_black";
case "i":
return "italic";
case "u":
return "underline";
default:
return str;
}
};
var ConverterContext = $hx_exports["ConverterContext"] = function(inputModuleName,moduleSearchPath,compilerOptions,stdLibMap,hxnodejsMap,options) {
this._rasterizeMappedTypes = true;
this._currentTypeStack = [];
this.unionizedFunctionTypes = true;
this.anyUnionCollapse = false;
this.typeStackLimit = 25;
this.shortenTypePaths = true;
this.processedDeclarationSymbols = [];
this.declarationSymbolQueue = new ds_OnceOnlySymbolQueue();
this.generatedModules = new haxe_ds_StringMap();
var _gthis = this;
this.options = options;
this.hxnodejsMap = hxnodejsMap;
moduleSearchPath = js_node_Path.resolve(moduleSearchPath);
this.moduleSearchPath = moduleSearchPath;
this.host = ts.createCompilerHost(compilerOptions);
var moduleName = inputModuleName;
var isRelativePath = moduleName.charAt(0) == ".";
if(tool_TsProgramTools.isDirectPathReferenceModule(moduleName)) {
moduleName = tool_FileTools.cwdRelativeFilePath(moduleName);
}
moduleName = haxe_io_Path.normalize(moduleName);
var moduleNameParts = moduleName.split("/");
if(moduleNameParts[0] == "@types" && moduleNameParts.length > 1) {
moduleNameParts.shift();
}
var normalized = moduleNameParts.join("/");
this.normalizedInputModuleName = isRelativePath ? "./" + normalized : normalized;
var s = Console.logPrefix + ("" + ("Converting module <b>" + inputModuleName + "</b>"));
var outputStream = 0;
if(outputStream == null) {
outputStream = 0;
}
if(s == null) {
s = "";
}
Console.printFormatted(s + "\n",outputStream);
Log.log("moduleSearchPath: <b>\"" + this.moduleSearchPath + "\"</>");
var result = ts.resolveModuleName(inputModuleName,moduleSearchPath + "/.",compilerOptions,this.host);
if(result.resolvedModule == null) {
var failedLookupLocations = Reflect.field(result,"failedLookupLocations");
Log.error("Failed to find typescript for module <b>\"" + inputModuleName + "\"</b>. Searched the following paths:<dim>\n\t" + failedLookupLocations.join("\n\t") + "</>");
throw haxe_Exception.thrown("Input module not resolved");
}
this.inputModule = result.resolvedModule;
var packageRootModule;
if(this.inputModule.packageId != null) {
var moduleName = this.inputModule.packageId.name;
var isRelativePath = moduleName.charAt(0) == ".";
if(tool_TsProgramTools.isDirectPathReferenceModule(moduleName)) {
moduleName = tool_FileTools.cwdRelativeFilePath(moduleName);
}
moduleName = haxe_io_Path.normalize(moduleName);
var moduleNameParts = moduleName.split("/");
if(moduleNameParts[0] == "@types" && moduleNameParts.length > 1) {
moduleNameParts.shift();
}
var normalized = moduleNameParts.join("/");
this.packageName = isRelativePath ? "./" + normalized : normalized;
if(this.inputModule.packageId.name != inputModuleName) {
var result = ts.resolveModuleName(this.packageName,moduleSearchPath + "/.",compilerOptions,this.host);
if(result.resolvedModule == null) {
var failedLookupLocations = Reflect.field(result,"failedLookupLocations");
Log.error("Root package for <b>" + inputModuleName + "</> was <b>" + this.packageName + "</> but this module could not be resolved. Searched the following paths:<dim>\n\t" + failedLookupLocations.join("\n\t") + "</>");
}
packageRootModule = result.resolvedModule;
} else {
packageRootModule = this.inputModule;
}
} else {
packageRootModule = null;
}
var inputSourcePaths = [this.inputModule.resolvedFileName];
if(packageRootModule != null) {
inputSourcePaths.unshift(packageRootModule.resolvedFileName);
}
this.program = ts.createProgram(inputSourcePaths,compilerOptions,this.host);
this.tc = this.program.getTypeChecker();
Log.diagnostics(null,tool_TsProgramTools.getAllDiagnostics(this.program));
var entryPointSourceFile = this.program.getSourceFile(this.inputModule.resolvedFileName);
if(entryPointSourceFile == null) {
throw haxe_Exception.thrown("Types not found – try installing external types with:\n\t<bg_black,white>npm install @types/" + inputModuleName + "</>");
}
var inputModuleSourceFiles = [];
tool_TsProgramTools.walkReferencedSourceFiles(this.program,entryPointSourceFile,this.host,true,function(s) {
inputModuleSourceFiles.push(s);
});
tool_TsProgramTools.assignModuleNames(this.program,moduleSearchPath,this.host);
var dependencies = tool_TsProgramTools.getDependencies(this.program,inputModuleSourceFiles,this.normalizedInputModuleName,this.host);
if(hxnodejsMap != null) {
var _g = [];
var _g1 = 0;
var _g2 = dependencies;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.normalizedModuleName != "node") {
_g.push(v);
}
}
dependencies = _g;
}
this.moduleDependencies = dependencies;
this.symbolAccessMap = new SymbolAccessMap(this.program);
this.haxeTypePathMap = new HaxeTypePathMap(this.packageName != null ? this.packageName : this.normalizedInputModuleName,options.globalPackageName,this.program,this.symbolAccessMap,stdLibMap,hxnodejsMap);
tool_TsProgramTools.walkReferencedSourceFiles(this.program,entryPointSourceFile,this.host,true,function(sourceFile) {
var _g = 0;
var _g1 = tool_TsProgramTools.getExposedSymbolsOfSourceFile(_gthis.program,sourceFile);
while(_g < _g1.length) {
var symbol = _g1[_g];
++_g;
tool_TsSymbolTools.walkDeclarationSymbols(_gthis.tc,symbol,function(symbol,access) {
_gthis.declarationSymbolQueue.tryEnqueue(symbol);
});
}
});
while(!this.declarationSymbolQueue.empty()) {
var symbol = this.declarationSymbolQueue.dequeue();
var _g = 0;
var _g1 = this.symbolAccessMap.getAccess(symbol);
while(_g < _g1.length) {
var access = _g1[_g];
++_g;
if(ConverterContext.isHaxeModuleSource(this.tc,symbol,access)) {
this.generateHaxeModulesFromSymbol(symbol,access);
}
if(ConverterContext.isGlobalField(this.tc,symbol,access)) {
var globalModule = SupportTypes.getGlobalModuleForFieldSymbol(this,symbol,access);
var field = this.fieldFromSymbol(symbol.name,symbol,symbol,SymbolAccess.Global([]),null);
tool_HaxeTools.enableAccess(field,haxe_macro_Access.AStatic);
globalModule.fields.push(field);
}
}
this.processedDeclarationSymbols.push(symbol);
}
PostProcess.run(this);
};
ConverterContext.__name__ = true;
ConverterContext.isHaxeModuleSource = function(tc,symbol,access) {
if(!((symbol.flags & (ts.SymbolFlags.Type | ts.SymbolFlags.ValueModule)) != 0 || tool_TsSymbolTools.isConstructorTypeVariableSymbol(tc,symbol))) {
if((symbol.flags & (ts.SymbolFlags.Function | ts.SymbolFlags.Variable)) != 0) {
if(access._hx_index == 1) {
var _g = access.moduleName;
var _g = access.sourceFileSymbol;
if(access.symbolChain.length == 0) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
} else {
return true;
}
};
ConverterContext.requiresHxClass = function(tc,symbol) {
if((symbol.flags & (ts.SymbolFlags.Class | ts.SymbolFlags.ValueModule | ts.SymbolFlags.Value)) == 0) {
return tool_TsSymbolTools.isConstructorTypeVariableSymbol(tc,symbol);
} else {
return true;
}
};
ConverterContext.requiresAdditionalStructureType = function(tc,symbol) {
if((symbol.flags & ts.SymbolFlags.Interface) != 0) {
return ConverterContext.requiresHxClass(tc,symbol);
} else {
return false;
}
};
ConverterContext.isGlobalField = function(tc,symbol,access) {
if(access._hx_index == 2) {
var _g = access.symbolChain;
if(_g.length == 1) {
var _g1 = _g[0];
if((symbol.flags & (ts.SymbolFlags.Variable | ts.SymbolFlags.Function)) != 0 && !tool_TsSymbolTools.isConstructorTypeVariableSymbol(tc,symbol)) {
return true;
} else {
return false;
}
} else {
return false;
}
} else {
return false;
}
};
ConverterContext.prototype = {
getReferencedHaxeTypePath: function(symbol,moduleSymbol,accessContext,preferInterfaceStructure) {
var _gthis = this;
var hxTypePath = this.haxeTypePathMap.getTypePath(symbol,accessContext,preferInterfaceStructure);
if(!hxTypePath.isExistingStdLibType) {
if(Lambda.exists(tool_TsSymbolTools.getDeclarationsArray(symbol),function(d) {
return d.getSourceFile().hasNoDefaultLib;
})) {
this.declarationSymbolQueue.tryEnqueue(symbol);
} else if(!this.declarationSymbolQueue.has(symbol)) {
var declaredInModules = tool_TsSymbolTools.getParentModuleNames(symbol);
var declaredWithinInputModule = Lambda.exists(declaredInModules,function(name) {
return name == _gthis.normalizedInputModuleName;
});
if(declaredWithinInputModule) {
Log.log("Discovered symbol through reference",null,symbol);
this.declarationSymbolQueue.tryEnqueue(symbol);
} else if(this.options.queueExternalSymbols) {
Log.log("Queuing external symbol",null,symbol);
this.declarationSymbolQueue.tryEnqueue(symbol);
} else if(this.hxnodejsMap != null) {
if(StringTools.startsWith(hxTypePath.pack.join("."),"js.node.")) {
this.declarationSymbolQueue.tryEnqueue(symbol);
}
}
}
}
var noPack;
if(this.shortenTypePaths && !hxTypePath.isExistingStdLibType) {
if(moduleSymbol != null) {
var contextTypePath = this.haxeTypePathMap.getTypePath(moduleSymbol,accessContext,false);
noPack = contextTypePath.pack.join(".") == hxTypePath.pack.join(".");
} else {
noPack = false;
}
} else {
noPack = false;
}
return { name : hxTypePath.moduleName, sub : hxTypePath.moduleName != hxTypePath.name ? hxTypePath.name : null, pack : noPack ? [] : hxTypePath.pack};
}
,getGeneratedModule: function(typePath) {
var this1 = this.generatedModules;
var key = this.getHaxeModuleKey(typePath.pack,typePath.name);
return this1.h[key];
}
,generateHaxeModulesFromSymbol: function(symbol,access) {
var _gthis = this;
var pos = tool_TsSymbolTools.getPosition(symbol);
var isConstructorTypeVariable = tool_TsSymbolTools.isConstructorTypeVariableSymbol(this.tc,symbol);
var isValueModuleOnlySymbol = (symbol.flags & ts.SymbolFlags.ValueModule) != 0 && (symbol.flags & ts.SymbolFlags.Type) == 0 && !isConstructorTypeVariable;
var fundamentalTypePath = this.haxeTypePathMap.getTypePath(symbol,access,false);
if(!fundamentalTypePath.isExistingStdLibType) {
var hxModule;
if((symbol.flags & ts.SymbolFlags.Enum) != 0) {
var isCompileTimeEnum = (symbol.flags & ts.SymbolFlags.ConstEnum) != 0;
var hxEnumType = this.complexTypeBaseOfEnumSymbol(symbol);
var _g = [];
var _g1 = 0;
var _g2 = this.tc.getExportsOfModule(symbol);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if((v.flags & ts.SymbolFlags.EnumMember) != 0) {
_g.push(v);
}
}
var enumMembers = _g;
var _g = [];
var _g1 = 0;
while(_g1 < enumMembers.length) {
var enumMember = enumMembers[_g1];
++_g1;
_g.push(this.fieldFromSymbol(enumMember.name,enumMember,symbol,access,null));
}
var hxEnumFields = _g;
hxModule = { pack : fundamentalTypePath.pack, name : fundamentalTypePath.name, kind : haxe_macro_TypeDefKind.TDAbstract(hxEnumType,[hxEnumType],[hxEnumType]), params : [], isExtern : true, fields : hxEnumFields, doc : this.getDoc(symbol), meta : (isCompileTimeEnum ? [] : [tool_SymbolAccessTools.toAccessMetadata(access)]).concat([{ name : ":enum", pos : pos}]), pos : pos, tsSymbol : symbol, tsSymbolAccess : access};
} else if((symbol.flags & ts.SymbolFlags.TypeAlias) != 0) {
var _g = [];
var _g1 = 0;
var _g2 = tool_TsSymbolTools.getDeclarationsArray(symbol);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(v.kind == ts.SyntaxKind.TypeAliasDeclaration) {
_g.push(v);
}
}
var typeAliasDeclaration = _g[0];
if(typeAliasDeclaration == null) {
Log.warn("TypeAlias symbol did not have a TypeAliasDeclaration",null,symbol);
}
var tsType = this.tc.getDeclaredTypeOfSymbol(symbol);
var hxAliasType = this.complexTypeFromTsType(tsType,symbol,access,typeAliasDeclaration,symbol,false);
var forceAbstractKind = (symbol.flags & ts.SymbolFlags.ValueModule) != 0 || isConstructorTypeVariable;
var hxTypeDef = forceAbstractKind ? { pack : fundamentalTypePath.pack, name : fundamentalTypePath.name, fields : [], kind : haxe_macro_TypeDefKind.TDAbstract(hxAliasType,[hxAliasType],[hxAliasType]), params : this.typeParamDeclFromTypeDeclarationSymbol(symbol,access,typeAliasDeclaration), doc : this.getDoc(symbol), isExtern : true, meta : [tool_SymbolAccessTools.toAccessMetadata(access),{ name : ":forward", pos : pos},{ name : ":forwardStatics", pos : pos}], pos : pos, tsSymbol : symbol, tsSymbolAccess : access} : { pack : fundamentalTypePath.pack, name : fundamentalTypePath.name, fields : [], kind : haxe_macro_TypeDefKind.TDAlias(hxAliasType), params : this.typeParamDeclFromTypeDeclarationSymbol(symbol,access,typeAliasDeclaration), doc : this.getDoc(symbol), pos : pos, tsSymbol : symbol, tsSymbolAccess : access};
hxModule = hxTypeDef;
} else if(ConverterContext.requiresHxClass(this.tc,symbol)) {
var classDeclaration = Lambda.find(symbol.declarations,function(d) {
return d.kind == ts.SyntaxKind.ClassDeclaration;
});
var declaration;
if(classDeclaration != null) {
declaration = classDeclaration;
} else if(symbol.valueDeclaration != null) {
declaration = symbol.valueDeclaration;
} else {
Log.error("Expected valueDeclaration for a symbol that requires a class in haxe",null,symbol);
declaration = null;
}
var declaredType = this.tc.getDeclaredTypeOfSymbol(symbol);
var meta = [tool_SymbolAccessTools.toAccessMetadata(access)];
var superClassPath = null;
if(isValueModuleOnlySymbol) {
meta.push({ name : "valueModuleOnly", pos : pos});
}
var callSignatures = this.tc.getSignaturesOfType(declaredType,ts.SignatureKind.Call);
var indexSignatures = tool_TsTypeTools.getIndexSignaturesOfType(this.tc,declaredType);
var _g = [];
var _g1 = 0;
var _g2 = this.tc.getPropertiesOfType(declaredType);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(tool_TsSymbolTools.isAccessibleField(v)) {
_g.push(v);
}
}
var classMembers = _g;
var classSuperType = tool_TsSymbolTools.getClassExtendsType(this.tc,symbol);
if(classSuperType != null) {
var hxSuperType = this.complexTypeFromObjectType(classSuperType,symbol,access,false,declaration);
if(hxSuperType._hx_index == 0) {
var p = hxSuperType.p;
if(!this.isHxAny(hxSuperType)) {
superClassPath = p;
} else {
Log.warn("Class super-type did not translate to a class-path (instead it was: <b>" + new Printer().printComplexType(hxSuperType) + "</>)",null,symbol);
superClassPath = null;
}
} else {
Log.warn("Class super-type did not translate to a class-path (instead it was: <b>" + new Printer().printComplexType(hxSuperType) + "</>)",null,symbol);
superClassPath = null;
}
var _g = [];
var _g1 = 0;
var _g2 = this.tc.getPropertiesOfType(classSuperType);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(tool_TsSymbolTools.isAccessibleField(v)) {
_g.push(v);
}
}
var classSuperMembers = _g;
var _g = [];
var _g1 = 0;
var _g2 = classMembers;
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
var m = [v];
var classSuperMatch = Lambda.find(classSuperMembers,(function(m) {
return function(sm) {
return sm.name == m[0].name;
};
})(m));
var classMembers1;
if(classSuperMatch != null) {
if((m[0].flags & ts.SymbolFlags.Method) != 0) {
var format = ts.TypeFormatFlags.NoTruncation;
classMembers1 = _gthis.tc.typeToString(_gthis.getTsTypeOfField(m[0]),m[0].valueDeclaration,format) != _gthis.tc.typeToString(_gthis.getTsTypeOfField(classSuperMatch),classSuperMatch.valueDeclaration,format);
} else {
classMembers1 = false;
}
} else {
classMembers1 = true;
}
if(classMembers1) {
_g.push(v);
}
}
classMembers = _g;
}
var fields = this.generateTypeFields(symbol,access,declaration,tool_TsSymbolTools.getConstructorSignatures(symbol,this.tc),callSignatures,indexSignatures,classMembers,fundamentalTypePath.name);
if(classDeclaration != null) {
if(!Lambda.exists(fields,function(f) {
return f.name == "new";
}) && classSuperType == null) {
var inlobj_name = "";
var inlobj_pos_file = "src/ConverterContext.hx";
var inlobj_pos_min = 20974;
var inlobj_pos_max = 20999;
var inlobj_isExtern = false;
var inlobj_kind = haxe_macro_TypeDefKind.TDClass(null,[],false,false,false);
var inlobj_fields_0 = { name : "new", kind : haxe_macro_FieldType.FFun({ args : [], ret : null, expr : null, params : []}), pos : { file : "src/ConverterContext.hx", min : 20982, max : 20997}};
fields.unshift(inlobj_fields_0);
}
}
tool_HaxeTools.resolveNameCollisions(fields);
hxModule = { pack : fundamentalTypePath.pack, name : fundamentalTypePath.name, fields : fields, kind : haxe_macro_TypeDefKind.TDClass(superClassPath,[],false,false), params : this.typeParamDeclFromTypeDeclarationSymbol(symbol,access,declaration), isExtern : true, doc : this.getDoc(symbol), meta : meta, pos : pos, tsSymbol : symbol, tsSymbolAccess : access};
} else if((symbol.flags & ts.SymbolFlags.Interface) != 0) {
hxModule = this.createInterfaceModule(symbol,access,false);
} else {
Log.error("generateHaxeModulesFromSymbol(): Unhandled symbol, no flags were recognized",null,symbol);
var fundamentalTypePath1 = fundamentalTypePath.pack;
var fundamentalTypePath2 = fundamentalTypePath.name;
var hxModule1 = this.getDoc(symbol);
hxModule = { pack : fundamentalTypePath1, name : fundamentalTypePath2, fields : [], kind : haxe_macro_TypeDefKind.TDAbstract(haxe_macro_ComplexType.TPath({ pack : [], name : "Dynamic", params : []}),[haxe_macro_ComplexType.TPath({ pack : [], name : "Dynamic", params : []})],[haxe_macro_ComplexType.TPath({ pack : [], name : "Dynamic", params : []})]), doc : hxModule1, isExtern : true, pos : pos, tsSymbol : symbol, tsSymbolAccess : access};
}
if(isConstructorTypeVariable) {
var constructorTypeDeclaration = symbol.valueDeclaration;
if(constructorTypeDeclaration != null) {
var constructorType = this.tc.getTypeOfSymbolAtLocation(symbol,constructorTypeDeclaration);
var constructSignatures = this.tc.getSignaturesOfType(constructorType,ts.SignatureKind.Construct);
var callSignatures = this.tc.getSignaturesOfType(constructorType,ts.SignatureKind.Call);
var indexSignatures = tool_TsTypeTools.getIndexSignaturesOfType(this.tc,constructorType);
var _g = [];
var _g1 = 0;
var _g2 = this.tc.getPropertiesOfType(constructorType);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(tool_TsSymbolTools.isAccessibleField(v)) {
_g.push(v);
}
}
var fields = _g;
if(indexSignatures.length > 0) {
Log.warn("Index signatures are not yet supported",null,symbol);
}
var newField = this.newFieldFromSignatures(constructSignatures,symbol,access,constructorTypeDeclaration);
hxModule.fields.unshift(newField);
if(callSignatures.length > 0) {
var callField = this.functionFieldFromCallSignatures(ConverterContext.selfCallFunctionName,callSignatures,symbol,access,constructorTypeDeclaration);
tool_HaxeTools.enableAccess(callField,haxe_macro_Access.AStatic);
hxModule.fields.push(callField);
}
var _g = 0;
while(_g < fields.length) {
var field = fields[_g];
++_g;
var hxField = this.fieldFromSymbol(field.name,field,symbol,access,constructorTypeDeclaration);
tool_HaxeTools.enableAccess(hxField,haxe_macro_Access.AStatic);
hxModule.fields.push(hxField);
}
} else {
Log.error("A symbol with a constructor type variable declaration should have a valueDeclaration",null,symbol);
}
}
var _g = 0;
var _g1 = [];
var _g2 = 0;
var _g3 = tool_TsSymbolTools.getExports(symbol);
while(_g2 < _g3.length) {
var v = _g3[_g2];
++_g2;
if((v.flags & ts.SymbolFlags.ClassMember) != 0 && tool_TsSymbolTools.isAccessibleField(v)) {
_g1.push(v);
}
}
var _g2 = _g1;
while(_g < _g2.length) {
var staticClassMember = _g2[_g];
++_g;
var field = this.fieldFromSymbol(staticClassMember.name,staticClassMember,symbol,access,null);
tool_HaxeTools.enableAccess(field,haxe_macro_Access.AStatic);
hxModule.fields.push(field);
}
if((symbol.flags & ts.SymbolFlags.Module) != 0) {
var _g = [];
var _g1 = 0;
var _g2 = this.tc.getExportsOfModule(symbol);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if((v.flags & ts.SymbolFlags.ModuleMember) != 0 && (tool_TsSymbolTools.isAccessibleField(v) || (v.flags & ts.SymbolFlags.Alias) != 0)) {
_g.push(v);
}
}
var moduleMemberFields = _g;
var _g = 0;
while(_g < moduleMemberFields.length) {
var moduleMember = moduleMemberFields[_g];
++_g;
var nativeFieldName = moduleMember.name;
if((moduleMember.flags & ts.SymbolFlags.Alias) != 0) {
moduleMember = this.tc.getAliasedSymbol(moduleMember);
if(!tool_TsSymbolTools.isAccessibleField(moduleMember)) {
continue;
}
}
if(tool_TsSymbolTools.isConstructorTypeVariableSymbol(this.tc,moduleMember)) {
continue;
}
var field = this.fieldFromSymbol(nativeFieldName,moduleMember,symbol,access,null);
tool_HaxeTools.enableAccess(field,haxe_macro_Access.AStatic);
hxModule.fields.push(field);
}
}
this.saveHaxeModule(hxModule);
}
if(ConverterContext.requiresAdditionalStructureType(this.tc,symbol)) {
this.saveHaxeModule(this.createInterfaceModule(symbol,access,true));
}
}
,createInterfaceModule: function(symbol,access,preferInterfaceStructure) {
var _gthis = this;
var pos = tool_TsSymbolTools.getPosition(symbol);
var typePath = this.haxeTypePathMap.getTypePath(symbol,access,preferInterfaceStructure);
var declaration = Lambda.find(symbol.declarations,function(d) {
return d.kind == ts.SyntaxKind.InterfaceDeclaration;
});
var declaredType = this.tc.getDeclaredTypeOfSymbol(symbol);
var _g = [];
var _g1 = 0;
var _g2 = this.tc.getPropertiesOfType(declaredType);
while(_g1 < _g2.length) {
var v = _g2[_g1];
++_g1;
if(tool_TsSymbolTools.isAccessibleField(v)) {
_g.push(v);
}
}
var declaredMembers = _g;
var callSignatures = this.tc.getSignaturesOfType(declaredType,ts.SignatureKind.Call);
var kind;
if(callSignatures.length > 0 && declaredMembers.length == 0 && preferInterfaceStructure == false) {
var result = new Array(callSignatures.length);
var _g = 0;
var _g1 = callSignatures.length;
while(_g < _g1) {
var i = _g++;
result[i] = _gthis.complexTypeFromCallSignature(callSignatures[i],symbol,access,declaration);
}
var functionSignature = SupportTypes.getUnionType(this,result);
kind = haxe_macro_TypeDefKind.TDAlias(functionSignature);
} else {
var fields = this.generateTypeFields(symbol,access,declaration,[],callSignatures,tool_TsTypeTools.getIndexSignaturesOfType(this.tc,declaredType),declaredMembers,typePath.name);
var _g = 0;
while(_g < fields.length) {
var field = fields[_g];
++_g;
if(field.access != null) {
var _g1 = [];
var _g2 = 0;
var _g3 = field.access;
while(_g2 < _g3.length) {
var v = _g3[_g2];
++_g2;
var kind1;
switch(v._hx_index) {
case 4:case 7:
kind1 = true;
break;
default:
kind1 = false;
}
if(kind1) {
_g1.push(v);
}
}
field.access = _g1;
}
}
tool_HaxeTools.resolveNameCollisions(fields);
kind = haxe_macro_TypeDefKind.TDAlias(haxe_macro_ComplexType.TAnonymous(fields));
}
return { pack : typePath.pack, name : typePath.name, fields : [], kind : kind, params : this.typeParamDeclFromTypeDeclarationSymbol(symbol,access,declaration), isExtern : false, doc : this.getDoc(symbol), meta : [], pos : pos, tsSymbol : symbol, tsSymbolAccess : access};
}
,generateTypeFields: function(symbol,access,declaration,constructorSignatures,callSignatures,indexSignatures,classMembers,haxeClassName) {
var fields = [];
if(constructorSignatures.length > 0) {
fields.push(this.newFieldFromSignatures(constructorSignatures,symbol,access,declaration));
}
if(callSignatures.length > 0) {
fields.push(this.functionFieldFromCallSignatures(ConverterContext.selfCallFunctionName,callSignatures,symbol,access,declaration));
}
if((symbol.flags & ts.SymbolFlags.Function) != 0) {
var tsType = this.getTsTypeOfField(symbol);
var signatures = this.tc.getSignaturesOfType(this.tc.getNonNullableType(tsType),ts.SignatureKind.Call);
var selfCallStatic = this.functionFieldFromCallSignatures("call",signatures,symbol,access,declaration);
tool_HaxeTools.enableAccess(selfCallStatic,haxe_macro_Access.AStatic);
fields.push(selfCallStatic);
} else {
var tmp;
if((symbol.flags & ts.SymbolFlags.Variable) != 0) {
if(access._hx_index == 1) {
var _g = access.moduleName;
var _g = access.sourceFileSymbol;
tmp = access.symbolChain.length == 0;
} else {
tmp = false;
}
} else {
tmp = false;
}
if(tmp) {
var field = this.fieldFromSymbol("value",symbol,symbol,access,declaration);
var _g = field.kind;
switch(_g._hx_index) {
case 0:
var _g1 = _g.e;
var type = _g.t;
field.kind = haxe_macro_FieldType.FProp("get","never",type);
field.access = [haxe_macro_Access.AStatic];
fields.push(field);
var inlobj_name = "";
var inlobj_pos_file = "src/ConverterContext.hx";
var inlobj_pos_min = 30612;
var inlobj_pos_max = 30704;
var inlobj_isExtern = false;
var inlobj_kind = haxe_macro_TypeDefKind.TDClass(null,[],false,false,false);
var inlobj_fields_0 = { name : "get_value", access : [haxe_macro_Access.AStatic,haxe_macro_Access.AInline], kind : haxe_macro_FieldType.FFun({ args : [], ret : type, expr : { expr : haxe_macro_ExprDef.EReturn({ expr : haxe_macro_ExprDef.ECast({ expr : haxe_macro_ExprDef.EConst(haxe_macro_Constant.CIdent(haxeClassName)), pos : { file : "src/ConverterContext.hx", min : 30681, max : 30696}},null), pos : { file : "src/ConverterContext.hx", min : 30674, max : 30696}}), pos : { file : "src/ConverterContext.hx", min : 30667, max : 30696}}, params : []}), pos : { file : "src/ConverterContext.hx", min : 30626, max : 30696}};
fields.push(inlobj_fields_0);
break;
case 1:
var f = _g.f;
var tsType = this.getTsTypeOfField(symbol);
var signatures = this.tc.getSignaturesOfType(this.tc.getNonNullableType(tsType),ts.SignatureKind.Call);
var selfCallStatic = this.functionFieldFromCallSignatures("call",signatures,symbol,access,declaration);
tool_HaxeTools.enableAccess(selfCallStatic,haxe_macro_Access.AStatic);
fields.push(selfCallStatic);
break;
case 2:
var _g1 = _g.get;
var _g1 = _g.set;
var _g1 = _g.e;
var type = _g.t;
field.kind = haxe_macro_FieldType.FProp("get","never",type);
field.access = [haxe_macro_Access.AStatic];
fields.push(field);
var inlobj_name = "";
var inlobj_pos_file = "src/ConverterContext.hx";
var inlobj_pos_min = 30612;
var inlobj_pos_max = 30704;
var inlobj_isExtern = false;
var inlobj_kind = haxe_macro_TypeDefKind.TDClass(null,[],false,false,false);
var inlobj_fields_0 = { name : "get_value", access : [haxe_macro_Access.AStatic,haxe_macro_Access.AInline], kind : haxe_macro_FieldType.FFun({ args : [], ret : type, expr : { expr : haxe_macro_ExprDef.EReturn({ expr : haxe_macro_ExprDef.ECast({ expr : haxe_macro_ExprDef.EConst(haxe_macro_Constant.CIdent(haxeClassName)), pos : { file : "src/ConverterContext.hx", min : 30681, max : 30696}},null), pos : { file : "src/ConverterContext.hx", min : 30674, max : 30696}}), pos : { file : "src/ConverterContext.hx", min : 30667, max : 30696}}, params : []}), pos : { file : "src/ConverterContext.hx", min : 30626, max : 30696}};
fields.push(inlobj_fields_0);
break;
}
}
}
if(indexSignatures.length > 0) {
Log.warn("Index signatures are not yet supported",null,symbol);
}
var _g = 0;
while(_g < classMembers.length) {
var classMember = classMembers[_g];
++_g;
fields.push(this.fieldFromSymbol(classMember.name,classMember,symbol,access,declaration));
}
return fields;
}
,isTypeStructureInHaxe: function(type,moduleSymbol,accessContext,enclosingDeclaration) {
if((type.flags & ts.TypeFlags.Object) != 0) {
if(this.isHxAny(this.complexTypeFromTsType(type,moduleSymbol,accessContext,enclosingDeclaration))) {
return false;
}
var objectType = type;
var isAnonType = (objectType.objectFlags & ts.ObjectFlags.Anonymous) != 0;
var isInterface = type.symbol != null && (type.symbol.flags & ts.SymbolFlags.Interface) != 0;
var isValueModule = type.symbol != null && (type.symbol.flags & ts.SymbolFlags.ValueModule) != 0;
var isConstructorType = tool_TsTypeTools.isConstructorType(this.tc,objectType);
var appearsToBeStructure = !isConstructorType && !isValueModule && (isAnonType || isInterface);
var appearsToBeStructure1 = appearsToBeStructure;
return appearsToBeStructure;
} else {
return false;
}
}
,getHaxeModuleKey: function(pack,name) {
var _this = pack.concat([name]);
var result = new Array(_this.length);
var _g = 0;
var _g1 = _this.length;
while(_g < _g1) {
var i = _g++;
result[i] = _this[i].toLowerCase();
}
return result.join("/");
}
,saveHaxeModule: function($module) {
var isBuiltIn = $module.tsSymbol != null && tool_TsSymbolTools.isBuiltIn($module.tsSymbol);
var skipModule = false;
if(!this.options.globalTypes) {
if(!skipModule) {
if(!isBuiltIn) {
var _g = $module.tsSymbolAccess;
if(_g == null) {
skipModule = false;
} else if(_g._hx_index == 2) {
var _g1 = _g.symbolChain;
skipModule = true;
} else {
skipModule = false;
}
} else {
skipModule = false;
}
} else {
skipModule = true;
}
}
if(!this.options.modularTypes) {
if(!skipModule) {
if(!isBuiltIn) {
var _g = $module.tsSymbolAccess;
if(_g == null) {
skipModule = false;
} else {
switch(_g._hx_index) {
case 0:
var _g1 = _g.modulePath;
var _g1 = _g.moduleSymbol;
var _g1 = _g.symbolChain;
skipModule = true;
break;
case 1:
var _g1 = _g.moduleName;
var _g1 = _g.sourceFileSymbol;
var _g1 = _g.symbolChain;
skipModule = true;
break;
default:
skipModule = false;
}
}
} else {
skipModule = false;
}
} else {
skipModule = true;
}
}
if(skipModule) {
return;
}
var path = this.getHaxeModuleKey($module.pack,$module.name);
var existingModule = this.generatedModules.h[path];
if(existingModule != null) {
Log.warn("<red><b>saveHaxeModule():</> Module <b>\"" + path + "\"</> has already been generated once and will be overwritten</>");
}
if(Object.prototype.hasOwnProperty.call(this.generatedModules.h,path)) {
debugger;
}
this.generatedModules.h[path] = $module;
}
,getDoc: function(symbol) {
var sourceLocationInfo = [];
if(this.options.locationComments) {
var node = symbol.valueDeclaration != null ? symbol.valueDeclaration : tool_TsSymbolTools.getDeclarationsArray(symbol)[0];
if(node != null) {
var sourceFile = node.getSourceFile();
if(sourceFile != null) {
var start = node.getStart();
var lineAndCharacter = sourceFile.getLineAndCharacterOfPosition(start);
var line = lineAndCharacter.line;
var character = lineAndCharacter.character;
sourceLocationInfo.push("" + tool_FileTools.cwdRelativeFilePath(sourceFile.fileName) + ":" + (line + 1) + (character > 0 ? ":" + (character + 1) : ""));
}
}
}
var _this = symbol.getDocumentationComment(this.tc);
var result = new Array(_this.length);
var _g = 0;
var _g1 = _this.length;
while(_g < _g1) {
var i = _g++;
result[i] = StringTools.trim(_this[i].text);
}
return result.concat(sourceLocationInfo).join("\n");
}
,complexTypeFromTsType: function(type,moduleSymbol,accessContext,enclosingDeclaration,disallowAliasTarget,preferInterfaceStructure) {
if(preferInterfaceStructure == null) {
preferInterfaceStructure = false;
}
var _gthis = this;
if(tool_TsTypeTools.isThisType(type)) {
var thisTarget = tool_TsTypeTools.getThisTypeTarget(type);
if(thisTarget != null) {
type = thisTarget;
}
}
if(this._currentTypeStack.length >= this.typeStackLimit) {
Log.error("Internal error: Reached type-depth limit, stopping further type conversions. This indicates unbound recursive type conversion");
debugger;
return haxe_macro_ComplexType.TPath({ pack : [], name : "Dynamic", params : []});
}
var stackHasType = Lambda.has(this._currentTypeStack,type);
if(type.aliasSymbol != null && disallowAliasTarget != type.aliasSymbol) {
this._currentTypeStack.push(type);
var