Skip to content

Commit 1073839

Browse files
committed
RSTRING_PTR returns raw char* instead of string
1 parent 5ca334c commit 1073839

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

_tools/ruby_h_to_go/lib/ruby_header_parser/parser.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ def create_typeref(definition:, function_name:, typeref_field:, filepath:, line_
265265
typeref_pointer = nil
266266
if typeref_type.match?(/\*+$/)
267267
typeref_type = typeref_type.gsub(/\*+$/, "").strip
268-
typeref_pointer = :ref
268+
typeref_pointer = data.function_self_pointer_hint(function_name)
269269
end
270270

271271
TyperefDefinition.new(type: typeref_type, pointer: typeref_pointer)

_tools/ruby_h_to_go/spec/ruby_header_parser/parser_spec.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,21 @@
301301
its(:typeref) { should eq typeref(type: "VALUE") }
302302
its(:args) { should eq args }
303303
end
304+
305+
context "RSTRING_PTR" do
306+
subject { definitions.find { |d| d.name == "RSTRING_PTR" } }
307+
308+
let(:args) do
309+
[
310+
argument(type: "VALUE", name: "str"),
311+
]
312+
end
313+
314+
its(:name) { should eq "RSTRING_PTR" }
315+
its(:definition) { should eq "RSTRING_PTR(VALUE str)" }
316+
its(:typeref) { should eq typeref(type: "char", pointer: :raw) }
317+
its(:args) { should eq args }
318+
end
304319
end
305320

306321
describe "#extract_struct_definitions" do

0 commit comments

Comments
 (0)