Module: WinGUI::Util::ScopedStruct

Instance Method Summary collapse

Instance Method Details

#new(*args) ⇒ Object

Raises:

  • (ArgumentError)


43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/ffi-wingui-core/common.rb', line 43

def new(*args)
	raise ArgumentError, 'Cannot accept both arguments and a block' if
		args.length > 0 && block_given?

	struct = super

	return struct unless block_given?

	begin
		yield struct
	ensure
		struct.pointer.free

		p "Native memory for #{struct} freed" if $DEBUG
	end

	nil
end