# File dl/lib/dl/types.rb, line 175
def encode_argument_type(alias_type)
proc_encode = nil
proc_decode = nil
@TYDEFS.each{|aty,ty,enc,dec,_,_,_|
if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
alias_type = alias_type.gsub(aty,ty) if ty
alias_type.strip! if alias_type
if( proc_encode )
if( enc )
conv1 = proc_encode
proc_encode = proc{|v| enc.call(conv1.call(v))}
end
else
if( enc )
proc_encode = enc
end
end
if( proc_decode )
if( dec )
conv2 = proc_decode
proc_decode = proc{|v| dec.call(conv2.call(v))}
end
else
if( dec )
proc_decode = dec
end
end
end
}
return [alias_type, proc_encode, proc_decode]
end
# File dl/lib/dl/types.rb, line 207
def encode_return_type(ty)
ty, enc, dec = encode_argument_type(ty)
return [ty, enc, dec]
end
# File dl/lib/dl/types.rb, line 212
def encode_struct_type(alias_type)
proc_encode = nil
proc_decode = nil
@TYDEFS.each{|aty,_,_,_,ty,enc,dec|
if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
alias_type = alias_type.gsub(aty,ty) if ty
alias_type.strip! if alias_type
if( proc_encode )
if( enc )
conv1 = proc_encode
proc_encode = proc{|v| enc.call(conv1.call(v))}
end
else
if( enc )
proc_encode = enc
end
end
if( proc_decode )
if( dec )
conv2 = proc_decode
proc_decode = proc{|v| dec.call(conv2.call(v))}
end
else
if( dec )
proc_decode = dec
end
end
end
}
return [alias_type, proc_encode, proc_decode]
end
Commenting is here to help enhance the documentation. For example, code samples, or clarification of the documentation.
If you have questions about Ruby or the documentation, please post to one of the Ruby mailing lists. You will get better, faster, help that way.
If you wish to post a correction of the docs, please do so, but also file bug report so that it can be corrected for the next release. Thank you.
If you want to help improve the Ruby documentation, please see Improve the docs, or visit Documenting-ruby.org.