// SPDX-License-Identifier: LGPL-2.1-or-later
#include
#include
#include
#include
extern "C" int fc_web_surface_python_probe();
namespace { std::string error; int rejected=0, recovered=0, released=0; }
extern "C" {
EMSCRIPTEN_KEEPALIVE int fc_web_surface_python_recovery_probe()
{
error.clear(); rejected=0; recovered=0; released=0;
if (fc_web_surface_python_probe() != 1) { error="Surface Python baseline failed"; return 0; }
PyObject* missing = PyImport_ImportModule("Surface.Missing");
if (missing) {
Py_DECREF(missing);
error="unsupported Surface submodule was accepted";
}
else {
PyObject* type=nullptr; PyObject* value=nullptr; PyObject* traceback=nullptr;
PyErr_Fetch(&type,&value,&traceback); PyErr_NormalizeException(&type,&value,&traceback);
if (value) { PyObject* text=PyObject_Str(value); if (text) { error=PyUnicode_AsUTF8(text); Py_DECREF(text); } }
Py_XDECREF(type); Py_XDECREF(value); Py_XDECREF(traceback); PyErr_Clear();
rejected = error.find("No module named 'Surface.Missing'") != std::string::npos ? 1 : 0;
}
recovered = fc_web_surface_python_probe() == 1 ? 1 : 0;
released = 1;
return rejected && recovered ? 1 : 0;
}
EMSCRIPTEN_KEEPALIVE const char* fc_web_surface_python_recovery_error(){return error.c_str();}
EMSCRIPTEN_KEEPALIVE int fc_web_surface_python_recovery_rejected(){return rejected;}
EMSCRIPTEN_KEEPALIVE int fc_web_surface_python_recovery_recovered(){return recovered;}
EMSCRIPTEN_KEEPALIVE int fc_web_surface_python_recovery_resources_released(){return released;}
}