Class: WrapperFunction
- Inherits:
-
Object
- Object
- WrapperFunction
- Extended by:
- Forwardable
- Includes:
- MemberNames
- Defined in:
- ext/generate_gvl_code.rb
Overview
the zkrb_gvl_zoo_* function
Constant Summary collapse
- PREFIX =
'zkrb_gvl'
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#struct ⇒ Object
readonly
Returns the value of attribute struct.
-
#zoo_fn_name ⇒ Object
readonly
Returns the value of attribute zoo_fn_name.
Instance Method Summary collapse
- #body ⇒ Object
- #fn_signature ⇒ Object
-
#initialize(zoo_fn_name, struct) ⇒ WrapperFunction
constructor
A new instance of WrapperFunction.
Methods included from MemberNames
Constructor Details
#initialize(zoo_fn_name, struct) ⇒ WrapperFunction
Returns a new instance of WrapperFunction.
104 105 106 107 108 |
# File 'ext/generate_gvl_code.rb', line 104 def initialize(zoo_fn_name, struct) @zoo_fn_name = zoo_fn_name @struct = struct @name = "#{PREFIX}_#{zoo_fn_name}" end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
102 103 104 |
# File 'ext/generate_gvl_code.rb', line 102 def name @name end |
#struct ⇒ Object (readonly)
Returns the value of attribute struct.
102 103 104 |
# File 'ext/generate_gvl_code.rb', line 102 def struct @struct end |
#zoo_fn_name ⇒ Object (readonly)
Returns the value of attribute zoo_fn_name.
102 103 104 |
# File 'ext/generate_gvl_code.rb', line 102 def zoo_fn_name @zoo_fn_name end |
Instance Method Details
#body ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'ext/generate_gvl_code.rb', line 114 def body @body ||= ( lines = ["#{fn_signature} {"] lines << " #{struct.name} *a = (#{struct.name} *)data;" funcall = " a->rc = #{zoo_fn_name}(" funcall << member_names.map { |m| "a->#{m}" }.join(', ') funcall << ');' lines << funcall lines << " return Qnil;" lines << "}" lines.join("\n") ) end |
#fn_signature ⇒ Object
110 111 112 |
# File 'ext/generate_gvl_code.rb', line 110 def fn_signature @fn_signature ||= "static VALUE #{name}(void *data)" end |