mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 16:28:24 +02:00
Merged revision(s) 28691, 31914 from branches/svenbarth/packages:
Convert export options from constants to a set and accordingly adjust all usage locations git-svn-id: trunk@32945 -
This commit is contained in:
parent
af4f75de75
commit
3b71841a84
@ -31,18 +31,20 @@ uses
|
||||
symtype,symdef,symsym,
|
||||
aasmbase,aasmdata;
|
||||
|
||||
const
|
||||
{ export options }
|
||||
eo_resident = $1;
|
||||
eo_index = $2;
|
||||
eo_name = $4;
|
||||
|
||||
type
|
||||
{ export options }
|
||||
texportoption=(eo_none,
|
||||
eo_resident,
|
||||
eo_index,
|
||||
eo_name
|
||||
);
|
||||
texportoptions=set of texportoption;
|
||||
|
||||
texported_item = class(TLinkedListItem)
|
||||
sym : tsym;
|
||||
index : longint;
|
||||
name : pshortstring;
|
||||
options : word;
|
||||
options : texportoptions;
|
||||
is_var : boolean;
|
||||
constructor create;
|
||||
destructor destroy;override;
|
||||
@ -71,14 +73,14 @@ type
|
||||
TExportLibClass=class of TExportLib;
|
||||
|
||||
|
||||
procedure exportprocsym(sym: tsym; const s : string; index: longint; options: word);
|
||||
procedure exportvarsym(sym: tsym; const s : string; index: longint; options: word);
|
||||
procedure exportprocsym(sym: tsym; const s : string; index: longint; options: texportoptions);
|
||||
procedure exportvarsym(sym: tsym; const s : string; index: longint; options: texportoptions);
|
||||
{ to export symbols not directly related to a tsym (e.g., the Objective-C
|
||||
rtti) }
|
||||
procedure exportname(const s : string; options: word);
|
||||
procedure exportname(const s : string; options: texportoptions);
|
||||
|
||||
procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: word);
|
||||
procedure exportallprocsymnames(ps: tprocsym; options: word);
|
||||
procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: texportoptions);
|
||||
procedure exportallprocsymnames(ps: tprocsym; options: texportoptions);
|
||||
|
||||
|
||||
var
|
||||
@ -98,20 +100,20 @@ uses
|
||||
TExported_procedure
|
||||
****************************************************************************}
|
||||
|
||||
procedure exportprocsym(sym: tsym; const s : string; index: longint; options: word);
|
||||
procedure exportprocsym(sym: tsym; const s : string; index: longint; options: texportoptions);
|
||||
var
|
||||
hp : texported_item;
|
||||
begin
|
||||
hp:=texported_item.create;
|
||||
hp.name:=stringdup(s);
|
||||
hp.sym:=sym;
|
||||
hp.options:=options or eo_name;
|
||||
hp.options:=options+[eo_name];
|
||||
hp.index:=index;
|
||||
exportlib.exportprocedure(hp);
|
||||
end;
|
||||
|
||||
|
||||
procedure exportvarsym(sym: tsym; const s : string; index: longint; options: word);
|
||||
procedure exportvarsym(sym: tsym; const s : string; index: longint; options: texportoptions);
|
||||
var
|
||||
hp : texported_item;
|
||||
begin
|
||||
@ -119,19 +121,19 @@ procedure exportvarsym(sym: tsym; const s : string; index: longint; options: wor
|
||||
hp.name:=stringdup(s);
|
||||
hp.sym:=sym;
|
||||
hp.is_var:=true;
|
||||
hp.options:=options or eo_name;
|
||||
hp.options:=options+[eo_name];
|
||||
hp.index:=index;
|
||||
exportlib.exportvar(hp);
|
||||
end;
|
||||
|
||||
|
||||
procedure exportname(const s : string; options: word);
|
||||
procedure exportname(const s : string; options: texportoptions);
|
||||
begin
|
||||
exportvarsym(nil,s,0,options);
|
||||
end;
|
||||
|
||||
|
||||
procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: word);
|
||||
procedure exportallprocdefnames(sym: tprocsym; pd: tprocdef; options: texportoptions);
|
||||
var
|
||||
item: TCmdStrListItem;
|
||||
begin
|
||||
@ -148,7 +150,7 @@ procedure exportname(const s : string; options: word);
|
||||
end;
|
||||
|
||||
|
||||
procedure exportallprocsymnames(ps: tprocsym; options: word);
|
||||
procedure exportallprocsymnames(ps: tprocsym; options: texportoptions);
|
||||
var
|
||||
i: longint;
|
||||
begin
|
||||
@ -167,7 +169,7 @@ begin
|
||||
sym:=nil;
|
||||
index:=-1;
|
||||
name:=nil;
|
||||
options:=0;
|
||||
options:=[];
|
||||
is_var:=false;
|
||||
end;
|
||||
|
||||
|
@ -88,7 +88,7 @@ var
|
||||
hp2 : texported_item;
|
||||
begin
|
||||
{ first test the index value }
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
begin
|
||||
Message1(parser_e_no_export_with_index_for_target,target_info.shortname);
|
||||
exit;
|
||||
|
@ -287,7 +287,7 @@ end;
|
||||
{ TODO: package visibility (private_extern) -- must not be exported
|
||||
either}
|
||||
if not(vf.visibility in [vis_private,vis_strictprivate]) then
|
||||
exportname(prefix+vf.RealName,0);
|
||||
exportname(prefix+vf.RealName,[]);
|
||||
end;
|
||||
end;
|
||||
|
||||
@ -297,15 +297,15 @@ end;
|
||||
if (target_info.system in systems_objc_nfabi) then
|
||||
begin
|
||||
{ export class and metaclass symbols }
|
||||
exportname(def.rtti_mangledname(objcclassrtti),0);
|
||||
exportname(def.rtti_mangledname(objcmetartti),0);
|
||||
exportname(def.rtti_mangledname(objcclassrtti),[]);
|
||||
exportname(def.rtti_mangledname(objcmetartti),[]);
|
||||
{ export public/protected instance variable offset symbols }
|
||||
exportobjcclassfields(def);
|
||||
end
|
||||
else
|
||||
begin
|
||||
{ export the class symbol }
|
||||
exportname('.objc_class_name_'+def.objextname^,0);
|
||||
exportname('.objc_class_name_'+def.objextname^,[]);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -63,14 +63,14 @@ implementation
|
||||
srsymtable : TSymtable;
|
||||
hpname : shortstring;
|
||||
index : longint;
|
||||
options : word;
|
||||
options : texportoptions;
|
||||
|
||||
function IsGreater(hp1,hp2:texported_item):boolean;
|
||||
var
|
||||
i2 : boolean;
|
||||
begin
|
||||
i2:=(hp2.options and eo_index)<>0;
|
||||
if (hp1.options and eo_index)<>0 then
|
||||
i2:=eo_index in hp2.options;
|
||||
if eo_index in hp1.options then
|
||||
begin
|
||||
if i2 then
|
||||
IsGreater:=hp1.index>hp2.index
|
||||
@ -88,7 +88,7 @@ implementation
|
||||
consume(_EXPORTS);
|
||||
repeat
|
||||
hpname:='';
|
||||
options:=0;
|
||||
options:=[];
|
||||
index:=0;
|
||||
if token=_ID then
|
||||
begin
|
||||
@ -151,7 +151,7 @@ implementation
|
||||
index:=0;
|
||||
consume(_INTCONST);
|
||||
end;
|
||||
options:=options or eo_index;
|
||||
include(options,eo_index);
|
||||
pt.free;
|
||||
if target_info.system in [system_i386_win32,system_i386_wdosx,system_arm_wince,system_i386_wince] then
|
||||
DefString:=srsym.realname+'='+InternalProcName+' @ '+tostr(index)
|
||||
@ -167,13 +167,13 @@ implementation
|
||||
hpname:=chr(tordconstnode(pt).value.svalue and $ff)
|
||||
else
|
||||
consume(_CSTRING);
|
||||
options:=options or eo_name;
|
||||
include(options,eo_name);
|
||||
pt.free;
|
||||
DefString:=hpname+'='+InternalProcName;
|
||||
end;
|
||||
if try_to_consume(_RESIDENT) then
|
||||
begin
|
||||
options:=options or eo_resident;
|
||||
include(options,eo_resident);
|
||||
DefString:=srsym.realname+'='+InternalProcName;{Resident ignored!}
|
||||
end;
|
||||
if (DefString<>'') and UseDeffileForExports then
|
||||
@ -188,7 +188,7 @@ implementation
|
||||
{ export section (it doesn't make sense to export }
|
||||
{ the generic mangled name, because the name of }
|
||||
{ the parent unit is used in that) }
|
||||
if ((options and (eo_name or eo_index))=0) and
|
||||
if (options*[eo_name,eo_index]=[]) and
|
||||
(tprocdef(tprocsym(srsym).procdeflist[0]).aliasnames.count>1) then
|
||||
exportallprocsymnames(tprocsym(srsym),options)
|
||||
else
|
||||
@ -198,7 +198,7 @@ implementation
|
||||
{ same index? And/or should we also export the aliases }
|
||||
{ if a name is specified? (JM) }
|
||||
|
||||
if ((options and eo_name)=0) then
|
||||
if not (eo_name in options) then
|
||||
{ Export names are not mangled on Windows and OS/2 }
|
||||
if (target_info.system in (systems_all_windows+[system_i386_emx, system_i386_os2])) then
|
||||
hpname:=orgs
|
||||
@ -216,7 +216,7 @@ implementation
|
||||
end;
|
||||
staticvarsym:
|
||||
begin
|
||||
if ((options and eo_name)=0) then
|
||||
if not (eo_name in options) then
|
||||
{ for "cvar" }
|
||||
if (vo_has_mangledname in tstaticvarsym(srsym).varoptions) then
|
||||
hpname:=srsym.mangledname
|
||||
|
@ -1372,7 +1372,7 @@ type
|
||||
begin
|
||||
hp:=texported_item.create;
|
||||
hp.name:=stringdup(s);
|
||||
hp.options:=hp.options or eo_name;
|
||||
include(hp.options,eo_name);
|
||||
exportlib.exportprocedure(hp);
|
||||
end;
|
||||
|
||||
@ -1383,7 +1383,7 @@ type
|
||||
begin
|
||||
hp:=texported_item.create;
|
||||
hp.name:=stringdup(s);
|
||||
hp.options:=hp.options or eo_name;
|
||||
include(hp.options,eo_name);
|
||||
exportlib.exportvar(hp);
|
||||
end;
|
||||
|
||||
|
@ -93,7 +93,7 @@ var
|
||||
hp2 : texported_item;
|
||||
begin
|
||||
{ first test the index value }
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
begin
|
||||
Message1(parser_e_no_export_with_index_for_target,'beos');
|
||||
exit;
|
||||
|
@ -94,7 +94,7 @@ var
|
||||
hp2 : texported_item;
|
||||
begin
|
||||
{ first test the index value }
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
begin
|
||||
Message1(parser_e_no_export_with_index_for_target,'haiku');
|
||||
exit;
|
||||
|
@ -165,16 +165,16 @@ var
|
||||
hp2 : texported_item;
|
||||
begin
|
||||
{ first test the index value }
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
begin
|
||||
Comment(V_Error,'can''t export with index under netware');
|
||||
exit;
|
||||
end;
|
||||
{ use pascal name is none specified }
|
||||
if (hp.options and eo_name)=0 then
|
||||
if not (eo_name in hp.options) then
|
||||
begin
|
||||
hp.name:=stringdup(hp.sym.name);
|
||||
hp.options:=hp.options or eo_name;
|
||||
include(hp.options,eo_name);
|
||||
end;
|
||||
{ now place in correct order }
|
||||
hp2:=texported_item(current_module._exports.first);
|
||||
|
@ -167,16 +167,16 @@ var
|
||||
hp2 : texported_item;
|
||||
begin
|
||||
{ first test the index value }
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
begin
|
||||
Comment(V_Error,'can''t export with index under netware');
|
||||
exit;
|
||||
end;
|
||||
{ use pascal name is none specified }
|
||||
if (hp.options and eo_name)=0 then
|
||||
if eo_name in hp.options then
|
||||
begin
|
||||
hp.name:=stringdup(hp.sym.name);
|
||||
hp.options:=hp.options or eo_name;
|
||||
include(hp.options,eo_name);
|
||||
end;
|
||||
{ now place in correct order }
|
||||
hp2:=texported_item(current_module._exports.first);
|
||||
|
@ -651,12 +651,12 @@ implementation
|
||||
|
||||
procedure TExportLibWin.exportprocedure(hp : texported_item);
|
||||
begin
|
||||
if ((hp.options and eo_index)<>0) and ((hp.index<=0) or (hp.index>$ffff)) then
|
||||
if (eo_index in hp.options) and ((hp.index<=0) or (hp.index>$ffff)) then
|
||||
begin
|
||||
message1(parser_e_export_invalid_index,tostr(hp.index));
|
||||
exit;
|
||||
end;
|
||||
if hp.options and eo_index=eo_index then
|
||||
if eo_index in hp.options then
|
||||
EList_indexed.Add(hp)
|
||||
else
|
||||
EList_nonindexed.Add(hp);
|
||||
@ -830,7 +830,7 @@ implementation
|
||||
hp:=texported_item(current_module._exports.first);
|
||||
while assigned(hp) do
|
||||
begin
|
||||
if (hp.options and eo_name)<>0 then
|
||||
if eo_name in hp.options then
|
||||
begin
|
||||
current_asmdata.getjumplabel(name_label);
|
||||
name_table_pointers.concat(Tai_const.Create_rva_sym(name_label));
|
||||
|
@ -127,7 +127,7 @@ end;
|
||||
|
||||
procedure TExportLibWin16.exportprocedure(hp: texported_item);
|
||||
begin
|
||||
if ((hp.options and eo_index)<>0) and ((hp.index<=0) or (hp.index>$ffff)) then
|
||||
if (eo_index in hp.options) and ((hp.index<=0) or (hp.index>$ffff)) then
|
||||
begin
|
||||
message1(parser_e_export_invalid_index,tostr(hp.index));
|
||||
exit;
|
||||
@ -172,9 +172,9 @@ begin
|
||||
DllExport_COMENT:=TOmfRecord_COMENT.Create;
|
||||
DllExport_COMENT.CommentClass:=CC_OmfExtension;
|
||||
expflag:=0;
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
expflag:=expflag or $80;
|
||||
if (hp.options and eo_resident)<>0 then
|
||||
if eo_resident in hp.options then
|
||||
expflag:=expflag or $40;
|
||||
if assigned(hp.sym) then
|
||||
case hp.sym.typ of
|
||||
@ -188,7 +188,7 @@ begin
|
||||
else
|
||||
internal_name:=hp.name^;
|
||||
DllExport_COMENT.CommentString:=#2+Chr(expflag)+Chr(Length(hp.name^))+hp.name^+Chr(Length(internal_name))+internal_name;
|
||||
if (hp.options and eo_index)<>0 then
|
||||
if eo_index in hp.options then
|
||||
DllExport_COMENT.CommentString:=DllExport_COMENT.CommentString+Chr(Byte(hp.index))+Chr(Byte(hp.index shr 8));
|
||||
DllExport_COMENT.EncodeTo(RawRecord);
|
||||
RawRecord.WriteTo(ObjWriter);
|
||||
|
Loading…
Reference in New Issue
Block a user