summaryrefslogtreecommitdiffstats
path: root/lib/e17/ffi_helper.rb
blob: 36c9c6b7e6b7e500fe2366a74a7ee51b0186f5a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#! /usr/bin/env ruby
# -*- coding: UTF-8 -*-
#
require 'ffi'
#
module FFIHelper
    def attach_fcts
        @fcts.each do |func|
            begin
                attach_function *func
            rescue Object => e
                puts "Could not attach #{func} #{e.message}"
            end
        end
    end
    def create_aliases l
        @fcts.each do |f,a,r|
            module_eval <<-code
            class << self
                alias #{f.to_s[l..-1]} #{f}
            end
            code
        end
    end
end
#
# EOF