summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-12-13 13:05:40 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-12-13 13:21:53 +0900
commit9ad34da47ff7d71446e667897559047ed5635b60 (patch)
tree69ea8db15c2c56357659a793c92955274fa3934a
parent54f0e63a8c53753af7db8653972ac450415eae13 (diff)
[DOC] Mention RBOOL in extension.rdoc [Feature #13125]
-rw-r--r--doc/extension.ja.rdoc15
-rw-r--r--doc/extension.rdoc15
2 files changed, 30 insertions, 0 deletions
diff --git a/doc/extension.ja.rdoc b/doc/extension.ja.rdoc
index 3b68ec6cbc..feae7b97da 100644
--- a/doc/extension.ja.rdoc
+++ b/doc/extension.ja.rdoc
@@ -190,6 +190,21 @@ INT2NUM() :: 任意の整数からVALUEへ
INT2NUM()は整数がFIXNUMの範囲に収まらない場合,Bignumに変換
してくれます(が,少し遅い).
+Cの真偽値をRubyの +true+ または +false+ に変換する
+
+RBOOL() ::
+
+<code>RBOOL(v)</code> は _v_ が非0のとき +Qtrue+ ,それ以外
+の _v_ が0のとき +Qfalse+ を返します.
+
+注意: RBOOLは定義されているのはRuby 3.1以降なので,それより
+古いバージョンをサポートするプログラム中で使いたいときは,以
+下のような定義を追加しておく必要があるでしょう.
+
+ #ifndef RBOOL
+ #define RBOOL(v) ((v) ? Qtrue : Qfalse)
+ #endif
+
=== Rubyのデータを操作する
先程も述べた通り,Rubyの構造体をアクセスする時に内容の更新を
diff --git a/doc/extension.rdoc b/doc/extension.rdoc
index 15417179e1..12cff6b497 100644
--- a/doc/extension.rdoc
+++ b/doc/extension.rdoc
@@ -169,6 +169,21 @@ INT2NUM() :: for arbitrary sized integers.
INT2NUM() converts an integer into a Bignum if it is out of the FIXNUM
range, but is a bit slower.
+To convert C boolean to Ruby +true+ or +false+ :
+
+RBOOL() ::
+
+<code>RBOOL(v)</code> returns +Qtrue+ if _v_ is not 0, or +Qfalse+
+otherwisze _v_ is 0.
+
+Notice: RBOOL is defined since Ruby 3.1, if you want to use it in a
+program which supports older versions, the fallback definition will be
+needed, like as the following.
+
+ #ifndef RBOOL
+ #define RBOOL(v) ((v) ? Qtrue : Qfalse)
+ #endif
+
=== Manipulating Ruby Data
As I already mentioned, it is not recommended to modify an object's