4343
|
1 /* |
|
2 |
|
3 Copyright (C) 2003 John W. Eaton |
|
4 |
|
5 This file is part of Octave. |
|
6 |
|
7 Octave is free software; you can redistribute it and/or modify it |
|
8 under the terms of the GNU General Public License as published by the |
|
9 Free Software Foundation; either version 2, or (at your option) any |
|
10 later version. |
|
11 |
|
12 Octave is distributed in the hope that it will be useful, but WITHOUT |
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
15 for more details. |
|
16 |
|
17 You should have received a copy of the GNU General Public License |
|
18 along with Octave; see the file COPYING. If not, write to the Free |
5307
|
19 Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
|
20 02110-1301, USA. |
4343
|
21 |
|
22 */ |
|
23 |
|
24 #ifdef HAVE_CONFIG_H |
|
25 #include <config.h> |
|
26 #endif |
|
27 |
|
28 #include <iostream> |
5164
|
29 #include <vector> |
4343
|
30 |
|
31 #include "defun.h" |
4654
|
32 #include "error.h" |
|
33 #include "gripes.h" |
4343
|
34 #include "oct-map.h" |
|
35 #include "ov-base.h" |
|
36 #include "ov-fcn-handle.h" |
4980
|
37 #include "ov-usr-fcn.h" |
4343
|
38 #include "pr-output.h" |
4980
|
39 #include "pt-pr-code.h" |
|
40 #include "pt-misc.h" |
|
41 #include "pt-stmt.h" |
|
42 #include "pt-cmd.h" |
|
43 #include "pt-exp.h" |
|
44 #include "pt-assign.h" |
4343
|
45 #include "variables.h" |
4988
|
46 #include "parse.h" |
|
47 |
|
48 #include "byte-swap.h" |
|
49 #include "ls-oct-ascii.h" |
|
50 #include "ls-hdf5.h" |
|
51 #include "ls-utils.h" |
4343
|
52 |
|
53 DEFINE_OCTAVE_ALLOCATOR (octave_fcn_handle); |
|
54 |
4612
|
55 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (octave_fcn_handle, |
|
56 "function handle", |
|
57 "function handle"); |
4343
|
58 |
4924
|
59 octave_value_list |
|
60 octave_fcn_handle::subsref (const std::string& type, |
|
61 const std::list<octave_value_list>& idx, |
|
62 int nargout) |
|
63 { |
|
64 octave_value_list retval; |
|
65 |
|
66 switch (type[0]) |
|
67 { |
|
68 case '(': |
|
69 { |
|
70 octave_function *f = function_value (); |
5312
|
71 |
|
72 // XXX FIXME XXX -- need to check to see if the function has a |
|
73 // new definition. The following does not work for function |
|
74 // handles that refer to subfunctions or functions defined on |
|
75 // the command line. |
|
76 // |
|
77 // if (function_out_of_date (f)) |
|
78 // { |
|
79 // octave_value tmp = lookup_function (fcn_name ()); |
|
80 // |
|
81 // octave_function *ftmp = tmp.function_value (true); |
|
82 // |
|
83 // if (ftmp) |
|
84 // f = ftmp; |
|
85 // } |
|
86 |
|
87 if (f) |
|
88 retval = f->subsref (type, idx, nargout); |
|
89 else |
|
90 error ("invalid function handle"); |
4924
|
91 } |
|
92 break; |
|
93 |
|
94 |
|
95 case '{': |
|
96 case '.': |
|
97 { |
4930
|
98 std::string typ_nm = type_name (); |
|
99 error ("%s cannot be indexed with %c", typ_nm.c_str (), type[0]); |
4924
|
100 } |
|
101 break; |
|
102 |
|
103 default: |
|
104 panic_impossible (); |
|
105 } |
|
106 |
|
107 // XXX FIXME XXX -- perhaps there should be an |
|
108 // octave_value_list::next_subsref member function? See also |
|
109 // octave_builtin::subsref. |
|
110 |
|
111 if (idx.size () > 1) |
4994
|
112 retval = retval(0).next_subsref (nargout, type, idx); |
4924
|
113 |
|
114 return retval; |
|
115 } |
|
116 |
4988
|
117 bool |
|
118 octave_fcn_handle::save_ascii (std::ostream& os, bool&, bool) |
|
119 { |
|
120 os << nm << "\n"; |
4989
|
121 |
4988
|
122 if (nm == "@<anonymous>") |
|
123 { |
4989
|
124 print_raw (os, true); |
|
125 os << "\n"; |
4988
|
126 } |
|
127 |
|
128 return true; |
|
129 } |
|
130 |
|
131 bool |
|
132 octave_fcn_handle::load_ascii (std::istream& is) |
|
133 { |
|
134 is >> nm; |
4989
|
135 |
4988
|
136 if (nm == "@<anonymous>") |
|
137 { |
|
138 char c; |
|
139 OSSTREAM buf; |
|
140 |
4989
|
141 // Skip preceeding newline(s). |
|
142 while (is.get (c) && c == '\n') |
|
143 /* do nothing */; |
4988
|
144 |
|
145 if (is) |
|
146 { |
|
147 buf << c; |
|
148 |
|
149 // Get a line of text whitespace characters included, leaving |
4989
|
150 // newline in the stream. |
|
151 |
4988
|
152 while (is.peek () != '\n') |
|
153 { |
|
154 is.get (c); |
|
155 if (! is) |
|
156 break; |
|
157 buf << c; |
|
158 } |
|
159 } |
|
160 |
|
161 buf << OSSTREAM_ENDS; |
|
162 |
|
163 int parse_status; |
4989
|
164 octave_value anon_fcn_handle = eval_string (OSSTREAM_STR (buf), |
4988
|
165 true, parse_status); |
|
166 OSSTREAM_FREEZE (buf); |
|
167 |
4989
|
168 if (parse_status == 0) |
|
169 { |
|
170 octave_fcn_handle *fh = anon_fcn_handle.fcn_handle_value (); |
|
171 if (fh) |
|
172 fcn = fh->fcn; |
|
173 else |
|
174 return false; |
|
175 } |
|
176 else |
|
177 return false; |
4988
|
178 } |
|
179 else |
|
180 { |
|
181 fcn = lookup_function (nm); |
|
182 if (! fcn.is_function ()) |
|
183 return false; |
|
184 } |
|
185 |
|
186 return true; |
|
187 } |
|
188 |
|
189 bool |
|
190 octave_fcn_handle::save_binary (std::ostream& os, bool&) |
|
191 { |
|
192 FOUR_BYTE_INT tmp = nm.length (); |
|
193 os.write (X_CAST (char *, &tmp), 4); |
|
194 os.write (nm.c_str (), nm.length ()); |
|
195 if (nm == "@<anonymous>") |
|
196 { |
|
197 OSSTREAM buf; |
|
198 print_raw (buf, true); |
|
199 std::string stmp = OSSTREAM_STR (buf); |
|
200 OSSTREAM_FREEZE (buf); |
|
201 tmp = stmp.length (); |
|
202 os.write (X_CAST (char *, &tmp), 4); |
|
203 os.write (stmp.c_str (), stmp.length ()); |
|
204 } |
|
205 return true; |
|
206 } |
|
207 |
|
208 bool |
|
209 octave_fcn_handle::load_binary (std::istream& is, bool swap, |
|
210 oct_mach_info::float_format) |
|
211 { |
|
212 FOUR_BYTE_INT tmp; |
|
213 if (! is.read (X_CAST (char *, &tmp), 4)) |
|
214 return false; |
|
215 if (swap) |
|
216 swap_bytes<4> (&tmp); |
|
217 |
|
218 OCTAVE_LOCAL_BUFFER (char, ctmp1, tmp+1); |
|
219 is.read (ctmp1, tmp); |
|
220 nm = std::string (ctmp1); |
|
221 |
|
222 if (! is) |
|
223 return false; |
|
224 |
|
225 if (nm == "@<anonymous>") |
|
226 { |
|
227 if (! is.read (X_CAST (char *, &tmp), 4)) |
|
228 return false; |
|
229 if (swap) |
|
230 swap_bytes<4> (&tmp); |
|
231 |
|
232 OCTAVE_LOCAL_BUFFER (char, ctmp2, tmp+1); |
|
233 is.read (ctmp2, tmp); |
|
234 |
|
235 int parse_status; |
|
236 octave_value anon_fcn_handle = eval_string (ctmp2, true, parse_status); |
|
237 |
4989
|
238 if (parse_status == 0) |
|
239 { |
|
240 octave_fcn_handle *fh = anon_fcn_handle.fcn_handle_value (); |
|
241 if (fh) |
|
242 fcn = fh->fcn; |
|
243 else |
|
244 return false; |
|
245 } |
|
246 else |
|
247 return false; |
4988
|
248 } |
|
249 else |
|
250 { |
|
251 fcn = lookup_function (nm); |
|
252 if (! fcn.is_function ()) |
|
253 return false; |
|
254 } |
|
255 return true; |
|
256 } |
|
257 |
|
258 #if defined (HAVE_HDF5) |
|
259 bool |
|
260 octave_fcn_handle::save_hdf5 (hid_t loc_id, const char *name, |
|
261 bool /* save_as_floats */) |
|
262 { |
|
263 hid_t group_hid = -1; |
|
264 group_hid = H5Gcreate (loc_id, name, 0); |
|
265 if (group_hid < 0 ) return false; |
|
266 |
|
267 hid_t space_hid = -1, data_hid = -1, type_hid = -1;; |
|
268 bool retval = true; |
|
269 |
|
270 // attach the type of the variable |
|
271 type_hid = H5Tcopy (H5T_C_S1); |
|
272 H5Tset_size (type_hid, nm.length () + 1); |
|
273 if (type_hid < 0) |
|
274 { |
|
275 H5Gclose (group_hid); |
|
276 return false; |
|
277 } |
|
278 |
|
279 OCTAVE_LOCAL_BUFFER (hsize_t, hdims, 2); |
|
280 hdims[0] = 0; |
|
281 hdims[1] = 0; |
|
282 space_hid = H5Screate_simple (0 , hdims, (hsize_t*) 0); |
|
283 if (space_hid < 0) |
|
284 { |
|
285 H5Tclose (type_hid); |
|
286 H5Gclose (group_hid); |
|
287 return false; |
|
288 } |
|
289 |
|
290 data_hid = H5Dcreate (group_hid, "nm", type_hid, space_hid, H5P_DEFAULT); |
|
291 if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, |
4989
|
292 H5P_DEFAULT, |
4990
|
293 X_CAST (void *, nm.c_str ())) < 0) |
4988
|
294 { |
|
295 H5Sclose (space_hid); |
|
296 H5Tclose (type_hid); |
|
297 H5Gclose (group_hid); |
|
298 return false; |
|
299 } |
|
300 H5Dclose (data_hid); |
|
301 |
|
302 if (nm == "@<anonymous>") |
|
303 { |
|
304 OSSTREAM buf; |
|
305 print_raw (buf, true); |
|
306 std::string stmp = OSSTREAM_STR (buf); |
|
307 OSSTREAM_FREEZE (buf); |
|
308 |
|
309 // attach the type of the variable |
|
310 H5Tset_size (type_hid, stmp.length () + 1); |
|
311 if (type_hid < 0) |
|
312 { |
|
313 H5Gclose (group_hid); |
|
314 return false; |
|
315 } |
|
316 |
|
317 data_hid = H5Dcreate (group_hid, "fcn", type_hid, space_hid, |
|
318 H5P_DEFAULT); |
|
319 if (data_hid < 0 || H5Dwrite (data_hid, type_hid, H5S_ALL, H5S_ALL, |
4989
|
320 H5P_DEFAULT, |
4990
|
321 X_CAST (void *, stmp.c_str ())) < 0) |
4988
|
322 { |
|
323 H5Sclose (space_hid); |
|
324 H5Tclose (type_hid); |
|
325 H5Gclose (group_hid); |
|
326 return false; |
|
327 } |
|
328 |
|
329 H5Dclose (data_hid); |
|
330 } |
|
331 |
|
332 H5Sclose (space_hid); |
|
333 H5Tclose (type_hid); |
|
334 H5Gclose (group_hid); |
|
335 |
|
336 return retval; |
|
337 } |
|
338 |
|
339 bool |
|
340 octave_fcn_handle::load_hdf5 (hid_t loc_id, const char *name, |
|
341 bool /* have_h5giterate_bug */) |
|
342 { |
|
343 hid_t group_hid, data_hid, space_hid, type_hid, type_class_hid, st_id; |
|
344 hsize_t rank; |
|
345 int slen; |
|
346 |
|
347 group_hid = H5Gopen (loc_id, name); |
|
348 if (group_hid < 0 ) return false; |
|
349 |
|
350 data_hid = H5Dopen (group_hid, "nm"); |
|
351 |
|
352 if (data_hid < 0) |
|
353 { |
|
354 H5Gclose (group_hid); |
|
355 return false; |
|
356 } |
|
357 |
|
358 type_hid = H5Dget_type (data_hid); |
|
359 type_class_hid = H5Tget_class (type_hid); |
|
360 |
|
361 if (type_class_hid != H5T_STRING) |
|
362 { |
|
363 H5Tclose (type_hid); |
|
364 H5Dclose (data_hid); |
|
365 H5Gclose (group_hid); |
|
366 return false; |
|
367 } |
|
368 |
|
369 space_hid = H5Dget_space (data_hid); |
|
370 rank = H5Sget_simple_extent_ndims (space_hid); |
|
371 |
|
372 if (rank != 0) |
|
373 { |
|
374 H5Sclose (space_hid); |
|
375 H5Tclose (type_hid); |
|
376 H5Dclose (data_hid); |
|
377 H5Gclose (group_hid); |
|
378 return false; |
|
379 } |
|
380 |
|
381 slen = H5Tget_size (type_hid); |
|
382 if (slen < 0) |
|
383 { |
|
384 H5Sclose (space_hid); |
|
385 H5Tclose (type_hid); |
|
386 H5Dclose (data_hid); |
|
387 H5Gclose (group_hid); |
|
388 return false; |
|
389 } |
|
390 |
|
391 OCTAVE_LOCAL_BUFFER (char, nm_tmp, slen); |
|
392 |
|
393 // create datatype for (null-terminated) string to read into: |
|
394 st_id = H5Tcopy (H5T_C_S1); |
|
395 H5Tset_size (st_id, slen); |
|
396 |
|
397 if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, |
|
398 X_CAST (void *, nm_tmp)) < 0) |
|
399 { |
|
400 H5Sclose (space_hid); |
|
401 H5Tclose (type_hid); |
|
402 H5Gclose (group_hid); |
|
403 return false; |
|
404 } |
|
405 H5Tclose (st_id); |
|
406 H5Dclose (data_hid); |
|
407 nm = nm_tmp; |
|
408 |
|
409 if (nm == "@<anonymous>") |
|
410 { |
|
411 data_hid = H5Dopen (group_hid, "fcn"); |
|
412 |
|
413 if (data_hid < 0) |
|
414 { |
|
415 H5Gclose (group_hid); |
|
416 return false; |
|
417 } |
|
418 |
|
419 type_hid = H5Dget_type (data_hid); |
|
420 type_class_hid = H5Tget_class (type_hid); |
|
421 |
|
422 if (type_class_hid != H5T_STRING) |
|
423 { |
|
424 H5Tclose (type_hid); |
|
425 H5Dclose (data_hid); |
|
426 H5Gclose (group_hid); |
|
427 return false; |
|
428 } |
|
429 |
|
430 space_hid = H5Dget_space (data_hid); |
|
431 rank = H5Sget_simple_extent_ndims (space_hid); |
|
432 |
|
433 if (rank != 0) |
|
434 { |
|
435 H5Sclose (space_hid); |
|
436 H5Tclose (type_hid); |
|
437 H5Dclose (data_hid); |
|
438 H5Gclose (group_hid); |
|
439 return false; |
|
440 } |
|
441 |
|
442 slen = H5Tget_size (type_hid); |
|
443 if (slen < 0) |
|
444 { |
|
445 H5Sclose (space_hid); |
|
446 H5Tclose (type_hid); |
|
447 H5Dclose (data_hid); |
|
448 H5Gclose (group_hid); |
|
449 return false; |
|
450 } |
|
451 |
|
452 OCTAVE_LOCAL_BUFFER (char, fcn_tmp, slen); |
|
453 |
|
454 // create datatype for (null-terminated) string to read into: |
|
455 st_id = H5Tcopy (H5T_C_S1); |
|
456 H5Tset_size (st_id, slen); |
|
457 |
|
458 if (H5Dread (data_hid, st_id, H5S_ALL, H5S_ALL, H5P_DEFAULT, |
|
459 X_CAST (void *, fcn_tmp)) < 0) |
|
460 { |
|
461 H5Sclose (space_hid); |
|
462 H5Tclose (type_hid); |
|
463 H5Gclose (group_hid); |
|
464 return false; |
|
465 } |
|
466 H5Dclose (data_hid); |
|
467 H5Tclose (st_id); |
|
468 |
|
469 int parse_status; |
|
470 octave_value anon_fcn_handle = eval_string (fcn_tmp, true, parse_status); |
|
471 |
4989
|
472 if (parse_status == 0) |
|
473 { |
|
474 octave_fcn_handle *fh = anon_fcn_handle.fcn_handle_value (); |
|
475 if (fh) |
|
476 fcn = fh->fcn; |
|
477 else |
|
478 return false; |
|
479 } |
|
480 else |
|
481 return false; |
4988
|
482 } |
|
483 else |
|
484 { |
|
485 fcn = lookup_function (nm); |
|
486 if (! fcn.is_function ()) |
|
487 return false; |
|
488 } |
|
489 |
|
490 return true; |
|
491 } |
|
492 #endif |
|
493 |
4343
|
494 void |
|
495 octave_fcn_handle::print (std::ostream& os, bool pr_as_read_syntax) const |
|
496 { |
|
497 print_raw (os, pr_as_read_syntax); |
|
498 newline (os); |
|
499 } |
|
500 |
|
501 void |
|
502 octave_fcn_handle::print_raw (std::ostream& os, bool pr_as_read_syntax) const |
|
503 { |
4980
|
504 bool printed = false; |
|
505 |
|
506 if (nm == "@<anonymous>") |
|
507 { |
|
508 tree_print_code tpc (os); |
|
509 |
4989
|
510 // FCN is const because this member function is, so we can't |
4980
|
511 // use it to call user_function_value, so we make a copy first. |
|
512 |
|
513 octave_value ftmp = fcn; |
|
514 |
|
515 octave_user_function *f = ftmp.user_function_value (); |
|
516 |
|
517 if (f) |
|
518 { |
|
519 tree_parameter_list *p = f->parameter_list (); |
|
520 |
|
521 os << "@("; |
|
522 |
|
523 if (p) |
|
524 p->accept (tpc); |
|
525 |
|
526 os << ") "; |
|
527 |
|
528 tree_statement_list *b = f->body (); |
|
529 |
|
530 if (b) |
|
531 { |
|
532 assert (b->length () == 1); |
|
533 |
|
534 tree_statement *s = b->front (); |
|
535 |
|
536 if (s) |
|
537 { |
|
538 if (s->is_expression ()) |
|
539 { |
|
540 tree_expression *e = s->expression (); |
|
541 |
|
542 if (e) |
|
543 { |
|
544 if (e->is_assignment_expression ()) |
|
545 { |
|
546 // The parser builds an assignment to |
|
547 // __retval__, and we don't want to |
|
548 // display that part. |
|
549 |
|
550 tree_simple_assignment *tsa |
|
551 = reinterpret_cast <tree_simple_assignment *> (e); |
|
552 tree_expression *rhs = tsa->right_hand_side (); |
|
553 |
|
554 if (rhs) |
|
555 rhs->accept (tpc); |
|
556 } |
|
557 else |
|
558 e->accept (tpc); |
|
559 } |
|
560 } |
|
561 else |
|
562 { |
|
563 tree_command *c = s->command (); |
|
564 |
|
565 tpc.suspend_newline (); |
|
566 c->accept (tpc); |
|
567 tpc.resume_newline (); |
|
568 } |
|
569 } |
|
570 } |
|
571 |
|
572 printed = true; |
|
573 } |
|
574 } |
|
575 |
|
576 if (! printed) |
|
577 octave_print_internal (os, nm, pr_as_read_syntax, |
|
578 current_print_indent_level ()); |
4343
|
579 } |
|
580 |
|
581 octave_value |
|
582 make_fcn_handle (const std::string& nm) |
|
583 { |
|
584 octave_value retval; |
|
585 |
4930
|
586 octave_value f = lookup_function (nm); |
4343
|
587 |
4930
|
588 if (f.is_function ()) |
|
589 retval = octave_value (new octave_fcn_handle (f, nm)); |
4343
|
590 else |
|
591 error ("error creating function handle \"@%s\"", nm.c_str ()); |
|
592 |
|
593 return retval; |
|
594 } |
|
595 |
4933
|
596 DEFUN (functions, args, , |
4343
|
597 "-*- texinfo -*-\n\ |
4933
|
598 @deftypefn {Built-in Function} {} functions (@var{fcn_handle})\n\ |
|
599 Return a struct containing information about the function handle\n\ |
|
600 @var{fcn_handle}.\n\ |
|
601 @end deftypefn") |
4343
|
602 { |
|
603 octave_value retval; |
|
604 |
4933
|
605 if (args.length () == 1) |
4343
|
606 { |
4933
|
607 octave_fcn_handle *fh = args(0).fcn_handle_value (); |
4343
|
608 |
|
609 if (! error_state) |
|
610 { |
4933
|
611 octave_function *fcn = fh ? fh->function_value (true) : 0; |
4343
|
612 |
4933
|
613 if (fcn) |
4930
|
614 { |
4933
|
615 Octave_map m; |
4649
|
616 |
4933
|
617 std::string fh_nm = fh->fcn_name (); |
|
618 |
4978
|
619 m.assign ("function", fh_nm); |
4343
|
620 |
4933
|
621 if (fcn->is_nested_function ()) |
|
622 m.assign ("type", "subfunction"); |
|
623 else |
|
624 m.assign ("type", "simple"); |
|
625 |
|
626 std::string nm = fcn->fcn_file_name (); |
4343
|
627 |
4933
|
628 if (nm.empty ()) |
4935
|
629 { |
|
630 if (fh_nm == "@<anonymous>") |
|
631 m.assign ("file", "none"); |
|
632 else |
|
633 m.assign ("file", "built-in function"); |
|
634 } |
4343
|
635 else |
4933
|
636 m.assign ("file", nm); |
|
637 |
|
638 retval = m; |
4343
|
639 } |
|
640 else |
4933
|
641 error ("functions: invalid function handle object"); |
4343
|
642 } |
|
643 else |
4933
|
644 error ("functions: argument must be a function handle object"); |
4343
|
645 } |
|
646 else |
4933
|
647 print_usage ("functions"); |
4343
|
648 |
|
649 return retval; |
|
650 } |
|
651 |
4933
|
652 DEFUN (func2str, args, , |
4343
|
653 "-*- texinfo -*-\n\ |
4933
|
654 @deftypefn {Built-in Function} {} func2str (@var{fcn_handle})\n\ |
|
655 Return a string containing the name of the function referenced by\n\ |
|
656 the function handle @var{fcn_handle}.\n\ |
|
657 @end deftypefn") |
4343
|
658 { |
|
659 octave_value retval; |
|
660 |
4933
|
661 if (args.length () == 1) |
4930
|
662 { |
4933
|
663 octave_fcn_handle *fh = args(0).fcn_handle_value (); |
4930
|
664 |
4933
|
665 if (! error_state && fh) |
|
666 { |
|
667 std::string fh_nm = fh->fcn_name (); |
4978
|
668 retval = fh_nm; |
4933
|
669 } |
4343
|
670 else |
4933
|
671 error ("func2str: expecting valid function handle as first argument"); |
4343
|
672 } |
|
673 else |
4933
|
674 print_usage ("func2str"); |
4343
|
675 |
|
676 return retval; |
|
677 } |
|
678 |
4933
|
679 DEFUN (str2func, args, , |
4343
|
680 "-*- texinfo -*-\n\ |
4933
|
681 @deftypefn {Built-in Function} {} str2func (@var{fcn_name})\n\ |
|
682 Return a function handle constructed from the string @var{fcn_name}.\n\ |
|
683 @end deftypefn") |
4343
|
684 { |
|
685 octave_value retval; |
|
686 |
4933
|
687 if (args.length () == 1) |
4343
|
688 { |
4933
|
689 std::string nm = args(0).string_value (); |
4343
|
690 |
4933
|
691 if (! error_state) |
|
692 retval = make_fcn_handle (nm); |
4343
|
693 else |
4933
|
694 error ("str2func: expecting string as first argument"); |
4343
|
695 } |
|
696 else |
4933
|
697 print_usage ("str2func"); |
4343
|
698 |
|
699 return retval; |
|
700 } |
|
701 |
|
702 /* |
|
703 ;;; Local Variables: *** |
|
704 ;;; mode: C++ *** |
|
705 ;;; End: *** |
|
706 */ |