Class: GeneratedCode

Inherits:
Struct
  • Object
show all
Defined in:
ext/generate_gvl_code.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*a) ⇒ GeneratedCode

Returns a new instance of GeneratedCode.



186
187
188
189
190
191
192
# File 'ext/generate_gvl_code.rb', line 186

def initialize(*a)
  super

  self.structs     ||= []
  self.wrapper_fns ||= []
  self.calling_fns ||= []
end

Instance Attribute Details

#calling_fnsObject

Returns the value of attribute calling_fns

Returns:

  • (Object)

    the current value of calling_fns



185
186
187
# File 'ext/generate_gvl_code.rb', line 185

def calling_fns
  @calling_fns
end

#structsObject

Returns the value of attribute structs

Returns:

  • (Object)

    the current value of structs



185
186
187
# File 'ext/generate_gvl_code.rb', line 185

def structs
  @structs
end

#wrapper_fnsObject

Returns the value of attribute wrapper_fns

Returns:

  • (Object)

    the current value of wrapper_fns



185
186
187
# File 'ext/generate_gvl_code.rb', line 185

def wrapper_fns
  @wrapper_fns
end

Class Method Details

.from_zookeeper_h(text) ⇒ Object



194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'ext/generate_gvl_code.rb', line 194

def self.from_zookeeper_h(text)
  new.tap do |code|
    while true
      break unless text =~ REGEXP
      text = $~.post_match

      zoo_fn_name, argstr = $1
      argstr = $2

      typed_args = argstr.split(',').map(&:strip)

      # gah, fix up functions which have a void_completion_t with no name assigned
      if idx = typed_args.index('void_completion_t')
        typed_args[idx] = 'void_completion_t completion'
      end

      struct = CallStruct.new(zoo_fn_name, typed_args)
      wrapper_fn = WrapperFunction.new(zoo_fn_name, struct)
      calling_fn = CallingFunction.new(zoo_fn_name, struct, wrapper_fn)

      code.structs << struct
      code.wrapper_fns << wrapper_fn
      code.calling_fns << calling_fn
    end
  end
end