thrift-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (THRIFT-4586) Thrift generated strings for Cocoa/Objective-C should use copy not strong.
Date Tue, 03 Jul 2018 12:19:00 GMT

    [ https://issues.apache.org/jira/browse/THRIFT-4586?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16531287#comment-16531287
] 

ASF GitHub Bot commented on THRIFT-4586:
----------------------------------------

jeking3 closed pull request #1564: THRIFT-4586: Correctly generates NSString with copy instead
of strong - Cocoa
URL: https://github.com/apache/thrift/pull/1564
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc b/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc
index 5bed2d71a5..ac644f5c59 100644
--- a/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_cocoa_generator.cc
@@ -238,6 +238,12 @@ class t_cocoa_generator : public t_oop_generator {
   std::string getter_name(string field_name);
   std::string setter_name(string field_name);
 
+  bool type_can_be_copy(t_type* ttype) {
+    ttype = get_true_type(ttype);
+    
+    return ttype->is_string();
+  }
+  
   bool type_can_be_null(t_type* ttype) {
     ttype = get_true_type(ttype);
 
@@ -3011,7 +3017,9 @@ string t_cocoa_generator::declare_property(t_field* tfield) {
   std::ostringstream render;
   render << "@property (";
 
-  if (type_can_be_null(tfield->get_type())) {
+  if (type_can_be_copy(tfield->get_type())) {
+    render << "copy, ";
+  } else if (type_can_be_null(tfield->get_type())) {
     render << "strong, ";
   } else {
     render << "assign, ";


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


> Thrift generated strings for Cocoa/Objective-C should use copy not strong.
> --------------------------------------------------------------------------
>
>                 Key: THRIFT-4586
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4586
>             Project: Thrift
>          Issue Type: Bug
>            Reporter: Kevin Carbone
>            Assignee: James E. King III
>            Priority: Major
>
> Thrift generated strings for Cocoa/Objective-C should use copy not strong.
> Currently all strings use strong. This is dangerous if one assigns a strong reference
to an analytics object.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Mime
View raw message