home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / octa21ep.zip / octave / SOURCE.ZIP / src / defun-int.h next >
C/C++ Source or Header  |  1999-05-30  |  4KB  |  137 lines

  1. /*
  2.  
  3. Copyright (C) 1996, 1997 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 2, or (at your option) any
  10. 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, write to the Free
  19. Software Foundation, 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  20.  
  21. */
  22.  
  23. /* Modified by Klaus Gebhardt, 1999 */
  24.  
  25. #if !defined (octave_defun_int_h)
  26. #define octave_defun_int_h 1
  27.  
  28. #include <string>
  29.  
  30. #include "ov-builtin.h"
  31. #include "ov-mapper.h"
  32. #include "symtab.h"
  33. #include "version.h"
  34.  
  35. class octave_value;
  36.  
  37. extern void print_usage (const string& nm, bool just_usage = false);
  38.  
  39. extern void check_version (const string& version, const string& fcn);
  40.  
  41. extern void
  42. install_builtin_mapper (octave_mapper *mf);
  43.  
  44. extern void
  45. install_builtin_function (octave_builtin::fcn f, const string& name,
  46.               const string& doc, bool is_text_fcn = false);
  47.  
  48. extern void
  49. install_builtin_variable (const string& n, const octave_value& v,
  50.               bool iaf, bool p, bool e,
  51.               symbol_record::change_function chg_fcn,
  52.               const string& h);
  53.  
  54. extern void
  55. alias_builtin (const string& alias, const string& name);
  56.  
  57. // MAKE_BUILTINS is defined to extract function names and related
  58. // information and create the *.def files that are eventually used to
  59. // create the buitlins.cc file.
  60.  
  61. #ifdef MAKE_BUILTINS
  62.  
  63. // Generate code to install name in the symbol table.  The script
  64. // mkdefs will create a .def file for every .cc file that uses DEFUN,
  65. // DEFUN_TEXT, or DEFUN_DLD.
  66.  
  67. #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \
  68.   BEGIN_INSTALL_BUILTIN \
  69.     extern DECLARE_FUN (name, args_name, nargout_name); \
  70.     install_builtin_function (F ## name, #name, doc, is_text_fcn); \
  71.   END_INSTALL_BUILTIN
  72.  
  73. // Generate code for making another name for an existing function.
  74.  
  75. #define DEFALIAS_INTERNAL(alias, name) \
  76.   BEGIN_INSTALL_BUILTIN \
  77.   alias_builtin (#alias, #name); \
  78.   END_INSTALL_BUILTIN
  79.  
  80. #else /* ! MAKE_BUILTINS */
  81.  
  82. // Generate the first line of the function definition.  This ensures
  83. // that the internal functions all have the same signature.
  84.  
  85. #define DEFUN_INTERNAL(name, args_name, nargout_name, is_text_fcn, doc) \
  86.   DECLARE_FUN (name, args_name, nargout_name)
  87.  
  88. // No definition is required for an alias.
  89.  
  90. #define DEFALIAS_INTERNAL(name, alias)
  91.  
  92. #endif /* ! MAKE_BUILTINS */
  93.  
  94. // Define the code that will be used to insert the new function into
  95. // the symbol table.
  96.  
  97. #define DEFINE_FUN_INSTALLER_FUN(name, doc) \
  98.   bool \
  99.   FS ## name (void) \
  100.   { \
  101.     static bool installed = false; \
  102.     if (! installed) \
  103.       { \
  104.     check_version (OCTAVE_VERSION, #name); \
  105.     install_builtin_function (F ## name, #name, doc); \
  106.     installed = true; \
  107.       } \
  108.     return installed; \
  109.   }
  110.  
  111. #define DECLARE_FUN(name, args_name, nargout_name) \
  112.   octave_value_list \
  113.   F ## name (const octave_value_list& args_name, int nargout_name)
  114.  
  115. // How builtin variables are actually installed.
  116.  
  117. #define DEFVAR_INTERNAL(name, sname, defn, inst_as_fcn, protect, \
  118.             chg_fcn, doc) \
  119.   install_builtin_variable (name, octave_value (defn), inst_as_fcn, \
  120.                 protect, (chg_fcn != 0), chg_fcn, doc)
  121.  
  122. // How mapper functions are actually installed.
  123.  
  124. #define DEFUN_MAPPER_INTERNAL(name, ch_map, d_d_map, d_c_map, c_c_map, \
  125.                   lo, hi, can_ret_cmplx_for_real, doc) \
  126.   install_builtin_mapper \
  127.     (new octave_mapper (ch_map, d_d_map, d_c_map, c_c_map, lo, hi, \
  128.             can_ret_cmplx_for_real, #name, #doc))
  129.  
  130. #endif
  131.  
  132. /*
  133. ;;; Local Variables: ***
  134. ;;; mode: C++ ***
  135. ;;; End: ***
  136. */
  137.