Sordie.co.uk

libsassy/libSassy.Interfaces.pas

Raw

{(
 )) libSassy.Interfaces
((    Object interface support
 ))
((  Copyright  Sordie Aranka Solomon-Smith 2016
 ))
((  This work is made available under the terms of the Creative Commons
 )) Attribution-NonCommercial-ShareAlike 3.0 Unported license
((  http://creativecommons.org/licenses/by-nc-sa/3.0/
 )}

{$DEFINE USESTDINTF}

unit libSassy.Interfaces;

interface

uses
  System.SysUtils;


type
{$REGION 'TInterface'}
{$IFDEF USESTDINTF}
  TInterface = TInterfacedObject;
{$ELSE}
  TInterface = class(TObject, IInterface)
    function QueryInterface(const IID: TGUID; out Obj): HRESULT; stdcall;

    function _AddRef:  Integer; stdcall;
    function _Release: Integer; stdcall;
  end;
{$ENDIF}
{$ENDREGION}

implementation

{$REGION 'TInterface'}
{$IFNDEF USESTDINTF}
function TInterface.QueryInterface;
begin
  if GetInterface(IID, Obj) then
    Result := 0
  else
    Result := E_NOINTERFACE;
end;

function TInterface._AddRef;
begin
  Result := 1;
end;

function TInterface._Release;
begin
  Result := 1;
end;
{$ENDIF}
{$ENDREGION}

end.