diff options
Diffstat (limited to 'common/rust_translation_notes.txt')
-rw-r--r-- | common/rust_translation_notes.txt | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/common/rust_translation_notes.txt b/common/rust_translation_notes.txt new file mode 100644 index 0000000..ece37a0 --- /dev/null +++ b/common/rust_translation_notes.txt @@ -0,0 +1,56 @@ +#ifdef LZ_PLT +#define PIXEL one_byte_pixel_t +#define FNAME(name) glz_plt_##name +#define ENCODE_PIXEL(e, pix) encode(e, (pix).a) // gets the pixel and write only the needed bytes + // from the pixel +#define SAME_PIXEL(pix1, pix2) ((pix1).a == (pix2).a) +#define MIN_REF_ENCODE_SIZE 4 +#define MAX_REF_ENCODE_SIZE 7 +#define HASH_FUNC(v, p) { \ + v = DJB2_START; \ + DJB2_HASH(v, p[0].a); \ + DJB2_HASH(v, p[1].a); \ + DJB2_HASH(v, p[2].a); \ + v &= HASH_MASK; \ + } +#endif + +is going to become: + +templated functions for anything that looks like a function, using references +then I will make sure those functions are inlined. +assuming inlining happens early enough, the resulting code should be the same (!citation/proof needed!) + +all functions produced by FNAME are to be templates. They are all statics and so called directly by +glz_encode. + +Only problem is code optionally compiled. i.e. + +fn if_i_only_could() +{ +#ifdef PLT + encode(magic_plt); +#endif + encode(always_encode_this); +} + +PIXEL type +FNAME(name) -> traits + +Problems +======== + +no nested structs +no variadic argument C ABI (but can call external variadic argument C ABI fine, i.e. libc printf) +no preprocessor. poor grasp of traits +hard to use pointers. or I just don't like offset. + +C to Rust +========= + +static void f() +=> +fn f() + +static by default - that is, for compilation unit which is a crate?. Anyway you need to 'pub' whatever you want visible outside (i.e. in the symbol table) + |