node/lib/metasm/metasm/parse_c.rb
# convert (pack) a ruby value into a C buffer
# packs integers, converts Strings to their C pointer (using DynLdr)
convert (pack) a ruby value into a C buffer
packs integers, converts Strings to their C pointer (using DynLdr)
convert ( pack ) a ruby value into a C buffer packs integers converts Strings to their C pointer ( using DynLdr )
def encode_c_value(type, val)
			type = type.type if type.kind_of? Variable
			case val
			when nil; val = 0
			when ::Integer
			when ::String
				val = DynLdr.str_ptr(val)
			when ::Hash
				type = type.pointed while type.pointer?
				raise "need a struct ptr for #{type} #{val.inspect}" if not type.kind_of? Union
				buf = alloc_c_struct(type, val)
				val.instance_variable_set('@rb2c', buf) 
				val = buf
			when ::Proc
				val = DynLdr.convert_rb2c(type, val)	
			when AllocCStruct
				val = DynLdr.str_ptr(val.str) + val.stroff
			else raise "TODO #{val.inspect}"
			end
			val = Expression.encode_immediate(val, sizeof(type), @endianness) if val.kind_of?(::Integer)
			val
		end
def encode_c_value ( type , val ) type = type . type if type . kind_of? Variable case val when nil ; val = 0 when :: Integer when :: String val = DynLdr . str_ptr ( val ) when :: Hash type = type . pointed while type . pointer? raise "need a struct ptr for #{type} #{val.inspect}" if not type . kind_of? Union buf = alloc_c_struct ( type , val ) val . instance_variable_set ( '@rb2c' , buf ) val = buf when :: Proc val = DynLdr . convert_rb2c ( type , val ) when AllocCStruct val = DynLdr . str_ptr ( val . str ) + val . stroff else raise "TODO #{val.inspect}" end val = Expression . encode_immediate ( val , sizeof ( type ) , @endianness ) if val . kind_of? ( :: Integer ) val end
convert (pack) a ruby value into a C buffer
packs integers, converts Strings to their C pointer (using DynLdr)
convert ( pack ) a ruby value into a C buffer packs integers converts Strings to their C pointer ( using DynLdr )
# GC trick # allocate a DynLdr callback #when ::Float		# TODO
type
val