mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 53320,54756: [Backport #12246]
* doc/extension.rdoc: [DOC] `nul` should be uppercase. change 'nul' => 'NUL'. [Fix GH-1172] * doc/extension.rdoc: Improvements to english grammers. [Bug #12246][ruby-core:74792][ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@54766 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
2d360c5e95
commit
52c883bee3
4 changed files with 40 additions and 30 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
||||||
|
Tue Apr 26 02:58:51 2016 Marcus Stollsteimer <sto.mar@web.de>
|
||||||
|
|
||||||
|
* doc/extension.rdoc: Improvements to english grammers.
|
||||||
|
[Bug #12246][ruby-core:74792][ci skip]
|
||||||
|
|
||||||
|
Tue Apr 26 02:58:51 2016 craft4coder <yooobuntu@163.com>
|
||||||
|
|
||||||
|
* doc/extension.rdoc: [DOC] `nul` should be uppercase.
|
||||||
|
change 'nul' => 'NUL'. [Fix GH-1172]
|
||||||
|
|
||||||
Tue Apr 26 02:54:57 2016 Marcus Stollsteimer <sto.mar@web.de>
|
Tue Apr 26 02:54:57 2016 Marcus Stollsteimer <sto.mar@web.de>
|
||||||
|
|
||||||
* encoding.c: Fix return value of `Encoding::ISO8859_1.name`
|
* encoding.c: Fix return value of `Encoding::ISO8859_1.name`
|
||||||
|
|
|
@ -126,10 +126,10 @@ var は lvalue である必要があります.
|
||||||
また,StringValuePtr() に類似した StringValueCStr() というマ
|
また,StringValuePtr() に類似した StringValueCStr() というマ
|
||||||
クロもあります.StringValueCStr(var) は var を String に置き
|
クロもあります.StringValueCStr(var) は var を String に置き
|
||||||
換えてから var の文字列表現に対する char* を返します.返され
|
換えてから var の文字列表現に対する char* を返します.返され
|
||||||
る文字列の末尾には nul 文字が付加されます.なお,途中に nul
|
る文字列の末尾には NUL 文字が付加されます.なお,途中に NUL
|
||||||
文字が含まれる場合は ArgumentError が発生します.
|
文字が含まれる場合は ArgumentError が発生します.
|
||||||
一方,StringValuePtr() では,末尾に nul 文字がある保証はなく,
|
一方,StringValuePtr() では,末尾に NUL 文字がある保証はなく,
|
||||||
途中に nul 文字が含まれている可能性もあります.
|
途中に NUL 文字が含まれている可能性もあります.
|
||||||
|
|
||||||
それ以外のデータタイプは対応するCの構造体があります.対応す
|
それ以外のデータタイプは対応するCの構造体があります.対応す
|
||||||
る構造体のあるVALUEはそのままキャスト(型変換)すれば構造体の
|
る構造体のあるVALUEはそのままキャスト(型変換)すれば構造体の
|
||||||
|
|
|
@ -9,7 +9,7 @@ Ruby variables do not have a static type, and data themselves have
|
||||||
types, so data will need to be converted between the languages.
|
types, so data will need to be converted between the languages.
|
||||||
|
|
||||||
Data in Ruby are represented by the C type `VALUE'. Each VALUE data
|
Data in Ruby are represented by the C type `VALUE'. Each VALUE data
|
||||||
has its data-type.
|
has its data type.
|
||||||
|
|
||||||
To retrieve C data from a VALUE, you need to:
|
To retrieve C data from a VALUE, you need to:
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ To retrieve C data from a VALUE, you need to:
|
||||||
|
|
||||||
Converting to the wrong data type may cause serious problems.
|
Converting to the wrong data type may cause serious problems.
|
||||||
|
|
||||||
== Data-Types
|
== Data Types
|
||||||
|
|
||||||
The Ruby interpreter has the following data types:
|
The Ruby interpreter has the following data types:
|
||||||
|
|
||||||
|
@ -74,7 +74,7 @@ data types, your code will look something like this:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
There is the data-type check function
|
There is the data type check function
|
||||||
|
|
||||||
void Check_Type(VALUE value, int type)
|
void Check_Type(VALUE value, int type)
|
||||||
|
|
||||||
|
@ -94,7 +94,7 @@ The equivalent C constants are: Qnil, Qfalse, Qtrue.
|
||||||
Note that Qfalse is false in C also (i.e. 0), but not Qnil.
|
Note that Qfalse is false in C also (i.e. 0), but not Qnil.
|
||||||
|
|
||||||
The T_FIXNUM data is a 31bit or 63bit length fixed integer.
|
The T_FIXNUM data is a 31bit or 63bit length fixed integer.
|
||||||
This size is depend on the size of long: if long is 32bit then
|
This size depends on the size of long: if long is 32bit then
|
||||||
T_FIXNUM is 31bit, if long is 64bit then T_FIXNUM is 63bit.
|
T_FIXNUM is 31bit, if long is 64bit then T_FIXNUM is 63bit.
|
||||||
T_FIXNUM can be converted to a C integer by using the
|
T_FIXNUM can be converted to a C integer by using the
|
||||||
FIX2INT() macro or FIX2LONG(). Though you have to check that the
|
FIX2INT() macro or FIX2LONG(). Though you have to check that the
|
||||||
|
@ -102,32 +102,32 @@ data is really FIXNUM before using them, they are faster. FIX2LONG()
|
||||||
never raises exceptions, but FIX2INT() raises RangeError if the
|
never raises exceptions, but FIX2INT() raises RangeError if the
|
||||||
result is bigger or smaller than the size of int.
|
result is bigger or smaller than the size of int.
|
||||||
There are also NUM2INT() and NUM2LONG() which converts any Ruby
|
There are also NUM2INT() and NUM2LONG() which converts any Ruby
|
||||||
numbers into C integers. These macros includes a type check,
|
numbers into C integers. These macros include a type check,
|
||||||
so an exception will be raised if the conversion failed. NUM2DBL()
|
so an exception will be raised if the conversion failed. NUM2DBL()
|
||||||
can be used to retrieve the double float value in the same way.
|
can be used to retrieve the double float value in the same way.
|
||||||
|
|
||||||
You can use the macros
|
You can use the macros
|
||||||
StringValue() and StringValuePtr() to get a char* from a VALUE.
|
StringValue() and StringValuePtr() to get a char* from a VALUE.
|
||||||
StringValue(var) replaces var's value with the result of "var.to_str()".
|
StringValue(var) replaces var's value with the result of "var.to_str()".
|
||||||
StringValuePtr(var) does same replacement and returns char*
|
StringValuePtr(var) does the same replacement and returns the char*
|
||||||
representation of var. These macros will skip the replacement if var
|
representation of var. These macros will skip the replacement if var
|
||||||
is a String. Notice that the macros take only the lvalue as their
|
is a String. Notice that the macros take only the lvalue as their
|
||||||
argument, to change the value of var in place.
|
argument, to change the value of var in place.
|
||||||
|
|
||||||
You can also use the macro named StringValueCStr(). This is just
|
You can also use the macro named StringValueCStr(). This is just
|
||||||
like StringValuePtr(), but always add nul character at the end of
|
like StringValuePtr(), but always adds a NUL character at the end of
|
||||||
the result. If the result contains nul character, this macro causes
|
the result. If the result contains a NUL character, this macro causes
|
||||||
the ArgumentError exception.
|
the ArgumentError exception.
|
||||||
StringValuePtr() doesn't guarantee the existence of a nul at the end
|
StringValuePtr() doesn't guarantee the existence of a NUL at the end
|
||||||
of the result, and the result may contain nul.
|
of the result, and the result may contain NUL.
|
||||||
|
|
||||||
Other data types have corresponding C structures, e.g. struct RArray
|
Other data types have corresponding C structures, e.g. struct RArray
|
||||||
for T_ARRAY etc. The VALUE of the type which has the corresponding
|
for T_ARRAY etc. The VALUE of the type which has the corresponding
|
||||||
structure can be cast to retrieve the pointer to the struct. The
|
structure can be cast to retrieve the pointer to the struct. The
|
||||||
casting macro will be of the form RXXXX for each data type; for
|
casting macro will be of the form RXXXX for each data type; for
|
||||||
instance, RARRAY(obj). See "ruby.h". However, we do not recommend
|
instance, RARRAY(obj). See "ruby.h". However, we do not recommend
|
||||||
to access RXXXX data directly because these data structure is complex.
|
to access RXXXX data directly because these data structures are complex.
|
||||||
Use corresponding rb_xxx() functions to access internal struct.
|
Use corresponding rb_xxx() functions to access the internal struct.
|
||||||
For example, to access an entry of array, use rb_ary_entry(ary, offset)
|
For example, to access an entry of array, use rb_ary_entry(ary, offset)
|
||||||
and rb_ary_store(ary, offset, obj).
|
and rb_ary_store(ary, offset, obj).
|
||||||
|
|
||||||
|
@ -145,22 +145,22 @@ To convert C data to Ruby values:
|
||||||
|
|
||||||
FIXNUM ::
|
FIXNUM ::
|
||||||
|
|
||||||
left shift 1 bit, and turn on LSB.
|
left shift 1 bit, and turn on its least significant bit (LSB).
|
||||||
|
|
||||||
Other pointer values ::
|
Other pointer values ::
|
||||||
|
|
||||||
cast to VALUE.
|
cast to VALUE.
|
||||||
|
|
||||||
You can determine whether a VALUE is pointer or not by checking its LSB.
|
You can determine whether a VALUE is a pointer or not by checking its LSB.
|
||||||
|
|
||||||
Notice Ruby does not allow arbitrary pointer values to be a VALUE. They
|
Notice: Ruby does not allow arbitrary pointer values to be a VALUE. They
|
||||||
should be pointers to the structures which Ruby knows about. The known
|
should be pointers to the structures which Ruby knows about. The known
|
||||||
structures are defined in <ruby.h>.
|
structures are defined in <ruby.h>.
|
||||||
|
|
||||||
To convert C numbers to Ruby values, use these macros.
|
To convert C numbers to Ruby values, use these macros:
|
||||||
|
|
||||||
INT2FIX() :: for integers within 31bits.
|
INT2FIX() :: for integers within 31bits.
|
||||||
INT2NUM() :: for arbitrary sized integer.
|
INT2NUM() :: for arbitrary sized integers.
|
||||||
|
|
||||||
INT2NUM() converts an integer into a Bignum if it is out of the FIXNUM
|
INT2NUM() converts an integer into a Bignum if it is out of the FIXNUM
|
||||||
range, but is a bit slower.
|
range, but is a bit slower.
|
||||||
|
@ -258,7 +258,7 @@ rb_utf8_str_new_literal(const char *ptr) ::
|
||||||
|
|
||||||
rb_str_resize(VALUE str, long len) ::
|
rb_str_resize(VALUE str, long len) ::
|
||||||
|
|
||||||
Resizes Ruby string to len bytes. If str is not modifiable, this
|
Resizes a Ruby string to len bytes. If str is not modifiable, this
|
||||||
function raises an exception. The length of str must be set in
|
function raises an exception. The length of str must be set in
|
||||||
advance. If len is less than the old length the content beyond
|
advance. If len is less than the old length the content beyond
|
||||||
len bytes is discarded, else if len is greater than the old length
|
len bytes is discarded, else if len is greater than the old length
|
||||||
|
@ -268,9 +268,9 @@ rb_str_resize(VALUE str, long len) ::
|
||||||
|
|
||||||
rb_str_set_len(VALUE str, long len) ::
|
rb_str_set_len(VALUE str, long len) ::
|
||||||
|
|
||||||
Sets the length of Ruby string. If str is not modifiable, this
|
Sets the length of a Ruby string. If str is not modifiable, this
|
||||||
function raises an exception. This function preserves the content
|
function raises an exception. This function preserves the content
|
||||||
upto len bytes, regardless RSTRING_LEN(str). len must not exceed
|
up to len bytes, regardless RSTRING_LEN(str). len must not exceed
|
||||||
the capacity of str.
|
the capacity of str.
|
||||||
|
|
||||||
=== Array Functions
|
=== Array Functions
|
||||||
|
@ -400,9 +400,9 @@ There are two functions to define private/protected methods:
|
||||||
void rb_define_protected_method(VALUE klass, const char *name,
|
void rb_define_protected_method(VALUE klass, const char *name,
|
||||||
VALUE (*func)(), int argc)
|
VALUE (*func)(), int argc)
|
||||||
|
|
||||||
At last, rb_define_module_function defines a module functions,
|
At last, rb_define_module_function defines a module function,
|
||||||
which are private AND singleton methods of the module.
|
which are private AND singleton methods of the module.
|
||||||
For example, sqrt is the module function defined in Math module.
|
For example, sqrt is a module function defined in the Math module.
|
||||||
It can be called in the following way:
|
It can be called in the following way:
|
||||||
|
|
||||||
Math.sqrt(4)
|
Math.sqrt(4)
|
||||||
|
@ -478,7 +478,7 @@ function:
|
||||||
|
|
||||||
VALUE rb_eval_string_protect(const char *str, int *state)
|
VALUE rb_eval_string_protect(const char *str, int *state)
|
||||||
|
|
||||||
It returns nil when an error occur. Moreover, *state is zero if str was
|
It returns nil when an error occurred. Moreover, *state is zero if str was
|
||||||
successfully evaluated, or nonzero otherwise.
|
successfully evaluated, or nonzero otherwise.
|
||||||
|
|
||||||
=== ID or Symbol
|
=== ID or Symbol
|
||||||
|
@ -562,7 +562,7 @@ See also Constant Definition above.
|
||||||
|
|
||||||
= Information Sharing Between Ruby and C
|
= Information Sharing Between Ruby and C
|
||||||
|
|
||||||
=== Ruby Constants That C Can Be Accessed From C
|
=== Ruby Constants That Can Be Accessed From C
|
||||||
|
|
||||||
As stated in section 1.3,
|
As stated in section 1.3,
|
||||||
the following Ruby constants can be referred from C.
|
the following Ruby constants can be referred from C.
|
||||||
|
@ -746,7 +746,7 @@ A pointer to the structure will be assigned to the variable sval.
|
||||||
|
|
||||||
See the example below for details.
|
See the example below for details.
|
||||||
|
|
||||||
= Example - Creating dbm Extension
|
= Example - Creating the dbm Extension
|
||||||
|
|
||||||
OK, here's the example of making an extension library. This is the
|
OK, here's the example of making an extension library. This is the
|
||||||
extension to access DBMs. The full source is included in the ext/
|
extension to access DBMs. The full source is included in the ext/
|
||||||
|
@ -1249,7 +1249,7 @@ rb_str_new2(s) ::
|
||||||
|
|
||||||
char * -> String
|
char * -> String
|
||||||
|
|
||||||
== Defining Class and Module
|
== Defining Classes and Modules
|
||||||
|
|
||||||
VALUE rb_define_class(const char *name, VALUE super) ::
|
VALUE rb_define_class(const char *name, VALUE super) ::
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#define RUBY_VERSION "2.3.0"
|
#define RUBY_VERSION "2.3.0"
|
||||||
#define RUBY_RELEASE_DATE "2016-04-26"
|
#define RUBY_RELEASE_DATE "2016-04-26"
|
||||||
#define RUBY_PATCHLEVEL 110
|
#define RUBY_PATCHLEVEL 111
|
||||||
|
|
||||||
#define RUBY_RELEASE_YEAR 2016
|
#define RUBY_RELEASE_YEAR 2016
|
||||||
#define RUBY_RELEASE_MONTH 4
|
#define RUBY_RELEASE_MONTH 4
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue