ghazel-ffi_gen 1.3.4 → 1.3.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 59badeb70519b6d81f70233f3b9b5f458b3cd837
4
- data.tar.gz: e226b09ad9744c9e601f47596f9090ee9bfda943
3
+ metadata.gz: 814f926f32ab7a8092edafb03d11e41677c4fd30
4
+ data.tar.gz: 7c9df589bfc4da60582ffab234441e187445cbae
5
5
  SHA512:
6
- metadata.gz: d91da378622756f0f51f5aad6eceb0a06d8af6a3653f452466fc4800a4e6abdfa99094d34a2e7f53962c8395cf4aeff64fd211df885c3e08bb02f3c68745eae0
7
- data.tar.gz: c263479f3ce193f5f4f420050231300dad6c92f2a41b31143f236c031334f0c7619893353c6154e299867e5e284cae1acd328564f7b98020fbf342c27f04005b
6
+ metadata.gz: 58190d289a912053875897844067f69e4b4f6c5b9f106ebdf291784caa688c7730fdc830fd69e7c8d7f1c1846e59c77a02aacec087b5bc4bcbf1e19ba018e193
7
+ data.tar.gz: 1ec94347d53eeb823c57a1bf112b23e67edf0632cc6272a0a73bdc6e6f21ec9be1f9e109e7114e932bc8ae8bcb4f757cda3ff482ec27cae0bd9b5a9e3736c2c7
@@ -152,11 +152,13 @@ class FFIGen
152
152
 
153
153
  class FunctionOrCallback
154
154
  def write_java(writer)
155
- return if @is_callback # not yet supported
156
-
157
155
  jna_signature = "#{@parameters.map{ |parameter| "#{parameter[:type].java_jna_type} #{parameter[:name].to_java_downcase}" }.join(', ')}"
158
156
  if @is_callback
159
- writer.puts "callback :#{java_name}, #{jna_signature}", ""
157
+ writer.puts "public static interface #{java_name} extends Callback {"
158
+ writer.indent do
159
+ writer.puts "#{@return_type.java_jna_type} invoke(#{jna_signature});"
160
+ end
161
+ writer.puts "}"
160
162
  else
161
163
  writer.puts "@NativeName(\"#{@name.raw}\")", "#{@return_type.java_jna_type} #{java_name}(#{jna_signature});", ""
162
164
  end
@@ -169,7 +171,7 @@ class FFIGen
169
171
  parameters = []
170
172
  lp = nil
171
173
  @parameters.each do |p|
172
- if lp && lp[:type].is_a?(PointerType) && lp[:type].pointee_type.clang_type == :u_char && p[:type].clang_type == :u_long
174
+ if lp && lp[:type].is_a?(PointerType) && lp[:type].pointee_type.respond_to?(:clang_type) && lp[:type].pointee_type.clang_type == :u_char && p[:type].clang_type == :u_long
173
175
  n = lp[:name].to_java_downcase
174
176
  replace[n] = "bytesToPointer(#{n})"
175
177
  replace[p[:name].to_java_downcase] = "new NativeLong(#{n}.length)";
data/lib/ffi_gen.rb CHANGED
@@ -512,7 +512,19 @@ class FFIGen
512
512
 
513
513
  when :typedef_decl
514
514
  typedef_children = Clang.get_children declaration_cursor
515
- if typedef_children.size == 1
515
+ underlying = Clang.get_typedef_decl_underlying_type(declaration_cursor)
516
+ function_proto = Clang.get_canonical_type(Clang.get_pointee_type(underlying))
517
+ if function_proto[:kind] == :function_proto
518
+ return_type = resolve_type Clang.get_result_type(function_proto)
519
+ parameters = []
520
+ Clang.get_num_arg_types(function_proto).times do |i|
521
+ param_type = resolve_type Clang.get_arg_type(function_proto, i)
522
+ # XXX: TODO: get arg name, somehow
523
+ param_name = Name.new ['arg', i.to_s]
524
+ parameters << { name:param_name, type: param_type, description: [] }
525
+ end
526
+ FunctionOrCallback.new self, name, parameters, return_type, true, false, comment, []
527
+ elsif typedef_children.size == 1
516
528
  child_declaration = @declarations_by_type[Clang.get_cursor_type(typedef_children.first)]
517
529
  child_declaration.name = name if child_declaration and child_declaration.name.nil?
518
530
  nil
@@ -678,7 +690,7 @@ class FFIGen
678
690
  break
679
691
  end
680
692
  end
681
- pointee_type = resolve_type current_type
693
+ pointee_type = resolve_type pointee_type
682
694
  type = PointerType.new pointee_type, pointee_name, pointer_depth
683
695
  end
684
696
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ghazel-ffi_gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.4
4
+ version: 1.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Richard Musiol
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-30 00:00:00.000000000 Z
11
+ date: 2015-06-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi