class FFIDB::Exporters::Python

Code generator for the Python programming language (using ctypes).

@see docs.python.org/3/library/ctypes.html

Constants

TYPE_MAP

Public Instance Methods

finish() click to toggle source
# File lib/ffidb/exporters/python.rb, line 13
def finish
  puts self.render_template('python.erb')
end

Protected Instance Methods

param_type(c_type) click to toggle source

@param [Symbol, FFIDB::Type] c_type @return [String]

Calls superclass method FFIDB::Exporter#param_type
# File lib/ffidb/exporters/python.rb, line 35
def param_type(c_type)
  case type = super(c_type)
    when Symbol then type.to_s  # a typedef
    when 'None' then type
    else "ctypes.#{type}"
  end
end
struct_type(c_type) click to toggle source

@param [Symbol, FFIDB::Type] c_type @return [String]

# File lib/ffidb/exporters/python.rb, line 22
def struct_type(c_type)
  case c_type
    when Symbol then c_type.to_s  # a typedef
    else case
      when c_type.array? then [self.param_type(c_type.array_type), '*', c_type.array_size].join(' ')
      else self.param_type(c_type)
    end
  end
end