make it possible to merge PGF files in the compiler

This commit is contained in:
krangelov
2021-12-22 10:47:22 +01:00
parent c4bd898dc0
commit 12b4958b99
10 changed files with 165 additions and 75 deletions

View File

@@ -213,6 +213,33 @@ PgfDB *pgf_new_ngf(PgfText *abstract_name,
return NULL;
}
PGF_API
void pgf_merge_pgf(PgfDB *db, PgfRevision revision,
const char* fpath,
PgfExn* err)
{
FILE *in = NULL;
PGF_API_BEGIN {
in = fopen(fpath, "rb");
if (!in) {
throw pgf_systemerror(errno, fpath);
}
{
DB_scope scope(db, WRITER_SCOPE);
ref<PgfPGF> pgf = PgfDB::revision2pgf(revision);
PgfReader rdr(in);
rdr.merge_pgf(pgf);
}
} PGF_API_END
end:
if (in != NULL)
fclose(in);
}
PGF_API
void pgf_write_pgf(const char* fpath,
PgfDB *db, PgfRevision revision,