Skip to content

Rpc service parsing #173

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

Merged
merged 15 commits into from
Jan 27, 2022
Merged

Rpc service parsing #173

merged 15 commits into from
Jan 27, 2022

Conversation

mattiekat
Copy link
Contributor

@mattiekat mattiekat commented Jan 6, 2022

StartScope();
var indexAsOpcode = new OpcodeAttribute(serviceIndex, true);
var returnStruct = new StructDefinition(
$"_{serviceName.ToPascalCase()}{name.ToPascalCase()}Return",
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should throw an extra delimiter between the service name and function name for good measure, so that _User_ListAdd and _UserList_Add or something won't clash.

Copy link
Contributor

Choose a reason for hiding this comment

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

It might be cool to make some helper methods for this, like

private static string RpcNamePrefix(string serviceName, string name)
    => $"_{serviceName.ToPascalCase()}_{name.ToPascalCase()}";

private static string RpcReturnStructName(string serviceName, string name)
    => RpcNamePrefix(serviceName, name) + "Return";

just in case we change our minds about e.g. the Pascal-casing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Two things on this

  1. I assume that the different languages will convert to whatever name capitalization makes sense for them (e.g. Rust will use pascal for structs no matter what the name here is and snake case for functions) if they care
  2. You are right that another delimiter is technically needed, but a _ might be problematic because of the previous point.

Since the structs are not really to be used by the end user we could just uglify them a bit and use something like "_Service{serviceName}Function{functionName}" even. All that matters is we know what it is when we go to generate code.

@mattiekat mattiekat mentioned this pull request Jan 12, 2022
@mattiekat mattiekat marked this pull request as ready for review January 27, 2022 22:07
@mattiekat mattiekat merged commit 8af016d into master Jan 27, 2022
@mattiekat mattiekat changed the title Rpc Rpc service parsing Jan 27, 2022
@mattiekat mattiekat deleted the rpc branch January 27, 2022 22:41
@mattiekat mattiekat linked an issue Mar 1, 2022 that may be closed by this pull request
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

Successfully merging this pull request may close these issues.

RPC Proposal
2 participants