module Upl::Extern
ffi bindings for swipl.so
Constants
- FALSE
- PL_ATOM
- PL_BLOB
- PL_BOOL
- PL_BYTE
- PL_CHAR
- PL_CHARS
- PL_CHAR_LIST
- PL_CODE
- PL_CODE_LIST
- PL_CYCLIC_TERM
- PL_DICT
- PL_DOUBLE
- PL_FA_CREF
- PL_FA_ISO
- PL_FA_META
- PL_FA_NONDETERMINISTIC
- PL_FA_NOTRACE
Foreign
predicate flags- PL_FA_VARARGS
- PL_FLOAT
- PL_FUNCTOR
- PL_FUNCTOR_CHARS
- PL_INT
- PL_INT64
- PL_INTEGER
- PL_INTPTR
- PL_LIST
- PL_LIST_PAIR
- PL_LONG
- PL_MBCHARS
- PL_MBCODES
- PL_MBSTRING
- PL_NCHARS
- PL_NIL
- PL_NOT_A_LIST
- PL_NUTF8_CHARS
- PL_NUTF8_CODES
- PL_NUTF8_STRING
- PL_NWCHARS
- PL_NWCODES
- PL_NWSTRING
- PL_PARTIAL_LIST
- PL_POINTER
- PL_PREDICATE_INDICATOR
- PL_RATIONAL
- PL_SHORT
- PL_STRING
- PL_TERM
- PL_UTF8_CHARS
- PL_UTF8_STRING
- PL_VARIABLE
- TRUE
Public Class Methods
ruby_free_fn()
click to toggle source
# File lib/upl/extern.rb, line 44 def self.ruby_free_fn @ruby_free_fn ||= Fiddle::Function.new Fiddle::RUBY_FREE, [Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOID end
so_path()
click to toggle source
use swipl config to find the .so file should result in something like
/usr/lib64/swipl-7.7.18/lib/x86_64-linux/libswipl.so
which should actually exist
# File lib/upl/extern.rb, line 29 def self.so_path values = swipl_config_values p = Pathname "#{values['PLBASE']}/lib/#{values['PLARCH']}/#{values['PLLIB'].gsub('-l', 'lib')}.#{values['PLSOEXT']}" p.realpath.to_s rescue Errno::ENOENT => ex puts "problem with library #{p.to_s}: #{ex.message}" exit 1 end
swipl_config_values()
click to toggle source
fetch config values from swipl executable
# File lib/upl/extern.rb, line 11 def self.swipl_config_values @swipl_config_value ||= begin swipl_exe = 'swipl' values = `#{swipl_exe} --dump-runtime-variables=sh`.each_line.with_object Hash.new do |line,ha| # split by = and for rhs strip surrounding quotes and trailing ; line =~ /^([^=]+)="([^"]*)";\s*$/ ha[$1] = $2.strip end end rescue Errno::ENOENT => ex puts "#{swipl_exe} not found on path #{ENV['PATH']}" exit 1 end
swipl_free_fn()
click to toggle source
# File lib/upl/extern.rb, line 48 def self.swipl_free_fn @swipl_free_fn ||= Fiddle::Function.new self['PL_free'], [Fiddle::TYPE_VOIDP], Fiddle::TYPE_VOID end