diff options
| author | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-02-06 06:54:12 +0000 |
|---|---|---|
| committer | ttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2005-02-06 06:54:12 +0000 |
| commit | 2daa629e268a51d7d668c3c12c3f04777fc81228 (patch) | |
| tree | 165dde56bed8257b9f3028135dc50b438f8d5060 /ext/dl/lib | |
| parent | b9b2c6c2e88ddffc85d6629cebf446b9a2f3ec82 (diff) | |
| download | ruby-2daa629e268a51d7d668c3c12c3f04777fc81228.tar.gz ruby-2daa629e268a51d7d668c3c12c3f04777fc81228.tar.xz ruby-2daa629e268a51d7d668c3c12c3f04777fc81228.zip | |
added DL::Importer.sizeof().
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@7897 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl/lib')
| -rw-r--r-- | ext/dl/lib/dl/import.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/ext/dl/lib/dl/import.rb b/ext/dl/lib/dl/import.rb index 2f21e9195..2ad805598 100644 --- a/ext/dl/lib/dl/import.rb +++ b/ext/dl/lib/dl/import.rb @@ -62,6 +62,38 @@ module DL @type_alias[alias_type] = orig_type end + def sizeof(ty) + case ty + when String + ty = parse_ctype(ty, @type_alias).abs() + case ty + when TYPE_CHAR + return SIZEOF_CHAR + when TYPE_SHORT + return SIZEOF_SHORT + when TYPE_INT + return SIZEOF_INT + when TYPE_LONG + return SIZEOF_LONG + when TYPE_LONG_LONG + return SIZEOF_LONG_LON + when TYPE_FLOAT + return SIZEOF_FLOAT + when TYPE_DOUBLE + return SIZEOF_DOUBLE + when TYPE_VOIDP + return SIZEOF_VOIDP + else + raise(DLError, "unknown type: #{ty}") + end + when Class + if( ty.instance_methods().include?("to_ptr") ) + return ty.size() + end + end + return CPtr[ty].size() + end + def parse_bind_options(opts) h = {} prekey = nil |
