diff --git a/ext/dl/lib/dl/struct.rb b/ext/dl/lib/dl/struct.rb index b16aa6e6b0..6c21af71ac 100644 --- a/ext/dl/lib/dl/struct.rb +++ b/ext/dl/lib/dl/struct.rb @@ -30,7 +30,12 @@ module DL instance_eval [ "def #{name}", " v = @ptr[\"#{name}\"]", - " v = @dec[\"#{name}\"].call(v,#{@len}) if @dec[\"#{name}\"]", + " v = @dec[\"#{name}\"].call(v,@len[\"#{name}\"]) if @dec[\"#{name}\"]", + " return v", + "end", + "def #{name}=(v)", + " v = @enc[\"#{name}\"].call(v,@len[\"#{name}\"]) if @enc[\"#{name}\"]", + " @ptr[\"#{name}\"] = v", " return v", "end", ].join("\n")