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));
|
||||
return Promise.as(
|
||||
compiled.map(x => x.prelude)
|
||||
.concat(compiled.map(x => x.tPrototypes))
|
||||
.concat(compiled.map(x => x.tCode))
|
||||
.concat(compiled.map(x => x.prototypes))
|
||||
.concat(compiled.map(x => x.code))
|
||||
.concat(["namespace touch_develop {"])
|
||||
.concat(compiled.map(x => x.tPrototypes))
|
||||
.concat(compiled.map(x => x.tCode))
|
||||
.concat(compiled.map(x => x.prototypes))
|
||||
.concat(compiled.map(x => x.code))
|
||||
.concat(["}"])
|
||||
.filter(x => x != "")
|
||||
.join("\n") +
|
||||
.join("\n") + "\n" +
|
||||
(a.isLibrary
|
||||
? "\nvoid app_main() {\n"+
|
||||
" uBit.display.scroll(\"Error: trying to run a library\");\n"+
|
||||
"}\n"
|
||||
: "")
|
||||
: "\nvoid app_main() {\n"+
|
||||
" touch_develop::app_main();\n"+
|
||||
"}\n")
|
||||
);
|
||||
});
|
||||
}
|
||||
|
|
|
@ -480,16 +480,16 @@ module TDev {
|
|||
var n = H.mangleName(r.name);
|
||||
return [
|
||||
e.indent + "struct " + n + "_;",
|
||||
e.indent + "typedef ManagedType< " + n + "_> " + n + ";",
|
||||
e.indent + "typedef ManagedType<" + n + "_> " + n + ";",
|
||||
].join("\n");
|
||||
}
|
||||
|
||||
private wrapNamespaceIf(s: string) {
|
||||
if (this.libName != null)
|
||||
return (s.length
|
||||
? "namespace "+this.libName+" {\n"+
|
||||
? " namespace "+this.libName+" {\n"+
|
||||
s +
|
||||
"\n}"
|
||||
"\n }"
|
||||
: "");
|
||||
else
|
||||
return s;
|
||||
|
@ -506,6 +506,7 @@ module TDev {
|
|||
// This function runs over all declarations. After execution, the three
|
||||
// member fields [prelude], [prototypes] and [code] are filled accordingly.
|
||||
public visitApp(e: EmitterEnv, decls: J.JDecl[]) {
|
||||
e = indent(e);
|
||||
if (this.libName)
|
||||
e = indent(e);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче