mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
3 changed files with 16 additions and 8 deletions
|
@ -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>
|
||||
|
||||
* 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).
|
||||
See "ruby.h".
|
||||
|
||||
For example, `RSTRING(str)->len' is the way to get the size of the
|
||||
Ruby String object. The allocated region can be accessed by
|
||||
`RSTRING(str)->ptr'. For arrays, use `RARRAY(ary)->len' and
|
||||
`RARRAY(ary)->ptr' respectively.
|
||||
There are some accessing macros for structure members, for example
|
||||
`RSTRING_LEN(s)' to to get the size of the Ruby String object. The
|
||||
allocated region can be accessed by `RSTRING_PTR(str). For arrays, use
|
||||
`RARRAY_LEN(ary) and `RARRAY_PTR(ary) respectively.
|
||||
|
||||
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
|
||||
|
|
|
@ -129,10 +129,11 @@ obsolete
|
|||
ruby.hでは構造体へキャストするマクロも「RXXXXX()」(全部大文
|
||||
字にしたもの)という名前で提供されています(例: RSTRING()).
|
||||
|
||||
例えば,文字列strの長さを得るためには「RSTRING(str)->len」と
|
||||
し,文字列strをchar*として得るためには「RSTRING(str)->ptr」
|
||||
とします.配列の場合には,それぞれ「RARRAY(ary)->len」,
|
||||
「RARRAY(ary)->ptr」となります.
|
||||
構造体からデータを取り出すマクロが提供されています。文字列
|
||||
strの長さを得るためには「RSTRING_LEN(str)」とし,文字列strを
|
||||
char*として得るためには「RSTRING_PTR(str)」とします.配列の
|
||||
場合には,それぞれ「RARRAY_LEN(ary)」,「RARRAY_PTR(ary)」と
|
||||
なります.
|
||||
|
||||
Rubyの構造体を直接アクセスする時に気をつけなければならないこ
|
||||
とは,配列や文字列の構造体の中身は参照するだけで,直接変更し
|
||||
|
|
Loading…
Reference in a new issue