Class: FFI::Inline::Compiler

Inherits:
Object
  • Object
show all
Defined in:
lib/ffi/inline/compilers.rb

Constant Summary collapse

Extension =
case RbConfig::CONFIG['target_os']
when /darwin/      then 'dylib'
when /mswin|mingw/ then 'dll'
else                    'so'
end

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, *aliases) ⇒ Compiler

Returns a new instance of Compiler.



49
50
51
52
# File 'lib/ffi/inline/compilers.rb', line 49

def initialize (name, *aliases)
	@name    = name
	@aliases = aliases
end

Instance Attribute Details

#aliasesObject (readonly)

Returns the value of attribute aliases.



46
47
48
# File 'lib/ffi/inline/compilers.rb', line 46

def aliases
  @aliases
end

#nameObject (readonly)

Returns the value of attribute name.



46
47
48
# File 'lib/ffi/inline/compilers.rb', line 46

def name
  @name
end

#optionsObject

Returns the value of attribute options.



47
48
49
# File 'lib/ffi/inline/compilers.rb', line 47

def options
  @options
end

Class Method Details

.[](name) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/ffi/inline/compilers.rb', line 22

def self.[] (name)
	return name if name.is_a?(Compiler)

	@compilers.find {|compiler|
		compiler.name.downcase == name.downcase ||
		compiler.aliases.any? { |ali| ali.downcase == name.downcase }
	}
end

.define(name, *aliases, &block) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/ffi/inline/compilers.rb', line 31

def self.define (name, *aliases, &block)
	inherit_from = self

	if name.is_a?(Compiler)
		name = name.class
	end

	if name.is_a?(Class)
		inherit_from = name
		name         = aliases.shift
	end

	@compilers << Class.new(inherit_from, &block).new(name, *aliases)
end

Instance Method Details

#compileObject



58
59
60
# File 'lib/ffi/inline/compilers.rb', line 58

def compile
	raise 'the Compiler has not been specialized'
end

#exists?Boolean

Returns:

  • (Boolean)


54
55
56
# File 'lib/ffi/inline/compilers.rb', line 54

def exists?
	raise 'the Compiler has not been specialized'
end