rbind 0.0.8 → 0.0.9

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.
@@ -286,6 +286,7 @@ module Rbind
286
286
  attr_accessor :library_name
287
287
  attr_accessor :libs
288
288
  attr_accessor :pkg_config
289
+ attr_accessor :gems
289
290
  attr_accessor :generate_cmake
290
291
  attr_accessor :output_path
291
292
 
@@ -304,6 +305,7 @@ module Rbind
304
305
  @erb_pkg_config = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","c","rbind.pc.in")).read)
305
306
  @includes = Array.new
306
307
  @pkg_config= Array.new
308
+ @gems = Array.new
307
309
  @library_name = library_name
308
310
  @generate_cmake = true
309
311
  @libs = []
@@ -320,11 +322,17 @@ module Rbind
320
322
  file_conversions = File.new(File.join(path,"conversions.cc"),"w")
321
323
  file_conversions_hdr = File.new(File.join(path,"conversions.hpp"),"w")
322
324
  rbind_pkgs = Rbind.rbind_pkgs(@pkg_config)
325
+ gem_paths = @gems.map do |gem|
326
+ Rbind.gem_path(gem)
327
+ end
323
328
 
324
329
  types_hdr = TypesHelperHDR.new("_#{library_name.upcase}_TYPES_H_",@root)
325
330
  types_hdr.includes = rbind_pkgs.map do |p|
326
331
  "<#{p}/types.h>"
327
332
  end
333
+ types_hdr.includes += gem_paths.map do |gem|
334
+ "<#{gem}/types.h>"
335
+ end
328
336
  file_types_hdr.write @erb_types_hdr.result(types_hdr.binding)
329
337
 
330
338
  types = TypesHelper.new("types",@root)
@@ -334,6 +342,9 @@ module Rbind
334
342
  consts.includes = rbind_pkgs.map do |p|
335
343
  "<#{p}/constants.h>"
336
344
  end
345
+ consts.includes += gem_paths.map do |gem|
346
+ "<#{gem}/constants.h>"
347
+ end
337
348
  file_consts.write @erb_consts.result(consts.binding)
338
349
 
339
350
  conversions_hdr = ConversionsHelperHDR.new("#{library_name.upcase}_CONVERSIONS_H_",@root)
@@ -341,6 +352,9 @@ module Rbind
341
352
  "<#{p}/conversions.hpp>"
342
353
  end
343
354
  conversions_hdr.includes += includes
355
+ conversions_hdr.includes += gem_paths.map do |gem|
356
+ "<#{gem}/conversions.hpp>"
357
+ end
344
358
  file_conversions_hdr.write @erb_conversions_hdr.result(conversions_hdr.binding)
345
359
 
346
360
  conversions = ConversionsHelper.new("conversions",@root)
@@ -354,7 +368,10 @@ module Rbind
354
368
 
355
369
  if generate_cmake && !File.exist?(File.join(path,"CMakeLists.txt"))
356
370
  file_cmakelists = File.new(File.join(path,"CMakeLists.txt"),"w")
357
- cmakelists = CMakeListsHelper.new(@library_name,@pkg_config,@libs)
371
+ libs = gem_paths.map do |path|
372
+ Dir.glob(File.join(path,"lib*"))
373
+ end
374
+ cmakelists = CMakeListsHelper.new(@library_name,@pkg_config,@libs+libs)
358
375
  file_cmakelists.write @erb_cmakelists.result(cmakelists.binding)
359
376
  if !File.exist?(File.join(path,"rbind.pc.in"))
360
377
  file_pkg_config = File.new(File.join(path,"rbind.pc.in"),"w")
data/lib/rbind/rbind.rb CHANGED
@@ -8,6 +8,7 @@ module Rbind
8
8
  attr_accessor :includes
9
9
  attr_accessor :name
10
10
  attr_accessor :pkg_config
11
+ attr_accessor :gems
11
12
 
12
13
  def self.pkg_paths(pkg_name)
13
14
  out = IO.popen("pkg-config --cflags-only-I #{pkg_name}")
@@ -24,6 +25,14 @@ module Rbind
24
25
  end
25
26
  end
26
27
 
28
+ def self.gem_path(gem_name)
29
+ out = IO.popen("gem contents #{gem_name}")
30
+ out.readlines.each do |line|
31
+ return $1 if line =~ /(.*)extern.rbind/
32
+ end
33
+ raise "Cannot find paths for gem #{gem_name}"
34
+ end
35
+
27
36
  def self.rbind_pkg_paths(pkg_names)
28
37
  rbind_packages = rbind_pkgs(pkg_names)
29
38
  rbind_paths = rbind_packages.map do |pkg|
@@ -40,6 +49,7 @@ module Rbind
40
49
  @name = name
41
50
  @includes = []
42
51
  @pkg_config = []
52
+ @gems = []
43
53
  @parser = DefaultParser.new
44
54
  lib_name = "rbind_#{name.downcase}"
45
55
  @generator_c = GeneratorC.new(@parser,lib_name)
@@ -83,6 +93,13 @@ module Rbind
83
93
  ::Rbind.log.info "parsing extern rbind pkg file #{path}"
84
94
  parser.parse(File.open(path).read,config.ruby_module_name)
85
95
  end
96
+ @gems.each do |gem|
97
+ path = Rbind.gem_path(gem)
98
+ config = YAML.load(File.open(File.join(path,"config.rbind")).read)
99
+ path = File.join(path,"extern.rbind")
100
+ ::Rbind.log.info "parsing extern gem file #{path}"
101
+ parser.parse(File.open(path).read,config.ruby_module_name)
102
+ end
86
103
  end
87
104
 
88
105
  def parse_headers_dry(*headers)
@@ -135,7 +152,7 @@ module Rbind
135
152
  config = YAML.load(File.open(File.join(pkg,"config.rbind")).read)
136
153
  config.ruby_module_name
137
154
  end
138
- @generator_ruby.required_module_names = modules
155
+ @generator_ruby.required_module_names = modules + gems
139
156
  @generator_ruby.generate(path)
140
157
  end
141
158
 
@@ -143,6 +160,7 @@ module Rbind
143
160
  ::Rbind.log.info "generate c wrappers"
144
161
  @generator_c.includes = includes
145
162
  @generator_c.pkg_config = pkg_config
163
+ @generator_c.gems = gems
146
164
  @generator_c.generate(path)
147
165
  end
148
166
 
@@ -6,9 +6,17 @@
6
6
  end
7
7
  begin
8
8
  <%- if !return_type || return_type.basic_type? || operator? -%>
9
+ <%- if constructor? || !instance_method? -%>
9
10
  return Rbind::<%= cname %>(*args)
11
+ <%- else -%>
12
+ return Rbind::<%= cname %>(self,*args)
13
+ <%- end -%>
10
14
  <%- else -%>
15
+ <%- if instance_method? -%>
16
+ result = Rbind::<%= cname %>(self,*args)
17
+ <%- else -%>
11
18
  result = Rbind::<%= cname %>(*args)
19
+ <%- end -%>
12
20
  # store owner insight the pointer to not get garbage collected
13
21
  result.instance_variable_get(:@__obj_ptr__).instance_variable_set(:@__owner__,self) if !result.__owner__?
14
22
  return result
data/rbind.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rbind'
3
- s.version = '0.0.8'
3
+ s.version = '0.0.9'
4
4
  s.date = '2013-06-30'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Alexander Duda']
metadata CHANGED
@@ -1,28 +1,23 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rbind
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.9
4
5
  prerelease:
5
- version: 0.0.8
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Alexander Duda
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2013-06-30 00:00:00 Z
12
+ date: 2013-06-30 00:00:00.000000000 Z
14
13
  dependencies: []
15
-
16
- description: ""
17
- email:
14
+ description: ''
15
+ email:
18
16
  - Alexander.Duda@dfki.de
19
17
  executables: []
20
-
21
18
  extensions: []
22
-
23
19
  extra_rdoc_files: []
24
-
25
- files:
20
+ files:
26
21
  - lib/rbind.rb
27
22
  - lib/rbind/core.rb
28
23
  - lib/rbind/core/.roperation.rb.swp
@@ -75,30 +70,27 @@ files:
75
70
  - test/test_generator_ruby.rb
76
71
  homepage: http://github.com/
77
72
  licenses: []
78
-
79
73
  post_install_message:
80
74
  rdoc_options: []
81
-
82
- require_paths:
75
+ require_paths:
83
76
  - lib
84
- required_ruby_version: !ruby/object:Gem::Requirement
77
+ required_ruby_version: !ruby/object:Gem::Requirement
85
78
  none: false
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: "0"
90
- required_rubygems_version: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ! '>='
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
84
  none: false
92
- requirements:
93
- - - ">="
94
- - !ruby/object:Gem::Version
85
+ requirements:
86
+ - - ! '>='
87
+ - !ruby/object:Gem::Version
95
88
  version: 1.3.6
96
89
  requirements: []
97
-
98
90
  rubyforge_project:
99
91
  rubygems_version: 1.8.23
100
92
  signing_key:
101
93
  specification_version: 3
102
94
  summary: Library for genereating automated ffi-bindings for c/c++ libraries
103
95
  test_files: []
104
-
96
+ has_rdoc: