Save FreeCAD WebAssembly development state
Some checks failed
FreeCAD master CI / Prepare (push) Has been cancelled
FreeCAD master CI / Pixi (push) Has been cancelled
FreeCAD master CI / Ubuntu (push) Has been cancelled
FreeCAD master CI / Windows (push) Has been cancelled
FreeCAD master CI / Lint (push) Has been cancelled
FreeCAD master CI / WrapUp (push) Has been cancelled
CodeQL Advanced / Analyze (actions) (push) Has been cancelled
CodeQL Advanced / Analyze (python) (push) Has been cancelled
Scorecard supply-chain security / Scorecard analysis (push) Has been cancelled

This commit is contained in:
2026-09-07 18:58:02 +08:00
parent 2778e3f9c2
commit f2eaf096d8
113 changed files with 30708 additions and 119 deletions

View File

@@ -0,0 +1,35 @@
// SPDX-License-Identifier: LGPL-2.1-or-later
#include <Base/Exception.h>
#include <Python.h>
#include <emscripten/emscripten.h>
#include <string>
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;}
}