Wrap all the C++-generated code in a namespace.
Avoids collisions with the global functions defined by the DAL.
This commit is contained in:
Родитель
bd63ab2283
Коммит
ab9c7b8559
|
@ -73,17 +73,21 @@ module TDev {
|
||||||
var compiled = everything.map((a: J.JApp, i: number) => compile1(everything, resolveMap[i], a));
|
var compiled = everything.map((a: J.JApp, i: number) => compile1(everything, resolveMap[i], a));
|
||||||
return Promise.as(
|
return Promise.as(
|
||||||
compiled.map(x => x.prelude)
|
compiled.map(x => x.prelude)
|
||||||
|
.concat(["namespace touch_develop {"])
|
||||||
.concat(compiled.map(x => x.tPrototypes))
|
.concat(compiled.map(x => x.tPrototypes))
|
||||||
.concat(compiled.map(x => x.tCode))
|
.concat(compiled.map(x => x.tCode))
|
||||||
.concat(compiled.map(x => x.prototypes))
|
.concat(compiled.map(x => x.prototypes))
|
||||||
.concat(compiled.map(x => x.code))
|
.concat(compiled.map(x => x.code))
|
||||||
|
.concat(["}"])
|
||||||
.filter(x => x != "")
|
.filter(x => x != "")
|
||||||
.join("\n") +
|
.join("\n") + "\n" +
|
||||||
(a.isLibrary
|
(a.isLibrary
|
||||||
? "\nvoid app_main() {\n"+
|
? "\nvoid app_main() {\n"+
|
||||||
" uBit.display.scroll(\"Error: trying to run a library\");\n"+
|
" uBit.display.scroll(\"Error: trying to run a library\");\n"+
|
||||||
"}\n"
|
"}\n"
|
||||||
: "")
|
: "\nvoid app_main() {\n"+
|
||||||
|
" touch_develop::app_main();\n"+
|
||||||
|
"}\n")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -480,16 +480,16 @@ module TDev {
|
||||||
var n = H.mangleName(r.name);
|
var n = H.mangleName(r.name);
|
||||||
return [
|
return [
|
||||||
e.indent + "struct " + n + "_;",
|
e.indent + "struct " + n + "_;",
|
||||||
e.indent + "typedef ManagedType< " + n + "_> " + n + ";",
|
e.indent + "typedef ManagedType<" + n + "_> " + n + ";",
|
||||||
].join("\n");
|
].join("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
private wrapNamespaceIf(s: string) {
|
private wrapNamespaceIf(s: string) {
|
||||||
if (this.libName != null)
|
if (this.libName != null)
|
||||||
return (s.length
|
return (s.length
|
||||||
? "namespace "+this.libName+" {\n"+
|
? " namespace "+this.libName+" {\n"+
|
||||||
s +
|
s +
|
||||||
"\n}"
|
"\n }"
|
||||||
: "");
|
: "");
|
||||||
else
|
else
|
||||||
return s;
|
return s;
|
||||||
|
@ -506,6 +506,7 @@ module TDev {
|
||||||
// This function runs over all declarations. After execution, the three
|
// This function runs over all declarations. After execution, the three
|
||||||
// member fields [prelude], [prototypes] and [code] are filled accordingly.
|
// member fields [prelude], [prototypes] and [code] are filled accordingly.
|
||||||
public visitApp(e: EmitterEnv, decls: J.JDecl[]) {
|
public visitApp(e: EmitterEnv, decls: J.JDecl[]) {
|
||||||
|
e = indent(e);
|
||||||
if (this.libName)
|
if (this.libName)
|
||||||
e = indent(e);
|
e = indent(e);
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче