64件ヒット
[1-64件を表示]
(0.086秒)
別のキーワード
ライブラリ
- ビルトイン (4)
-
fiddle
/ import (36) - rake (24)
クラス
-
Rake
:: Application (12) -
Rake
:: FileList (12) - Refinement (4)
モジュール
-
Fiddle
:: Importer (36)
キーワード
-
add
_ loader (12) - bind (12)
-
import
_ methods (4) - struct (12)
- union (12)
検索結果
先頭5件
-
Rake
:: FileList # import(array) -> self (18114.0) -
与えられた配列を自身にインポートします。
...指定します。
//emlist[][ruby]{
# Rakefile での記載例とする
IO.write("test1.rb", "test")
IO.write("test2.rb", "test")
task default: :test_rake_app
task :test_rake_app do
file_list = FileList.new("test1.rb", "test2.rb", "test3.rb")
file_list.import(["test4.rb", "test5.rb"]) # => [... -
Refinement
# import _ methods(*modules) -> self (6144.0) -
モジュールからメソッドをインポートします。
...ポートします。
Module#includeと違って、import_methods はメソッドをコピーして
refinement に追加して、refinementでインポートしたメソッドを有効化します。
メソッドをコピーするため、Rubyコードで定義されたメソッドだけしか
イ......[ruby]{
module StrUtils
def indent(level)
' ' * level + self
end
end
module M
refine String do
import_methods StrUtils
end
end
using M
p "foo".indent(3) # => " foo"
module M
refine String do
import_methods Enumerable
# Can't import method which is not defined with Ruby... -
Fiddle
:: Importer # union(signature) -> Class (3035.0) -
C の共用体型に対応する Ruby のクラスを構築して返します。
...する Ruby のクラスを構築して返します。
共用体型を Ruby 上で定義する方法は Fiddle::Importer#struct と
ほぼ同様です。C における
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", "unsigned long long")
EPollData = union(["void *ptr",
"int fd",
"uint32_t u32",... -
Fiddle
:: Importer # bind(signature , *opts) { . . . } -> Fiddle :: Function (3023.0) -
Ruby のブロックを C の関数で wrap し、その関数をモジュールに インポートします。
...Ruby のブロックを C の関数で wrap し、その関数をモジュールに
インポートします。
これでインポートされた関数はモジュール関数として定義されます。
また、Fiddle::Importer#[] で Fiddle::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, size_t, void*)"... -
Fiddle
:: Importer # struct(signature) -> Class (3023.0) -
C の構造体型に対応する Ruby のクラスを構築して返します。
...C の構造体型に対応する Ruby のクラスを構築して返します。
構造体の各要素は C と似せた表記ができます。そしてそれを
配列で signature に渡してデータを定義します。例えば C における
struct timeval {
long tv_sec;
long tv_u......照してください。
@param signature 構造体の各要素を文字列で表現したものの配列
require 'fiddle/import'
module M
extend Fiddle::Importer
dlload "libc.so.6"
extern "int gettimeofday(void*, void*)"
Timeval = struct(["long tv_sec", "long tv_usec"])... -
Rake
:: Application # add _ loader(ext , loader) (13.0) -
与えられた拡張子で終わるファイル名のファイルをロードするためのローダーを 自身に追加します。
...][ruby]{
require "rake/loaders/makefile"
# Rakefile での記載例とする
task default: :test
task :test
makefile =<<-EOS
<< <<-'SAMPLE_MF'
# Comments
a: a1 a2 a3 a4
EOS
IO.write("sample.mf", makefile)
Rake.application.add_loader("mf", Rake::MakefileLoader.new)
Rake.application.add_import("sam......ple.mf")
Rake::Task.task_defined?("a") # => false
Rake.application.load_imports
Rake::Task.task_defined?("a") # => true
//}...