mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-11-04 10:19:31 +01:00 
			
		
		
		
	the IInterface implementation to be XPCom-compatible --- Merging r15997 through r16179 into '.': U rtl/inc/variants.pp U rtl/inc/objpash.inc U rtl/inc/objpas.inc U rtl/objpas/classes/persist.inc U rtl/objpas/classes/compon.inc U rtl/objpas/classes/classesh.inc A tests/test/tconstref1.pp A tests/test/tconstref2.pp A tests/test/tconstref3.pp U tests/test/tinterface4.pp A tests/test/tconstref4.pp U tests/webtbs/tw10897.pp U tests/webtbs/tw4086.pp U tests/webtbs/tw15363.pp U tests/webtbs/tw2177.pp U tests/webtbs/tw16592.pp U tests/tbs/tb0546.pp U compiler/sparc/cpupara.pas U compiler/i386/cpupara.pas U compiler/pdecsub.pas U compiler/symdef.pas U compiler/powerpc/cpupara.pas U compiler/avr/cpupara.pas U compiler/browcol.pas U compiler/defcmp.pas U compiler/powerpc64/cpupara.pas U compiler/ncgrtti.pas U compiler/x86_64/cpupara.pas U compiler/opttail.pas U compiler/htypechk.pas U compiler/tokens.pas U compiler/objcutil.pas U compiler/ncal.pas U compiler/symtable.pas U compiler/symsym.pas U compiler/m68k/cpupara.pas U compiler/regvars.pas U compiler/arm/cpupara.pas U compiler/symconst.pas U compiler/mips/cpupara.pas U compiler/paramgr.pas U compiler/psub.pas U compiler/pdecvar.pas U compiler/dbgstabs.pas U compiler/options.pas U packages/fcl-fpcunit/src/testutils.pp git-svn-id: trunk@16180 -
		
			
				
	
	
		
			157 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			157 lines
		
	
	
		
			3.4 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
{
 | 
						|
    This file is part of the Free Component Library (FCL)
 | 
						|
    Copyright (c) 1999-2000 by the Free Pascal development team
 | 
						|
 | 
						|
    See the file COPYING.FPC, included in this distribution,
 | 
						|
    for details about the copyright.
 | 
						|
 | 
						|
    This program is distributed in the hope that it will be useful,
 | 
						|
    but WITHOUT ANY WARRANTY; without even the implied warranty of
 | 
						|
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 | 
						|
 | 
						|
 **********************************************************************}
 | 
						|
 | 
						|
{****************************************************************************}
 | 
						|
{*                             TPersistent                                  *}
 | 
						|
{****************************************************************************}
 | 
						|
 | 
						|
procedure TPersistent.AssignError(Source: TPersistent);
 | 
						|
 | 
						|
Var SourceName : String;
 | 
						|
 | 
						|
begin
 | 
						|
  If Source<>Nil then
 | 
						|
    SourceName:=Source.ClassName
 | 
						|
  else
 | 
						|
    SourceName:='Nil';
 | 
						|
  raise EConvertError.CreateFmt (SAssignError,[SourceName,ClassName]);
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
 | 
						|
procedure TPersistent.AssignTo(Dest: TPersistent);
 | 
						|
 | 
						|
 | 
						|
begin
 | 
						|
  Dest.AssignError(Self);
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
procedure TPersistent.DefineProperties(Filer: TFiler);
 | 
						|
 | 
						|
begin
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
function  TPersistent.GetOwner: TPersistent;
 | 
						|
 | 
						|
begin
 | 
						|
  Result:=Nil;
 | 
						|
end;
 | 
						|
 | 
						|
destructor TPersistent.Destroy;
 | 
						|
 | 
						|
begin
 | 
						|
  Inherited Destroy;
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
procedure TPersistent.Assign(Source: TPersistent);
 | 
						|
 | 
						|
begin
 | 
						|
  If Source<>Nil then
 | 
						|
    Source.AssignTo(Self)
 | 
						|
  else
 | 
						|
    AssignError(Nil);
 | 
						|
end;
 | 
						|
 | 
						|
function  TPersistent.GetNamePath: string;
 | 
						|
 | 
						|
Var OwnerName :String;
 | 
						|
 | 
						|
begin
 | 
						|
 Result:=ClassNAme;
 | 
						|
 If GetOwner<>Nil then
 | 
						|
   begin
 | 
						|
   OwnerName:=GetOwner.GetNamePath;
 | 
						|
   If OwnerName<>'' then Result:=OwnerName+'.'+Result;
 | 
						|
   end;
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
{****************************************************************************}
 | 
						|
{*                          TInterfacedPersistent                           *}
 | 
						|
{****************************************************************************}
 | 
						|
 | 
						|
procedure TInterfacedPersistent.AfterConstruction;
 | 
						|
begin
 | 
						|
  inherited;
 | 
						|
  if assigned(GetOwner) then
 | 
						|
    GetOwner.GetInterface(IUnknown,FOwnerInterface);
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
function TInterfacedPersistent._AddRef: Integer;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
 | 
						|
begin
 | 
						|
  if assigned(FOwnerInterface) then
 | 
						|
    Result:=FOwnerInterface._AddRef
 | 
						|
  else
 | 
						|
    Result:=-1;
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
function TInterfacedPersistent._Release: Integer;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
 | 
						|
begin
 | 
						|
  if assigned(FOwnerInterface) then
 | 
						|
    Result:=FOwnerInterface._Release
 | 
						|
  else
 | 
						|
    Result:=-1;
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
function TInterfacedPersistent.QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} IID: TGUID; out Obj): HResult;{$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
 | 
						|
begin
 | 
						|
  if GetInterface(IID, Obj) then
 | 
						|
    Result:=0
 | 
						|
  else
 | 
						|
    Result:=HResult($80004002);
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
{****************************************************************************}
 | 
						|
{*                                TRecall                                   *}
 | 
						|
{****************************************************************************}
 | 
						|
 | 
						|
constructor TRecall.Create(AStorage,AReference: TPersistent);
 | 
						|
begin
 | 
						|
  inherited Create;
 | 
						|
  FStorage:=AStorage;
 | 
						|
  FReference:=AReference;
 | 
						|
  Store;
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
destructor TRecall.Destroy;
 | 
						|
begin
 | 
						|
  if Assigned(FReference) then
 | 
						|
   FReference.Assign(FStorage);
 | 
						|
  Forget;
 | 
						|
  inherited;
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
procedure TRecall.Forget;
 | 
						|
begin
 | 
						|
  FReference:=nil;
 | 
						|
  FreeAndNil(FStorage);
 | 
						|
end;
 | 
						|
 | 
						|
 | 
						|
procedure TRecall.Store;
 | 
						|
begin
 | 
						|
  if Assigned(FReference) then
 | 
						|
    FStorage.Assign(FReference);
 | 
						|
end;
 | 
						|
 | 
						|
 |