ó
XxTc           @   sn   d  d l  m Z d  d l m Z d  d l Z d  d l Z d   Z d   Z e d k rj e e j	 d  n  d S(   i˙˙˙˙(   t   division(   t   write_this_is_auto_generatedNc         C   s   |  } | j    } d t   S(   Nsw  /*! \file
    Declarations and macros for exception handling.
 */

#ifndef %(mn_upper)s_ERROR_H
#define %(mn_upper)s_ERROR_H

#include <scitbx/error_utils.h>

#define %(mn_upper)s_CHECK_POINT \
  std::cout << __FILE__ << "(" << __LINE__ << ")" << std::endl << std::flush
#define %(mn_upper)s_CHECK_POINT_MSG(msg) \
  std::cout << msg << " @ " __FILE__ << "(" << __LINE__ << ")" << std::endl << std::flush
#define %(mn_upper)s_EXAMINE(A) \
  std::cout << "variable " << #A << ": " << A << std::endl << std::flush

//! Common %(mn)s namespace.
namespace %(mn)s {

  //! All %(mn)s exceptions are derived from this class.
  class error : public ::scitbx::error_base<error>
  {
    public:

      //! General %(mn)s error message.
      explicit
      error(std::string const& msg) throw()
        : ::scitbx::error_base<error>("%(mn)s", msg)
      {}

      //! Error message with file name and line number.
      /*! Used by the macros below.
       */
      error(const char* file, long line, std::string const& msg = "",
            bool internal = true) throw()
        : ::scitbx::error_base<error>("%(mn)s", file, line, msg, internal)
      {}
  };

  //! Special class for "Index out of range." exceptions.
  /*! These exceptions are propagated to Python as IndexError.
   */
  class error_index : public error
  {
    public:
      //! Default constructor. The message may be customized.
      explicit
      error_index(std::string const& msg = "Index out of range.") throw()
        : error(msg)
      {}
  };

} // namespace %(mn)s

//! For throwing an error exception with file name, line number, and message.
#define %(mn_upper)s_ERROR(msg) \
  SCITBX_ERROR_UTILS_REPORT(%(mn)s::error, msg)
//! For throwing an "Internal Error" exception.
#define %(mn_upper)s_INTERNAL_ERROR() \
  SCITBX_ERROR_UTILS_REPORT_INTERNAL(%(mn)s::error)
//! For throwing a "Not implemented" exception.
#define %(mn_upper)s_NOT_IMPLEMENTED() \
  SCITBX_ERROR_UTILS_REPORT_NOT_IMPLEMENTED(%(mn)s::error)

//! Custom %(mn)s assertion.
#define %(mn_upper)s_ASSERT(assertion) \
  SCITBX_ERROR_UTILS_ASSERT(%(mn)s::error, %(mn_upper)s_ASSERT, assertion)

#endif // %(mn_upper)s_ERROR_H
(   t   uppert   vars(   t   module_namet   mnt   mn_upper(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/command_line/generate_error_h.pyt	   as_string   s    Fc         C   sc   t  j d } t |   d k r, d | GHd  St d t j d |  t j j t d |  d   d  S(   Nt   LIBTBX_DISPATCHER_NAMEi   s   usage: %s module_name > error.ht   ft   file_name_generatorR   i    (   t   ost   environt   lenR   t   syst   stdoutt   writeR   (   t   argst   this_command(    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/command_line/generate_error_h.pyt   runO   s    	t   __main__i   (
   t
   __future__R    t   libtbx.utilsR   R   R   R   R   t   __name__t   argv(    (    (    sR   /public2/ftp/pub/ccp4/6.5/ccp4-6.5/lib/py2/scitbx/command_line/generate_error_h.pyt   <module>   s   	J	