Class: Ruby2CExtension::Scopes::WrappedScope

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby2cext/scopes.rb

Instance Method Summary collapse

Constructor Details

#initialize(base_scope) ⇒ WrappedScope

Returns a new instance of WrappedScope.



191
192
193
# File 'lib/ruby2cext/scopes.rb', line 191

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



196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/ruby2cext/scopes.rb', line 196

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_codeObject



221
222
223
# File 'lib/ruby2cext/scopes.rb', line 221

def init_c_code
	raise Ruby2CExtError::Bug, "unexpected call of init_c_code"
end

#var_ptr_for_wrapObject



217
218
219
# File 'lib/ruby2cext/scopes.rb', line 217

def var_ptr_for_wrap
	raise Ruby2CExtError::Bug, "unexpected call of var_ptr_for_wrap"
end