(* ----------------------------------------------------------------------------
 * This file was automatically generated by SWIG (http://www.swig.org).
 * Version 3.0.11
 *
 * Do not make changes to this file unless you know what you are doing--modify
 * the SWIG interface file instead.
 * ----------------------------------------------------------------------------- *)

unit example;


{$define example_FUNCTION_WRAPPER}


{$define example_CLASS_WRAPPER}

interface



//type PDouble = ^double;


	type  
		Pdouble=^double;
		doubleArray = array[0..(MaxInt div sizeof(double))-1] of double;
		PdoubleArray = ^doubleArray;



	type  
		Pcardinal=^cardinal;
		cardinalArray = array[0..(MaxInt div sizeof(cardinal))-1] of cardinal;
		PcardinalArray = ^cardinalArray;



	type  
		CFILE=type Pointer;
		CFILEArray = array[0..(MaxInt div sizeof(CFILE))-1] of CFILE;
		PCFILEArray = ^CFILEArray;


type

   Tcolor = (RED = 0, BLUE = 1, GREEN = 2);

   TFoo_speed = (IMPULSE = 10, WARP = 20, LUDICROUS = 30);

Foo = type pointer;
PFooArray = ^FooArray_;
FooArray_=array[0..(MaxInt div sizeof(Foo))-1] of Foo;

type
	Psize_t = ^Cardinal;


function New_Foo (): Foo; stdcall;

procedure Foo_enum_test ( self: Foo;
s: integer); stdcall;

procedure Delete_Foo ( self: Foo); stdcall;

procedure Enum_test (c, s: integer); stdcall;

{$ifdef example_CLASS_WRAPPER}

type

  TFoo = class (TObject, IUnknown)

  private
    FCObjPtr : Foo;
    FOwnCObjPtr : boolean;

  protected
	procedure SetCObjPtr(Value : Foo);
  // IUnknown
    function _AddRef : integer; stdcall;
    function _Release: integer; stdcall;
    function QueryInterface(const GUID:TGUID; out Intf): HRESULT; stdcall;
 public

    constructor Create ();overload; 

    procedure enum_test ( s: integer);

    destructor Destroy; override;
  
  public  
    property CObjPtr : Foo read FCObjPtr write SetCObjPtr;
    property OwnCObjPtr : boolean read FOwnCObjPtr  write FOwnCObjPtr ;

  end;


{$endif} //example_CLASS_WRAPPER

{$ifdef example_FUNCTION_WRAPPER}

// Functions Wrapper 


{$endif} //example_FUNCTION_WRAPPER

implementation


const __DLLNAME= 'example.dll';


const __WRAPDLLNAME= 'example.dll';


function New_Foo (): Foo; stdcall; external __DLLNAME name 'Delphi_new_Foo';

procedure Foo_enum_test ( self: Foo;
s: integer); stdcall; external __DLLNAME name 'Delphi_Foo_enum_test';

procedure Delete_Foo ( self: Foo); stdcall; external __DLLNAME name 'Delphi_delete_Foo';

procedure Enum_test (c, s: integer); stdcall; external __DLLNAME name 'Delphi_enum_test';

{$ifdef example_FUNCTION_WRAPPER}

// Functions Wrapper 


{$endif} //example_FUNCTION_WRAPPER

{$ifdef example_CLASS_WRAPPER}

constructor TFoo.Create ();

begin

  inherited Create;
  FOwnCObjPtr := true;
   FCObjPtr := example.New_Foo();

end;

procedure TFoo.enum_test ( s: integer);

begin

  assert(FCObjPtr <> nil);
 example.Foo_enum_test(Self.FCObjPtr, s);

end;


function TFoo._AddRef : integer;
begin
   Result := -1;
end;

function TFoo._Release: integer;
begin
   Result := -1;
end;

function TFoo.QueryInterface(const GUID:TGUID; out Intf): HRESULT;
begin
   if GetInterface(GUID, Intf) then
      Result := S_OK
   else
      Result := S_FALSE	;
end; 
 
destructor TFoo.Destroy; 
begin   
  if (FCObjPtr <> nil) and  FOwnCObjPtr then begin 
    example.delete_Foo(FCObjPtr);
    FOwnCObjPtr := false;
  end;
  FCObjPtr := nil; 
  inherited Destroy;
end;

procedure TFoo.SetCObjPtr(Value : Foo);
begin
 
  if (Value <> FCObjPtr) then begin
	if (FCObjPtr <> nil) and  FOwnCObjPtr then begin 
		example.delete_Foo(FCObjPtr);
	end;
	FCObjPtr := Value;
  
  
  end;

end;


{$endif} //example_CLASS_WRAPPER

initialization



// constant initialization



//initialization


finalization


//finalization


end.
