rbind 0.0.11 → 0.0.12

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.
Files changed (3) hide show
  1. data/README.md +190 -0
  2. data/rbind.gemspec +4 -4
  3. metadata +3 -2
@@ -0,0 +1,190 @@
1
+ # Library for automatically genereating ffi-bindings for c/c++ libraries
2
+
3
+ Rbind is developed to automatically generate ruby bindings for OpenCV but is
4
+ not tight to this library. It allows to import already wrapped types from other
5
+ gems/libraries using rbind to share the same types across multiple
6
+ gems/libraries. For now rbind uses a copy of the OpenCV python hdr parser to
7
+ parse c/c++ header files and looks for certain defines. This gem is still
8
+ under heavy development and the API might change in the future.
9
+
10
+ ## Features:
11
+ - inheritance
12
+ - method overloading
13
+ - default values
14
+ - argument annotation
15
+ - type sharing across libraries
16
+ - gem support
17
+
18
+ ## TODO:
19
+ - add documentation
20
+ - add unit test especially for string normalization
21
+ - move to clang
22
+ - make parser more robust (empty lines will produce an error)
23
+ - proper error if name of a argument is missing
24
+ - add better support for type specializing on the ruby side
25
+ - add support for yard
26
+ - use directly type lib types as inter-media types (optional)
27
+ - check that all functions have a return value or are constructors
28
+ - add alias for the original c++ method names
29
+ - make ruby/lib configurable
30
+ - support for changing ownership (add special flag)
31
+
32
+ ## Defines which are picked up from the c++ header files
33
+ - CV_EXPORTS_W CV_EXPORTS
34
+ - CV_EXPORTS_W_SIMPLE CV_EXPORTS
35
+ - CV_EXPORTS_AS(synonym) CV_EXPORTS
36
+ - CV_EXPORTS_W_MAP CV_EXPORTS
37
+ - CV_IN_OUT
38
+ - CV_OUT
39
+ - CV_PROP
40
+ - CV_PROP_RW
41
+ - CV_WRAP
42
+ - CV_WRAP_AS(synonym)
43
+ - CV_WRAP_DEFAULT(value)
44
+
45
+ # Example1 (ropencv)
46
+ ## file rbind.rb
47
+
48
+ require 'rbind'
49
+ rbind = Rbind::Rbind.new("OpenCV")
50
+
51
+ # add dependency to opencv
52
+ rbind.pkg_config << "opencv"
53
+
54
+ #add opencv headers
55
+ rbind.includes = ["opencv2/core/core_c.h", "opencv2/core/types_c.h",
56
+ "opencv2/core/core.hpp", "opencv2/flann/miniflann.hpp",
57
+ "opencv2/imgproc/imgproc_c.h", "opencv2/imgproc/types_c.h",
58
+ "opencv2/imgproc/imgproc.hpp", "opencv2/photo/photo_c.h",
59
+ "opencv2/photo/photo.hpp", "opencv2/video/video.hpp",
60
+ "opencv2/features2d/features2d.hpp", "opencv2/objdetect/objdetect.hpp",
61
+ "opencv2/calib3d/calib3d.hpp", "opencv2/ml/ml.hpp",
62
+ "opencv2/highgui/highgui_c.h", "opencv2/highgui/highgui.hpp",
63
+ "opencv2/contrib/contrib.hpp", "opencv2/nonfree/nonfree.hpp",
64
+ "opencv2/nonfree/features2d.hpp"]
65
+
66
+ # auto add vector and ptr types
67
+ rbind.on_type_not_found do |owner,type|
68
+ if type =~ /Ptr_(.*)/
69
+ t = rbind.parser.find_type(owner,$1)
70
+ t2 = Rbind::RPtr.new(type,rbind,t).typedef("cv::Ptr<#{t.full_name} >")
71
+ rbind.parser.add_type t2
72
+ elsif type =~ /vector_(.*)/
73
+ t = rbind.parser.find_type(owner,$1)
74
+ t2 = Rbind::RVector.new(type,rbind,t).typedef("std::vector<#{t.full_name} >")
75
+ rbind.parser.add_type t2
76
+ end
77
+ end
78
+
79
+ # parse type definitions
80
+ rbind.parse File.join(File.dirname(__FILE__),"pre_opencv244.txt")
81
+ rbind.parse File.join(File.dirname(__FILE__),"opencv.txt")
82
+
83
+ # using namespace cv (cv::Mat can now be addressed as Mat)
84
+ rbind.use_namespace rbind.cv
85
+
86
+ # alias a type
87
+ rbind.cv.types_alias["string"] = rbind.cv.String
88
+
89
+ # parse headers
90
+ rbind.parse_headers
91
+
92
+ # fix some errors because of missing defines in the c++ headers
93
+ rbind.cv.putText.parameter(0).add_flag(:IO)
94
+ rbind.cv.chamerMatching.parameter(0).add_flag(:IO)
95
+ rbind.cv.chamerMatching.parameter(1).add_flag(:IO)
96
+ rbind.cv.chamerMatching.parameter(2).add_flag(:IO)
97
+
98
+ # add some more vector types
99
+ rbind.parser.find_type(rbind,"vector_Point3f")
100
+ rbind.parser.find_type(rbind,"vector_Point3d")
101
+
102
+ # generate files
103
+ rbind.generator_ruby.file_prefix = "ropencv"
104
+ rbind.generate(File.join(File.dirname(__FILE__),"src"),File.join(File.dirname(__FILE__),"..","lib","ruby","ropencv"))
105
+
106
+ ## file opencv.txt
107
+ ...
108
+ class cv.RNG
109
+ uint64 state
110
+ cv.RNG.RNG
111
+ cv.RNG.RNG
112
+ uint64 state
113
+ cv.RNG.uniform int
114
+ int a
115
+ int b
116
+ cv.RNG.uniform float
117
+ float a
118
+ float b
119
+ cv.RNG.uniform double
120
+ double a
121
+ double b
122
+ cv.RNG.fill void
123
+ Mat mat /IO
124
+ int distType
125
+ Mat a
126
+ Mat b
127
+ bool saturateRange false
128
+ cv.RNG.gaussian double
129
+ double sigma
130
+
131
+ ## file opencv_test.rb
132
+ require 'ropencv'
133
+ include OpenCV
134
+
135
+ scalar = cv::Scalar.new(1,0,0,0)
136
+ scalar[2] = 2
137
+ puts scalar[0]
138
+ puts scalar[1]
139
+ puts scalar[2]
140
+ puts scalar[3]
141
+
142
+ # Example2
143
+ ## file rbind.rb
144
+ require 'rbind'
145
+ rbind = Rbind::Rbind.new("FrameHelper")
146
+
147
+ # add pkg config dependency
148
+ rbind.pkg_config << "base-types"
149
+
150
+ # add dependency to ruby bindings for opencv
151
+ rbind.gems << "ropencv"
152
+
153
+ # add headers which shall be parsed
154
+ rbind.includes = [File.absolute_path(File.join(File.dirname(__FILE__),"..","..","src","FrameHelperTypes.h")),
155
+ File.absolute_path(File.join(File.dirname(__FILE__),"..","..","src","FrameHelper.h"))]
156
+
157
+ # parse additional file specifying some types
158
+ rbind.parse File.join(File.dirname(__FILE__),"types.txt")
159
+
160
+ # parse types exported by the gem ropencv
161
+ rbind.parse_extern
162
+
163
+ # using namespace cv (cv::Mat can now be addressed as Mat)
164
+ rbind.use_namespace rbind.cv
165
+
166
+ # parse headers
167
+ rbind.parse_headers
168
+
169
+ # add additional target to the linker
170
+ rbind.libs << "frame_helper"
171
+
172
+ # generate all files
173
+ rbind.generate(File.join(File.dirname(__FILE__),"src"),File.join(File.dirname(__FILE__),"lib","ruby","frame_helper"))
174
+
175
+ ## file types.txt
176
+ struct base.samples.frame.Frame
177
+ base.samples.frame.Frame.Frame
178
+
179
+ ## file FrameHelper.h
180
+ class CV_EXPORTS_W FrameHelper
181
+ {
182
+ ...
183
+ public:
184
+ CV_WRAP FrameHelper();
185
+ CV_WRAP void convert(const base::samples::frame::Frame &src,CV_OUT base::samples::frame::Frame &dst,
186
+ int offset_x = 0, int offset_y = 0, int algo = INTER_LINEAR, bool bundistort=false);
187
+ ...
188
+ }
189
+
190
+
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rbind'
3
- s.version = '0.0.11'
3
+ s.version = '0.0.12'
4
4
  s.date = '2013-07-03'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Alexander Duda']
@@ -9,10 +9,10 @@ Gem::Specification.new do |s|
9
9
  s.summary = 'Library for genereating automated ffi-bindings for c/c++ libraries'
10
10
  s.description = 'Rbind is developed to automatically generate ruby bindings for OpenCV '\
11
11
  'but is not tight to this library. It allows to import already wrapped types '\
12
- 'from other gems/libraries using rbind to share the same types accross '\
13
- 'mulltiple gems/libraries. For now rbind uses a copy of the OpenCV python hdr_parser '\
12
+ 'from other gems/libraries using rbind to share the same types across '\
13
+ 'multiple gems/libraries. For now rbind uses a copy of the OpenCV python hdr_parser '\
14
14
  'to parse c/c++ header files and looks for certain defines. '\
15
- 'This gem is still under heavy development and the api might change in the future.'
15
+ 'This gem is still under heavy development and the API might change in the future.'
16
16
  s.files = `git ls-files`.split("\n")
17
17
  s.require_path = 'lib'
18
18
  s.required_rubygems_version = ">= 1.3.6"
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbind
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.11
5
+ version: 0.0.12
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alexander Duda
@@ -13,7 +13,7 @@ cert_chain: []
13
13
  date: 2013-07-03 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
- description: Rbind is developed to automatically generate ruby bindings for OpenCV but is not tight to this library. It allows to import already wrapped types from other gems/libraries using rbind to share the same types accross mulltiple gems/libraries. For now rbind uses a copy of the OpenCV python hdr_parser to parse c/c++ header files and looks for certain defines. This gem is still under heavy development and the api might change in the future.
16
+ description: Rbind is developed to automatically generate ruby bindings for OpenCV but is not tight to this library. It allows to import already wrapped types from other gems/libraries using rbind to share the same types across multiple gems/libraries. For now rbind uses a copy of the OpenCV python hdr_parser to parse c/c++ header files and looks for certain defines. This gem is still under heavy development and the API might change in the future.
17
17
  email:
18
18
  - Alexander.Duda@dfki.de
19
19
  executables: []
@@ -23,6 +23,7 @@ extensions: []
23
23
  extra_rdoc_files: []
24
24
 
25
25
  files:
26
+ - README.md
26
27
  - lib/rbind.rb
27
28
  - lib/rbind/core.rb
28
29
  - lib/rbind/core/.roperation.rb.swp