Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cli Mode to add comments #3

Open
spotandjake opened this issue May 1, 2023 · 2 comments
Open

Cli Mode to add comments #3

spotandjake opened this issue May 1, 2023 · 2 comments

Comments

@spotandjake
Copy link
Contributor

Add a simple cli mode to add comments, this should not be that hard given it would just be some template literals like decode x and such and in langs like grain or assemblyscript for instance these get optimized away so size isnt really a worry.

@JairusSW
Copy link
Owner

JairusSW commented May 4, 2023

I'm visualizing something along these lines.
Either through a config file or the cli, the user can define a debug (or verbose?) option which would generate comments that explain the resulting binary format and the version it was compiled with.

fass build Vec3.fass -o build/ --assemblyscript --debug

/** @fass v0.1.0
 * Generated AssemblyScript code from Vec3.fass
 *
 * quad = u8
 * x = f32
 * y = f32
 * z = f32
 * Binary format = [quad, x, y, z]
**/
export class Vec3 {
    quad!: Quadrant;
    x!: f32;
    y!: f32;
    z!: f32;
    public __FASS_SIZE: u32 = 13;
    @inline __FASS_SERIALIZE(output: ArrayBuffer, input: Vec3): void {
        // Perhaps add comments here?
        store<u8>(changetype<usize>(output), input.quad, 0);
        store<f32>(changetype<usize>(output), input.x, 1);
        store<f32>(changetype<usize>(output), input.y, 5);
        store<f32>(changetype<usize>(output), input.z, 9);
    }
    @inline __FASS_DESERIALIZE(input: ArrayBuffer, output: Vec3): void {
        output.quad = load<u8>(changetype<usize>(input), 0);
        output.x = load<f32>(changetype<usize>(input), 1);
        output.y = load<f32>(changetype<usize>(input), 5);
        output.z = load<f32>(changetype<usize>(input), 9);
    }
}

export enum Quadrant {
    TL = 1,
    TR = 2,
    BL = 3,
    BR = 4
}

@spotandjake
Copy link
Contributor Author

Pretty much maybe you support like an ```
/*

also instead of having the fass version on the binding put that in a comment at the top of the module.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants