swipl 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +2 -0
- data/lib/swipl/cffi.rb +40 -26
- data/lib/swipl/version.rb +1 -1
- metadata +70 -74
- checksums.yaml +0 -7
data/README.md
CHANGED
@@ -14,6 +14,8 @@ gem 'swipl'
|
|
14
14
|
|
15
15
|
Set `SWI_LIB` to the where you have the libswipl.{dylib,so,dll} file. Unforunately I haven't figured out a better method for locating the library; open to ideas and pull requests to make this easier for client applications.
|
16
16
|
|
17
|
+
Please see SWIPL::CFFI for more advanced use cases.
|
18
|
+
|
17
19
|
### Basic Usage
|
18
20
|
|
19
21
|
You can query if a statement is truthy by passing it as string as follows:
|
data/lib/swipl/cffi.rb
CHANGED
@@ -3,35 +3,49 @@ require 'ffi'
|
|
3
3
|
module SWIPL
|
4
4
|
module CFFI
|
5
5
|
extend FFI::Library
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
6
|
+
|
7
|
+
def self.import_symbols
|
8
|
+
attach_function :PL_open_foreign_frame, [], :ulong
|
9
|
+
attach_function :PL_discard_foreign_frame, [:ulong], :int
|
10
|
+
|
11
|
+
# Warning: the following method repeatedly failed
|
12
|
+
attach_function :PL_atom_chars, [:ulong], :pointer
|
13
|
+
|
14
|
+
attach_function :PL_call, [:ulong, :pointer], :int
|
15
|
+
attach_function :PL_chars_to_term, [:pointer, :ulong], :int
|
16
|
+
attach_function :PL_close_query, [:ulong], :void
|
17
|
+
attach_function :PL_get_atom_chars, [:ulong, :pointer], :int
|
18
|
+
attach_function :PL_initialise, [:int, :pointer], :int
|
19
|
+
attach_function :PL_is_atom, [:ulong], :int
|
20
|
+
attach_function :PL_is_ground, [:ulong], :int
|
21
|
+
attach_function :PL_new_atom, [:pointer], :ulong
|
22
|
+
attach_function :PL_new_term_ref, [], :ulong
|
23
|
+
attach_function :PL_new_term_refs, [:int], :ulong
|
24
|
+
attach_function :PL_next_solution, [:ulong], :int
|
25
|
+
attach_function :PL_open_query, [:pointer, :int, :ulong, :ulong], :ulong
|
26
|
+
attach_function :PL_predicate, [:pointer, :int, :pointer], :ulong
|
27
|
+
attach_function :PL_thread_self, [], :int
|
28
|
+
attach_function :PL_unify, [ :ulong, :ulong ], :int
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.load( libraries )
|
32
|
+
ffi_lib libraries
|
33
|
+
self.import_symbols
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.bootstrap
|
37
|
+
lib_path = ENV["SWI_LIB"]
|
38
|
+
raise "SWI_LIB not set and loader for your platform." unless lib_path
|
39
|
+
|
40
|
+
@swipl_lib = lib_path
|
41
|
+
self.load( lib_path )
|
42
|
+
end
|
43
|
+
|
31
44
|
def self.init
|
32
45
|
return if @is_initialized
|
46
|
+
self.bootstrap unless @ffi_libs
|
33
47
|
|
34
|
-
libptr = ::FFI::MemoryPointer.from_string(
|
48
|
+
libptr = ::FFI::MemoryPointer.from_string( @swipl_lib )
|
35
49
|
plargv = ::FFI::MemoryPointer.new( :pointer, 1 )
|
36
50
|
plargv.write_pointer( libptr )
|
37
51
|
|
data/lib/swipl/version.rb
CHANGED
metadata
CHANGED
@@ -1,82 +1,74 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: swipl
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease:
|
5
|
+
version: 0.4.0
|
5
6
|
platform: ruby
|
6
|
-
authors:
|
7
|
+
authors:
|
7
8
|
- Mark Eschbach
|
8
9
|
autorequire:
|
9
10
|
bindir: exe
|
10
11
|
cert_chain: []
|
11
|
-
|
12
|
-
|
13
|
-
|
12
|
+
|
13
|
+
date: 2016-02-08 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
14
16
|
name: bundler
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - "~>"
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: '1.11'
|
20
|
-
type: :development
|
21
17
|
prerelease: false
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
name: rake
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - "~>"
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '10.0'
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
19
|
+
none: false
|
20
|
+
requirements:
|
21
|
+
- - ~>
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.11"
|
34
24
|
type: :development
|
25
|
+
version_requirements: *id001
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rake
|
35
28
|
prerelease: false
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
name: rspec
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - "~>"
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '3.0'
|
29
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
30
|
+
none: false
|
31
|
+
requirements:
|
32
|
+
- - ~>
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: "10.0"
|
48
35
|
type: :development
|
36
|
+
version_requirements: *id002
|
37
|
+
- !ruby/object:Gem::Dependency
|
38
|
+
name: rspec
|
49
39
|
prerelease: false
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
40
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: "3.0"
|
46
|
+
type: :development
|
47
|
+
version_requirements: *id003
|
48
|
+
- !ruby/object:Gem::Dependency
|
56
49
|
name: ffi
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - "~>"
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '1.9'
|
62
|
-
type: :runtime
|
63
50
|
prerelease: false
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
51
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ~>
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: "1.9"
|
57
|
+
type: :runtime
|
58
|
+
version_requirements: *id004
|
59
|
+
description: Interact with the SWI Prolog system in ruby. Currently uses FFI to bind using the C interface.
|
60
|
+
email:
|
72
61
|
- meschbach@gmail.com
|
73
62
|
executables: []
|
63
|
+
|
74
64
|
extensions: []
|
65
|
+
|
75
66
|
extra_rdoc_files: []
|
76
|
-
|
77
|
-
|
78
|
-
-
|
79
|
-
-
|
67
|
+
|
68
|
+
files:
|
69
|
+
- .gitignore
|
70
|
+
- .rspec
|
71
|
+
- .travis.yml
|
80
72
|
- Gemfile
|
81
73
|
- LICENSE.txt
|
82
74
|
- README.md
|
@@ -91,27 +83,31 @@ files:
|
|
91
83
|
- lib/swipl/version.rb
|
92
84
|
- swipl.gemspec
|
93
85
|
homepage: https://github.com/meschbach/gem-swipl
|
94
|
-
licenses:
|
86
|
+
licenses:
|
95
87
|
- MIT
|
96
|
-
metadata: {}
|
97
88
|
post_install_message:
|
98
89
|
rdoc_options: []
|
99
|
-
|
90
|
+
|
91
|
+
require_paths:
|
100
92
|
- lib
|
101
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
102
|
-
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
none: false
|
95
|
+
requirements:
|
103
96
|
- - ">="
|
104
|
-
- !ruby/object:Gem::Version
|
105
|
-
version:
|
106
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
107
|
-
|
97
|
+
- !ruby/object:Gem::Version
|
98
|
+
version: "0"
|
99
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
100
|
+
none: false
|
101
|
+
requirements:
|
108
102
|
- - ">="
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version:
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: "0"
|
111
105
|
requirements: []
|
106
|
+
|
112
107
|
rubyforge_project:
|
113
|
-
rubygems_version:
|
108
|
+
rubygems_version: 1.8.23
|
114
109
|
signing_key:
|
115
|
-
specification_version:
|
110
|
+
specification_version: 3
|
116
111
|
summary: Ruby bindings for SWI Prolog
|
117
112
|
test_files: []
|
113
|
+
|
checksums.yaml
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
---
|
2
|
-
SHA1:
|
3
|
-
metadata.gz: 187e536fbdc31b19a4622f713887c8060eaf4d4f
|
4
|
-
data.tar.gz: 674e107ad57b73640a26af99299202b4b3e3a856
|
5
|
-
SHA512:
|
6
|
-
metadata.gz: 28674680661610bf44248641440c8955d55c575bba0c390cf4594a89d23b431f15bdb3f6da04c39a613d7cf6a07b27e96bbd19545d1663a048fadbb802f373a2
|
7
|
-
data.tar.gz: b2d235f8204c8023bd097ef2664213eeeb608406f48f3c49326b31d75f09f25fc123f61e41e5884c7ce0e7970befec0538bee27d2b104da472cd35798dad2b09
|