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

[AssemblyScript] Added basic AssemblyScript support #6408

Closed
wants to merge 22 commits into from

Conversation

LucasSwitz
Copy link

@LucasSwitz LucasSwitz commented Jan 19, 2021

Couple notes that describe the differences from the TypeScript generator.

  • Namespace
    • AS does not support dot-notation nested namespaces.
    • AS does not support namespace extensions
    • I have not implemented namespace support in this patch.
  • Numbers:
    • Need to explicitly return i32 or f32 rather than number
    • Support is currently only added for 32 bit numbers. Adding 64 bit should be a simple extension.
  • Return types:
    • void functions need to explicitly return void
  • Unioned return types (a|b|c) are not supported currently.
  • scalars are not nullable
  • Cannot do (null | T ) need to explicitly check for null and assign manually.

@google-cla
Copy link

google-cla bot commented Jan 19, 2021

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@LucasSwitz
Copy link
Author

@googlebot I signed it!

@LucasSwitz LucasSwitz force-pushed the assembly_script_support branch 4 times, most recently from 3608863 to dd6a264 Compare January 19, 2021 20:54
@aardappel
Copy link
Collaborator

@krojew what do you think?

@LucasSwitz LucasSwitz force-pushed the assembly_script_support branch 2 times, most recently from d3ab3d3 to 519d1f5 Compare January 19, 2021 21:06
@LucasSwitz LucasSwitz force-pushed the assembly_script_support branch from 519d1f5 to f25a3d6 Compare January 19, 2021 21:12
@LucasSwitz
Copy link
Author

LucasSwitz commented Jan 19, 2021

Just saw #6302 merged. Will likely require a good bit of massaging on my side to resolve conflicts.

as/byte-buffer.ts Outdated Show resolved Hide resolved
@krojew
Copy link
Contributor

krojew commented Jan 20, 2021

I think this might warrant a new idl_gen_as.cpp at this moment.

@LucasSwitz
Copy link
Author

@krojew Agreed. Looked over the merge into the new TS generator and it looks like combining these two would be dubious at best. I'll split out my additions into a standalone AS generator.

@github-actions github-actions bot added the CI Continuous Integration label Jan 21, 2021
}

readInt8(offset: i32): i32 {
return (i32(this.readUint8(offset)) << 24) >> 24;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual sign extension is unnecessary when you cast to u8 -> i32 via as i32

Suggested change
return (i32(this.readUint8(offset)) << 24) >> 24;
return this.readUint8(offset) as i32;

as/byte-buffer.ts Outdated Show resolved Hide resolved
Comment on lines 78 to 80
readUint32(offset: i32): i32 {
return this.readInt32(offset) >>> 0;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
readUint32(offset: i32): i32 {
return this.readInt32(offset) >>> 0;
}
readUint32(offset: i32): u32 {
return this.readInt32(offset);
}

as/long.ts Outdated Show resolved Hide resolved
@LucasSwitz LucasSwitz force-pushed the assembly_script_support branch 2 times, most recently from e33f6ec to b700d3f Compare May 27, 2021 13:06
as/byte-buffer.ts Outdated Show resolved Hide resolved
@LucasSwitz LucasSwitz force-pushed the assembly_script_support branch from b700d3f to c071b69 Compare May 27, 2021 13:40
@github-actions github-actions bot added the c# label May 27, 2021
@LucasSwitz LucasSwitz force-pushed the assembly_script_support branch from fc861aa to 50a7279 Compare May 27, 2021 15:28
@LucasSwitz LucasSwitz closed this Jun 14, 2021
@tonibofarull
Copy link

tonibofarull commented May 16, 2022

Any update on this? @LucasSwitz
You did an amazing job, thank you!

Copy link

@ghost ghost left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c# c++ CI Continuous Integration codegen Involving generating code from schema typescript
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants