Sha256: d812ba791e6cbe1d69565c6dcfdebb2913bed6492e87abd3ee8b76d7281ffd8d

Contents?: true

Size: 840 Bytes

Versions: 4

Compression:

Stored size: 840 Bytes

Contents

require 'ffi'

module RedSnow
  # expose function free() to allow release memory allocated by C-interface
  module Memory
    extend FFI::Library
    ffi_lib FFI::Library::LIBC

    attach_function :free, [:pointer], :void
  end

  # C-binding with Snow Crash Library using [FFI](https://github.com/ffi/ffi)
  # @see https://github.com/apiaryio/drafter/blob/master/src/cdrafter.h
  module Binding
    extend FFI::Library

    prefix = FFI::Platform.mac? ? '' : 'lib.target/'

    ffi_lib File.expand_path("../../../ext/drafter/build/out/Release/#{prefix}libdrafter.#{FFI::Platform::LIBSUFFIX}", __FILE__)
    enum :option, [
      :render_descriptions_option,
      :require_blueprint_name_option,
      :export_sourcemap_option
    ]

    attach_function('drafter_c_parse', 'drafter_c_parse', [:string, :option, :pointer], :int)
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
redsnow-0.4.4 lib/redsnow/binding.rb
redsnow-0.4.3 lib/redsnow/binding.rb
redsnow-0.4.1 lib/redsnow/binding.rb
redsnow-0.4.0 lib/redsnow/binding.rb