vm passed in box_alien and alien_offset (win32)

db4
Phil Dawes 2009-08-22 21:35:47 +01:00
parent 7759b89de9
commit fa2dccd6d3
3 changed files with 14 additions and 7 deletions

View File

@ -218,9 +218,10 @@ char *factorvm::alien_offset(cell obj)
} }
} }
VM_C_API char *alien_offset(cell obj) VM_C_API char *alien_offset(cell obj, factorvm *myvm)
{ {
return vm->alien_offset(obj); ASSERTVM();
return VM_PTR->alien_offset(obj);
} }
/* pop an object representing a C pointer */ /* pop an object representing a C pointer */
@ -231,6 +232,7 @@ char *factorvm::unbox_alien()
VM_C_API char *unbox_alien() VM_C_API char *unbox_alien()
{ {
printf("*PHIL unbox_alien\n");
return vm->unbox_alien(); return vm->unbox_alien();
} }
@ -243,9 +245,10 @@ void factorvm::box_alien(void *ptr)
dpush(allot_alien(F,(cell)ptr)); dpush(allot_alien(F,(cell)ptr));
} }
VM_C_API void box_alien(void *ptr) VM_C_API void box_alien(void *ptr, factorvm *myvm)
{ {
return vm->box_alien(ptr); ASSERTVM();
return VM_PTR->box_alien(ptr);
} }
/* for FFI calls passing structs by value */ /* for FFI calls passing structs by value */
@ -256,6 +259,7 @@ void factorvm::to_value_struct(cell src, void *dest, cell size)
VM_C_API void to_value_struct(cell src, void *dest, cell size) VM_C_API void to_value_struct(cell src, void *dest, cell size)
{ {
printf("PHIL to_value_struct\n");
return vm->to_value_struct(src,dest,size); return vm->to_value_struct(src,dest,size);
} }
@ -269,6 +273,7 @@ void factorvm::box_value_struct(void *src, cell size)
VM_C_API void box_value_struct(void *src, cell size) VM_C_API void box_value_struct(void *src, cell size)
{ {
printf("PHIL box_value_struct\n");
return vm->box_value_struct(src,size); return vm->box_value_struct(src,size);
} }
@ -283,6 +288,7 @@ void factorvm::box_small_struct(cell x, cell y, cell size)
VM_C_API void box_small_struct(cell x, cell y, cell size) VM_C_API void box_small_struct(cell x, cell y, cell size)
{ {
printf("PHIL box_small_struct\n");
return vm->box_small_struct(x,y,size); return vm->box_small_struct(x,y,size);
} }
@ -299,6 +305,7 @@ void factorvm::box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size) VM_C_API void box_medium_struct(cell x1, cell x2, cell x3, cell x4, cell size)
{ {
printf("PHIL box_medium_struct\n");
return vm->box_medium_struct(x1, x2, x3, x4, size); return vm->box_medium_struct(x1, x2, x3, x4, size);
} }

View File

@ -36,9 +36,9 @@ PRIMITIVE(dlsym);
PRIMITIVE(dlclose); PRIMITIVE(dlclose);
PRIMITIVE(dll_validp); PRIMITIVE(dll_validp);
VM_C_API char *alien_offset(cell object); VM_C_API char *alien_offset(cell object, factorvm *vm);
VM_C_API char *unbox_alien(); VM_C_API char *unbox_alien();
VM_C_API void box_alien(void *ptr); VM_C_API void box_alien(void *ptr, factorvm *vm);
VM_C_API void to_value_struct(cell src, void *dest, cell size); VM_C_API void to_value_struct(cell src, void *dest, cell size);
VM_C_API void box_value_struct(void *src, cell size); VM_C_API void box_value_struct(void *src, cell size);
VM_C_API void box_small_struct(cell x, cell y, cell size); VM_C_API void box_small_struct(cell x, cell y, cell size);

View File

@ -39,7 +39,7 @@ void init_ffi()
void ffi_dlopen(dll *dll) void ffi_dlopen(dll *dll)
{ {
dll->dll = dlopen(alien_offset(dll->path), RTLD_LAZY); dll->dll = dlopen(alien_offset(dll->path,vm), RTLD_LAZY);
} }
void *ffi_dlsym(dll *dll, symbol_char *symbol) void *ffi_dlsym(dll *dll, symbol_char *symbol)