Class: Rbind::RAttribute

Inherits:
RBase
  • Object
show all
Defined in:
lib/rbind/core/rattribute.rb

Direct Known Subclasses

RParameter

Instance Attribute Summary collapse

Attributes inherited from RBase

#alias, #auto_alias, #cname, #csignature, #flags, #ignore, #name, #namespace, #owner, #signature, #version

Instance Method Summary collapse

Methods inherited from RBase

#add_flag, basename, #binding, #full_name, #ignore?, #map_to_namespace, namespace, #namespace?, normalize, #pretty_print, to_cname, #validate_flags

Constructor Details

#initialize(name, type, *flags) ⇒ RAttribute

Returns a new instance of RAttribute.

Raises:

  • (ArgumentError)


5
6
7
8
9
10
# File 'lib/rbind/core/rattribute.rb', line 5

def initialize(name,type,*flags)
    super(name,*flags)
    raise ArgumentError,"no type" unless type
    raise "wrong name #{name}" if name =~/.*\*.*/
    @type = type
end

Instance Attribute Details

#typeObject

Returns the value of attribute type.



3
4
5
# File 'lib/rbind/core/rattribute.rb', line 3

def type
  @type
end

Instance Method Details

#==(other) ⇒ Object



12
13
14
# File 'lib/rbind/core/rattribute.rb', line 12

def ==(other)
    type == other.type
end

#generate_signaturesObject



16
17
18
19
20
21
22
23
24
25
# File 'lib/rbind/core/rattribute.rb', line 16

def generate_signatures
    s = "#{type.signature}#{" " if !type.ptr? && !type.ref?}#{name}"
    cs= "#{type.csignature}#{" " if !type.ptr? && !type.ref?}#{name}"

    if read_only? && !type.basic_type?
        s = "const #{s}"
        cs = "const #{cs}"
    end
    [s,cs]
end

#read_only?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/rbind/core/rattribute.rb', line 37

def read_only?
    !write?
end

#to_ptrObject



31
32
33
34
35
# File 'lib/rbind/core/rattribute.rb', line 31

def to_ptr
    a = self.dup
    a.type = type.to_ptr
    a
end

#valid_flagsObject



27
28
29
# File 'lib/rbind/core/rattribute.rb', line 27

def valid_flags
    super << :RW
end

#write?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/rbind/core/rattribute.rb', line 41

def write?
    flags.include?(:RW) || flags.include?(:IO) || flags.include?(:O)
end