summaryrefslogtreecommitdiffstats
path: root/ext/dl
diff options
context:
space:
mode:
authorttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-11 03:06:33 +0000
committerttate <ttate@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2002-04-11 03:06:33 +0000
commit20d7a9e59f4f644f3e6d14d2cc6276c8d434c612 (patch)
treeb38da9ce8144fefe82cd6b932ae2822751280a40 /ext/dl
parent3684a4ae35cc7d8117375be72c6a32675f674bc7 (diff)
downloadruby-20d7a9e59f4f644f3e6d14d2cc6276c8d434c612.tar.gz
ruby-20d7a9e59f4f644f3e6d14d2cc6276c8d434c612.tar.xz
ruby-20d7a9e59f4f644f3e6d14d2cc6276c8d434c612.zip
define alias "struct" and "union" in the module Importable.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@2355 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/dl')
-rw-r--r--ext/dl/lib/dl/struct.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb
index 6c21af71a..eb727762a 100644
--- a/ext/dl/lib/dl/struct.rb
+++ b/ext/dl/lib/dl/struct.rb
@@ -10,11 +10,13 @@ module DL
init_types()
Struct.new(@types, contents)
end
+ alias struct define_struct
def define_union(contents)
init_types()
Union.new(@types, contents)
end
+ alias union define_union
class Memory
def initialize(ptr, names, ty, len, enc, dec)
@@ -56,8 +58,11 @@ module DL
parse(contents)
end
- def new
- ptr = DL::malloc(@size)
+ def new(size = nil)
+ if( !size )
+ size = @size
+ end
+ ptr = DL::malloc(size)
ptr.struct!(@tys, *@names)
mem = Memory.new(ptr, @names, @ty, @len, @enc, @dec)
return mem