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