Project

fiddler-rb

0.01
No release in over 3 years
Low commit activity in last 3 years
A nano helper for ruby fiddle
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.3
>= 0
 Project Readme

Fiddler

Fiddler is a super tiny (80 LOC) for fiddle of RUBY 2.+.

Installation

Add this line to your application's Gemfile:

gem 'fiddler-rb', require: 'fiddler'

And then execute:

$ bundle

Or install it yourself as:

$ gem install fiddler-rb

Usage

You can wrap your library like:

require 'fiddler'

module LevelDB
  module C
    include Fiddler

    prefix 'leveldb_'
    dlload 'libleveldb'

    cdef :open, VOIDP, options: VOIDP, name: VOIDP, errptr: VOIDP
    cdef :put, VOID, db: VOIDP, options: VOIDP, key: VOIDP, keylen: ULONG, val: VOIDP, vallen: ULONG, errptr: VOIDP
    cdef :get, VOIDP, db: VOIDP, options: VOIDP, key: VOIDP, keylen: ULONG, vallen: VOIDP, errptr: VOIDP
    cdef :delete, VOID, db: VOIDP, options: VOIDP, key: VOIDP, keylen: ULONG, errptr: VOIDP
  end
end

And then use the wrapper:

errors  = C::Pointer.malloc(C::SIZEOF_VOIDP)
options = C.struct ['char c', 'long n']

db = C.open options, './path', errors
db.free = C[:release_db]

C.put db, 'a', 1 ...
C.get db, 'a', ...
C.delete db, 'a', ...

Examples

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request