カテゴリー
Wiki内検索
*
最近更新したページ
最新コメント
win32/guitest by stunning seo guys
FrontPage by stunning seo guys
SWIG by awesome things!
Win32/Console by stunning seo guys
FrontPage by awesome things!
Win32SDK_ICM by stunning seo guys
Win32SDK_MM by check it out
Win32SDK_process by stunning seo guys
VisualuRuby by stunning seo guys

ruby-dl2/doc/struct.txt

ruby-dl2

struct.txt


NAME


dl/struct.rb

SYNOPSIS


module LIBC
  extend DL::Importer

  # create a class which provides methods for accessing structure
  # members or union members.
  Timeval = struct [
    "long tv_sec",
    "long tv_usec",
  ]
end

# create a proxy object to deal with a memory block addressed by 'addr'.
struct1 = LIBC::Timeval.new(addr)

# allocate a memory and create a proxy object to deal with it.
struct2 = LIBC::Timeval.malloc()

# access members.
struct1.tv_sec()
struct1.tv_usec()

# obtain a pointer as a CPtr object.
ptr = struct1.to_ptr()
 
# obtain a pointer as an address.
addr = struct1.to_i()

# allocate a memory for an int value, create a proxy object for the memory
# and returns the proxy object.
struct3 = LIBC.value("int", 0)
val = struct3.value()

DESCRIPTION


dl/struct.rb provides methods so that we can easily deal with a memory.

BUGS


SEE ALSO


dl.so, dl/import.rb, dl/func.rb
2006年09月20日(水) 17:24:20 Modified by aqualung




スマートフォン版で見る