Class: RedShift::Component::FunctionWrapper

Inherits:
SingletonShadowClass show all
Defined in:
lib/redshift/target/c/component-gen.rb

Overview

FunctionWrappers wrap function pointers for access from ruby.

Direct Known Subclasses

ExprWrapper, FlowWrapper, GuardWrapper

Class Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SingletonShadowClass

#inspect

Constructor Details

#initializeFunctionWrapper

Returns a new instance of FunctionWrapper.



118
119
120
# File 'lib/redshift/target/c/component-gen.rb', line 118

def initialize
  calc_function_pointer
end

Class Attribute Details

.constructorObject

Returns the value of attribute constructor.



123
124
125
# File 'lib/redshift/target/c/component-gen.rb', line 123

def constructor
  @constructor
end

Class Method Details

.constructObject



125
126
127
128
129
130
# File 'lib/redshift/target/c/component-gen.rb', line 125

def construct
  class_eval &constructor
rescue => ex
  ex.message << " While defining #{inspect_str}."
  raise
end

.make_subclass(file_name, &bl) ⇒ Object



132
133
134
135
136
137
138
139
140
141
142
143
# File 'lib/redshift/target/c/component-gen.rb', line 132

def make_subclass(file_name, &bl)
  cl = Class.new(self)
  cl.constructor = bl
  cl.shadow_library_file file_name
  clname = file_name.sub /^#{@tag}/i, @tag
  Object.const_set clname, cl ## maybe put in other namespace?
  before_commit {cl.construct}
    # this is deferred to commit time to resolve forward refs
    ## this would be more elegant with defer.rb
    ## maybe precommit should be used for this now?
  cl
end