Method: FFI::AbstractMemory#get
- Defined in:
- ext/ffi_c/AbstractMemory.c
#get(type, offset) ⇒ Object
Return data of given type contained in memory.
347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 |
# File 'ext/ffi_c/AbstractMemory.c', line 347 static VALUE memory_get(VALUE self, VALUE type_name, VALUE offset) { AbstractMemory* ptr; VALUE nType; Type *type; MemoryOp *op; nType = rbffi_Type_Lookup(type_name); if(NIL_P(nType)) goto undefined_type; TypedData_Get_Struct(self, AbstractMemory, &rbffi_abstract_memory_data_type, ptr); TypedData_Get_Struct(nType, Type, &rbffi_type_data_type, type); op = get_memory_op(type); if(op == NULL) goto undefined_type; return op->get(ptr, NUM2LONG(offset)); undefined_type: { VALUE msg = rb_sprintf("undefined type '%" PRIsVALUE "'", type_name); rb_exc_raise(rb_exc_new3(rb_eArgError, msg)); return Qnil; } } |