codereport / jsource

J Language Source Code. Livestream links ⬇️
https://www.youtube.com/playlist?list=PLVFrD1dmDdvfVhYLU_iKkV67X9XqCJLWe
Other
38 stars 20 forks source link

Port conversions to c++ #200

Open juntuu opened 3 years ago

juntuu commented 3 years ago

The main funtion doing the conversion work is convert<From, To>(). The external interface is unchanged (except B -> bool).

Also added template parameter to specify return type of pointer_to_values() (https://github.com/codereport/jsource/pull/200/commits/e9e7f414ff0a8d5e9416630cf642c0729c50c72a). This changes the semantics of set_value_at() to depend on the type of the value:

T value;
set_value_at(arr, idx, value)

// was previously equivalent to
int64_t *values = (int64_t*)AV(arr);
values[idx] = value;

// is now equivalent to
T *values = (T*)AV(arr);
values[idx] = value;

This allows use of set_value_at() with types wider than, or not convertible to, int64_t. However, this requires more care with the value parameter, it must be the correct type (correct bit width), to get the correct stride.

codereport commented 3 years ago

This is awesome! Will do a live code review on the next live stream!

juntuu commented 3 years ago

CI compiler is giving somewhat ambiguous error:

../jsrc/conversions.cpp:565:71: error: call of overloaded ‘jtccvt(JST*&, <unnamed enum>, AD*&, AD**)’ is ambiguous
--

No idea how it thinks jtccvt() from all the functions would be overloaded...

Turned out the CI compiler had different idea of I compared to int64_t