comparison src/graphics.cc @ 7824:adb520646d7e

Fix execution of callback strings and allow execution of callback by name.
author Michael Goffioul <michael.goffioul@gmail.com>
date Fri, 08 Feb 2008 16:46:34 +0100
parents edbaa13397ee
children 3584f37eac69
comparison
equal deleted inserted replaced
7823:feaaf725c54f 7824:adb520646d7e
198 { 198 {
199 octave_value_list args; 199 octave_value_list args;
200 octave_function *fcn = 0; 200 octave_function *fcn = 0;
201 201
202 args(0) = h.as_octave_value (); 202 args(0) = h.as_octave_value ();
203 args(1) = data; 203 if (data.is_defined ())
204 args(1) = data;
205 else
206 args(1) = Matrix ();
204 207
205 unwind_protect::begin_frame ("execute_callback"); 208 unwind_protect::begin_frame ("execute_callback");
206 unwind_protect::add (xreset_gcbo); 209 unwind_protect::add (xreset_gcbo);
207 210
208 xset_gcbo (h); 211 xset_gcbo (h);
211 214
212 if (cb.is_function_handle ()) 215 if (cb.is_function_handle ())
213 fcn = cb.function_value (); 216 fcn = cb.function_value ();
214 else if (cb.is_string ()) 217 else if (cb.is_string ())
215 { 218 {
219 int status;
216 std::string s = cb.string_value (); 220 std::string s = cb.string_value ();
217 octave_value f = symbol_table::find_function (s); 221
218 int status; 222 eval_string (s, false, status);
219
220 if (f.is_defined ())
221 fcn = f.function_value ();
222 else
223 eval_string (s, false, status);
224 } 223 }
225 else if (cb.is_cell () && cb.length () > 0 224 else if (cb.is_cell () && cb.length () > 0
226 && (cb.rows () == 1 || cb.columns () == 1) 225 && (cb.rows () == 1 || cb.columns () == 1)
227 && cb.cell_value ()(0).is_function_handle ()) 226 && cb.cell_value ()(0).is_function_handle ())
228 { 227 {
558 void 557 void
559 callback_property::execute (const octave_value& data) const 558 callback_property::execute (const octave_value& data) const
560 { 559 {
561 if (callback.is_defined () && ! callback.is_empty ()) 560 if (callback.is_defined () && ! callback.is_empty ())
562 execute_callback (callback, get_parent (), data); 561 execute_callback (callback, get_parent (), data);
562 }
563
564 void
565 callback_property::execute (const octave_value& cb, const graphics_handle& h,
566 const octave_value& data)
567 {
568 if (cb.is_defined () && ! cb.is_empty ())
569 execute_callback (cb, h, data);
563 } 570 }
564 571
565 // --------------------------------------------------------------------- 572 // ---------------------------------------------------------------------
566 573
567 void 574 void