rbind 0.0.14 → 0.0.15

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.
@@ -0,0 +1,41 @@
1
+ module Rbind
2
+ class RString < RClass
3
+ def initialize(name,root)
4
+ super(name)
5
+
6
+ size_t = root.type("size_t")
7
+ char = root.type("char")
8
+ string = root.type("c_string")
9
+ const_string = root.type("const_c_string")
10
+ bool = root.type("bool")
11
+ void = root.type("void")
12
+ int = root.type("int")
13
+
14
+ add_operation ROperation.new(self.name,nil)
15
+ add_operation ROperation.new(self.name,nil,RParameter.new("other",self))
16
+ add_operation ROperation.new(self.name,nil,RParameter.new("str",string),RParameter.new("size",size_t))
17
+ add_operation ROperation.new("size",size_t)
18
+ add_operation ROperation.new("length",size_t)
19
+ add_operation ROperation.new("operator[]",char,RParameter.new("idx",size_t))
20
+ add_operation ROperation.new("c_str",const_string)
21
+ add_operation ROperation.new("empty",bool)
22
+ add_operation ROperation.new("clear",void)
23
+ add_operation ROperation.new("compare",int,RParameter.new("other",self))
24
+ add_operation ROperation.new("swap",void,RParameter.new("other",self).add_flag(:IO))
25
+ end
26
+
27
+ def specialize_ruby
28
+ %Q$ def self.to_native(obj,context)
29
+ if obj.is_a? ::String
30
+ str = obj.to_str
31
+ OpenCV::Cv::String.new(str,str.length).__obj_ptr__
32
+ else
33
+ rbind_to_native(obj,context)
34
+ end
35
+ end
36
+ def to_s
37
+ c_str
38
+ end}$
39
+ end
40
+ end
41
+ end
data/lib/rbind/core.rb CHANGED
@@ -12,3 +12,4 @@ require 'rbind/core/rnamespace.rb'
12
12
  require 'rbind/core/rstruct.rb'
13
13
  require 'rbind/core/rclass.rb'
14
14
  require 'rbind/core/rvector.rb'
15
+ require 'rbind/core/rstring.rb'
data/lib/rbind/rbind.rb CHANGED
@@ -26,6 +26,7 @@ module Rbind
26
26
  end
27
27
 
28
28
  def self.gem_path(gem_name)
29
+ # TODO use gem api
29
30
  out = IO.popen("gem contents #{gem_name}")
30
31
  out.readlines.each do |line|
31
32
  return $1 if line =~ /(.*)extern.rbind/
@@ -158,7 +159,8 @@ module Rbind
158
159
 
159
160
  def generate_c(path)
160
161
  ::Rbind.log.info "generate c wrappers"
161
- @generator_c.includes = includes
162
+ @generator_c.includes += includes
163
+ @generator_c.includes.uniq!
162
164
  @generator_c.pkg_config = pkg_config
163
165
  @generator_c.gems = gems
164
166
  @generator_c.generate(path)
@@ -189,6 +191,11 @@ module Rbind
189
191
  @generator_c.libs
190
192
  end
191
193
 
194
+ def import_std_string
195
+ @generator_c.includes << "<string>"
196
+ @parser.add_type(RString.new("std::string",@parser))
197
+ end
198
+
192
199
  def method_missing(m,*args)
193
200
  t = @parser.type(m.to_s,false,false)
194
201
  return t if t
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.14'
3
+ s.version = '0.0.15'
4
4
  s.date = '2013-09-03'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Alexander Duda']
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.14
4
+ version: 0.0.15
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -38,6 +38,7 @@ files:
38
38
  - lib/rbind/core/roperation.rb
39
39
  - lib/rbind/core/rparameter.rb
40
40
  - lib/rbind/core/rsetter.rb
41
+ - lib/rbind/core/rstring.rb
41
42
  - lib/rbind/core/rstruct.rb
42
43
  - lib/rbind/core/rvector.rb
43
44
  - lib/rbind/default_parser.rb
@@ -102,4 +103,3 @@ signing_key:
102
103
  specification_version: 3
103
104
  summary: Library for genereating automated ffi-bindings for c/c++ libraries
104
105
  test_files: []
105
- has_rdoc: