Back to index

lightning-sunbird  0.9+nobinonly
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Attributes
WSPComplexTypeWrapper Class Reference

#include <wspprivate.h>

Inheritance diagram for WSPComplexTypeWrapper:
Inheritance graph
[legend]
Collaboration diagram for WSPComplexTypeWrapper:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 WSPComplexTypeWrapper ()
virtual ~WSPComplexTypeWrapper ()
nsresult GetPropertyValue (PRUint32 aMethodIndex, const nsXPTMethodInfo *aMethodInfo, nsIVariant **_retval)
void Init (in nsISupports aComplexTypeInstance, in nsIInterfaceInfo aInterfaceInfo)
nsIVariant getProperty (in AString name)
 Get a property value for the given name.

Static Public Member Functions

NS_DECL_ISUPPORTS
NS_DECL_NSIPROPERTYBAG static
NS_DECL_NSIWEBSERVICECOMPLEXTYPEWRAPPER
NS_METHOD 
Create (nsISupports *outer, const nsIID &aIID, void **aInstancePtr)

Public Attributes

readonly attribute
nsISimpleEnumerator 
enumerator
 Get a nsISimpleEnumerator whose elements are nsIProperty objects.

Protected Attributes

nsCOMPtr< nsISupports > mComplexTypeInstance
nsCOMPtr< nsIInterfaceInfomInterfaceInfo

Detailed Description

Definition at line 231 of file wspprivate.h.


Constructor & Destructor Documentation

Definition at line 176 of file wspcomplextypewrapper.cpp.

{
}

Here is the caller graph for this function:

Definition at line 180 of file wspcomplextypewrapper.cpp.

{
}

Member Function Documentation

NS_METHOD WSPComplexTypeWrapper::Create ( nsISupports *  outer,
const nsIID aIID,
void **  aInstancePtr 
) [static]

Definition at line 194 of file wspcomplextypewrapper.cpp.

{
  NS_ENSURE_ARG_POINTER(aInstancePtr);
  NS_ENSURE_NO_AGGREGATION(outer);

  WSPComplexTypeWrapper* wrapper = new WSPComplexTypeWrapper();
  if (!wrapper) {
    return NS_ERROR_OUT_OF_MEMORY;
  }

  NS_ADDREF(wrapper);
  nsresult rv = wrapper->QueryInterface(aIID, aInstancePtr);
  NS_RELEASE(wrapper);
  return rv;
}

Here is the call graph for this function:

nsIVariant nsIPropertyBag::getProperty ( in AString  name) [inherited]

Get a property value for the given name.

Exceptions:
NS_ERROR_FAILUREif a property with that name doesn't exist.
nsresult WSPComplexTypeWrapper::GetPropertyValue ( PRUint32  aMethodIndex,
const nsXPTMethodInfo aMethodInfo,
nsIVariant **  _retval 
)

Definition at line 253 of file wspcomplextypewrapper.cpp.

{
  nsresult rv;
  nsAutoString outstr;
  PRUint32 numParams;
  nsXPTCVariant var[2];
  uint8 type_tag;
  nsXPTType arrayType;
  nsCOMPtr<nsIInterfaceInfo> iinfo;

  var[0].ClearFlags();
  var[1].ClearFlags();

  // There are two possibilities here: a getter or a
  // method that returns array and array size out parameters.
  if (aMethodInfo->IsGetter()) {
    // If it's a getter make sure that it takes just a single (out) param
    if (aMethodInfo->GetParamCount() != 1) {
      return NS_ERROR_FAILURE;
    }
  
    const nsXPTParamInfo& paramInfo = aMethodInfo->GetParam(0);
    const nsXPTType& type = paramInfo.GetType();
    type_tag = type.TagPart();
    
    numParams = 1;
    var[0].type = type_tag;
    if (paramInfo.IsOut()) {
      var[0].SetPtrIsData();
      var[0].ptr = &var[0].val;
    }
    else if (paramInfo.IsDipper() && type.IsPointer() && 
             (type_tag == nsXPTType::T_DOMSTRING)) {
      var[0].val.p = &outstr;
    }
    else {
      NS_ERROR("Unexpected parameter type for getter");
      return NS_ERROR_FAILURE;
    }

    if (type_tag == nsXPTType::T_INTERFACE) {
      rv = mInterfaceInfo->GetInfoForParam(aMethodIndex, &paramInfo, 
                                           getter_AddRefs(iinfo));
      if (NS_FAILED(rv)) {
        return rv;
      }
    }
  }
  // If it isn't a getter, then it has to be an array
  // getter method
  else {
    // It must take two parameters for this to work
    if (aMethodInfo->GetParamCount() != 2) {
      return NS_ERROR_FAILURE;
    }

    numParams = 2;

    // The first parameter must be "out PRUint32"
    const nsXPTParamInfo& paramInfo1 = aMethodInfo->GetParam(0);
    const nsXPTType& type1 = paramInfo1.GetType();
    if (!paramInfo1.IsOut() || (type1.TagPart() != nsXPTType::T_U32)) {
      NS_ERROR("Unexpected parameter type for getter");
      return NS_ERROR_FAILURE;
    }
    
    var[0].type = nsXPTType::T_U32;
    var[0].SetPtrIsData();
    var[0].ptr = &var[0].val;
    
    // The second parameter must be "[array] out"
    const nsXPTParamInfo& paramInfo2 = aMethodInfo->GetParam(1);
    const nsXPTType& type2 = paramInfo2.GetType();
    type_tag = type2.TagPart();
    if (!paramInfo2.IsOut() || !type2.IsArray()) {
      NS_ERROR("Unexpected parameter type for getter");
      return NS_ERROR_FAILURE;
    }

    var[1].type = type_tag;
    var[1].SetPtrIsData();
    var[1].ptr = &var[1].val;

    rv = mInterfaceInfo->GetTypeForParam(aMethodIndex, &paramInfo2, 1,
                                         &arrayType);
    if (NS_FAILED(rv)) {
      return rv;
    }
    
    if (arrayType.IsInterfacePointer()) {
      rv = mInterfaceInfo->GetInfoForParam(aMethodIndex, &paramInfo2, 
                                           getter_AddRefs(iinfo));
      if (NS_FAILED(rv)) {
        return rv;
      }
    }
  }

  rv = XPTC_InvokeByIndex(mComplexTypeInstance, aMethodIndex,
                          numParams, var);

  if (NS_FAILED(rv)) {
    return rv;
  }

  if (type_tag == nsXPTType::T_ARRAY) {
    rv = WSPProxy::ArrayXPTCMiniVariantToVariant(arrayType.TagPart(), var[1], 
                                                 var[0].val.u32, iinfo, 
                                                 _retval);
  }
  else {
    rv = WSPProxy::XPTCMiniVariantToVariant(type_tag, var[0], iinfo, _retval);
  }

  return rv;
}

Here is the call graph for this function:

void nsIWebServiceComplexTypeWrapper::Init ( in nsISupports  aComplexTypeInstance,
in nsIInterfaceInfo  aInterfaceInfo 
) [inherited]

Member Data Documentation

Get a nsISimpleEnumerator whose elements are nsIProperty objects.

Definition at line 53 of file nsIPropertyBag.idl.

Definition at line 250 of file wspprivate.h.

Definition at line 251 of file wspprivate.h.


The documentation for this class was generated from the following files: