Class: Ruby2CExtension::Scopes::WrappedScope
- Defined in:
- lib/ruby2cext/scopes.rb
Instance Method Summary collapse
- #init_c_code ⇒ Object
-
#initialize(base_scope) ⇒ WrappedScope
constructor
A new instance of WrappedScope.
-
#method_missing(meth, *arg) ⇒ Object
redirect to @base_scope.
- #var_ptr_for_wrap ⇒ Object
Constructor Details
#initialize(base_scope) ⇒ WrappedScope
Returns a new instance of WrappedScope.
189 190 191 |
# File 'lib/ruby2cext/scopes.rb', line 189 def initialize(base_scope) @base_scope = base_scope end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *arg) ⇒ Object
redirect to @base_scope
194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 |
# File 'lib/ruby2cext/scopes.rb', line 194 def method_missing(meth, *arg) res = @base_scope.send(meth, *arg) if String === res case res when "lvar_ary" raise Ruby2CExtError::Bug, "unexpected need for lvar_ary in WrappedScope" when "dvar_ary" raise Ruby2CExtError::Bug, "unexpected need for dvar_ary in WrappedScope" when /\bclosure\b/ res.gsub!(/\bclosure\b/, "(wrap_ptr->closure)") when /\b[ld]var\b/ res.gsub!(/\b[ld]var\b/, "(wrap_ptr->var)") when /^rb_define/ # nothing else raise Ruby2CExtError::Bug, "unexpected string returned from #{@base_scope.class}##{meth}: #{res}" end end res end |
Instance Method Details
#init_c_code ⇒ Object
219 220 221 |
# File 'lib/ruby2cext/scopes.rb', line 219 def init_c_code raise Ruby2CExtError::Bug, "unexpected call of init_c_code" end |
#var_ptr_for_wrap ⇒ Object
215 216 217 |
# File 'lib/ruby2cext/scopes.rb', line 215 def var_ptr_for_wrap raise Ruby2CExtError::Bug, "unexpected call of var_ptr_for_wrap" end |