rbind 0.0.26 → 0.0.27

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.
@@ -1,4 +1,10 @@
1
- require 'ffi'
1
+ begin
2
+ require 'ffi'
3
+ rescue LoadError
4
+ STDERR.puts "Cannot require 'ffi'"
5
+ STDERR.puts "You can install ffi via 'gem install ffi'"
6
+ exit 1
7
+ end
2
8
  require File.join(File.dirname(__FILE__),'<%= file_prefix %>_types.rb')
3
9
  <%= required_module_names %>
4
10
 
@@ -9,7 +15,7 @@ module <%= name %>
9
15
  extend FFI::Library
10
16
 
11
17
  #load library <%= library_name %>
12
- path = File.join(File.dirname(__FILE__),"..")
18
+ path = File.dirname(__FILE__)
13
19
  path = if Dir.exist?(path)
14
20
  Dir.chdir(path) do
15
21
  path = Dir.glob("lib<%= library_name %>.*").first
@@ -1,10 +1,12 @@
1
1
  #!/usr/bin/env python
2
2
 
3
+ from __future__ import print_function
3
4
  import os, sys, re, string
4
5
 
5
6
  # the list only for debugging. The real list, used in the real OpenCV build, is specified in CMakeLists.txt
6
7
  opencv_hdr_list = [
7
8
  "../../core/include/opencv2/core.hpp",
9
+ "../../core/include/opencv2/core/ocl.hpp",
8
10
  "../../flann/include/opencv2/flann/miniflann.hpp",
9
11
  "../../ml/include/opencv2/ml.hpp",
10
12
  "../../imgproc/include/opencv2/imgproc.hpp",
@@ -13,7 +15,8 @@ opencv_hdr_list = [
13
15
  "../../video/include/opencv2/video/tracking.hpp",
14
16
  "../../video/include/opencv2/video/background_segm.hpp",
15
17
  "../../objdetect/include/opencv2/objdetect.hpp",
16
- "../../contrib/include/opencv2/contrib.hpp",
18
+ "../../imgcodecs/include/opencv2/imgcodecs.hpp",
19
+ "../../videoio/include/opencv2/videoio.hpp",
17
20
  "../../highgui/include/opencv2/highgui.hpp"
18
21
  ]
19
22
 
@@ -43,13 +46,13 @@ class CppHeaderParser(object):
43
46
  def get_macro_arg(self, arg_str, npos):
44
47
  npos2 = npos3 = arg_str.find("(", npos)
45
48
  if npos2 < 0:
46
- print "Error: no arguments for the macro at %d" % (self.lineno,)
49
+ print("Error: no arguments for the macro at %d" % (self.lineno,))
47
50
  sys.exit(-1)
48
51
  balance = 1
49
52
  while 1:
50
53
  t, npos3 = self.find_next_token(arg_str, ['(', ')'], npos3+1)
51
54
  if npos3 < 0:
52
- print "Error: no matching ')' in the macro call at %d" % (self.lineno,)
55
+ print("Error: no matching ')' in the macro call at %d" % (self.lineno,))
53
56
  sys.exit(-1)
54
57
  if t == '(':
55
58
  balance += 1
@@ -143,13 +146,13 @@ class CppHeaderParser(object):
143
146
  angle_stack.append(0)
144
147
  elif w == "," or w == '>':
145
148
  if not angle_stack:
146
- print "Error at %d: argument contains ',' or '>' not within template arguments" % (self.lineno,)
149
+ print("Error at %d: argument contains ',' or '>' not within template arguments" % (self.lineno,))
147
150
  sys.exit(-1)
148
151
  if w == ",":
149
152
  arg_type += "_and_"
150
153
  elif w == ">":
151
154
  if angle_stack[0] == 0:
152
- print "Error at %s:%d: template has no arguments" % (self.hname, self.lineno)
155
+ print("Error at %s:%d: template has no arguments" % (self.hname, self.lineno))
153
156
  sys.exit(-1)
154
157
  if angle_stack[0] > 1:
155
158
  arg_type += "_end_"
@@ -173,7 +176,7 @@ class CppHeaderParser(object):
173
176
  p1 = arg_name.find("[")
174
177
  p2 = arg_name.find("]",p1+1)
175
178
  if p2 < 0:
176
- print "Error at %d: no closing ]" % (self.lineno,)
179
+ print("Error at %d: no closing ]" % (self.lineno,))
177
180
  sys.exit(-1)
178
181
  counter_str = arg_name[p1+1:p2].strip()
179
182
  if counter_str == "":
@@ -203,6 +206,8 @@ class CppHeaderParser(object):
203
206
  def parse_enum(self, decl_str):
204
207
  l = decl_str
205
208
  ll = l.split(",")
209
+ if ll[-1].strip() == "":
210
+ ll = ll[:-1]
206
211
  prev_val = ""
207
212
  prev_val_delta = -1
208
213
  decl = []
@@ -358,7 +363,7 @@ class CppHeaderParser(object):
358
363
  if bool(re.match(r".*\)\s*const(\s*=\s*0)?", decl_str)):
359
364
  decl[2].append("/C")
360
365
  if "virtual" in decl_str:
361
- print decl_str
366
+ print(decl_str)
362
367
  return decl
363
368
 
364
369
  def parse_func_decl(self, decl_str):
@@ -412,12 +417,12 @@ class CppHeaderParser(object):
412
417
  if decl_str.startswith("CVAPI"):
413
418
  rtype_end = decl_str.find(")", args_begin+1)
414
419
  if rtype_end < 0:
415
- print "Error at %d. no terminating ) in CVAPI() macro: %s" % (self.lineno, decl_str)
420
+ print("Error at %d. no terminating ) in CVAPI() macro: %s" % (self.lineno, decl_str))
416
421
  sys.exit(-1)
417
422
  decl_str = decl_str[args_begin+1:rtype_end] + " " + decl_str[rtype_end+1:]
418
423
  args_begin = decl_str.find("(")
419
424
  if args_begin < 0:
420
- print "Error at %d: no args in '%s'" % (self.lineno, decl_str)
425
+ print("Error at %d: no args in '%s'" % (self.lineno, decl_str))
421
426
  sys.exit(-1)
422
427
 
423
428
  decl_start = decl_str[:args_begin].strip()
@@ -425,7 +430,7 @@ class CppHeaderParser(object):
425
430
  if decl_start.endswith("operator"):
426
431
  args_begin = decl_str.find("(", args_begin+1)
427
432
  if args_begin < 0:
428
- print "Error at %d: no args in '%s'" % (self.lineno, decl_str)
433
+ print("Error at %d: no args in '%s'" % (self.lineno, decl_str))
429
434
  sys.exit(-1)
430
435
  decl_start = decl_str[:args_begin].strip()
431
436
  # TODO: normalize all type of operators
@@ -455,7 +460,7 @@ class CppHeaderParser(object):
455
460
  return [] # exotic - dynamic 2d array
456
461
  else:
457
462
  #print rettype, funcname, modlist, argno
458
- print "Error at %s:%d the function/method name is missing: '%s'" % (self.hname, self.lineno, decl_start)
463
+ print("Error at %s:%d the function/method name is missing: '%s'" % (self.hname, self.lineno, decl_start))
459
464
  sys.exit(-1)
460
465
 
461
466
  if self.wrap_mode and (("::" in funcname) or funcname.startswith("~")):
@@ -486,9 +491,9 @@ class CppHeaderParser(object):
486
491
  npos += 1
487
492
  t, npos = self.find_next_token(decl_str, ["(", ")", ",", "<", ">"], npos)
488
493
  if not t:
489
- print "Error: no closing ')' at %d" % (self.lineno,)
490
- print decl_str
491
- print decl_str[arg_start:]
494
+ print("Error: no closing ')' at %d" % (self.lineno,))
495
+ print(decl_str)
496
+ print(decl_str[arg_start:])
492
497
  sys.exit(-1)
493
498
  if t == "<":
494
499
  angle_balance += 1
@@ -577,17 +582,21 @@ class CppHeaderParser(object):
577
582
  return name
578
583
  if name.startswith("cv."):
579
584
  return name
585
+ qualified_name = (("." in name) or ("::" in name))
580
586
  n = ""
581
587
  for b in self.block_stack:
582
588
  block_type, block_name = b[self.BLOCK_TYPE], b[self.BLOCK_NAME]
583
589
  if block_type in ["file", "enum"]:
584
590
  continue
585
591
  if block_type not in ["struct", "class", "namespace"]:
586
- print "Error at %d: there are non-valid entries in the current block stack " % (self.lineno, self.block_stack)
592
+ print("Error at %d: there are non-valid entries in the current block stack " % (self.lineno, self.block_stack))
587
593
  sys.exit(-1)
588
- if block_name:
594
+ if block_name and (block_type == "namespace" or not qualified_name):
589
595
  n += block_name + "."
590
- return n + name.replace("::", ".")
596
+ n += name.replace("::", ".")
597
+ if n.endswith(".Algorithm"):
598
+ n = "cv.Algorithm"
599
+ return n
591
600
 
592
601
  def parse_stmt(self, stmt, end_token):
593
602
  """
@@ -605,7 +614,7 @@ class CppHeaderParser(object):
605
614
  stmt_type = "block"
606
615
 
607
616
  if context == "block":
608
- print "Error at %d: should not call parse_stmt inside blocks" % (self.lineno,)
617
+ print("Error at %d: should not call parse_stmt inside blocks" % (self.lineno,))
609
618
  sys.exit(-1)
610
619
 
611
620
  if context == "class" or context == "struct":
@@ -632,13 +641,13 @@ class CppHeaderParser(object):
632
641
  try:
633
642
  classname, bases, modlist = self.parse_class_decl(stmt[len("typedef "):])
634
643
  except:
635
- print "Error at %s:%d" % (self.hname, self.lineno)
644
+ print("Error at %s:%d" % (self.hname, self.lineno))
636
645
  exit(1)
637
646
  if classname.startswith("_Ipl"):
638
647
  classname = classname[1:]
639
648
  decl = [stmt_type + " " + self.get_dotted_name(classname), "", modlist, []]
640
649
  if bases:
641
- decl[1] = ": " + ", ".join([b if "::" in b else self.get_dotted_name(b).replace(".","::") for b in bases])
650
+ decl[1] = ": " + ", ".join([self.get_dotted_name(b).replace(".","::") for b in bases])
642
651
  return stmt_type, classname, True, decl
643
652
 
644
653
  if stmt.startswith("class") or stmt.startswith("struct"):
@@ -647,13 +656,13 @@ class CppHeaderParser(object):
647
656
  try:
648
657
  classname, bases, modlist = self.parse_class_decl(stmt)
649
658
  except:
650
- print "Error at %s:%d" % (self.hname, self.lineno)
659
+ print("Error at %s:%d" % (self.hname, self.lineno))
651
660
  exit(1)
652
661
  decl = []
653
662
  if ("CV_EXPORTS_W" in stmt) or ("CV_EXPORTS_AS" in stmt) or (not self.wrap_mode):# and ("CV_EXPORTS" in stmt)):
654
663
  decl = [stmt_type + " " + self.get_dotted_name(classname), "", modlist, []]
655
664
  if bases:
656
- decl[1] = ": " + ", ".join([b if "::" in b else self.get_dotted_name(b).replace(".","::") for b in bases])
665
+ decl[1] = ": " + ", ".join([self.get_dotted_name(b).replace(".","::") for b in bases])
657
666
  return stmt_type, classname, True, decl
658
667
 
659
668
  if stmt.startswith("enum"):
@@ -767,7 +776,7 @@ class CppHeaderParser(object):
767
776
  state = SCAN
768
777
 
769
778
  if state != SCAN:
770
- print "Error at %d: invlid state = %d" % (self.lineno, state)
779
+ print("Error at %d: invlid state = %d" % (self.lineno, state))
771
780
  sys.exit(-1)
772
781
 
773
782
  while 1:
@@ -795,7 +804,7 @@ class CppHeaderParser(object):
795
804
  while 1:
796
805
  t2, pos2 = self.find_next_token(l, ["\\", "\""], pos2)
797
806
  if t2 == "":
798
- print "Error at %d: no terminating '\"'" % (self.lineno,)
807
+ print("Error at %d: no terminating '\"'" % (self.lineno,))
799
808
  sys.exit(-1)
800
809
  if t2 == "\"":
801
810
  break
@@ -836,7 +845,7 @@ class CppHeaderParser(object):
836
845
 
837
846
  if token == "}":
838
847
  if not self.block_stack:
839
- print "Error at %d: the block stack is empty" % (self.lineno,)
848
+ print("Error at %d: the block stack is empty" % (self.lineno,))
840
849
  self.block_stack[-1:] = []
841
850
  if pos+1 < len(l) and l[pos+1] == ';':
842
851
  pos += 1
@@ -851,20 +860,22 @@ class CppHeaderParser(object):
851
860
  Prints the list of declarations, retrieived by the parse() method
852
861
  """
853
862
  for d in decls:
854
- print d[0], d[1], ";".join(d[2])
863
+ print(d[0], d[1], ";".join(d[2]))
855
864
  for a in d[3]:
856
- print " ", a[0], a[1], a[2],
865
+ print(" ", a[0], a[1], a[2], end="")
857
866
  if a[3]:
858
- print "; ".join(a[3])
867
+ print("; ".join(a[3]))
859
868
  else:
860
- print
869
+ print()
861
870
 
862
871
  if __name__ == '__main__':
863
872
  parser = CppHeaderParser()
864
873
  decls = []
865
874
  # for hname in opencv_hdr_list:
866
875
  # decls += parser.parse(hname)
867
- for hname in sys.argv[1:]:
868
- decls += parser.parse(hname)
876
+ if len(sys.argv) > 2:
877
+ for hname in sys.argv[1:]:
878
+ decls += parser.parse(hname)
879
+ else:
880
+ decls += parser.parse(sys.argv[1])
869
881
  parser.print_decls(decls)
870
- print len(decls)
data/manifest.xml CHANGED
@@ -6,7 +6,5 @@
6
6
  <license></license>
7
7
  <url>http://</url>
8
8
  <logo>http://</logo>
9
-
10
- <depend package="gem-hooks" />
11
9
  <depend package="ffi" />
12
10
  </package>
data/rbind.gemspec CHANGED
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'rbind'
3
- s.version = '0.0.26'
4
- s.date = '2014-10-11'
3
+ s.version = '0.0.27'
4
+ s.date = '2015-03-08'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Alexander Duda']
7
7
  s.email = ['Alexander.Duda@dfki.de']
@@ -13,7 +13,6 @@ Gem::Specification.new do |s|
13
13
  s.files = `git ls-files`.split("\n")
14
14
  s.require_path = 'lib'
15
15
  s.required_rubygems_version = ">= 1.3.6"
16
- s.add_runtime_dependency "hooks", ">= 0.3.1"
17
16
  s.add_runtime_dependency "ffi", ">= 1.9.0"
18
17
 
19
18
  #s.rubyforge_project = s.name
metadata CHANGED
@@ -1,41 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rbind
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.26
4
+ version: 0.0.27
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alexander Duda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-10-11 00:00:00.000000000 Z
11
+ date: 2015-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: hooks
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '>='
18
- - !ruby/object:Gem::Version
19
- version: 0.3.1
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '>='
25
- - !ruby/object:Gem::Version
26
- version: 0.3.1
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: ffi
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - '>='
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
19
  version: 1.9.0
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - '>='
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
26
  version: 1.9.0
41
27
  description: Rbind is developed to automatically generate ruby bindings for OpenCV
@@ -50,13 +36,12 @@ files:
50
36
  - README.md
51
37
  - do_install.sh
52
38
  - lib/rbind.rb
53
- - lib/rbind/clang/clang.rb
54
- - lib/rbind/clang/clang_types.rb
55
- - lib/rbind/clang_parser.rb
56
39
  - lib/rbind/core.rb
40
+ - lib/rbind/core/hooks.rb
57
41
  - lib/rbind/core/rattribute.rb
58
42
  - lib/rbind/core/rbase.rb
59
43
  - lib/rbind/core/rcallback.rb
44
+ - lib/rbind/core/rcast_operation.rb
60
45
  - lib/rbind/core/rclass.rb
61
46
  - lib/rbind/core/rdata_type.rb
62
47
  - lib/rbind/core/renum.rb
@@ -74,17 +59,14 @@ files:
74
59
  - lib/rbind/logger.rb
75
60
  - lib/rbind/rbind.rb
76
61
  - lib/rbind/templates/c/CMakeLists.txt
77
- - lib/rbind/templates/c/cmake/FindGem.cmake
78
62
  - lib/rbind/templates/c/cmake/FindRuby.cmake
79
63
  - lib/rbind/templates/c/consts.h
80
64
  - lib/rbind/templates/c/conversions.cc
81
65
  - lib/rbind/templates/c/conversions.hpp
82
- - lib/rbind/templates/c/find_gem.txt
83
66
  - lib/rbind/templates/c/find_package.txt
84
67
  - lib/rbind/templates/c/operation_wrapper.cc
85
68
  - lib/rbind/templates/c/operations.cc
86
69
  - lib/rbind/templates/c/operations.h
87
- - lib/rbind/templates/c/rbind.pc.in
88
70
  - lib/rbind/templates/c/type_conversion.cc
89
71
  - lib/rbind/templates/c/type_conversion.hpp
90
72
  - lib/rbind/templates/c/type_delete.h
@@ -131,17 +113,17 @@ require_paths:
131
113
  - lib
132
114
  required_ruby_version: !ruby/object:Gem::Requirement
133
115
  requirements:
134
- - - '>='
116
+ - - ">="
135
117
  - !ruby/object:Gem::Version
136
118
  version: '0'
137
119
  required_rubygems_version: !ruby/object:Gem::Requirement
138
120
  requirements:
139
- - - '>='
121
+ - - ">="
140
122
  - !ruby/object:Gem::Version
141
123
  version: 1.3.6
142
124
  requirements: []
143
125
  rubyforge_project:
144
- rubygems_version: 2.0.14
126
+ rubygems_version: 2.2.2
145
127
  signing_key:
146
128
  specification_version: 4
147
129
  summary: Library for genereating automated ffi-bindings for c/c++ libraries