diff src/oct-parse.yy @ 11225:8d8e10058df6

move builtin function from dispatch.cc to oct-parse.yy
author John W. Eaton <jwe@octave.org>
date Wed, 10 Nov 2010 16:09:07 -0500
parents 40206fe759db
children 795c97ace02c
line wrap: on
line diff
--- a/src/oct-parse.yy	Wed Nov 10 22:03:58 2010 +0100
+++ b/src/oct-parse.yy	Wed Nov 10 16:09:07 2010 -0500
@@ -4231,6 +4231,41 @@
   return retval;
 }
 
+DEFUN (builtin, args, nargout,
+  "-*- texinfo -*-\n\
+@deftypefn {Loadable Function} {[@dots{}]} builtin (@var{f}, @dots{})\n\
+Call the base function @var{f} even if @var{f} is overloaded to\n\
+some other function for the given type signature.\n\
+@seealso{dispatch}\n\
+@end deftypefn")
+{
+  octave_value_list retval; 
+
+  int nargin = args.length ();
+
+  if (nargin > 0)
+    {
+      const std::string name (args(0).string_value ());
+ 
+      if (! error_state)
+        {
+          octave_value fcn = symbol_table::builtin_find (name);
+
+          if (fcn.is_defined ())
+            retval = feval (fcn.function_value (), args.splice (0, 1),
+                            nargout);
+          else
+            error ("builtin: lookup for symbol `%s' failed", name.c_str ());
+        }
+      else
+        error ("builtin: expecting function name as first argument");
+    }
+  else
+    print_usage ();
+
+  return retval;
+}
+
 octave_value_list
 eval_string (const std::string& s, bool silent, int& parse_status, int nargout)
 {