Resources | developer.brewmp.com Resources | developer.brewmp.com

Developer

resources

IDL interface type in Lua

The interface keyword can be used to declare an interface or used as a data type. When used as a type, it means:

interface type: a pointer to an interface and an interface ID

When used as a rout parameter, add an AEEIID constraint to identify the interface held by the returned pointer. When used as an in parameter, it is accompanied by an AEEIID. The following is an example IDL:

interface IFoo {
    AEEResult PutObject(in interface pif);
    AEEResult GetObject(rout interface pif);
 };

The following is an example implementation of the above IDL in Lua:

function IFoo:PutObject(pif, pifIID)
     if pifIID == AEEIID_IBar then
        -- we can safely treat iface as an IBar
        return iface:MyIBarMethod()
     else
        return AEE_EUNSUPPORTED
     end
 end
 
 function IFoo:GetObject(iid) 
     if iid == AEEIID_IBar then
        -- the caller asked for an ibar instance
        return self.myIBar
     else
        return AEE_EUNSUPPORTED
     end
 end

The following is an example usage:

foo:PutObject( foo:GetObject(AEEIID_IBar), AEEIID_IBar )