Skip to content

Commit

Permalink
[DOC] Update extension.rdoc
Browse files Browse the repository at this point in the history
Refine the uses of word "Data", which were often ambiguous.  Also,
that word now refers the new class unrelated to `T_DATA`.
  • Loading branch information
nobu committed Dec 26, 2022
1 parent b37e9c7 commit cb820bf
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
10 changes: 5 additions & 5 deletions doc/extension.ja.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -888,12 +888,12 @@ dbm.cではTypedData_Make_Structを以下のように使っています.

obj = TypedData_Make_Struct(klass, struct dbmdata, &dbm_type, dbmp);

ここではdbmdata構造体へのポインタをDataにカプセル化してい
ます.DBM*を直接カプセル化しないのはclose()した時の処理を考
えてのことです
ここではdbmdata構造体へのポインタをRubyオブジェクトにカプセ
ル化しています.DBM*を直接カプセル化しないのはclose()した時
の処理を考えてのことです

Dataオブジェクトからdbmstruct構造体のポインタを取り出すため
に以下のマクロを使っています
Rubyオブジェクトからdbmdata構造体のポインタを取り出すために
以下のマクロを使っています

#define GetDBM(obj, dbmp) do {\
TypedData_Get_Struct((obj), struct dbmdata, &dbm_type, (dbmp));\
Expand Down
24 changes: 12 additions & 12 deletions doc/extension.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ In C, variables have types and data do not have types. In contrast,
Ruby variables do not have a static type, and data themselves have
types, so data will need to be converted between the languages.

Data in Ruby are represented by the C type `VALUE'. Each VALUE data
has its data type.
Objects in Ruby are represented by the C type `VALUE'. Each VALUE
data has its data type.

To retrieve C data from a VALUE, you need to:

Expand All @@ -20,7 +20,7 @@ To retrieve C data from a VALUE, you need to:

Converting to the wrong data type may cause serious problems.

=== Data Types
=== Ruby data types

The Ruby interpreter has the following data types:

Expand Down Expand Up @@ -54,7 +54,7 @@ T_ZOMBIE :: object awaiting finalization

Most of the types are represented by C structures.

=== Check Data Type of the VALUE
=== Check type of the VALUE data

The macro TYPE() defined in ruby.h shows the data type of the VALUE.
TYPE() returns the constant number T_XXXX described above. To handle
Expand Down Expand Up @@ -88,7 +88,7 @@ There are also faster check macros for fixnums and nil.
FIXNUM_P(obj)
NIL_P(obj)

=== Convert VALUE into C Data
=== Convert VALUE into C data

The data for type T_NIL, T_FALSE, T_TRUE are nil, false, true
respectively. They are singletons for the data type.
Expand Down Expand Up @@ -143,7 +143,7 @@ Notice: Do not change the value of the structure directly, unless you
are responsible for the result. This ends up being the cause of
interesting bugs.

=== Convert C Data into VALUE
=== Convert C data into VALUE

To convert C data to Ruby values:

Expand All @@ -169,7 +169,7 @@ 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.

=== Manipulating Ruby Data
=== Manipulating Ruby object

As I already mentioned, it is not recommended to modify an object's
internal structure. To manipulate objects, use the functions supplied
Expand Down Expand Up @@ -636,7 +636,7 @@ The prototypes of the getter and setter functions are as follows:
VALUE (*getter)(ID id);
void (*setter)(VALUE val, ID id);

=== Encapsulate C Data into a Ruby Object
=== Encapsulate C data into a Ruby object

Sometimes you need to expose your struct in the C world as a Ruby
object.
Expand Down Expand Up @@ -762,7 +762,7 @@ You can allocate and wrap the structure in one step.

TypedData_Make_Struct(klass, type, data_type, sval)

This macro returns an allocated Data object, wrapping the pointer to
This macro returns an allocated T_DATA object, wrapping the pointer to
the structure, which is also allocated. This macro works like:

(sval = ZALLOC(type), TypedData_Wrap_Struct(klass, data_type, sval))
Expand All @@ -773,7 +773,7 @@ be assigned to sval, which should be a pointer of the type specified.

==== Ruby object to C struct

To retrieve the C pointer from the Data object, use the macro
To retrieve the C pointer from the T_DATA object, use the macro
TypedData_Get_Struct().

TypedData_Get_Struct(obj, type, &data_type, sval)
Expand Down Expand Up @@ -1225,7 +1225,7 @@ Data_Get_Struct(data, type, sval) ::
This macro retrieves the pointer value from DATA, and assigns it to
the variable sval.

=== Checking Data Types
=== Checking VALUE types

RB_TYPE_P(value, type) ::

Expand Down Expand Up @@ -1255,7 +1255,7 @@ void Check_Type(VALUE value, int type) ::

Ensures +value+ is of the given internal +type+ or raises a TypeError

=== Data Type Conversion
=== VALUE type conversion

FIX2INT(value), INT2FIX(i) ::

Expand Down

0 comments on commit cb820bf

Please sign in to comment.