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

Added support for generation of mutable structs #259

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Ochibobo
Copy link

An issue was opened here by @dourouc05 that requests support for a mutable API. This PR attempts to address that.

Copy link

codecov bot commented Dec 21, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.93%. Comparing base (2e80936) to head (2c8b303).

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #259      +/-   ##
==========================================
- Coverage   92.99%   90.93%   -2.07%     
==========================================
  Files          25       25              
  Lines        2812     2636     -176     
==========================================
- Hits         2615     2397     -218     
- Misses        197      239      +42     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mrkn
Copy link

mrkn commented Jan 21, 2025

@Ochibobo I love this feature.

In addition, what do you think about adding a new boolean option called julia_mutalbe_struct to specify this flag in the option directive, as shown below?

syntax = "proto3";

option julia_mutable_struct = true;

message Message {
    string message = 1;
};

@@ -88,6 +90,7 @@ All imported `.proto` files are compiled as well; an error is thrown if they can
- `output_directory::Union{String,Nothing}=nothing`: Path to store the generated Julia source code. When omitted, the translated code is saved to temp directory, the path is shown as a @info log.

# Keywords
- `with_mutable_structs::Bool=false`: If set to `true`, generate structs that are mutable in nature.
Copy link
Member

Choose a reason for hiding this comment

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

Thanks! The overall idea looks good to me!

Let's shorten the name to mutable_structs and let's mention that this changes the default struct "kind" -- in the future we might want to add more granularity for controlling this via comments etc.

I also think we should add the word mutable to the JULIA_RESERVED_KEYWORDS list in src/codegen/names.jl

Suggested change
- `with_mutable_structs::Bool=false`: If set to `true`, generate structs that are mutable in nature.
- `mutable_structs::Bool=false`: If set to `true`, the generator will default to generating mutable structs.

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.

3 participants