* patch from Sergei Gorelkin to return ansi/widestrings by reference

in an invisible parameter (Delphi compatible, faster/smaller code)

git-svn-id: trunk@9718 -
This commit is contained in:
Jonas Maebe 2008-01-11 22:36:50 +00:00
parent cc90b67b4a
commit cdfb7c8f26
4 changed files with 4 additions and 1 deletions

View File

@ -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

View File

@ -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;

View File

@ -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;

View File

@ -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;