You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "kpy3 (via GitHub)" <gi...@apache.org> on 2025/04/04 09:53:48 UTC

[PR] Erlang generator improvements [thrift]

kpy3 opened a new pull request, #3120:
URL: https://github.com/apache/thrift/pull/3120

   <!-- Explain the changes in the pull request below: -->
     
   Add some minor improvements to Erlang generator:
   
   - Mark records generated from union as 'union' instead of 'struct'
   - Allow choose type for string, can be 'string', 'binary' or 'both' (default)
   - Allow sets to be initialised with new(fast) backend (default is old)
   
   <!-- We recommend you review the checklist/tips before submitting a pull request. -->
   
   - [ ] Did you create an [Apache Jira](https://issues.apache.org/jira/projects/THRIFT/issues/) ticket?  ([Request account here](https://selfserve.apache.org/jira-account.html), not required for trivial changes)
   - [ ] If a ticket exists: Does your pull request title follow the pattern "THRIFT-NNNN: describe my issue"?
   - [ ] Did you squash your changes to a single commit?  (not required, but preferred)
   - [x] Did you do your best to avoid breaking changes?  If one was needed, did you label the Jira ticket with "Breaking-Change"?
   - [ ] If your change does not involve any code, include `[skip ci]` anywhere in the commit message to free up build resources.
   
   <!--
     The Contributing Guide at:
     https://github.com/apache/thrift/blob/master/CONTRIBUTING.md
     has more details and tips for committing properly.
   -->
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Erlang generator improvements [thrift]

Posted by "Jens-G (via GitHub)" <gi...@apache.org>.
Jens-G commented on code in PR #3120:
URL: https://github.com/apache/thrift/pull/3120#discussion_r2030000155


##########
compiler/cpp/src/thrift/generate/t_erl_generator.cc:
##########
@@ -715,21 +755,30 @@ string t_erl_generator::render_default_value(t_field* field) {
       return "dict:new()";
     }
   } else if (type->is_set()) {
-    return "sets:new()";
+    return render_default_sets_value();
   } else if (type->is_list()) {
     return "[]";
   } else {
     return "undefined";
   }
 }
 
+string t_erl_generator::render_default_sets_value() {
+  switch (sets_to_) {
+  case SetsTo::V1:
+    return "sets:new()";
+  case SetsTo::V2:
+    return "sets:new([{version,2}])";
+  }
+}

Review Comment:
   there's something missing obviosuly



##########
compiler/cpp/src/thrift/generate/t_erl_generator.cc:
##########
@@ -761,6 +810,17 @@ string t_erl_generator::render_member_type(t_field* field) {
   }
 }
 
+string t_erl_generator::render_string_type() {
+  switch (string_to_) {
+  case StringTo::String:
+    return "string()";
+  case StringTo::Binary:
+    return "binary()";
+  case StringTo::Both:
+    return "string() | binary()";
+  }
+}

Review Comment:
   same here



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Erlang generator improvements [thrift]

Posted by "Jens-G (via GitHub)" <gi...@apache.org>.
Jens-G merged PR #3120:
URL: https://github.com/apache/thrift/pull/3120


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


Re: [PR] Erlang generator improvements [thrift]

Posted by "kpy3 (via GitHub)" <gi...@apache.org>.
kpy3 commented on code in PR #3120:
URL: https://github.com/apache/thrift/pull/3120#discussion_r2031835365


##########
compiler/cpp/src/thrift/generate/t_erl_generator.cc:
##########
@@ -715,21 +755,30 @@ string t_erl_generator::render_default_value(t_field* field) {
       return "dict:new()";
     }
   } else if (type->is_set()) {
-    return "sets:new()";
+    return render_default_sets_value();
   } else if (type->is_list()) {
     return "[]";
   } else {
     return "undefined";
   }
 }
 
+string t_erl_generator::render_default_sets_value() {
+  switch (sets_to_) {
+  case SetsTo::V1:
+    return "sets:new()";
+  case SetsTo::V2:
+    return "sets:new([{version,2}])";
+  }
+}

Review Comment:
   I've added default branch to switch here



##########
compiler/cpp/src/thrift/generate/t_erl_generator.cc:
##########
@@ -761,6 +810,17 @@ string t_erl_generator::render_member_type(t_field* field) {
   }
 }
 
+string t_erl_generator::render_string_type() {
+  switch (string_to_) {
+  case StringTo::String:
+    return "string()";
+  case StringTo::Binary:
+    return "binary()";
+  case StringTo::Both:
+    return "string() | binary()";
+  }
+}

Review Comment:
   And here :)



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@thrift.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org