1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* ext/dl/handle.c (**) adding documentation

* test/dl/test_handle.rb (**) testing to_i and initialize

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25461 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
tenderlove 2009-10-25 00:11:29 +00:00
parent 60f86b2edb
commit 159e6439c0
2 changed files with 27 additions and 0 deletions

View file

@ -100,6 +100,13 @@ predefined_dlhandle(void *handle)
return obj;
}
/*
* call-seq:
* initialize(lib = nil, flags = DL::RTLD_LAZY | DL::RTLD_GLOBAL)
*
* Create a new handler that opens library named +lib+ with +flags+. If no
* library is specified, RTLD_DEFAULT is used.
*/
VALUE
rb_dlhandle_initialize(int argc, VALUE argv[], VALUE self)
{
@ -194,6 +201,11 @@ rb_dlhandle_disable_close(VALUE self)
return Qnil;
}
/*
* call-seq: to_i
*
* Returns the memory address for this handle.
*/
VALUE
rb_dlhandle_to_i(VALUE self)
{

View file

@ -2,6 +2,11 @@ require 'test_base'
module DL
class TestHandle < TestBase
def test_to_i
handle = DL::Handle.new(LIBC_SO)
assert handle.to_i
end
def test_static_sym_secure
assert_raises(SecurityError) do
Thread.new do
@ -90,5 +95,15 @@ module DL
end.join
end
end
def test_initialize_noargs
handle = DL::Handle.new
assert handle['rb_str_new']
end
def test_initialize_flags
handle = DL::Handle.new(LIBC_SO, DL::RTLD_LAZY | DL::RTLD_GLOBAL)
assert handle['calloc']
end
end
end