Extended maintenance of Ruby versions 1.8.7 and 1.9.2 will end on July 31, 2014. Read more

In Files

  • dl/lib/dl/types.rb

DL::Types

Constants

TYPES

Public Class Methods

new() click to toggle source
 
               # File dl/lib/dl/types.rb, line 163
def initialize
  init_types()
end
            

Public Instance Methods

encode_argument_type(alias_type) click to toggle source
 
               # 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
            
encode_return_type(ty) click to toggle source
 
               # 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
            
encode_struct_type(alias_type) click to toggle source
 
               # 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
            
init_types() click to toggle source
 
               # File dl/lib/dl/types.rb, line 171
def init_types
  @TYDEFS = TYPES.dup
end
            
typealias(ty1, ty2, enc=nil, dec=nil, ty3=nil, senc=nil, sdec=nil) click to toggle source
 
               # File dl/lib/dl/types.rb, line 167
def typealias(ty1, ty2, enc=nil, dec=nil, ty3=nil, senc=nil, sdec=nil)
  @TYDEFS.unshift([ty1, ty2, enc, dec, ty3, senc, sdec])
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 visit Documenting-ruby.org.

blog comments powered by Disqus