Module: Packer

Included in:
ExternObject, Tgui::ToolTip
Defined in:
lib/white_gold/abi/packer.rb

Instance Method Summary collapse

Instance Method Details

#abi_pack(host, type, *a) ⇒ Object



24
25
26
# File 'lib/white_gold/abi/packer.rb', line 24

def abi_pack host, type, *a
  Interface.parse_packer(type).call host, *a
end

#abi_packer(base, &body) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/white_gold/abi/packer.rb', line 4

def abi_packer base, &body
  if block_given?
    define_method abi_packer_method_name(base), &body
  elsif base.is_a? Module
    define_method abi_packer_method_name(base) do |*o|
      base.from *o
    end
  else
    raise "..."
  end
end

#abi_packer_method_name(base) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/white_gold/abi/packer.rb', line 16

def abi_packer_method_name base
  case base
  when String then "abi_pack#{Interface.abi_const_string_method_suffix base}".to_sym
  when Symbol then base.to_s.start_with?("_") ? "abi_pack#{base}".to_sym : base
  else "abi_pack#{Interface.abi_const_string_method_suffix base.name}".to_sym
  end
end