* README.EXT: should mention new macros: RSTRING_PTR, RSTRING_LEN,
RARRAY_PTR, RARRAY_LEN. * README.EXT.ja: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10950 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
46799937ee
commit
f208b3ad51
@ -1,3 +1,10 @@
|
|||||||
|
Sat Sep 16 19:47:16 2006 Yukihiro Matsumoto <matz@ruby-lang.org>
|
||||||
|
|
||||||
|
* README.EXT: should mention new macros: RSTRING_PTR, RSTRING_LEN,
|
||||||
|
RARRAY_PTR, RARRAY_LEN.
|
||||||
|
|
||||||
|
* README.EXT.ja: ditto.
|
||||||
|
|
||||||
Sat Sep 16 16:39:23 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sat Sep 16 16:39:23 2006 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb:
|
* Makefile.in, common.in, instruby.rb, ext/extmk.rb, lib/mkmf.rb:
|
||||||
|
@ -115,10 +115,10 @@ can be cast to retrieve the pointer to the struct. The casting macro
|
|||||||
will be of the form RXXXX for each data type; for instance, RARRAY(obj).
|
will be of the form RXXXX for each data type; for instance, RARRAY(obj).
|
||||||
See "ruby.h".
|
See "ruby.h".
|
||||||
|
|
||||||
For example, `RSTRING(str)->len' is the way to get the size of the
|
There are some accessing macros for structure members, for example
|
||||||
Ruby String object. The allocated region can be accessed by
|
`RSTRING_LEN(s)' to to get the size of the Ruby String object. The
|
||||||
`RSTRING(str)->ptr'. For arrays, use `RARRAY(ary)->len' and
|
allocated region can be accessed by `RSTRING_PTR(str). For arrays, use
|
||||||
`RARRAY(ary)->ptr' respectively.
|
`RARRAY_LEN(ary) and `RARRAY_PTR(ary) respectively.
|
||||||
|
|
||||||
Notice: Do not change the value of the structure directly, unless you
|
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
|
are responsible for the result. This ends up being the cause of interesting
|
||||||
|
@ -129,10 +129,11 @@ obsolete
|
|||||||
ruby.hでは構造体へキャストするマクロも「RXXXXX()」(全部大文
|
ruby.hでは構造体へキャストするマクロも「RXXXXX()」(全部大文
|
||||||
字にしたもの)という名前で提供されています(例: RSTRING()).
|
字にしたもの)という名前で提供されています(例: RSTRING()).
|
||||||
|
|
||||||
例えば,文字列strの長さを得るためには「RSTRING(str)->len」と
|
構造体からデータを取り出すマクロが提供されています。文字列
|
||||||
し,文字列strをchar*として得るためには「RSTRING(str)->ptr」
|
strの長さを得るためには「RSTRING_LEN(str)」とし,文字列strを
|
||||||
とします.配列の場合には,それぞれ「RARRAY(ary)->len」,
|
char*として得るためには「RSTRING_PTR(str)」とします.配列の
|
||||||
「RARRAY(ary)->ptr」となります.
|
場合には,それぞれ「RARRAY_LEN(ary)」,「RARRAY_PTR(ary)」と
|
||||||
|
なります.
|
||||||
|
|
||||||
Rubyの構造体を直接アクセスする時に気をつけなければならないこ
|
Rubyの構造体を直接アクセスする時に気をつけなければならないこ
|
||||||
とは,配列や文字列の構造体の中身は参照するだけで,直接変更し
|
とは,配列や文字列の構造体の中身は参照するだけで,直接変更し
|
||||||
|
Loading…
x
Reference in New Issue
Block a user