comparison exceptions.h @ 392:09a1acb81d8b

Delete legacy code no longer used in project * configure.ac: Drop checks for headers and functions no longer needed. * exceptions.cc, exceptions.h: Delete pytave::init_exceptions and related methods and properties for registering exceptions with Boost.Python runtime. * octave_to_python.cc, octave_to_python.h (pytave::octlist_to_pytuple): Delete. * python_to_octave.cc, python_to_octave.h (pytave::pytuple_to_octlist): Delete.
author Mike Miller <mtmiller@octave.org>
date Mon, 03 Apr 2017 13:31:00 -0700
parents 6fffa6219b2c
children 9bf8ba050122
comparison
equal deleted inserted replaced
391:70071a5512de 392:09a1acb81d8b
30 namespace pytave 30 namespace pytave
31 { 31 {
32 class pytave_exception 32 class pytave_exception
33 { 33 {
34 public: 34 public:
35 static void translate_exception (const pytave_exception& py_ex)
36 {
37 PyErr_SetString (PyExc_Exception, py_ex.error.c_str ());
38 }
39
40 pytave_exception (const std::string& err) { error = err; }; 35 pytave_exception (const std::string& err) { error = err; };
41 36
42 private: 37 private:
43 std::string error; 38 std::string error;
44 }; 39 };
45 40
46 class octave_error_exception 41 class octave_error_exception
47 { 42 {
48 public: 43 public:
49 static bool init ()
50 {
51 excclass = PyErr_NewException (const_cast<char*> ("pytave.OctaveError"),
52 PyExc_RuntimeError, 0);
53 return (excclass != 0);
54 };
55
56 static void translate_exception (const octave_error_exception& py_ex)
57 {
58 PyErr_SetString (excclass, py_ex.error.c_str ());
59 }
60
61 static PyObject *excclass;
62
63 octave_error_exception (const std::string& err) { error = err; }; 44 octave_error_exception (const std::string& err) { error = err; };
64 45
65 private: 46 private:
66 std::string error; 47 std::string error;
67 }; 48 };
68 49
69 class octave_parse_exception 50 class octave_parse_exception
70 { 51 {
71 public: 52 public:
72 static bool init ()
73 {
74 excclass = PyErr_NewException (const_cast<char*> ("pytave.ParseError"),
75 PyExc_RuntimeError, 0);
76 return (excclass != 0);
77 };
78
79 static void translate_exception (const octave_parse_exception& py_ex)
80 {
81 PyErr_SetString (excclass, py_ex.error.c_str ());
82 }
83
84 static PyObject *excclass;
85
86 octave_parse_exception (const std::string& err) { error = err; }; 53 octave_parse_exception (const std::string& err) { error = err; };
87 54
88 private: 55 private:
89 std::string error; 56 std::string error;
90 }; 57 };
91 58
92 class value_convert_exception 59 class value_convert_exception
93 { 60 {
94 public: 61 public:
95 static bool init ()
96 {
97 excclass = PyErr_NewException (const_cast<char*> ("pytave.ValueConvertError"),
98 PyExc_TypeError, 0);
99 return (excclass != 0);
100 };
101
102 static void translate_exception (const value_convert_exception& py_ex)
103 {
104 PyErr_SetString (excclass, py_ex.error.c_str ());
105 }
106
107 static PyObject *excclass;
108
109 value_convert_exception (const std::string& err) { error = err; }; 62 value_convert_exception (const std::string& err) { error = err; };
110 63
111 private: 64 private:
112 std::string error; 65 std::string error;
113 }; 66 };
114 67
115 class object_convert_exception 68 class object_convert_exception
116 { 69 {
117 public: 70 public:
118 static bool init ()
119 {
120 excclass = PyErr_NewException (const_cast<char*> ("pytave.ObjectConvertError"),
121 PyExc_TypeError, 0);
122 return (excclass != 0);
123 };
124
125 static void translate_exception (const object_convert_exception& py_ex)
126 {
127 PyErr_SetString (excclass, py_ex.error.c_str ());
128 }
129
130 static PyObject *excclass;
131
132 object_convert_exception (const std::string& err) { error = err; }; 71 object_convert_exception (const std::string& err) { error = err; };
133 72
134 private: 73 private:
135 std::string error; 74 std::string error;
136 }; 75 };
137 76
138 class variable_name_exception 77 class variable_name_exception
139 { 78 {
140 public: 79 public:
141 static bool init ()
142 {
143 excclass = PyErr_NewException (const_cast<char*> ("pytave.VarNameError"),
144 PyExc_RuntimeError, 0);
145 return (excclass != 0);
146 };
147
148 static void translate_exception (const variable_name_exception& py_ex)
149 {
150 PyErr_SetString (excclass, py_ex.error.c_str ());
151 }
152
153 static PyObject *excclass;
154
155 variable_name_exception (const std::string& err) { error = err; }; 80 variable_name_exception (const std::string& err) { error = err; };
156 81
157 private: 82 private:
158 std::string error; 83 std::string error;
159 }; 84 };
160 85
161 bool init_exceptions (void);
162 std::string fetch_exception_message (void); 86 std::string fetch_exception_message (void);
163 } 87 }
164 88
165 #endif 89 #endif