turn abstractName into a property to better follow the Python API

This commit is contained in:
Krasimir Angelov
2022-09-12 11:03:15 +02:00
parent 7492cd52d1
commit f9ca462a06
2 changed files with 7 additions and 7 deletions

View File

@@ -403,16 +403,13 @@ async function mkAPI() {
asm.gu_pool_free(pool); asm.gu_pool_free(pool);
}); });
function PGF(pgfPtr,pool) { function PGF(pgfPtr,name,pool) {
this.pgfPtr = pgfPtr; this.pgfPtr = pgfPtr;
this.abstractName = name;
this.pool = pool; this.pool = pool;
this.languages = {}; this.languages = {};
registry.register(this,pool); registry.register(this,pool);
} }
PGF.prototype.abstractName = function() {
const namePtr = asm.pgf_abstract_name(this.pgfPtr);
return UTF8ToString(namePtr);
}
function Concr(pgf,name) { function Concr(pgf,name) {
this.pgf = pgf; this.pgf = pgf;
@@ -434,7 +431,10 @@ async function mkAPI() {
throw new Error('Cannot read PGF'); throw new Error('Cannot read PGF');
} }
const pgf = new PGF(pgfPtr,pool); const namePtr = asm.pgf_abstract_name(pgfPtr);
const abstractName = UTF8ToString(namePtr);
const pgf = new PGF(pgfPtr,abstractName,pool);
const itor = asm.gu_malloc(tmp_pool,sizeof_GuMapItor); const itor = asm.gu_malloc(tmp_pool,sizeof_GuMapItor);
const fn = const fn =

View File

@@ -10,6 +10,6 @@ mkAPI().then((pgf) => {
pgf.readPGF("Foods.pgf").then((gr) => { pgf.readPGF("Foods.pgf").then((gr) => {
// Print its name // Print its name
console.log(gr.abstractName()); console.log(gr.abstractName);
}); });
}); });