ov-builtin.h

Go to the documentation of this file.
00001 /*
00002 
00003 Copyright (C) 1996-2012 John W. Eaton
00004 
00005 This file is part of Octave.
00006 
00007 Octave is free software; you can redistribute it and/or modify it
00008 under the terms of the GNU General Public License as published by the
00009 Free Software Foundation; either version 3 of the License, or (at your
00010 option) any later version.
00011 
00012 Octave is distributed in the hope that it will be useful, but WITHOUT
00013 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00014 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00015 for more details.
00016 
00017 You should have received a copy of the GNU General Public License
00018 along with Octave; see the file COPYING.  If not, see
00019 <http://www.gnu.org/licenses/>.
00020 
00021 */
00022 
00023 #if !defined (octave_builtin_h)
00024 #define octave_builtin_h 1
00025 
00026 #include <string>
00027 
00028 #include "ov-fcn.h"
00029 #include "ov-typeinfo.h"
00030 
00031 class octave_value;
00032 class octave_value_list;
00033 
00034 // Builtin functions.
00035 
00036 class
00037 OCTINTERP_API
00038 octave_builtin : public octave_function
00039 {
00040 public:
00041 
00042   octave_builtin (void) : octave_function (), f (0) { }
00043 
00044   typedef octave_value_list (*fcn) (const octave_value_list&, int);
00045 
00046   octave_builtin (fcn ff, const std::string& nm = std::string (),
00047                   const std::string& ds = std::string ())
00048     : octave_function (nm, ds), f (ff) { }
00049 
00050   ~octave_builtin (void) { }
00051 
00052   octave_value subsref (const std::string& type,
00053                         const std::list<octave_value_list>& idx)
00054     {
00055       octave_value_list tmp = subsref (type, idx, 1);
00056       return tmp.length () > 0 ? tmp(0) : octave_value ();
00057     }
00058 
00059   octave_value_list subsref (const std::string& type,
00060                              const std::list<octave_value_list>& idx,
00061                              int nargout);
00062 
00063   octave_value_list subsref (const std::string& type,
00064                              const std::list<octave_value_list>& idx,
00065                              int nargout, const std::list<octave_lvalue>* lvalue_list);
00066 
00067   octave_function *function_value (bool = false) { return this; }
00068 
00069   bool is_builtin_function (void) const { return true; }
00070 
00071   octave_value_list
00072   do_multi_index_op (int nargout, const octave_value_list& args);
00073 
00074   octave_value_list
00075   do_multi_index_op (int nargout, const octave_value_list& args,
00076                      const std::list<octave_lvalue>* lvalue_list);
00077 
00078   static const std::list<octave_lvalue> *curr_lvalue_list;
00079 
00080 protected:
00081 
00082   // A pointer to the actual function.
00083   fcn f;
00084 
00085 private:
00086 
00087   // No copying!
00088 
00089   octave_builtin (const octave_builtin& ob);
00090 
00091   octave_builtin& operator = (const octave_builtin& ob);
00092 
00093   DECLARE_OCTAVE_ALLOCATOR
00094 
00095   DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
00096 };
00097 
00098 #endif
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines