// -*- C++ -*- %module tiger_misc %include "std_string.i" %{ #include #include #include #include // The need for this using directive seems to be a SWIG bug. It is // needed by the _wrap_error___lshift____SWIG_5 in the C++ wrapper // generated by swig (tiger_bind-wrap.cc). using misc::error; #include %} %exception { try { $function } catch (const misc::error& e) { std::ostringstream o; o << e; PyObject *err = Py_BuildValue("is", e.status_get_value(), o.str().c_str()); PyErr_SetObject(PyExc_RuntimeError, err); SWIG_fail; } } %include "misc/file-library.hh" // Save some warnings from SWIG. %ignore misc::error::operator=; %ignore misc::error::operator bool; // SWIG has trouble wrapping some of misc::error's operator<<'s; ignore them. %ignore misc::error::operator<<; %include "misc/error.hh" // Wrap misc::error::operator<<. %extend misc::error { std::string __str__() const { std::ostringstream o; o << *$self; return o.str(); } %pythoncode %{ @staticmethod def error_type_message() -> dict[int, str]: return { getattr(_tiger_misc, t): t[len("error_error_type_"):].upper() for t in dir(_tiger_misc) if t.startswith("error_error_type_") } %} } %ignore misc::symbol::operator=; %ignore misc::symbol::operator<<; %include "misc/symbol.hh" %extend misc::symbol { std::string __str__() const { return ($self)->get(); } } %include "misc/timer.hh"