[前][次][番号順一覧][スレッド一覧]

ruby-changes:67781

From: =E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3 <ko1@a...>
Date: Fri, 10 Sep 2021 20:01:56 +0900 (JST)
Subject: [ruby-changes:67781] d5460f1cda (master): include/ruby/internal/intern/error.h: add doxygen

https://git.ruby-lang.org/ruby.git/commit/?id=d5460f1cda

From d5460f1cdac1c941baa29625b794b630a5f2f593 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=8D=9C=E9=83=A8=E6=98=8C=E5=B9=B3?=
 <shyouhei@r...>
Date: Mon, 26 Apr 2021 11:31:26 +0900
Subject: include/ruby/internal/intern/error.h: add doxygen

Must not be a bad idea to improve documents. [ci skip]
---
 include/ruby/internal/intern/error.h | 253 ++++++++++++++++++++++++++++++++---
 1 file changed, 236 insertions(+), 17 deletions(-)

diff --git a/include/ruby/internal/intern/error.h b/include/ruby/internal/intern/error.h
index d063423..37d3b85 100644
--- a/include/ruby/internal/intern/error.h
+++ b/include/ruby/internal/intern/error.h
@@ -20,41 +20,244 @@ https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/intern/error.h#L20
  *             extension libraries.  They could be written in C++98.
  * @brief      Public APIs related to ::rb_eException.
  */
+#include "ruby/internal/attr/format.h"
+#include "ruby/internal/attr/noreturn.h"
 #include "ruby/internal/dllexport.h"
 #include "ruby/internal/value.h"
 #include "ruby/internal/fl_type.h"
 #include "ruby/backward/2/assume.h"
-#include "ruby/backward/2/attributes.h"
 
+/**
+ * This macro is used in conjunction  with rb_check_arity().  If you pass it to
+ * the function's last  (max) argument, that means the function  does not check
+ * upper limit.
+ */
 #define UNLIMITED_ARGUMENTS     (-1)
-#define rb_exc_new2             rb_exc_new_cstr
-#define rb_exc_new3             rb_exc_new_str
+
+#define rb_exc_new2             rb_exc_new_cstr  /**< @old{rb_exc_new_cstr} */
+#define rb_exc_new3             rb_exc_new_str  /**< @old{rb_exc_new_str} */
+
+/** @cond INTERNAL_MACRO */
 #define rb_check_trusted        rb_check_trusted
 #define rb_check_trusted_inline rb_check_trusted
 #define rb_check_arity          rb_check_arity
+/** @endcond */
 
 RBIMPL_SYMBOL_EXPORT_BEGIN()
 
 /* error.c */
-VALUE rb_exc_new(VALUE, const char*, long);
-VALUE rb_exc_new_cstr(VALUE, const char*);
-VALUE rb_exc_new_str(VALUE, VALUE);
-PRINTF_ARGS(NORETURN(void rb_loaderror(const char*, ...)), 1, 2);
-PRINTF_ARGS(NORETURN(void rb_loaderror_with_path(VALUE path, const char*, ...)), 2, 3);
-PRINTF_ARGS(NORETURN(void rb_name_error(ID, const char*, ...)), 2, 3);
-PRINTF_ARGS(NORETURN(void rb_name_error_str(VALUE, const char*, ...)), 2, 3);
-PRINTF_ARGS(NORETURN(void rb_frozen_error_raise(VALUE, const char*, ...)), 2, 3);
-NORETURN(void rb_invalid_str(const char*, const char*));
-NORETURN(void rb_error_frozen(const char*));
-NORETURN(void rb_error_frozen_object(VALUE));
+
+/**
+ * Creates an instance of the passed exception class.
+ *
+ * @param[in]  etype           A subclass of ::rb_eException.
+ * @param[in]  ptr             Buffer contains error message.
+ * @param[in]  len             Length  of `ptr`,  in bytes,  not including  the
+ *                             terminating NUL character.
+ * @exception  rb_eTypeError  `etype` is not a class.
+ * @exception  rb_eArgError   `len` is negative.
+ * @return     An instance of `etype`.
+ * @pre        At  least  `len` bytes  of  continuous  memory region  shall  be
+ *             accessible via `ptr`.
+ *
+ * @internal
+ *
+ * This function works for non-exception classes  as well, as long as they take
+ * one string argument.
+ */
+VALUE rb_exc_new(VALUE etype, const char *ptr, long len);
+
+RBIMPL_ATTR_NONNULL(())
+/**
+ * Identical to rb_exc_new(), except it assumes the passed pointer is a pointer
+ * to a C string.
+ *
+ * @param[in]  etype           A subclass of ::rb_eException.
+ * @param[in]  str             A C string (becomes an error message).
+ * @exception  rb_eTypeError  `etype` is not a class.
+ * @return     An instance of `etype`.
+ */
+VALUE rb_exc_new_cstr(VALUE etype, const char *str);
+
+/**
+ * Identical to rb_exc_new_cstr(),  except it takes a Ruby's  string instead of
+ * C's.
+ *
+ * @param[in]  etype           A subclass of ::rb_eException.
+ * @param[in]  str             An instance of ::rb_cString.
+ * @exception  rb_eTypeError  `etype` is not a class.
+ * @return     An instance of `etype`.
+ */
+VALUE rb_exc_new_str(VALUE etype, VALUE str);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL((1))
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 1, 2)
+/**
+ * Raises an instance of ::rb_eLoadError.
+ *
+ * @param[in]  fmt  Format specifier string compatible with rb_sprintf().
+ * @exception  rb_eLoadError  Always raises this.
+ * @note       It never returns.
+ *
+ * @internal
+ *
+ * Who needs this?  Except ruby itself?
+ */
+void rb_loaderror(const char *fmt, ...);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL((2))
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
+/**
+ * Identical  to rb_loaderror(),  except it  additionally takes  which file  is
+ * unable to  load.  The path can  be obtained later using  `LoadError#path` of
+ * the raising exception.
+ *
+ * @param[in]  path  What failed.
+ * @param[in]  fmt   Format specifier string compatible with rb_sprintf().
+ * @exception  rb_eLoadError  Always raises this.
+ * @note       It never returns.
+ */
+void rb_loaderror_with_path(VALUE path, const char *fmt, ...);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL((2))
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
+/**
+ * Raises an instance of ::rb_eNameError.  The name can be obtained later using
+ * `NameError#name` of the raising exception.
+ *
+ * @param[in]  name  What failed.
+ * @param[in]  fmt   Format specifier string compatible with rb_sprintf().
+ * @exception  rb_eNameError  Always raises this.
+ * @note       It never returns.
+ */
+void rb_name_error(ID name, const char *fmt, ...);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL((2))
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
+/**
+ * Identical to rb_name_error(), except it takes a ::VALUE instead of ::ID.
+ *
+ * @param[in]  name  What failed.
+ * @param[in]  fmt   Format specifier string compatible with rb_sprintf().
+ * @exception  rb_eNameError  Always raises this.
+ * @note       It never returns.
+ */
+void rb_name_error_str(VALUE name, const char *fmt, ...);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL((2))
+RBIMPL_ATTR_FORMAT(RBIMPL_PRINTF_FORMAT, 2, 3)
+/**
+ * Raises an instance  of ::rb_eFrozenError.  The object can  be obtained later
+ * using `FrozenError#receiver` of the raising exception.
+ *
+ * @param[in]  recv  What is frozen.
+ * @param[in]  fmt   Format specifier string compatible with rb_sprintf().
+ * @exception  rb_eFrozenError  Always raises this.
+ * @note       It never returns.
+ *
+ * @internal
+ *
+ * Note however,  that it  is often  not possible to  inspect a  frozen object,
+ * because the inspection itself could be forbidden by the frozen-ness.
+ */
+void rb_frozen_error_raise(VALUE recv, const char *fmt, ...);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL(())
+/**
+ * Honestly  I  don't  understand  the  name, but  it  raises  an  instance  of
+ * ::rb_eArgError.
+ *
+ * @param[in]  str           A message.
+ * @param[in]  type          Another message.
+ * @exception  rb_eArgError  Always raises this.
+ * @note       It never returns.
+ */
+void rb_invalid_str(const char *str, const char *type);
+
+RBIMPL_ATTR_NORETURN()
+RBIMPL_ATTR_NONNULL(())
+/**
+ * Identical  to rb_frozen_error_raise(),  except its  raising exception  has a
+ * message like "can't modify frozen /what/".
+ *
+ * @param[in]  what             What was frozen.
+ * @exception  rb_eFrozenError  Always raises this.
+ * @note       It never returns.
+ */
+void rb_error_frozen(const char *what);
+
+RBIMPL_ATTR_NORETURN()
+/**
+ * Identical  to  rb_error_frozen(),  except  it takes  arbitrary  Ruby  object
+ * instead of C's string.
+ *
+ * @param[in]  what             What was frozen.
+ * @exception  rb_eFrozenError  Always raises this.
+ * @note       It never returns.
+ */
+void rb_error_frozen_object(VALUE what);
+
+/**
+ * @deprecated  Does nothing.  This method is deprecated and will be removed in
+ *              Ruby 3.2.
+ */
 void rb_error_untrusted(VALUE);
-void rb_check_frozen(VALUE);
+
+/**
+ * Queries  if the  passed  object is  frozen.
+ *
+ * @param[in]  obj  Target object to test frozen-ness.
+ * @exception  rb_eFrozenError  It is frozen.
+ * @post       Upon successful return it is guaranteed _not_ frozen.
+ */
+void rb_check_frozen(VALUE obj);
+
+/**
+ * @deprecated  Does nothing.  This method is deprecated and will be removed in
+ *              Ruby 3.2.
+ */
 void rb_check_trusted(VALUE);
+
+/**
+ * Ensures that the passed object  can be `initialize_copy` relationship.  When
+ * you implement your own one you would better call this at the right beginning
+ * of your implementation.
+ *
+ * @param[in]  obj              Destination object.
+ * @param[in]  orig             Source object.
+ * @exception  rb_eFrozenError  `obj` is frozen.
+ * @post       Upon successful return obj is guaranteed safe to copy orig.
+ */
 void rb_check_copyable(VALUE obj, VALUE orig);
-NORETURN(MJIT_STATIC void rb_error_arity(int, int, int));
+
+RBIMPL_ATTR_NORETURN()
+/**
+ * @private
+ *
+ * This  is an  implementation detail  of  rb_scan_args().  You  don't have  to
+ * bother.
+ *
+ * @pre        `argc` is out of range of `min`..`max`, both inclusive.
+ * @param[in]  argc          Arbitrary integer.
+ * @param[in]  min           Minimum allowed `argc`.
+ * @param[in]  max           Maximum allowed `argc`.
+ * @exception  rb_eArgError  Always.
+ */
+MJIT_STATIC void rb_error_arity(int argc, int min, int max);
+
 RBIMPL_SYMBOL_EXPORT_END()
 
-/* Does anyone use this?  Remain not deleted for compatibility. */
+/**
+ * @deprecated
+ *
+ * Does anyone use this?  Remain not deleted for compatibility.
+ */
 #define rb_check_frozen_internal(obj) do { \
         VALUE frozen_obj = (obj); \
         if (RB_UNLIKELY(RB_OBJ_FROZEN(frozen_obj))) { \
@@ -62,6 +265,7 @@ RBIMPL_SYMBOL_EXPORT_END() https://github.com/ruby/ruby/blob/trunk/include/ruby/internal/intern/error.h#L265
         } \
     } while (0)
 
+/** @alias{rb_check_frozen} */
 static inl (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]