[fpc-pascal] c structs and pascal interfaces

Andrew Haines AndrewD207 at aol.com
Tue Jan 28 18:13:14 CET 2014


Hi,

I want to use c "interfaces" exposed as structs in fpc as interfaces. In 
particular I'm converting the OpenSLES header file to fpc.

Here's an example of an exported struct:
struct SLPlayItf_ {
	SLresult (*SetPlayState) (
		SLPlayItf self,
		SLuint32 state
	);
	SLresult (*GetPlayState) (
		SLPlayItf self,
		SLuint32 *pState
	);
	SLresult (*GetDuration) (
		SLPlayItf self,
		SLmillisecond *pMsec
	);
	.....
};

I'm not very familiar with interfaces but here's what I know. There are 
two types com and corba.

I think I need corba so I don't have the ref and unref procedures.

I would translate this to:
{$INTERFACES corba}
ISLPlatItf = interface
   function SetPlayState(state: SLuint32): SLresult; cdecl;
   function GetPlayState(state: PSLuint32): SLresult; cdecl;
   function GetDuration(msec: PSLmillisecond): SLresult; cdecl;
   ......
end;

So now two questions:

Is corba the interface type I need?

Am I wrong to exclude the self parameter from the interface translation?

Thanks,

Andrew Haines





More information about the fpc-pascal mailing list