diff --git a/interfaces/sourcegen/sourcegen/_data/ct_auto.yaml b/interfaces/sourcegen/sourcegen/_data/ct_auto.yaml index be97e038a2..4e7bcf0a47 100644 --- a/interfaces/sourcegen/sourcegen/_data/ct_auto.yaml +++ b/interfaces/sourcegen/sourcegen/_data/ct_auto.yaml @@ -12,6 +12,8 @@ recipes: - name: getGitCommit implements: gitCommit # inconsistent API (preexisting) - name: getCanteraError +- name: setLogWriter +- name: setLogCallback - name: addCanteraDirectory implements: addDirectory # inconsistent API (preexisting) - name: getDataDirectories @@ -42,5 +44,3 @@ recipes: implements: epsilon_0 - name: clearStorage - name: resetStorage -- name: setLogWriter -- name: setLogCallback diff --git a/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py b/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py index a6a982f45f..c99afb6b1d 100644 --- a/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py +++ b/interfaces/sourcegen/sourcegen/clib/_CLibSourceGenerator.py @@ -441,7 +441,8 @@ def merge_params( func_name = f"{recipe.prefix}_{recipe.name}" reserved = ["cabinetSize", "parentHandle", - "getCanteraError", "clearStorage", "resetStorage"] + "getCanteraError", "setLogWriter", "setLogCallback", + "clearStorage", "resetStorage"] if recipe.name in reserved: recipe.what = "reserved" loader = Environment(loader=BaseLoader) diff --git a/interfaces/sourcegen/sourcegen/clib/config.yaml b/interfaces/sourcegen/sourcegen/clib/config.yaml index 965810a2c5..68413a7e61 100644 --- a/interfaces/sourcegen/sourcegen/clib/config.yaml +++ b/interfaces/sourcegen/sourcegen/clib/config.yaml @@ -15,6 +15,7 @@ ignore_funcs: includes: "": - cantera/base/global.h + - cantera/base/ExternalLogger.h Solution: - cantera/base/Solution.h Interface: diff --git a/interfaces/sourcegen/sourcegen/clib/templates.yaml b/interfaces/sourcegen/sourcegen/clib/templates.yaml index d0570a596c..2b1456610e 100644 --- a/interfaces/sourcegen/sourcegen/clib/templates.yaml +++ b/interfaces/sourcegen/sourcegen/clib/templates.yaml @@ -53,6 +53,18 @@ clib-reserved-getCanteraError-h: |- */ int {{ prefix }}_getCanteraError(int bufLen, char* buf); +clib-reserved-setLogWriter-h: |- + /** + * Undocumented. + */ + int {{ prefix }}_setLogWriter(void* logger); + +clib-reserved-setLogCallback-h: |- + /** + * Undocumented. + */ + int {{ prefix }}_setLogCallback(LogCallback writer); + clib-reserved-resetStorage-h: |- /** * Delete all objects and erase mapping. @@ -449,6 +461,27 @@ clib-reserved-getCanteraError-cpp: |- return handleAllExceptions(-1, ERR); } +clib-reserved-setLogWriter-cpp: |- + // reserved: setLogWriter + try { + Logger* logwriter = (Logger*)logger; + setLogger(logwriter); + return 0; + } catch (...) { + return handleAllExceptions(-1, ERR); + } + +clib-reserved-setLogCallback-cpp: |- + // reserved: setLogCallback + static unique_ptr logwriter; + try { + logwriter = make_unique(writer); + setLogger(logwriter.get()); + return 0; + } catch (...) { + return handleAllExceptions(-1, ERR); + } + clib-reserved-resetStorage-cpp: |- // reserved: void Cabinet::reset() try {