rbind 0.0.12 → 0.0.13

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.
@@ -19,6 +19,8 @@ module Rbind
19
19
  name = normalize(name)
20
20
  cn = "#{cprefix}#{name.gsub("::","_")}"
21
21
  cn = cn.gsub("()","_fct")
22
+ cn = cn.gsub("<=","_smaller_equal")
23
+ cn = cn.gsub(">=","_greater_equal")
22
24
  cn = cn.gsub("!=","_unequal")
23
25
  cn = cn.gsub("==","_equal")
24
26
  cn = cn.gsub("&=","_and_set")
@@ -30,6 +32,8 @@ module Rbind
30
32
  cn = cn.gsub("/","_div")
31
33
  cn = cn.gsub("!","_not")
32
34
  cn = cn.gsub("&","_and")
35
+ cn = cn.gsub("<","_smaller")
36
+ cn = cn.gsub(">","_greater")
33
37
  cn.gsub("[]","_array")
34
38
  end
35
39
 
@@ -2,10 +2,11 @@ require 'yaml'
2
2
 
3
3
  module Rbind
4
4
  class GeneratorExtern
5
- Config = Struct.new(:ruby_module_name)
5
+ Config = Struct.new(:ruby_module_name,:file_prefix)
6
6
 
7
7
  attr_accessor :output_path
8
8
  attr_accessor :ruby_module_name
9
+ attr_accessor :file_prefix
9
10
  def self.normalize_type_name(name)
10
11
  name.gsub('::','.')
11
12
  end
@@ -14,9 +15,10 @@ module Rbind
14
15
  @root = root
15
16
  end
16
17
 
17
- def generate(path = @output_path,ruby_module_name = @ruby_module_name)
18
+ def generate(path = @output_path,ruby_module_name = @ruby_module_name,file_prefix = @file_prefix)
18
19
  @output_path = path
19
20
  @ruby_module_name = ruby_module_name
21
+ @file_prefix = file_prefix
20
22
  FileUtils.mkdir_p(path) if path && !File.directory?(path)
21
23
  file_extern = File.new(File.join(path,"extern.rbind"),"w")
22
24
  file_config = File.new(File.join(path,"config.rbind"),"w")
@@ -33,7 +35,7 @@ module Rbind
33
35
  file_extern.write "const #{GeneratorExtern.normalize_type_name(c.full_name)} /Extern\n"
34
36
  end
35
37
  file_extern.write("\n")
36
- file_config.write Config.new(ruby_module_name).to_yaml
38
+ file_config.write Config.new(ruby_module_name,file_prefix).to_yaml
37
39
  end
38
40
  end
39
41
  end
@@ -516,7 +516,7 @@ module Rbind
516
516
  @rbind_wrapper = ERB.new(File.open(File.join(File.dirname(__FILE__),"templates","ruby","rbind.rb")).read)
517
517
  @module_name = module_name
518
518
  @library_name = library_name
519
- @compact_namespace = false
519
+ @compact_namespace = true
520
520
  end
521
521
 
522
522
  def generate(path=@output_path)
data/lib/rbind/rbind.rb CHANGED
@@ -150,7 +150,7 @@ module Rbind
150
150
  paths = Rbind.rbind_pkg_paths(@pkg_config)
151
151
  modules = paths.map do |pkg|
152
152
  config = YAML.load(File.open(File.join(pkg,"config.rbind")).read)
153
- config.ruby_module_name
153
+ config.file_prefix
154
154
  end
155
155
  @generator_ruby.required_module_names = modules + gems
156
156
  @generator_ruby.generate(path)
@@ -165,7 +165,7 @@ module Rbind
165
165
  end
166
166
 
167
167
  def generate_extern(path)
168
- @generator_extern.generate(path,@generator_ruby.module_name)
168
+ @generator_extern.generate(path,@generator_ruby.module_name,@generator_ruby.file_prefix)
169
169
  end
170
170
 
171
171
  def use_namespace(name)
@@ -17,9 +17,8 @@ ADD_LIBRARY(<%= library_name %> SHARED ${RBIND_SRC})
17
17
  TARGET_LINK_LIBRARIES(<%= library_name %> <%= libs %> ${GEM_LIBRARIES})
18
18
 
19
19
  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/rbind.pc.in ${CMAKE_CURRENT_BINARY_DIR}/<%= library_name %>.pc @ONLY)
20
- set(ROOT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/..)
21
20
 
22
- # global install
21
+ set(ROOT_FOLDER ${CMAKE_CURRENT_SOURCE_DIR}/..)
23
22
  if(GEM_INSTALL)
24
23
  # local install
25
24
  install(TARGETS <%= library_name %> LIBRARY DESTINATION ${ROOT_FOLDER}/lib/lib)
@@ -39,7 +38,7 @@ else()
39
38
  MESSAGE(STATUS "Ruby library not found. Cannot install ruby extensions")
40
39
  ELSEIF(NOT RUBY_EXTENSIONS_AVAILABLE)
41
40
  STRING(REGEX REPLACE ".*lib(32|64)?/?" "lib/" RUBY_LIBRARY_INSTALL_DIR ${RUBY_RUBY_LIB_PATH})
42
- INSTALL(DIRECTORY ${ROOT_FOLDER}/lib/ruby DESTINATION ${RUBY_LIBRARY_INSTALL_DIR}
41
+ INSTALL(DIRECTORY ${ROOT_FOLDER}/lib/ruby/ DESTINATION ${RUBY_LIBRARY_INSTALL_DIR}
43
42
  FILES_MATCHING PATTERN "*.rb")
44
43
  ENDIF(NOT RUBY_INCLUDE_PATH)
45
44
  endif()
@@ -8,10 +8,13 @@ module <%= name %>
8
8
  extend FFI::Library
9
9
 
10
10
  #load library <%= library_name %>
11
- path = Dir.chdir(File.join(File.dirname(__FILE__),"..","..","lib")) do
12
- path = Dir.glob("lib<%= library_name %>.*").first
13
- File.absolute_path(path) if path
14
- end
11
+ path = File.join(File.dirname(__FILE__),"..","..","lib")
12
+ path = if Dir.exist?(path)
13
+ Dir.chdir(path) do
14
+ path = Dir.glob("lib<%= library_name %>.*").first
15
+ File.absolute_path(path) if path
16
+ end
17
+ end
15
18
  ffi_lib ["<%= library_name %>", path]
16
19
 
17
20
  #add error checking
@@ -1,6 +1,9 @@
1
1
  # wrapper for <%= full_name %>
2
2
  module <%= name %>
3
+ # @!group Constants
3
4
  <%= add_consts%>
5
+ # @!endgroup
6
+ #
4
7
  <%= add_methods %>
5
8
  <%= add_types %>
6
9
  end
@@ -1,3 +1,4 @@
1
+ # @api private
1
2
  # object wrapping <%= full_name %>
2
3
  class <%= name %>Struct < FFI::Struct
3
4
  layout :version,:uchar,
@@ -26,6 +27,7 @@ class <%= name %>
26
27
  raise ArgumentError, "no constructor for #{self}(#{args.inspect})"
27
28
  end
28
29
 
30
+ # @api private
29
31
  def self.rbind_to_native(obj,context)
30
32
  if obj.is_a? <%= name %>
31
33
  obj.__obj_ptr__
@@ -34,21 +36,27 @@ class <%= name %>
34
36
  end
35
37
  end
36
38
 
39
+ # @api private
37
40
  def self.rbind_from_native(ptr,context)
38
41
  <%= name %>.new(ptr)
39
42
  end
40
43
 
44
+ # @api private
41
45
  # can be overwritten by the user
42
46
  def self.to_native(obj,context)
43
47
  rbind_to_native(obj,context)
44
48
  end
45
49
 
50
+ # @api private
46
51
  # can be overwritten by the user
47
52
  def self.from_native(ptr,context)
48
53
  rbind_from_native(ptr,context)
49
54
  end
50
55
 
56
+ # @api private
51
57
  attr_reader :__obj_ptr__
58
+
59
+ # @api private
52
60
  def initialize(ptr)
53
61
  @__obj_ptr__ = if ptr.is_a? <%= name %>Struct
54
62
  ptr
@@ -57,20 +65,24 @@ class <%= name %>
57
65
  end
58
66
  end
59
67
 
68
+ # @api private
60
69
  # returns true if the underlying pointer is owner of
61
70
  # the real object
62
71
  def __owner__?
63
72
  @__obj_ptr__[:bowner]
64
73
  end
65
74
 
66
- # custom specializing
75
+ # @!group Sepcializing
67
76
  <%= add_specializing %>
77
+ # @!endgroup
68
78
 
69
- # consts
79
+ # @!group Constants
70
80
  <%= add_consts %>
81
+ # @!endgroup
71
82
 
72
83
  # methods
73
84
  <%= add_methods %>
85
+
74
86
  # types
75
87
  <%= add_types %>
76
88
  end
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.12'
3
+ s.version = '0.0.13'
4
4
  s.date = '2013-07-03'
5
5
  s.platform = Gem::Platform::RUBY
6
6
  s.authors = ['Alexander Duda']
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rbind
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.0.12
5
+ version: 0.0.13
6
6
  platform: ruby
7
7
  authors:
8
8
  - Alexander Duda
@@ -106,3 +106,4 @@ specification_version: 3
106
106
  summary: Library for genereating automated ffi-bindings for c/c++ libraries
107
107
  test_files: []
108
108
 
109
+ has_rdoc: