るりまサーチ (Ruby 2.3.0)

最速Rubyリファレンスマニュアル検索!
7件ヒット [1-7件を表示] (0.016秒)
トップページ > バージョン:2.3.0[x] > クエリ:Module[x] > ライブラリ:fiddle/import[x]

別のキーワード

  1. module attr
  2. module new
  3. erb def_module
  4. module constants
  5. module module_eval

モジュール

キーワード

検索結果

Fiddle::Importer#bind(signature, *opts) { ... } -> Fiddle::Function (25.0)

Ruby のブロックを C の関数で wrap し、その関数をモジュールに インポートします。

...::Function オブジェクトを返します。

@param signature 関数の名前とシネグチャ
@param opts オプション


require 'fiddle/import'

module M
extend Fiddle::Importer
dlload "libc.so.6"
typealias "size_t", "unsigned long"
extern "int qsort(void*, size_t,...

Fiddle::Importer#create_value(type, val = nil) -> Fiddle::CStruct (25.0)

型が type で要素名が "value" であるような構造体を 定義(Fiddle::Importer#struct)し、 その構造体のメモリを Fiddle::CStruct#malloc で確保し、 確保したメモリを保持しているオブジェクトを返します。

...された構造体に
その値を代入します。

@param type 型を表す文字列
@param val 構造体に確保される初期値


require 'fiddle/import'

module M
extend Fiddle::Importer
end

v = M.value("int", 32)
p v.value # => 32
v.value = 48
p v.value # => 48...

Fiddle::Importer#extern(signature, *opts) -> Fiddle::Function (25.0)

Fiddle::Importer#dlload で取り込んだライブラリから C の関数をインポートします。

...::Function オブジェクトを返します。

@param signature 関数の名前とシネグチャ
@param opts オプション


require 'fiddle/import'

module M
extern Fiddle::Importer
dlload "libc.so.6"
extern "int strcmp(char*, char*)"
end

M.strcmp("abc", "abc") # =...

Fiddle::Importer#sizeof(t) -> Integer (25.0)

C における sizeof(t) の値を返します。

...r t として文字列を渡し、それが表している型を Fiddle が知らなかった
場合に発生します

例:

require 'fiddle/import'

module M
extend Fiddle::Importer
Timeval = struct(["long tv_sec", "long tv_usec"])
p sizeof("char") # => 1
p sizeof("voi...

Fiddle::Importer#struct(signature) -> Class (25.0)

C の構造体型に対応する Ruby のクラスを構築して返します。

...くは
そちらを参照してください。


@param signature 構造体の各要素を文字列で表現したものの配列

require 'fiddle/import'

module M
extend Fiddle::Importer
dlload "libc.so.6"
extern "int gettimeofday(void*, void*)"
Timeval = struct(["long tv_sec...

絞り込み条件を変える

Fiddle::Importer#union(signature) -> Class (25.0)

C の共用体型に対応する Ruby のクラスを構築して返します。

...typedef union epoll_data
{
void *ptr;
int fd;
uint32_t u32;
uint64_t u64;
} epoll_data_t;
は、Ruby上では
require 'fiddle/import'

module M
extend Fiddle::Importer
dlload "libc.so.6"
typealias("uint32_t", "unsigned int")
typealias("uint64_t", "unsigne...

Fiddle::Importer#value(type, val = nil) -> Fiddle::CStruct (25.0)

型が type で要素名が "value" であるような構造体を 定義(Fiddle::Importer#struct)し、 その構造体のメモリを Fiddle::CStruct#malloc で確保し、 確保したメモリを保持しているオブジェクトを返します。

...された構造体に
その値を代入します。

@param type 型を表す文字列
@param val 構造体に確保される初期値


require 'fiddle/import'

module M
extend Fiddle::Importer
end

v = M.value("int", 32)
p v.value # => 32
v.value = 48
p v.value # => 48...