Class: Rbind::RDataType

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

Direct Known Subclasses

RConst, REnum, RNamespace

Instance Attribute Summary collapse

Attributes inherited from RBase

#alias, #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, *flags) ⇒ RDataType

Returns a new instance of RDataType.



11
12
13
14
15
# File 'lib/rbind/core/rdata_type.rb', line 11

def initialize(name,*flags)
    super
    @invalid_value = 0
    @check_type = true
end

Instance Attribute Details

#cdelete_methodObject

Returns the value of attribute cdelete_method.



7
8
9
# File 'lib/rbind/core/rdata_type.rb', line 7

def cdelete_method
  @cdelete_method
end

#check_typeObject

Returns the value of attribute check_type.



8
9
10
# File 'lib/rbind/core/rdata_type.rb', line 8

def check_type
  @check_type
end

#extern_package_nameObject

Returns the value of attribute extern_package_name.



9
10
11
# File 'lib/rbind/core/rdata_type.rb', line 9

def extern_package_name
  @extern_package_name
end

#invalid_valueObject

Returns the value of attribute invalid_value.



6
7
8
# File 'lib/rbind/core/rdata_type.rb', line 6

def invalid_value
  @invalid_value
end

#ptrObject

Returns the value of attribute ptr.



4
5
6
# File 'lib/rbind/core/rdata_type.rb', line 4

def ptr
  @ptr
end

#refObject

Returns the value of attribute ref.



4
5
6
# File 'lib/rbind/core/rdata_type.rb', line 4

def ref
  @ref
end

#typedef(value = nil) ⇒ Object

Returns the value of attribute typedef.



5
6
7
# File 'lib/rbind/core/rdata_type.rb', line 5

def typedef
  @typedef
end

Instance Method Details

#==(other) ⇒ Object



25
26
27
# File 'lib/rbind/core/rdata_type.rb', line 25

def ==(other)
    other.name == name && other.ptr == ptr
end

#basic_type?Boolean

elementar type of c

Returns:

  • (Boolean)


67
68
69
# File 'lib/rbind/core/rdata_type.rb', line 67

def basic_type?
    true
end

#check_type?Boolean

Returns:

  • (Boolean)


39
40
41
# File 'lib/rbind/core/rdata_type.rb', line 39

def check_type?
    @check_type
end

#cname(value = nil) ⇒ Object



43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/rbind/core/rdata_type.rb', line 43

def cname(value=nil)
    if !value
        if basic_type? && !@cname
            name
        else
            super
        end
    else
        super
        self
    end
end

#container?Boolean

holds ofther operations, types or consts

Returns:

  • (Boolean)


72
73
74
# File 'lib/rbind/core/rdata_type.rb', line 72

def container?
    false
end

#delete!Object



88
89
90
91
92
93
94
# File 'lib/rbind/core/rdata_type.rb', line 88

def delete!
    if @owner
        @owner.delete_type self.name
    else 
        raise "#{self} has no owner."
    end
end

#extern?Boolean

Returns:

  • (Boolean)


17
18
19
# File 'lib/rbind/core/rdata_type.rb', line 17

def extern?
   @flags.include? :Extern
end

#generate_signaturesObject



29
30
31
32
33
34
35
36
37
# File 'lib/rbind/core/rdata_type.rb', line 29

def generate_signatures
    if ref?
        ["#{full_name} &","#{cname} &"]
    elsif ptr?
        ["#{full_name} *","#{cname} *"]
    else
        super
    end
end

#ptr?Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/rbind/core/rdata_type.rb', line 96

def ptr?
    !!ptr
end

#ref?Boolean

Returns:

  • (Boolean)


100
101
102
# File 'lib/rbind/core/rdata_type.rb', line 100

def ref?
    !!ref
end

#to_ptrObject



80
81
82
83
84
85
86
# File 'lib/rbind/core/rdata_type.rb', line 80

def to_ptr
    return self if ptr? && !ref?
    t = self.dup
    t.ref = false
    t.ptr = true
    t
end

#to_valueObject



76
77
78
# File 'lib/rbind/core/rdata_type.rb', line 76

def to_value
    owner.type(name)
end

#typedef?Boolean

Returns:

  • (Boolean)


62
63
64
# File 'lib/rbind/core/rdata_type.rb', line 62

def typedef?
    !!@typedef
end

#valid_flagsObject



21
22
23
# File 'lib/rbind/core/rdata_type.rb', line 21

def valid_flags
    super << :Extern
end