diff libinterp/corefcn/variables.cc @ 17516:21656a949661

Add hook function to handle missing Octave components * __gripe_missing_component__.m: New internal function to handle errors due to missing Octave components. * scripts/help/module.mk (help_FCN_FILES): Add __gripe_missing_component__.m. * variables.cc (Vmissing_component_hook): New internal variable. * doc.m, mkoctfile.m, configure_make.m: Call __gripe_missing_component__ if required files are not found. * NEWS: Mention missing_component_hook.
author Mike Miller <mtmiller@ieee.org>
date Sun, 29 Sep 2013 16:06:41 -0400
parents f0edd6c752e9
children d63878346099
line wrap: on
line diff
--- a/libinterp/corefcn/variables.cc	Sun Sep 29 20:56:39 2013 +0200
+++ b/libinterp/corefcn/variables.cc	Sun Sep 29 16:06:41 2013 -0400
@@ -2606,3 +2606,33 @@
 
   return retval;
 }
+
+static std::string Vmissing_component_hook;
+
+DEFUN (missing_component_hook, args, nargout,
+    "-*- texinfo -*-\n\
+@deftypefn  {Built-in Function} {@var{val} =} missing_component_hook ()\n\
+@deftypefnx {Built-in Function} {@var{old_val} =} missing_component_hook (@var{new_val})\n\
+@deftypefnx {Built-in Function} {} missing_component_hook (@var{new_val}, \"local\")\n\
+Query or set the internal variable that specifies the function to call when\n\
+a component of Octave is missing.  This can be useful for packagers that\n\
+may split the Octave installation into multiple sub-packages, for example,\n\
+to provide a hint to users for how to install the missing components.\n\
+\n\
+When called from inside a function with the @qcode{\"local\"} option, the\n\
+variable is changed locally for the function and any subroutines it calls.  \n\
+The original variable value is restored when exiting the function.\n\
+\n\
+The hook function is expected to be of the form\n\
+\n\
+@example\n\
+@var{fcn} (@var{component})\n\
+@end example\n\
+\n\
+Octave will call @var{fcn} with the name of the function that requires the\n\
+component and a string describing the missing component.  The hook function\n\
+should return an error message to be displayed.\n\
+@end deftypefn")
+{
+  return SET_INTERNAL_VARIABLE (missing_component_hook);
+}