Explorar el Código

* patch from Sergei Gorelkin to return ansi/widestrings by reference
in an invisible parameter (Delphi compatible, faster/smaller code)

git-svn-id: trunk@9718 -

Jonas Maebe hace 17 años
padre
commit
cdfb7c8f26
Se han modificado 4 ficheros con 4 adiciones y 1 borrados
  1. 1 1
      compiler/paramgr.pas
  2. 1 0
      compiler/psub.pas
  3. 1 0
      rtl/inc/astrings.inc
  4. 1 0
      rtl/inc/wustrings.inc

+ 1 - 1
compiler/paramgr.pas

@@ -139,7 +139,7 @@ implementation
       begin
          ret_in_param:=((def.typ=arraydef) and not(is_dynamic_array(def))) or
            (def.typ=recorddef) or
-           ((def.typ=stringdef) and (tstringdef(def).stringtype in [st_shortstring,st_longstring])) or
+           (def.typ=stringdef) or
            ((def.typ=procvardef) and (po_methodpointer in tprocvardef(def).procoptions)) or
            { interfaces are also passed by reference to be compatible with delphi and COM }
            ((def.typ=objectdef) and (is_object(def) or is_interface(def))) or

+ 1 - 0
compiler/psub.pas

@@ -501,6 +501,7 @@ implementation
             { must be the return value finalized before reraising the exception? }
             if (not is_void(current_procinfo.procdef.returndef)) and
                (current_procinfo.procdef.returndef.needs_inittable) and
+               (not paramanager.ret_in_param(current_procinfo.procdef.returndef, current_procinfo.procdef.proccalloption)) and
                (not is_class(current_procinfo.procdef.returndef)) then
               addstatement(newstatement,finalize_data_node(load_result_node));
           end;

+ 1 - 0
rtl/inc/astrings.inc

@@ -737,6 +737,7 @@ begin
         PByte(ResultAddress+Size)^:=0;
       end;
    end;
+   fpc_ansistr_decr_ref(Pointer(fpc_ansistr_copy));
   Pointer(fpc_ansistr_Copy):=ResultAddress;
 end;
 

+ 1 - 0
rtl/inc/wustrings.inc

@@ -1228,6 +1228,7 @@ begin
         PWideChar(ResultAddress+Size*sizeof(WideChar))^:=#0;
       end;
    end;
+  fpc_widestr_decr_ref(Pointer(fpc_widestr_copy));
   Pointer(fpc_widestr_Copy):=ResultAddress;
 end;