00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #if !defined (octave_defun_int_h)
00024 #define octave_defun_int_h 1
00025
00026 #include <string>
00027
00028 #include "ov-builtin.h"
00029 #include "ov-dld-fcn.h"
00030 #include "symtab.h"
00031 #include "version.h"
00032
00033 class octave_value;
00034
00035 extern OCTINTERP_API void print_usage (void);
00036 extern OCTINTERP_API void print_usage (const std::string&);
00037
00038 extern OCTINTERP_API void check_version (const std::string& version, const std::string& fcn);
00039
00040 extern OCTINTERP_API void
00041 install_builtin_function (octave_builtin::fcn f, const std::string& name,
00042 const std::string& doc,
00043 bool can_hide_function = true);
00044
00045 extern OCTINTERP_API void
00046 install_dld_function (octave_dld_function::fcn f, const std::string& name,
00047 const octave_shlib& shl, const std::string& doc,
00048 bool relative = false);
00049
00050 extern OCTINTERP_API void
00051 install_mex_function (void *fptr, bool fmex, const std::string& name,
00052 const octave_shlib& shl, bool relative = false);
00053
00054 extern OCTINTERP_API void
00055 alias_builtin (const std::string& alias, const std::string& name);
00056
00057
00058 extern OCTINTERP_API octave_shlib
00059 get_current_shlib (void);
00060
00061
00062
00063
00064
00065 class octave_auto_shlib : public octave_shlib
00066 {
00067 public:
00068 octave_auto_shlib (void)
00069 : octave_shlib (get_current_shlib ()) { }
00070 octave_auto_shlib (const octave_shlib& shl)
00071 : octave_shlib (shl) { }
00072 };
00073
00074 extern OCTINTERP_API bool
00075 defun_isargout (int, int);
00076
00077 extern OCTINTERP_API void
00078 defun_isargout (int, int, bool *);
00079
00080 #define DECLARE_FUNX(name, args_name, nargout_name) \
00081 OCTAVE_EXPORT octave_value_list \
00082 name (const octave_value_list& args_name, int nargout_name)
00083
00084 #define DECLARE_FUN(name, args_name, nargout_name) \
00085 DECLARE_FUNX (F ## name, args_name, nargout_name)
00086
00087
00088
00089
00090
00091 typedef bool (*octave_dld_fcn_installer) (const octave_shlib&, bool relative);
00092
00093 typedef octave_function * (*octave_dld_fcn_getter) (const octave_shlib&, bool relative);
00094
00095 #define DEFINE_FUN_INSTALLER_FUN(name, doc) \
00096 DEFINE_FUNX_INSTALLER_FUN(#name, F ## name, G ## name, doc)
00097
00098 #define DEFINE_FUNX_INSTALLER_FUN(name, fname, gname, doc) \
00099 extern "C" \
00100 OCTAVE_EXPORT \
00101 octave_function * \
00102 gname (const octave_shlib& shl, bool relative) \
00103 { \
00104 octave_function *retval = 0; \
00105 \
00106 check_version (OCTAVE_API_VERSION, name); \
00107 \
00108 if (! error_state) \
00109 { \
00110 octave_dld_function *fcn = octave_dld_function::create (fname, shl, name, doc); \
00111 \
00112 if (relative) \
00113 fcn->mark_relative (); \
00114 \
00115 retval = fcn; \
00116 } \
00117 \
00118 return retval; \
00119 }
00120
00121
00122
00123
00124
00125 #if defined (MAKE_BUILTINS)
00126
00127
00128
00129
00130
00131 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \
00132 BEGIN_INSTALL_BUILTIN \
00133 XDEFUN_INTERNAL (name, args_name, nargout_name, doc) \
00134 END_INSTALL_BUILTIN
00135
00136 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \
00137 BEGIN_INSTALL_BUILTIN \
00138 XDEFCONSTFUN_INTERNAL (name, args_name, nargout_name, doc) \
00139 END_INSTALL_BUILTIN
00140
00141 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \
00142 BEGIN_INSTALL_BUILTIN \
00143 XDEFUNX_INTERNAL (name, fname, args_name, nargout_name, doc) \
00144 END_INSTALL_BUILTIN
00145
00146
00147
00148
00149
00150 #define DEFUN_DLD_INTERNAL(name, args_name, nargout_name, doc) \
00151 BEGIN_INSTALL_BUILTIN \
00152 XDEFUN_DLD_INTERNAL (name, args_name, nargout_name, doc) \
00153 END_INSTALL_BUILTIN
00154
00155 #define DEFUNX_DLD_INTERNAL(name, fname, args_name, nargout_name, doc) \
00156 BEGIN_INSTALL_BUILTIN \
00157 XDEFUNX_DLD_INTERNAL (name, fname, args_name, nargout_name, doc) \
00158 END_INSTALL_BUILTIN
00159
00160
00161
00162 #define DEFALIAS_INTERNAL(alias, name) \
00163 BEGIN_INSTALL_BUILTIN \
00164 XDEFALIAS_INTERNAL(alias, name) \
00165 END_INSTALL_BUILTIN
00166
00167 #else
00168
00169
00170
00171
00172 #define DEFUN_INTERNAL(name, args_name, nargout_name, doc) \
00173 DECLARE_FUN (name, args_name, nargout_name)
00174
00175 #define DEFCONSTFUN_INTERNAL(name, args_name, nargout_name, doc) \
00176 DECLARE_FUN (name, args_name, nargout_name)
00177
00178 #define DEFUNX_INTERNAL(name, fname, args_name, nargout_name, doc) \
00179 DECLARE_FUNX (fname, args_name, nargout_name)
00180
00181
00182
00183 #define DEFALIAS_INTERNAL(alias, name)
00184
00185 #endif
00186
00187 #endif