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 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:
@@ -3,35 +3,49 @@ require 'ffi'
3
3
  module SWIPL
4
4
  module CFFI
5
5
  extend FFI::Library
6
- ffi_lib ENV["SWI_LIB"]
7
-
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
-
30
- @is_initialized = false
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( ENV["SWI_LIB"] )
48
+ libptr = ::FFI::MemoryPointer.from_string( @swipl_lib )
35
49
  plargv = ::FFI::MemoryPointer.new( :pointer, 1 )
36
50
  plargv.write_pointer( libptr )
37
51
 
@@ -1,3 +1,3 @@
1
1
  module SWIPL
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
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
- version: 0.3.0
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
- date: 2016-02-04 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
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
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.11'
27
- - !ruby/object:Gem::Dependency
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
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: '10.0'
41
- - !ruby/object:Gem::Dependency
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
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '3.0'
55
- - !ruby/object:Gem::Dependency
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
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: '1.9'
69
- description: Interact with the SWI Prolog system in ruby. Currently uses FFI to bind
70
- using the C interface.
71
- email:
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
- files:
77
- - ".gitignore"
78
- - ".rspec"
79
- - ".travis.yml"
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
- require_paths:
90
+
91
+ require_paths:
100
92
  - lib
101
- required_ruby_version: !ruby/object:Gem::Requirement
102
- requirements:
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
103
96
  - - ">="
104
- - !ruby/object:Gem::Version
105
- version: '0'
106
- required_rubygems_version: !ruby/object:Gem::Requirement
107
- requirements:
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: '0'
103
+ - !ruby/object:Gem::Version
104
+ version: "0"
111
105
  requirements: []
106
+
112
107
  rubyforge_project:
113
- rubygems_version: 2.4.5.1
108
+ rubygems_version: 1.8.23
114
109
  signing_key:
115
- specification_version: 4
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