VM changes for FFI encoding work
parent
a3a0ce5bee
commit
e9b9172a8e
|
@ -251,10 +251,18 @@ double ffi_test_36(struct test_struct_12 x)
|
|||
return x.x;
|
||||
}
|
||||
|
||||
static int global_var;
|
||||
|
||||
void ffi_test_36_point_5(void)
|
||||
{
|
||||
printf("int_ffi_test_36_point_5\n");
|
||||
global_var = 0;
|
||||
}
|
||||
|
||||
int ffi_test_37(int (*f)(int, int, int))
|
||||
{
|
||||
static int global_var = 0;
|
||||
printf("ffi_test_37\n");
|
||||
printf("global_var is %d\n",global_var);
|
||||
global_var = f(global_var,global_var * 2,global_var * 3);
|
||||
printf("global_var is %d\n",global_var);
|
||||
fflush(stdout);
|
||||
|
|
|
@ -62,6 +62,8 @@ struct test_struct_12 { int a; double x; };
|
|||
|
||||
DLLEXPORT double ffi_test_36(struct test_struct_12 x);
|
||||
|
||||
DLLEXPORT void int_ffi_test_36_point_5(void);
|
||||
|
||||
DLLEXPORT int ffi_test_37(int (*f)(int, int, int));
|
||||
|
||||
DLLEXPORT unsigned long long ffi_test_38(unsigned long long x, unsigned long long y);
|
||||
|
|
|
@ -139,10 +139,6 @@ void *primitives[] = {
|
|||
primitive_set_alien_double,
|
||||
primitive_alien_cell,
|
||||
primitive_set_alien_cell,
|
||||
primitive_alien_to_char_string,
|
||||
primitive_string_to_char_alien,
|
||||
primitive_alien_to_u16_string,
|
||||
primitive_string_to_u16_alien,
|
||||
primitive_throw,
|
||||
primitive_alien_address,
|
||||
primitive_slot,
|
||||
|
|
12
vm/types.c
12
vm/types.c
|
@ -608,10 +608,6 @@ DEFINE_PRIMITIVE(resize_string)
|
|||
void box_##type##_string(const type *str) \
|
||||
{ \
|
||||
dpush(str ? tag_object(from_##type##_string(str)) : F); \
|
||||
} \
|
||||
DEFINE_PRIMITIVE(alien_to_##type##_string) \
|
||||
{ \
|
||||
drepl(tag_object(from_##type##_string(alien_offset(dpeek())))); \
|
||||
}
|
||||
|
||||
MEMORY_TO_STRING(char,u8)
|
||||
|
@ -671,14 +667,6 @@ F_BYTE_ARRAY *allot_c_string(CELL capacity, CELL size)
|
|||
type *unbox_##type##_string(void) \
|
||||
{ \
|
||||
return to_##type##_string(untag_string(dpop()),true); \
|
||||
} \
|
||||
DEFINE_PRIMITIVE(string_to_##type##_alien) \
|
||||
{ \
|
||||
CELL string, t; \
|
||||
string = dpeek(); \
|
||||
t = type_of(string); \
|
||||
if(t != ALIEN_TYPE && t != BYTE_ARRAY_TYPE && t != F_TYPE) \
|
||||
drepl(tag_object(string_to_##type##_alien(untag_string(string),true))); \
|
||||
}
|
||||
|
||||
STRING_TO_MEMORY(char);
|
||||
|
|
|
@ -160,24 +160,20 @@ DECLARE_PRIMITIVE(resize_string);
|
|||
F_STRING *memory_to_char_string(const char *string, CELL length);
|
||||
F_STRING *from_char_string(const char *c_string);
|
||||
DLLEXPORT void box_char_string(const char *c_string);
|
||||
DECLARE_PRIMITIVE(alien_to_char_string);
|
||||
|
||||
F_STRING *memory_to_u16_string(const u16 *string, CELL length);
|
||||
F_STRING *from_u16_string(const u16 *c_string);
|
||||
DLLEXPORT void box_u16_string(const u16 *c_string);
|
||||
DECLARE_PRIMITIVE(alien_to_u16_string);
|
||||
|
||||
void char_string_to_memory(F_STRING *s, char *string);
|
||||
F_BYTE_ARRAY *string_to_char_alien(F_STRING *s, bool check);
|
||||
char* to_char_string(F_STRING *s, bool check);
|
||||
DLLEXPORT char *unbox_char_string(void);
|
||||
DECLARE_PRIMITIVE(string_to_char_alien);
|
||||
|
||||
void u16_string_to_memory(F_STRING *s, u16 *string);
|
||||
F_BYTE_ARRAY *string_to_u16_alien(F_STRING *s, bool check);
|
||||
u16* to_u16_string(F_STRING *s, bool check);
|
||||
DLLEXPORT u16 *unbox_u16_string(void);
|
||||
DECLARE_PRIMITIVE(string_to_u16_alien);
|
||||
|
||||
/* String getters and setters */
|
||||
CELL string_nth(F_STRING* string, CELL index);
|
||||
|
|
Loading…
Reference in New Issue