Class: Rbind::RBase
- Inherits:
-
Object
- Object
- Rbind::RBase
- Defined in:
- lib/rbind/core/rbase.rb
Direct Known Subclasses
Class Attribute Summary collapse
-
.cprefix ⇒ Object
Returns the value of attribute cprefix.
Instance Attribute Summary collapse
-
#alias(val = nil) ⇒ Object
Returns the value of attribute alias.
-
#auto_alias ⇒ Object
set to true if rbind is aliasing the object.
-
#cname(name = nil) ⇒ Object
Returns the value of attribute cname.
-
#csignature(sig = nil) ⇒ Object
Returns the value of attribute csignature.
-
#doc(&block) ⇒ Object
Returns the value of attribute doc.
-
#extern_package_name ⇒ Object
Returns the value of attribute extern_package_name.
-
#ignore ⇒ Object
Returns the value of attribute ignore.
-
#name ⇒ Object
Returns the value of attribute name.
-
#namespace ⇒ Object
Returns the value of attribute namespace.
-
#owner ⇒ Object
Returns the value of attribute owner.
-
#signature(sig = nil) ⇒ Object
Returns the value of attribute signature.
-
#version ⇒ Object
Returns the value of attribute version.
Class Method Summary collapse
- .basename(name) ⇒ Object
- .namespace(name) ⇒ Object
- .normalize(name) ⇒ Object
- .split_name(name) ⇒ Object
- .to_cname(name) ⇒ Object
Instance Method Summary collapse
- #binding ⇒ Object
- #delete! ⇒ Object
-
#extern? ⇒ Boolean
returns true if this object is defined in another extern package.
- #full_name ⇒ Object
- #generate_signatures ⇒ Object
- #ignore? ⇒ Boolean
-
#initialize(name) ⇒ RBase
constructor
A new instance of RBase.
- #map_to_namespace(name) ⇒ Object
- #namespace? ⇒ Boolean
- #pretty_print(pp) ⇒ Object
- #rename(name) ⇒ Object
-
#specialize_ruby(&block) ⇒ Object
specialize.
- #to_s ⇒ Object
Constructor Details
#initialize(name) ⇒ RBase
Returns a new instance of RBase.
79 80 81 82 |
# File 'lib/rbind/core/rbase.rb', line 79 def initialize(name) rename(name) @version = 1 end |
Class Attribute Details
.cprefix ⇒ Object
Returns the value of attribute cprefix.
17 18 19 |
# File 'lib/rbind/core/rbase.rb', line 17 def cprefix @cprefix end |
Instance Attribute Details
#alias(val = nil) ⇒ Object
Returns the value of attribute alias.
5 6 7 |
# File 'lib/rbind/core/rbase.rb', line 5 def alias @alias end |
#auto_alias ⇒ Object
set to true if rbind is aliasing the object
6 7 8 |
# File 'lib/rbind/core/rbase.rb', line 6 def auto_alias @auto_alias end |
#cname(name = nil) ⇒ Object
Returns the value of attribute cname.
4 5 6 |
# File 'lib/rbind/core/rbase.rb', line 4 def cname @cname end |
#csignature(sig = nil) ⇒ Object
Returns the value of attribute csignature.
11 12 13 |
# File 'lib/rbind/core/rbase.rb', line 11 def csignature @csignature end |
#doc(&block) ⇒ Object
Returns the value of attribute doc.
14 15 16 |
# File 'lib/rbind/core/rbase.rb', line 14 def doc @doc end |
#extern_package_name ⇒ Object
Returns the value of attribute extern_package_name.
13 14 15 |
# File 'lib/rbind/core/rbase.rb', line 13 def extern_package_name @extern_package_name end |
#ignore ⇒ Object
Returns the value of attribute ignore.
12 13 14 |
# File 'lib/rbind/core/rbase.rb', line 12 def ignore @ignore end |
#name ⇒ Object
Returns the value of attribute name.
3 4 5 |
# File 'lib/rbind/core/rbase.rb', line 3 def name @name end |
#namespace ⇒ Object
Returns the value of attribute namespace.
7 8 9 |
# File 'lib/rbind/core/rbase.rb', line 7 def namespace @namespace end |
#owner ⇒ Object
Returns the value of attribute owner.
8 9 10 |
# File 'lib/rbind/core/rbase.rb', line 8 def owner @owner end |
#signature(sig = nil) ⇒ Object
Returns the value of attribute signature.
10 11 12 |
# File 'lib/rbind/core/rbase.rb', line 10 def signature @signature end |
#version ⇒ Object
Returns the value of attribute version.
9 10 11 |
# File 'lib/rbind/core/rbase.rb', line 9 def version @version end |
Class Method Details
.basename(name) ⇒ Object
69 70 71 |
# File 'lib/rbind/core/rbase.rb', line 69 def basename(name) split_name(name)[1] end |
.namespace(name) ⇒ Object
65 66 67 |
# File 'lib/rbind/core/rbase.rb', line 65 def namespace(name) split_name(name)[0] end |
.normalize(name) ⇒ Object
44 45 46 47 48 49 50 |
# File 'lib/rbind/core/rbase.rb', line 44 def normalize(name) name = name.to_s if name.split("/n").size > 1 raise "mulitple lines for a name is not supported: #{name}" end name.gsub(".","::").gsub(" ","") end |
.split_name(name) ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/rbind/core/rbase.rb', line 52 def split_name(name) name = normalize(name) # check for template if(name =~/([\w:]*)(<.*)$/) result = split_name($1) [result[0],result[1]+$2] elsif(name =~/(.*)::(.*)$/) [$1,$2] else [nil,name] end end |
.to_cname(name) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/rbind/core/rbase.rb', line 19 def to_cname(name) name = normalize(name) cn = "#{cprefix}#{name.gsub("::","_")}" if cn =~ /operator/ cn = cn.gsub("operator()","operator_fct") cn = cn.gsub("operator!=","operator_unequal") cn = cn.gsub("operator==","operator_equal") cn = cn.gsub("operator&=","operator_and_set") cn = cn.gsub("operator+=","operator_add") cn = cn.gsub("operator-=","operator_sub") cn = cn.gsub("operator+","operator_plus") cn = cn.gsub("operator-","operator_minus") cn = cn.gsub("operator*","operator_mult") cn = cn.gsub("operator/","operator_div") cn = cn.gsub("operator!","operator_not") cn = cn.gsub("operator&","operator_and") cn = cn.gsub("operator[]","operator_array") end cn = cn.gsub("*","_ptr") cn = cn.gsub("&","_ref") cn = cn.gsub("<","_") cn = cn.gsub(">","") cn = cn.gsub(",","__") end |
Instance Method Details
#binding ⇒ Object
193 194 195 |
# File 'lib/rbind/core/rbase.rb', line 193 def binding Kernel.binding end |
#delete! ⇒ Object
185 186 187 188 189 190 191 |
# File 'lib/rbind/core/rbase.rb', line 185 def delete! if @owner @owner.delete_type self.name else raise "#{self} has no owner." end end |
#extern? ⇒ Boolean
returns true if this object is defined in another extern package
93 94 95 |
# File 'lib/rbind/core/rbase.rb', line 93 def extern? extern_package_name && !extern_package_name.empty? end |
#full_name ⇒ Object
157 158 159 |
# File 'lib/rbind/core/rbase.rb', line 157 def full_name map_to_namespace(name) end |
#generate_signatures ⇒ Object
84 85 86 |
# File 'lib/rbind/core/rbase.rb', line 84 def generate_signatures ["#{full_name}","#{cname}"] end |
#ignore? ⇒ Boolean
88 89 90 |
# File 'lib/rbind/core/rbase.rb', line 88 def ignore? !!@ignore end |
#map_to_namespace(name) ⇒ Object
165 166 167 168 169 170 171 |
# File 'lib/rbind/core/rbase.rb', line 165 def map_to_namespace(name) if namespace "#{namespace}::#{name}" else name end end |
#namespace? ⇒ Boolean
153 154 155 |
# File 'lib/rbind/core/rbase.rb', line 153 def namespace? namespace && namespace.size != 0 end |
#pretty_print(pp) ⇒ Object
75 76 77 |
# File 'lib/rbind/core/rbase.rb', line 75 def pretty_print(pp) pp.text "#{signature}" end |
#rename(name) ⇒ Object
173 174 175 176 177 178 179 180 181 182 183 |
# File 'lib/rbind/core/rbase.rb', line 173 def rename(name) old_name = self.name name = RBase::normalize(name) raise ArgumentError, "no name" unless name && name.size > 0 @name = RBase::basename(name) @namespace = RBase::namespace(name) if @owner @owner.delete_type old_name @owner.add_type(self) end end |
#specialize_ruby(&block) ⇒ Object
specialize
208 209 210 211 212 213 214 |
# File 'lib/rbind/core/rbase.rb', line 208 def specialize_ruby(&block) if block @specialize_ruby = block elsif @specialize_ruby @specialize_ruby.call end end |
#to_s ⇒ Object
161 162 163 |
# File 'lib/rbind/core/rbase.rb', line 161 def to_s signature end |