Class: Rbind::RConst

Inherits:
RDataType show all
Defined in:
lib/rbind/core/rconst.rb

Instance Attribute Summary collapse

Attributes inherited from RDataType

#cdelete_method, #check_type, #extern_package_name, #invalid_value, #ptr, #ref, #typedef

Attributes inherited from RBase

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

Instance Method Summary collapse

Methods inherited from RDataType

#==, #check_type?, #cname, #container?, #delete!, #extern?, #ptr?, #ref?, #to_ptr, #to_value, #typedef?, #valid_flags

Methods inherited from RBase

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

Constructor Details

#initialize(name, value, *flags) ⇒ RConst

Returns a new instance of RConst.



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

def initialize(name,value,*flags)
    super(name,*flags)
    @value = value
end

Instance Attribute Details

#valueObject

Returns the value of attribute value.



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

def value
  @value
end

Instance Method Details

#basic_type?Boolean

Returns:

  • (Boolean)


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

def basic_type?
    false
end

#generate_signaturesObject



11
12
13
# File 'lib/rbind/core/rconst.rb', line 11

def generate_signatures
    ["#{full_name} = #{value}","const int #{cname} = #{map_value_to_namespace(value)}"]
end

#map_value_to_namespace(value) ⇒ Object



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

def map_value_to_namespace(value)
    a = value.split(" ")
    a = a.map do |str|
        if str =~/^[a-zA-Z]/
            RBase.to_cname("#{namespace}::#{str}")
        else
            str
        end
    end
    a.join(" ")
end

#pretty_print(pp) ⇒ Object



31
32
33
# File 'lib/rbind/core/rconst.rb', line 31

def pretty_print(pp)
    pp.text "#{signature}#{" Flags: #{flags.join(", ")}" unless flags.empty?}"
end