pastojs: added libpas2js hook SetPas2JSUnitAliasCallBack

git-svn-id: trunk@43813 -
This commit is contained in:
Mattias Gaertner 2019-12-30 11:00:58 +00:00
parent 25c11a94c4
commit 366ee5e835
2 changed files with 30 additions and 3 deletions

View File

@ -379,6 +379,7 @@ type
Procedure TestUnit_UnitNotFoundErrorPos; Procedure TestUnit_UnitNotFoundErrorPos;
Procedure TestUnit_AccessIndirectUsedUnitFail; Procedure TestUnit_AccessIndirectUsedUnitFail;
Procedure TestUnit_Intf1Impl2Intf1; Procedure TestUnit_Intf1Impl2Intf1;
Procedure TestUnit_Intf1Impl2Intf1_Duplicate;
// procs // procs
Procedure TestProcParam; Procedure TestProcParam;
@ -2386,8 +2387,13 @@ function TCustomTestResolver.OnPasResolverFindUnit(SrcResolver: TPasResolver;
{$ENDIF} {$ENDIF}
CurEngine:=FindModuleWithFilename(aFilename); CurEngine:=FindModuleWithFilename(aFilename);
if CurEngine=nil then exit(false); if CurEngine=nil then exit(false);
aModule:=InitUnit(CurEngine); if CurEngine.Module=nil then
if aModule=nil then exit(false); begin
aModule:=InitUnit(CurEngine);
if aModule=nil then exit(false);
end
else
aModule:=CurEngine.Module;
OnPasResolverFindUnit:=aModule; OnPasResolverFindUnit:=aModule;
Result:=true; Result:=true;
end; end;
@ -6091,6 +6097,27 @@ begin
ParseUnit; ParseUnit;
end; end;
procedure TTestResolver.TestUnit_Intf1Impl2Intf1_Duplicate;
begin
AddModuleWithIntfImplSrc('unit1.pp',
LinesToStr([
'type number = longint;']),
LinesToStr([
'uses afile;',
'procedure DoIt;',
'begin',
' i:=3;',
'end;']));
StartUnit(true);
Add([
'interface',
'uses unit1, foo in ''unit1.pp'';',
'var i: number;',
'implementation']);
ParseUnit;
end;
procedure TTestResolver.TestProcParam; procedure TTestResolver.TestProcParam;
begin begin
StartProgram(false); StartProgram(false);

View File

@ -212,7 +212,7 @@ begin
UnitNameMaxLen:=Max(UnitNameLen,255); UnitNameMaxLen:=Max(UnitNameLen,255);
s:=UseUnitName; s:=UseUnitName;
SetLength(s,UnitNameMaxLen); SetLength(s,UnitNameMaxLen);
if OnUnitAlias(OnUnitAliasData,Pointer(s),UnitNameLen,UnitNameMaxLen) then if OnUnitAlias(OnUnitAliasData,Pointer(s),UnitNameMaxLen) then
UseUnitName:=LeftStr(s,UnitNameLen); UseUnitName:=LeftStr(s,UnitNameLen);
end; end;
end; end;