Update examples

This commit is contained in:
Gregory Lirent 2023-03-23 18:18:51 +03:00
parent bc69fbb7cc
commit c81b412a82
5 changed files with 23 additions and 23 deletions

View File

@ -7,11 +7,11 @@
typedef vtype_array arr_t;
int print_value(void* value, ssize_t index, vtype type, void* data) {
int print_value(vtype_variable value, ssize_t index, void* data) {
const char *n = data;
vtype_int32 *v = value;
vtype_int32 *v = value.pointer;
assert(type == VTYPE_INT32);
assert(value.type == VTYPE_INT32);
printf("%s %d (index: %ld)\n", n, *v, index);

View File

@ -8,28 +8,28 @@
typedef vtype_dict dict_t;
int print_value(const void* key, vtype key_type, void* value, vtype value_type, void* data) {
int print_value(vtype_variable key, vtype_variable value, void* data) {
const char *n = data;
switch (key_type) {
switch (key.type) {
default: abort();
case VTYPE_INT32:
printf("%s %d: ", n, *(vtype_int32*)key);
printf("%s %d: ", n, *(vtype_int32*)key.pointer);
break;
case VTYPE_FLOAT:
printf("%s %f: ", n, *(vtype_float*)key);
printf("%s %f: ", n, *(vtype_float*)key.pointer);
break;
}
switch (value_type) {
switch (value.type) {
default: abort();
case VTYPE_INT32:
printf("%d\n", *(vtype_int32*)value);
printf("%d\n", *(vtype_int32*)value.pointer);
break;
case VTYPE_FLOAT:
printf("%f\n", *(vtype_float*)value);
printf("%f\n", *(vtype_float*)value.pointer);
break;
}

View File

@ -8,17 +8,17 @@
typedef vtype_list list_t;
int print_value(void* value, ssize_t index, vtype type, void* data) {
int print_value(vtype_variable value, ssize_t index, void* data) {
const char *n = data;
switch (type) {
switch (value.type) {
default: abort();
case VTYPE_INT32:
printf("%s %d (index: %ld)\n", n, *(vtype_int32*)value, index);
printf("%s %d (index: %ld)\n", n, *(vtype_int32*)value.pointer, index);
break;
case VTYPE_FLOAT:
printf("%s %f (index: %ld)\n", n, *(vtype_float*)value, index);
printf("%s %f (index: %ld)\n", n, *(vtype_float*)value.pointer, index);
break;
}

View File

@ -8,22 +8,22 @@
typedef vtype_map map_t;
int print_value(const void* key, vtype key_type, void* value, vtype value_type, void* data) {
int print_value(vtype_variable key, vtype_variable value, void* data) {
const char *n = data;
vtype_int32 *k = (void*)key;
vtype_int32 *k = (void*)key.pointer;
assert(key_type == VTYPE_INT32);
assert(key.type == VTYPE_INT32);
printf("%s %d: ", n, *k);
switch (value_type) {
switch (value.type) {
default: abort();
case VTYPE_INT32:
printf("%d\n", *(vtype_int32*)value);
printf("%d\n", *(vtype_int32*)value.pointer);
break;
case VTYPE_FLOAT:
printf("%f\n", *(vtype_float*)value);
printf("%f\n", *(vtype_float*)value.pointer);
break;
}

View File

@ -7,11 +7,11 @@
typedef vtype_set vset_t;
int print_value(const void* value, vtype type, void* data) {
int print_value(vtype_variable value, void* data) {
const char *n = data;
vtype_int32 *v = (void*)value;
vtype_int32 *v = (void*)value.pointer;
assert(type == VTYPE_INT32);
assert(value.type == VTYPE_INT32);
printf("%s %d\n", n, *v);