mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-15 05:29:30 +02:00
* Introduce constwresourcestring - in unicode mode, resource strings are unicode strings, and must be streamed differently
This commit is contained in:
parent
a71cc71585
commit
fe62b3ace8
@ -2208,12 +2208,13 @@ implementation
|
|||||||
var
|
var
|
||||||
resourcestrrec: trecorddef;
|
resourcestrrec: trecorddef;
|
||||||
begin
|
begin
|
||||||
if cs.consttyp<>constresourcestring then
|
if not (cs.consttyp in [constresourcestring,constwresourcestring]) then
|
||||||
internalerror(2014062102);
|
internalerror(2014062102);
|
||||||
if fqueue_offset<>0 then
|
if fqueue_offset<>0 then
|
||||||
internalerror(2014062103);
|
internalerror(2014062103);
|
||||||
{ warning: update if/when the type of resource strings changes }
|
{ warning: update if/when the type of resource strings changes }
|
||||||
case cs.consttyp of
|
case cs.consttyp of
|
||||||
|
constwresourcestring,
|
||||||
constresourcestring:
|
constresourcestring:
|
||||||
begin
|
begin
|
||||||
resourcestrrec:=trecorddef(search_system_type('TRESOURCESTRINGRECORD').typedef);
|
resourcestrrec:=trecorddef(search_system_type('TRESOURCESTRINGRECORD').typedef);
|
||||||
|
@ -338,7 +338,7 @@ uses
|
|||||||
procedure Tresourcestrings.ConstSym_Register(p:TObject;arg:pointer);
|
procedure Tresourcestrings.ConstSym_Register(p:TObject;arg:pointer);
|
||||||
begin
|
begin
|
||||||
if (tsym(p).typ=constsym) and
|
if (tsym(p).typ=constsym) and
|
||||||
(tconstsym(p).consttyp=constresourcestring) then
|
(tconstsym(p).consttyp in [constresourcestring,constwresourcestring]) then
|
||||||
List.Concat(TResourceStringItem.Create(TConstsym(p)));
|
List.Concat(TResourceStringItem.Create(TConstsym(p)));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -2703,6 +2703,7 @@ implementation
|
|||||||
usedef:=clongstringtype;
|
usedef:=clongstringtype;
|
||||||
end;
|
end;
|
||||||
constresourcestring,
|
constresourcestring,
|
||||||
|
constwresourcestring,
|
||||||
constwstring:
|
constwstring:
|
||||||
usedef:=nil;
|
usedef:=nil;
|
||||||
else
|
else
|
||||||
@ -2753,6 +2754,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
constwstring,
|
constwstring,
|
||||||
|
constwresourcestring,
|
||||||
constresourcestring:
|
constresourcestring:
|
||||||
begin
|
begin
|
||||||
{ write dummy for now }
|
{ write dummy for now }
|
||||||
|
@ -1939,7 +1939,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
constsym:
|
constsym:
|
||||||
begin
|
begin
|
||||||
if (tconstsym(tloadnode(hp).symtableentry).consttyp=constresourcestring) and
|
if (tconstsym(tloadnode(hp).symtableentry).consttyp in [constresourcestring,constwresourcestring]) and
|
||||||
(valid_addr in opts) then
|
(valid_addr in opts) then
|
||||||
result:=true
|
result:=true
|
||||||
else
|
else
|
||||||
|
@ -5511,7 +5511,7 @@ implementation
|
|||||||
if FindUnitSymtable(tloadnode(n).symtable).moduleid<>current_module.moduleid then
|
if FindUnitSymtable(tloadnode(n).symtable).moduleid<>current_module.moduleid then
|
||||||
current_module.addimportedsym(sym);
|
current_module.addimportedsym(sym);
|
||||||
end
|
end
|
||||||
else if (sym.typ=constsym) and (tconstsym(sym).consttyp=constresourcestring) then
|
else if (sym.typ=constsym) and (tconstsym(sym).consttyp in [constwresourcestring,constresourcestring]) then
|
||||||
begin
|
begin
|
||||||
if tloadnode(n).symtableentry.owner.moduleid<>current_module.moduleid then
|
if tloadnode(n).symtableentry.owner.moduleid<>current_module.moduleid then
|
||||||
current_module.addimportedsym(sym);
|
current_module.addimportedsym(sym);
|
||||||
|
@ -441,7 +441,7 @@ implementation
|
|||||||
end;
|
end;
|
||||||
constsym:
|
constsym:
|
||||||
begin
|
begin
|
||||||
if tconstsym(symtableentry).consttyp=constresourcestring then
|
if tconstsym(symtableentry).consttyp in [constresourcestring,constwresourcestring] then
|
||||||
begin
|
begin
|
||||||
location_reset_ref(location,LOC_CREFERENCE,def_cgsize(cansistringtype),cansistringtype.size,[]);
|
location_reset_ref(location,LOC_CREFERENCE,def_cgsize(cansistringtype),cansistringtype.size,[]);
|
||||||
indirect:=(tf_supports_packages in target_info.flags) and
|
indirect:=(tf_supports_packages in target_info.flags) and
|
||||||
|
@ -305,7 +305,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
is_constresourcestringnode:=(p.nodetype=loadn) and
|
is_constresourcestringnode:=(p.nodetype=loadn) and
|
||||||
(tloadnode(p).symtableentry.typ=constsym) and
|
(tloadnode(p).symtableentry.typ=constsym) and
|
||||||
(tconstsym(tloadnode(p).symtableentry).consttyp=constresourcestring);
|
(tconstsym(tloadnode(p).symtableentry).consttyp in [constresourcestring,constwresourcestring]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -1022,7 +1022,7 @@ function get_next_varsym(def: tabstractrecorddef; const SymList:TFPHashObjectLis
|
|||||||
labelsym :
|
labelsym :
|
||||||
ftcb.queue_emit_label(tlabelsym(srsym));
|
ftcb.queue_emit_label(tlabelsym(srsym));
|
||||||
constsym :
|
constsym :
|
||||||
if tconstsym(srsym).consttyp=constresourcestring then
|
if tconstsym(srsym).consttyp in [constresourcestring,constwresourcestring] then
|
||||||
ftcb.queue_emit_const(tconstsym(srsym))
|
ftcb.queue_emit_const(tconstsym(srsym))
|
||||||
else
|
else
|
||||||
Message(type_e_constant_expr_expected);
|
Message(type_e_constant_expr_expected);
|
||||||
|
@ -350,6 +350,8 @@ implementation
|
|||||||
begin
|
begin
|
||||||
if tconstsym(symtableentry).consttyp=constresourcestring then
|
if tconstsym(symtableentry).consttyp=constresourcestring then
|
||||||
resultdef:=getansistringdef
|
resultdef:=getansistringdef
|
||||||
|
else if tconstsym(symtableentry).consttyp=constwresourcestring then
|
||||||
|
resultdef:=cunicodestringtype
|
||||||
else
|
else
|
||||||
internalerror(22799);
|
internalerror(22799);
|
||||||
end;
|
end;
|
||||||
@ -481,7 +483,7 @@ implementation
|
|||||||
;
|
;
|
||||||
constsym:
|
constsym:
|
||||||
begin
|
begin
|
||||||
if tconstsym(symtableentry).consttyp=constresourcestring then
|
if tconstsym(symtableentry).consttyp in [constresourcestring,constwresourcestring] then
|
||||||
expectloc:=LOC_CREFERENCE;
|
expectloc:=LOC_CREFERENCE;
|
||||||
end;
|
end;
|
||||||
staticvarsym,
|
staticvarsym,
|
||||||
|
@ -1362,7 +1362,7 @@ implementation
|
|||||||
changestringtype(cunicodestringtype);
|
changestringtype(cunicodestringtype);
|
||||||
initwidestring(pw);
|
initwidestring(pw);
|
||||||
copywidestring(pcompilerwidestring(value_str),pw);
|
copywidestring(pcompilerwidestring(value_str),pw);
|
||||||
sym:=cconstsym.create_wstring(orgname,constresourcestring,pw);
|
sym:=cconstsym.create_wstring(orgname,constwresourcestring,pw);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
|
@ -3121,7 +3121,7 @@ implementation
|
|||||||
|
|
||||||
constsym :
|
constsym :
|
||||||
begin
|
begin
|
||||||
if tconstsym(srsym).consttyp=constresourcestring then
|
if tconstsym(srsym).consttyp in [constresourcestring,constwresourcestring]then
|
||||||
begin
|
begin
|
||||||
result:=cloadnode.create(srsym,srsymtable);
|
result:=cloadnode.create(srsym,srsymtable);
|
||||||
do_typecheckpass(result);
|
do_typecheckpass(result);
|
||||||
|
@ -48,7 +48,7 @@ const
|
|||||||
CurrentPPUVersion = 208;
|
CurrentPPUVersion = 208;
|
||||||
{ for any other changes to the ppu format, increase this version number
|
{ for any other changes to the ppu format, increase this version number
|
||||||
(it's a cardinal) }
|
(it's a cardinal) }
|
||||||
CurrentPPULongVersion = 21;
|
CurrentPPULongVersion = 22;
|
||||||
|
|
||||||
{ unit flags }
|
{ unit flags }
|
||||||
uf_big_endian = $000004;
|
uf_big_endian = $000004;
|
||||||
|
@ -1064,7 +1064,8 @@ type
|
|||||||
getmem(value.valueptr,value.len+1);
|
getmem(value.valueptr,value.len+1);
|
||||||
move(c.value.valueptr^,value.valueptr^,value.len+1);
|
move(c.value.valueptr^,value.valueptr^,value.len+1);
|
||||||
end;
|
end;
|
||||||
constwstring:
|
constwstring,
|
||||||
|
constwresourcestring:
|
||||||
begin
|
begin
|
||||||
initwidestring(value.valueptr);
|
initwidestring(value.valueptr);
|
||||||
copywidestring(c.value.valueptr,value.valueptr);
|
copywidestring(c.value.valueptr,value.valueptr);
|
||||||
@ -1519,7 +1520,8 @@ type
|
|||||||
conststring,
|
conststring,
|
||||||
constresourcestring :
|
constresourcestring :
|
||||||
freemem(value.valueptr,value.len+1);
|
freemem(value.valueptr,value.len+1);
|
||||||
constwstring :
|
constwstring,
|
||||||
|
constwresourcestring:
|
||||||
donewidestring(pcompilerwidestring(value.valueptr));
|
donewidestring(pcompilerwidestring(value.valueptr));
|
||||||
constreal :
|
constreal :
|
||||||
dispose(pbestreal(value.valueptr));
|
dispose(pbestreal(value.valueptr));
|
||||||
|
@ -765,7 +765,8 @@ type
|
|||||||
tconsttyp = (constnone,
|
tconsttyp = (constnone,
|
||||||
constord,conststring,constreal,
|
constord,conststring,constreal,
|
||||||
constset,constpointer,constnil,
|
constset,constpointer,constnil,
|
||||||
constresourcestring,constwstring,constguid
|
constresourcestring,constwstring,
|
||||||
|
constguid,constwresourcestring
|
||||||
);
|
);
|
||||||
|
|
||||||
{ RTTI information to store }
|
{ RTTI information to store }
|
||||||
|
@ -5892,6 +5892,7 @@ implementation
|
|||||||
hpc:=tconstsym(hp.defaultconstsym);
|
hpc:=tconstsym(hp.defaultconstsym);
|
||||||
hs:='';
|
hs:='';
|
||||||
case hpc.consttyp of
|
case hpc.consttyp of
|
||||||
|
constwresourcestring,
|
||||||
constwstring:
|
constwstring:
|
||||||
begin
|
begin
|
||||||
if pcompilerwidestring(hpc.value.valueptr)^.len>0 then
|
if pcompilerwidestring(hpc.value.valueptr)^.len>0 then
|
||||||
|
@ -573,6 +573,7 @@ implementation
|
|||||||
constreal,
|
constreal,
|
||||||
constset,
|
constset,
|
||||||
constresourcestring,
|
constresourcestring,
|
||||||
|
constwresourcestring,
|
||||||
constwstring,
|
constwstring,
|
||||||
constguid: begin
|
constguid: begin
|
||||||
if value1.len<>value2.len then
|
if value1.len<>value2.len then
|
||||||
@ -2675,6 +2676,28 @@ implementation
|
|||||||
pc : pchar;
|
pc : pchar;
|
||||||
pw : pcompilerwidestring;
|
pw : pcompilerwidestring;
|
||||||
i : longint;
|
i : longint;
|
||||||
|
|
||||||
|
procedure do_widestring_const;
|
||||||
|
var
|
||||||
|
i : longint;
|
||||||
|
begin
|
||||||
|
initwidestring(pw);
|
||||||
|
setlengthwidestring(pw,ppufile.getlongint);
|
||||||
|
{ don't use getdata, because the compilerwidechars may have to
|
||||||
|
be byteswapped
|
||||||
|
}
|
||||||
|
{$if sizeof(tcompilerwidechar) = 2}
|
||||||
|
for i:=0 to pw^.len-1 do
|
||||||
|
pw^.data[i]:=ppufile.getword;
|
||||||
|
{$elseif sizeof(tcompilerwidechar) = 4}
|
||||||
|
for i:=0 to pw^.len-1 do
|
||||||
|
pw^.data[i]:=cardinal(ppufile.getlongint);
|
||||||
|
{$else}
|
||||||
|
{$error Unsupported tcompilerwidechar size}
|
||||||
|
{$endif}
|
||||||
|
pcompilerwidestring(value.valueptr):=pw;
|
||||||
|
end;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited ppuload(constsym,ppufile);
|
inherited ppuload(constsym,ppufile);
|
||||||
constdef:=nil;
|
constdef:=nil;
|
||||||
@ -2693,31 +2716,22 @@ implementation
|
|||||||
end;
|
end;
|
||||||
constwstring :
|
constwstring :
|
||||||
begin
|
begin
|
||||||
initwidestring(pw);
|
do_widestring_const;
|
||||||
setlengthwidestring(pw,ppufile.getlongint);
|
|
||||||
{ don't use getdata, because the compilerwidechars may have to
|
|
||||||
be byteswapped
|
|
||||||
}
|
|
||||||
{$if sizeof(tcompilerwidechar) = 2}
|
|
||||||
for i:=0 to pw^.len-1 do
|
|
||||||
pw^.data[i]:=ppufile.getword;
|
|
||||||
{$elseif sizeof(tcompilerwidechar) = 4}
|
|
||||||
for i:=0 to pw^.len-1 do
|
|
||||||
pw^.data[i]:=cardinal(ppufile.getlongint);
|
|
||||||
{$else}
|
|
||||||
{$error Unsupported tcompilerwidechar size}
|
|
||||||
{$endif}
|
|
||||||
pcompilerwidestring(value.valueptr):=pw;
|
|
||||||
end;
|
end;
|
||||||
conststring,
|
conststring,
|
||||||
constresourcestring :
|
constresourcestring :
|
||||||
|
begin
|
||||||
|
ppufile.getderef(constdefderef);
|
||||||
|
value.len:=ppufile.getlongint;
|
||||||
|
getmem(pc,value.len+1);
|
||||||
|
ppufile.getdata(pc^,value.len);
|
||||||
|
pc[value.len]:=#0;
|
||||||
|
value.valueptr:=pc;
|
||||||
|
end;
|
||||||
|
constwresourcestring :
|
||||||
begin
|
begin
|
||||||
ppufile.getderef(constdefderef);
|
ppufile.getderef(constdefderef);
|
||||||
value.len:=ppufile.getlongint;
|
do_widestring_const;
|
||||||
getmem(pc,value.len+1);
|
|
||||||
ppufile.getdata(pc^,value.len);
|
|
||||||
pc[value.len]:=#0;
|
|
||||||
value.valueptr:=pc;
|
|
||||||
end;
|
end;
|
||||||
constreal :
|
constreal :
|
||||||
begin
|
begin
|
||||||
@ -2759,7 +2773,8 @@ implementation
|
|||||||
conststring,
|
conststring,
|
||||||
constresourcestring :
|
constresourcestring :
|
||||||
freemem(pchar(value.valueptr),value.len+1);
|
freemem(pchar(value.valueptr),value.len+1);
|
||||||
constwstring :
|
constwstring,
|
||||||
|
constwresourcestring:
|
||||||
donewidestring(pcompilerwidestring(value.valueptr));
|
donewidestring(pcompilerwidestring(value.valueptr));
|
||||||
constreal :
|
constreal :
|
||||||
dispose(pbestreal(value.valueptr));
|
dispose(pbestreal(value.valueptr));
|
||||||
@ -2776,7 +2791,7 @@ implementation
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
case consttyp of
|
case consttyp of
|
||||||
constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid:
|
constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constwresourcestring,constguid:
|
||||||
constdefderef.build(constdef);
|
constdefderef.build(constdef);
|
||||||
constwstring:
|
constwstring:
|
||||||
;
|
;
|
||||||
@ -2789,7 +2804,7 @@ implementation
|
|||||||
procedure tconstsym.deref;
|
procedure tconstsym.deref;
|
||||||
begin
|
begin
|
||||||
case consttyp of
|
case consttyp of
|
||||||
constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constguid:
|
constnil,constord,constreal,constpointer,constset,conststring,constresourcestring,constwresourcestring,constguid:
|
||||||
constdef:=tdef(constdefderef.resolve);
|
constdef:=tdef(constdefderef.resolve);
|
||||||
constwstring:
|
constwstring:
|
||||||
constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pcompilerwidestring(value.valueptr)));
|
constdef:=carraydef.getreusable(cwidechartype,getlengthwidestring(pcompilerwidestring(value.valueptr)));
|
||||||
@ -2800,6 +2815,15 @@ implementation
|
|||||||
|
|
||||||
|
|
||||||
procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
|
procedure tconstsym.ppuwrite(ppufile:tcompilerppufile);
|
||||||
|
|
||||||
|
procedure do_widestring_const;
|
||||||
|
|
||||||
|
begin
|
||||||
|
ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
|
||||||
|
ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
inherited ppuwrite(ppufile);
|
inherited ppuwrite(ppufile);
|
||||||
ppufile.putbyte(byte(consttyp));
|
ppufile.putbyte(byte(consttyp));
|
||||||
@ -2819,15 +2843,18 @@ implementation
|
|||||||
constwstring :
|
constwstring :
|
||||||
begin
|
begin
|
||||||
{ no need to store the def, we can reconstruct it }
|
{ no need to store the def, we can reconstruct it }
|
||||||
ppufile.putlongint(getlengthwidestring(pcompilerwidestring(value.valueptr)));
|
do_widestring_const;
|
||||||
ppufile.putdata(pcompilerwidestring(value.valueptr)^.data^,pcompilerwidestring(value.valueptr)^.len*sizeof(tcompilerwidechar));
|
|
||||||
end;
|
end;
|
||||||
conststring,
|
conststring,constresourcestring:
|
||||||
constresourcestring :
|
begin
|
||||||
|
ppufile.putderef(constdefderef);
|
||||||
|
ppufile.putlongint(value.len);
|
||||||
|
ppufile.putdata(pchar(value.valueptr)^,value.len);
|
||||||
|
end;
|
||||||
|
constwresourcestring:
|
||||||
begin
|
begin
|
||||||
ppufile.putderef(constdefderef);
|
ppufile.putderef(constdefderef);
|
||||||
ppufile.putlongint(value.len);
|
do_widestring_const
|
||||||
ppufile.putdata(pchar(value.valueptr)^,value.len);
|
|
||||||
end;
|
end;
|
||||||
constreal :
|
constreal :
|
||||||
begin
|
begin
|
||||||
@ -2883,7 +2910,7 @@ implementation
|
|||||||
|
|
||||||
WriteLn(T, PrintNodeIndention, '<visibility>', visibility, '</visibility>');
|
WriteLn(T, PrintNodeIndention, '<visibility>', visibility, '</visibility>');
|
||||||
|
|
||||||
if not (consttyp in [conststring, constresourcestring, constwstring]) then
|
if not (consttyp in [conststring, constresourcestring, constwresourcestring, constwstring]) then
|
||||||
{ constdef.size will return an internal error for string
|
{ constdef.size will return an internal error for string
|
||||||
constants because constdef is an open array internally }
|
constants because constdef is an open array internally }
|
||||||
WriteLn(T, PrintNodeIndention, '<size>', constdef.size, '</size>');
|
WriteLn(T, PrintNodeIndention, '<size>', constdef.size, '</size>');
|
||||||
|
Loading…
Reference in New Issue
Block a user