GNU Octave  4.0.0
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ov-builtin.h
Go to the documentation of this file.
1 /*
2 
3 Copyright (C) 1996-2015 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 3 of the License, or (at your
10 option) any 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, see
19 <http://www.gnu.org/licenses/>.
20 
21 */
22 
23 #if !defined (octave_ov_builtin_h)
24 #define octave_ov_builtin_h 1
25 
26 #include <string>
27 
28 #include "ov-fcn.h"
29 #include "ov-typeinfo.h"
30 
31 class octave_value;
32 class octave_value_list;
33 class jit_type;
34 
35 // Builtin functions.
36 
37 class
40 {
41 public:
42 
43  octave_builtin (void) : octave_function (), f (0), file (), jtype (0) { }
44 
45  typedef octave_value_list (*fcn) (const octave_value_list&, int);
46 
47  octave_builtin (fcn ff, const std::string& nm = std::string (),
48  const std::string& ds = std::string ())
49  : octave_function (nm, ds), f (ff), file (), jtype (0) { }
50 
51  octave_builtin (fcn ff, const std::string& nm, const std::string& fnm,
52  const std::string& ds)
53  : octave_function (nm, ds), f (ff), file (fnm), jtype (0) { }
54 
55  ~octave_builtin (void) { }
56 
57  std::string src_file_name (void) const { return file; }
58 
59  octave_value subsref (const std::string& type,
60  const std::list<octave_value_list>& idx)
61  {
62  octave_value_list tmp = subsref (type, idx, 1);
63  return tmp.length () > 0 ? tmp(0) : octave_value ();
64  }
65 
66  octave_value_list subsref (const std::string& type,
67  const std::list<octave_value_list>& idx,
68  int nargout);
69 
70  octave_value_list subsref (const std::string& type,
71  const std::list<octave_value_list>& idx,
72  int nargout,
73  const std::list<octave_lvalue>* lvalue_list);
74 
75  octave_function *function_value (bool = false) { return this; }
76 
77  bool is_builtin_function (void) const { return true; }
78 
79  octave_value_list
80  do_multi_index_op (int nargout, const octave_value_list& args);
81 
82  octave_value_list
83  do_multi_index_op (int nargout, const octave_value_list& args,
84  const std::list<octave_lvalue>* lvalue_list);
85 
86  jit_type *to_jit (void) const;
87 
88  void stash_jit (jit_type& type);
89 
90  fcn function (void) const;
91 
92  static const std::list<octave_lvalue> *curr_lvalue_list;
93 
94 protected:
95 
96  // A pointer to the actual function.
97  fcn f;
98 
99  // The name of the file where this function was defined.
100  std::string file;
101 
102  // A pointer to the jit type that represents the function.
104 
105 private:
106 
107  // No copying!
108 
109  octave_builtin (const octave_builtin& ob);
110 
111  octave_builtin& operator = (const octave_builtin& ob);
112 
113 
115 };
116 
117 #endif
bool is_builtin_function(void) const
Definition: ov-builtin.h:77
octave_idx_type length(void) const
Definition: oct-obj.h:89
jit_type * jtype
Definition: ov-builtin.h:103
std::string src_file_name(void) const
Definition: ov-builtin.h:57
std::string file
Definition: ov-builtin.h:100
#define DECLARE_OV_TYPEID_FUNCTIONS_AND_DATA
Definition: ov-base.h:142
F77_RET_T const double const double * f
static const std::list< octave_lvalue > * curr_lvalue_list
Definition: ov-builtin.h:92
#define OCTINTERP_API
Definition: mexproto.h:66
octave_builtin(fcn ff, const std::string &nm=std::string(), const std::string &ds=std::string())
Definition: ov-builtin.h:47
octave_builtin(fcn ff, const std::string &nm, const std::string &fnm, const std::string &ds)
Definition: ov-builtin.h:51
octave_function * function_value(bool=false)
Definition: ov-builtin.h:75
~octave_builtin(void)
Definition: ov-builtin.h:55
octave_builtin(void)
Definition: ov-builtin.h:43
return octave_value(v1.char_array_value().concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string())? '\'': '"'))
octave_value subsref(const std::string &type, const std::list< octave_value_list > &idx)
Definition: ov-builtin.h:59