Method: DL::Types#encode_struct_type

Defined in:
lib/dl/types.rb

#encode_struct_type(alias_type) ⇒ Object



213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# File 'lib/dl/types.rb', line 213

def encode_struct_type(alias_type)
  proc_encode = nil
  proc_decode = nil
  @TYDEFS.each{|aty,_,_,_,ty,enc,dec|
	if( (aty.is_a?(Regexp) && (aty =~ alias_type)) || (aty == alias_type) )
	  alias_type = alias_type.gsub(aty,ty) if ty
      alias_type.strip! if alias_type
	  if( proc_encode )
 if( enc )
   conv1 = proc_encode
   proc_encode = proc{|v| enc.call(conv1.call(v))}
 end
	  else
 if( enc )
   proc_encode = enc
 end
	  end
	  if( proc_decode )
 if( dec )
   conv2 = proc_decode
   proc_decode = proc{|v| dec.call(conv2.call(v))}
 end
	  else
 if( dec )
   proc_decode = dec
 end
	  end
	end
  }
  return [alias_type, proc_encode, proc_decode]
end