blob: 7e1470fe10ae6951330ae2fb87bc1f911a8480a5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
// -*- C++ -*-
%module tiger_misc
%include "std_string.i"
%{
#include <sstream>
#include <misc/file-library.hh>
#include <misc/symbol.hh>
#include <misc/error.hh>
// 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 <misc/timer.hh>
%}
%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"
|