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 +4 -4
- data/lib/ffi_gen/java_output.rb +6 -4
- data/lib/ffi_gen.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 814f926f32ab7a8092edafb03d11e41677c4fd30
|
4
|
+
data.tar.gz: 7c9df589bfc4da60582ffab234441e187445cbae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58190d289a912053875897844067f69e4b4f6c5b9f106ebdf291784caa688c7730fdc830fd69e7c8d7f1c1846e59c77a02aacec087b5bc4bcbf1e19ba018e193
|
7
|
+
data.tar.gz: 1ec94347d53eeb823c57a1bf112b23e67edf0632cc6272a0a73bdc6e6f21ec9be1f9e109e7114e932bc8ae8bcb4f757cda3ff482ec27cae0bd9b5a9e3736c2c7
|
data/lib/ffi_gen/java_output.rb
CHANGED
@@ -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 "
|
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
|
-
|
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
|
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
|
+
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-
|
11
|
+
date: 2015-06-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ffi
|