Class: RubyHToGo::TyperefDefinition

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Includes:
TypeHelper
Defined in:
_tools/ruby_h_to_go/lib/ruby_h_to_go/typeref_definition.rb

Overview

Proxy class for generating typeref in go function

Instance Method Summary collapse

Methods included from TypeHelper

#cast_to_cgo_type, #ruby_c_type_to_go_type

Constructor Details

#initialize(definition:) ⇒ TyperefDefinition

Returns a new instance of TyperefDefinition.

Parameters:

  • definition (RubyHeaderParser::TyperefDefinition)


13
14
15
# File '_tools/ruby_h_to_go/lib/ruby_h_to_go/typeref_definition.rb', line 13

def initialize(definition:)
  @definition = definition
end

Instance Method Details

#cast_func_for_function_returnString

Returns:

  • (String)


25
26
27
28
29
30
31
32
# File '_tools/ruby_h_to_go/lib/ruby_h_to_go/typeref_definition.rb', line 25

def cast_func_for_function_return
  return "" if type == "void" && !pointer?

  cast_func = ruby_c_type_to_go_type(pos: :return, pointer:)
  return "(#{cast_func})" if cast_func.start_with?("*")

  cast_func
end

#go_function_typerefString

Returns:

  • (String)


18
19
20
21
22
# File '_tools/ruby_h_to_go/lib/ruby_h_to_go/typeref_definition.rb', line 18

def go_function_typeref
  return "" if type == "void" && !pointer?

  ruby_c_type_to_go_type(pos: :typeref, pointer:)
end