Sha256: c0f82a7ba748d3e06306bb2799453f7522b3dbc0340d55fcb0e2da47fb7288ce

Contents?: true

Size: 1.03 KB

Versions: 1

Compression:

Stored size: 1.03 KB

Contents

# This is free and unencumbered software released into the public domain.

require_relative '../exporter'

module FFIDB::Exporters
  ##
  # Code generator for the Java programming language (using JNA).
  #
  # @see https://github.com/java-native-access/jna/blob/master/www/GettingStarted.md
  class Java < FFIDB::Exporter
    TYPE_MAP = ::YAML.load(File.read(File.expand_path("../../../etc/mappings/java.yaml", __dir__)))
      .freeze

    def begin_library(library)
      if library
        interface_name = self.options[:module] || library.name.capitalize
        library.define_singleton_method(:interface_name) { interface_name }
      end
      super(library)
    end

    def finish
      puts self.render_template('java.erb')
    end

    protected

    ##
    # @param  [FFIDB::Type] c_type
    # @return [#to_s]
    def param_type(c_type)
      case
        when c_type.enum? then :int
        else TYPE_MAP[c_type.to_s] || TYPE_MAP['void *']
      end
    end
    alias_method :struct_type, :param_type
  end # Java
end # FFIDB::Exporters

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ffidb-0.12.0 lib/ffidb/exporters/java.rb