Back to index

lightning-sunbird  0.9+nobinonly
nsXPCDispTestMethods.cpp
Go to the documentation of this file.
00001 // nsXPCDispTestMethods.cpp : Implementation of CIDispatchTestApp and DLL registration.
00002 
00003 #include "stdafx.h"
00004 #include "XPCIDispatchTest.h"
00005 #include "nsXPCDispTestMethods.h"
00006 #include "XPCDispUtilities.h"
00007 #include "nsXPCDispSimple.h"
00008 
00010 //
00011 
00012 STDMETHODIMP nsXPCDispTestMethods::InterfaceSupportsErrorInfo(REFIID riid)
00013 {
00014     static const IID* arr[] = 
00015     {
00016         &IID_nsIXPCDispTestMethods,
00017     };
00018 
00019     for (int i=0;i<sizeof(arr)/sizeof(arr[0]);i++)
00020     {
00021         if (InlineIsEqualGUID(*arr[i],riid))
00022             return S_OK;
00023     }
00024     return S_FALSE;
00025 }
00026 
00027 STDMETHODIMP nsXPCDispTestMethods::NoParameters()
00028 {
00029     return S_OK;
00030 }
00031 STDMETHODIMP nsXPCDispTestMethods::ReturnBSTR(BSTR * result)
00032 {
00033     if (result == NULL)
00034         return E_POINTER;
00035         
00036     CComBSTR x("Boo");
00037     *result = x.Detach();
00038     return S_OK;
00039 }
00040 STDMETHODIMP nsXPCDispTestMethods::ReturnI4(INT * result)
00041 {
00042     if (result == NULL)
00043         return E_POINTER;
00044     *result = 99999;
00045     return S_OK;
00046 }
00047 STDMETHODIMP nsXPCDispTestMethods::ReturnUI1(BYTE * result)
00048 {
00049     if (result == NULL)
00050         return E_POINTER;
00051     *result = 99;
00052     return S_OK;
00053 }
00054 STDMETHODIMP nsXPCDispTestMethods::ReturnI2(SHORT * result)
00055 {
00056     if (result == NULL)
00057         return E_POINTER;
00058     *result = 9999;
00059     return S_OK;
00060 }
00061 STDMETHODIMP nsXPCDispTestMethods::ReturnR4(FLOAT * result)
00062 {
00063     if (result == NULL)
00064         return E_POINTER;
00065     *result = 99999.1f;
00066     return S_OK;
00067 }
00068 STDMETHODIMP nsXPCDispTestMethods::ReturnR8(DOUBLE * result)
00069 {
00070     if (result == NULL)
00071         return E_POINTER;
00072     *result = 99999999999.99;
00073     return S_OK;
00074 }
00075 STDMETHODIMP nsXPCDispTestMethods::ReturnBool(VARIANT_BOOL * result)
00076 {
00077     if (result == NULL)
00078         return E_POINTER;
00079     *result = VARIANT_TRUE;
00080     return S_OK;
00081 }
00082 STDMETHODIMP nsXPCDispTestMethods::ReturnIDispatch(IDispatch * * result)
00083 {
00084     if (result == NULL)
00085         return E_POINTER;
00086     return nsXPCDispSimple::CreateInstance(result);
00087 }
00088 STDMETHODIMP nsXPCDispTestMethods::ReturnError(SCODE * result)
00089 {
00090     if (result == NULL)
00091         return E_POINTER;
00092     *result = E_FAIL;
00093     return S_OK;
00094 }
00095 STDMETHODIMP nsXPCDispTestMethods::ReturnDate(DATE * result)
00096 {
00097     if (result == NULL)
00098         return E_POINTER;
00099     CComBSTR dateStr(L"5/2/02");
00100     return VarDateFromStr(dateStr, LOCALE_SYSTEM_DEFAULT,
00101                           LOCALE_NOUSEROVERRIDE, result);
00102 }
00103 STDMETHODIMP nsXPCDispTestMethods::ReturnIUnknown(IUnknown * * result)
00104 {
00105     if (result == NULL)
00106         return E_POINTER;
00107         
00108     return XPCCreateInstance<IUnknown>(CLSID_nsXPCDispTestNoIDispatch, IID_IUnknown, result);
00109 }
00110 STDMETHODIMP nsXPCDispTestMethods::ReturnI1(unsigned char * result)
00111 {
00112     if (result == NULL)
00113         return E_POINTER;
00114         
00115     *result = 120;
00116     return S_OK;
00117 }
00118 STDMETHODIMP nsXPCDispTestMethods::ReturnUI2(USHORT * result)
00119 {
00120     if (result == NULL)
00121         return E_POINTER;
00122     *result = 9999;
00123     return S_OK;
00124 }
00125 STDMETHODIMP nsXPCDispTestMethods::ReturnUI4(ULONG * result)
00126 {
00127     if (result == NULL)
00128         return E_POINTER;
00129     *result = 3000000000;
00130     return S_OK;
00131 }
00132 STDMETHODIMP nsXPCDispTestMethods::ReturnInt(INT * result)
00133 {
00134     if (result == NULL)
00135         return E_POINTER;
00136     *result = -999999;
00137     return S_OK;
00138 }
00139 STDMETHODIMP nsXPCDispTestMethods::ReturnUInt(UINT * result)
00140 {
00141     if (result == NULL)
00142         return E_POINTER;
00143         
00144     *result = 3000000000;
00145     return S_OK;
00146 }
00147 STDMETHODIMP nsXPCDispTestMethods::TakesBSTR(BSTR result)
00148 {
00149     CComBSTR str(result);
00150     static CComBSTR test(L"TakesBSTR");
00151     return str == test ? S_OK: E_FAIL;
00152 }
00153 STDMETHODIMP nsXPCDispTestMethods::TakesI4(INT result)
00154 {
00155     return result == 999999 ? S_OK : E_FAIL;
00156 }
00157 STDMETHODIMP nsXPCDispTestMethods::TakesUI1(BYTE result)
00158 {
00159     return result == 42 ? S_OK : E_FAIL;
00160 }
00161 STDMETHODIMP nsXPCDispTestMethods::TakesI2(SHORT result)
00162 {
00163     return result == 32000 ? S_OK : E_FAIL;
00164 }
00165 STDMETHODIMP nsXPCDispTestMethods::TakesR4(FLOAT result)
00166 {
00167     // Hopefully we won't run into any precision/rounding issues
00168     return result == 99999.99f ? S_OK : E_FAIL;
00169 }
00170 STDMETHODIMP nsXPCDispTestMethods::TakesR8(DOUBLE result)
00171 {
00172     // Hopefully we won't run into any precision/rounding issues
00173     return result == 999999999.99 ? S_OK : E_FAIL;
00174 }
00175 STDMETHODIMP nsXPCDispTestMethods::TakesBool(VARIANT_BOOL result)
00176 {
00177     return result ? S_OK : E_FAIL;
00178 }
00179 
00180 inline
00181 HRESULT GetProperty(IDispatch *pDisp, const CComBSTR & name, CComVariant& output)
00182 {
00183     DISPID dispid = GetIDsOfNames(pDisp, name);
00184     DISPPARAMS dispParams;
00185     dispParams.cArgs = 0;
00186     dispParams.cNamedArgs = 0;
00187     dispParams.rgdispidNamedArgs = 0;
00188     dispParams.rgvarg = 0;
00189     return pDisp->Invoke(dispid, IID_NULL, LOCALE_SYSTEM_DEFAULT,DISPATCH_PROPERTYGET, &dispParams, &output, 0, 0);
00190 }
00191     
00192 inline
00193 HRESULT PutProperty(IDispatch *pDisp, const CComBSTR & name, const CComVariant& input)
00194 {
00195     DISPPARAMS dispParams;
00196     DISPID did = DISPID_PROPERTYPUT;
00197     dispParams.cArgs = 1;
00198     CComVariant var(input);
00199     dispParams.rgvarg = &var;
00200     dispParams.cNamedArgs = 1;
00201     dispParams.rgdispidNamedArgs = &did;
00202     CComVariant result;
00203     DISPID dispID = GetIDsOfNames(pDisp, name);
00204     return pDisp->Invoke(dispID, IID_NULL, LOCALE_SYSTEM_DEFAULT,
00205                                DISPATCH_PROPERTYPUT, &dispParams, &result,
00206                                0, 0);
00207 }
00208 
00209 HRESULT VerifynsXPCDispSimple(IDispatch * result)
00210 {
00211     CComVariant property;
00212     HRESULT hResult = GetProperty(result, L"Number", property);
00213     CComVariant test((long)5);
00214     if (FAILED(hResult))
00215         return hResult;
00216     if (property != test)
00217         return E_FAIL;
00218     return PutProperty(result, L"Number", 76);
00219 }
00220 
00221 STDMETHODIMP nsXPCDispTestMethods::TakesIDispatch(IDispatch * result)
00222 {
00223     return VerifynsXPCDispSimple(result);
00224 }
00225 STDMETHODIMP nsXPCDispTestMethods::TakesError(SCODE result)
00226 {
00227     return result == E_FAIL ? S_OK : E_FAIL;
00228 }
00229 STDMETHODIMP nsXPCDispTestMethods::TakesDate(DATE result)
00230 {
00231     CComBSTR dateStr(L"5/2/02");
00232     DATE myDate;
00233     HRESULT hResult = VarDateFromStr(dateStr, LOCALE_SYSTEM_DEFAULT,
00234                                     LOCALE_NOUSEROVERRIDE, &myDate);
00235     if (SUCCEEDED(hResult))
00236         return myDate == result ? S_OK : E_FAIL;
00237     else
00238         return hResult;
00239 }
00240 STDMETHODIMP nsXPCDispTestMethods::TakesIUnknown(IUnknown * result)
00241 {
00242     CComPtr<IUnknown> ptr(result);
00243     ULONG before = result->AddRef();
00244     ULONG after = result->Release();
00245     CComQIPtr<nsIXPCDispTestNoIDispatch> noIDispatch(ptr);
00246     return before - 1 == after ? S_OK : E_FAIL;
00247 }
00248 STDMETHODIMP nsXPCDispTestMethods::TakesI1(unsigned char result)
00249 {
00250     return result == 42 ? S_OK : E_FAIL;
00251 }
00252 STDMETHODIMP nsXPCDispTestMethods::TakesUI2(USHORT result)
00253 {
00254     return result == 50000 ? S_OK : E_FAIL;
00255 }
00256 STDMETHODIMP nsXPCDispTestMethods::TakesUI4(ULONG result)
00257 {
00258     return result == 0xF0000000 ? S_OK : E_FAIL;
00259 }
00260 STDMETHODIMP nsXPCDispTestMethods::TakesInt(INT result)
00261 {
00262     return result == -10000000 ? S_OK : E_FAIL;
00263 }
00264 STDMETHODIMP nsXPCDispTestMethods::TakesUInt(UINT result)
00265 {
00266     return result == 0xE0000000 ? S_OK : E_FAIL;
00267 }
00268 STDMETHODIMP nsXPCDispTestMethods::OutputsBSTR(BSTR * result)
00269 {
00270     if (result == NULL)
00271         return E_POINTER;
00272         
00273     CComBSTR x("Boo");
00274     *result = x.Detach();
00275     return S_OK;
00276 }
00277 STDMETHODIMP nsXPCDispTestMethods::OutputsI4(LONG * result)
00278 {
00279     if (result == NULL)
00280         return E_POINTER;
00281     *result = 99999;
00282     return S_OK;
00283 }
00284 STDMETHODIMP nsXPCDispTestMethods::OutputsUI1(BYTE * result)
00285 {
00286     if (result == NULL)
00287         return E_POINTER;
00288     *result = 99;
00289     return S_OK;
00290 }
00291 STDMETHODIMP nsXPCDispTestMethods::OutputsI2(SHORT * result)
00292 {
00293     if (result == NULL)
00294         return E_POINTER;
00295     *result = 9999;
00296     return S_OK;
00297 }
00298 STDMETHODIMP nsXPCDispTestMethods::OutputsR4(FLOAT * result)
00299 {
00300     if (result == NULL)
00301         return E_POINTER;
00302     *result = 999999.1f;
00303     return S_OK;
00304 }
00305 STDMETHODIMP nsXPCDispTestMethods::OutputsR8(DOUBLE * result)
00306 {
00307     if (result == NULL)
00308         return E_POINTER;
00309     *result = 99999999999.99;
00310     return S_OK;
00311 }
00312 STDMETHODIMP nsXPCDispTestMethods::OutputsBool(VARIANT_BOOL * result)
00313 {
00314     if (result == NULL)
00315         return E_POINTER;
00316     *result = VARIANT_TRUE;
00317     return S_OK;
00318 }
00319 STDMETHODIMP nsXPCDispTestMethods::OutputsIDispatch(IDispatch * * result)
00320 {
00321     if (result == NULL)
00322         return E_POINTER;
00323     return nsXPCDispSimple::CreateInstance(result);
00324 }
00325 STDMETHODIMP nsXPCDispTestMethods::OutputsError(SCODE * result)
00326 {
00327     if (result == NULL)
00328         return E_POINTER;
00329     *result = E_FAIL;
00330     return S_OK;
00331 }
00332 STDMETHODIMP nsXPCDispTestMethods::OutputsDate(DATE * result)
00333 {
00334     if (result == NULL)
00335         return E_POINTER;
00336     CComBSTR dateStr(L"5/2/02");
00337     return VarDateFromStr(dateStr, LOCALE_SYSTEM_DEFAULT,
00338                           LOCALE_NOUSEROVERRIDE, result);
00339 }
00340 STDMETHODIMP nsXPCDispTestMethods::OutputsIUnknown(IUnknown * * result)
00341 {
00342     if (result == NULL)
00343         return E_POINTER;
00344         
00345     return XPCCreateInstance<IUnknown>(CLSID_nsXPCDispTestNoIDispatch, IID_IUnknown, result);
00346 }
00347 STDMETHODIMP nsXPCDispTestMethods::OutputsI1(unsigned char * result)
00348 {
00349     if (result == NULL)
00350         return E_POINTER;
00351         
00352     *result = L'x';
00353     return S_OK;
00354 }
00355 STDMETHODIMP nsXPCDispTestMethods::OutputsUI2(USHORT * result)
00356 {
00357     if (result == NULL)
00358         return E_POINTER;
00359     *result = 9999;
00360     return S_OK;
00361 }
00362 STDMETHODIMP nsXPCDispTestMethods::OutputsUI4(ULONG * result)
00363 {
00364     if (result == NULL)
00365         return E_POINTER;
00366     *result = 3000000000;
00367     return S_OK;
00368 }
00369 STDMETHODIMP nsXPCDispTestMethods::InOutsBSTR(BSTR * result)
00370 {
00371     if (result == NULL)
00372         return E_POINTER;
00373     CComBSTR str(*result);
00374     str += L"Appended";
00375     SysFreeString(*result);
00376     *result = str.Detach();
00377     return S_OK;
00378 }
00379 STDMETHODIMP nsXPCDispTestMethods::InOutsI4(LONG * result)
00380 {
00381     if (result == NULL)
00382         return E_POINTER;
00383     *result -= 4000000;
00384     return S_OK;
00385 }
00386 STDMETHODIMP nsXPCDispTestMethods::InOutsUI1(BYTE * result)
00387 {
00388     if (result == NULL)
00389         return E_POINTER;
00390     *result -= 42;
00391     return S_OK;
00392 }
00393 STDMETHODIMP nsXPCDispTestMethods::InOutsI2(SHORT * result)
00394 {
00395     if (result == NULL)
00396         return E_POINTER;
00397     *result += 10000;
00398     return S_OK;
00399 }
00400 STDMETHODIMP nsXPCDispTestMethods::InOutsR4(FLOAT * result)
00401 {
00402     if (result == NULL)
00403         return E_POINTER;
00404     *result += 5.05f;
00405     return S_OK;
00406 }
00407 STDMETHODIMP nsXPCDispTestMethods::InOutsR8(DOUBLE * result)
00408 {
00409     if (result == NULL)
00410         return E_POINTER;
00411     *result += 50000000.00000005;
00412     return S_OK;
00413 }
00414 STDMETHODIMP nsXPCDispTestMethods::InOutsBool(VARIANT_BOOL * result)
00415 {
00416     if (result == NULL)
00417         return E_POINTER;
00418     *result = !*result;
00419     return S_OK;
00420 }
00421 STDMETHODIMP nsXPCDispTestMethods::InOutsIDispatch(IDispatch * * result)
00422 {
00423     if (result == NULL)
00424         return E_POINTER;
00425     CComPtr<nsIXPCDispSimple> ptr;
00426     ptr.CoCreateInstance(CLSID_nsXPCDispSimple);
00427     CComPtr<IDispatch> incoming(*result);
00428     CComVariant value;
00429     HRESULT hResult = GetProperty(incoming, L"Number", value);
00430     if (FAILED(hResult))
00431         return hResult;
00432     if (value.lVal != 10)
00433         return E_FAIL;
00434     hResult = ptr->put_Number(value.lVal + 5);
00435     if (FAILED(hResult))
00436         return hResult;
00437 
00438     *result = ptr.Detach();
00439     return S_OK;
00440 }
00441 STDMETHODIMP nsXPCDispTestMethods::InOutsError(SCODE * result)
00442 {
00443     if (result == NULL)
00444         return E_POINTER;
00445     *result += 1;
00446     return S_OK;
00447 }
00448 STDMETHODIMP nsXPCDispTestMethods::InOutsDate(DATE * result)
00449 {
00450     if (result == NULL)
00451         return E_POINTER;
00452     ULONG days;
00453     HRESULT hResult = VarUI4FromDate(*result, &days);
00454     if (FAILED(hResult))
00455         return hResult;
00456 
00457     return VarDateFromUI4(days + 1, result);
00458 }
00459 STDMETHODIMP nsXPCDispTestMethods::InOutsIUnknown(IUnknown * * result)
00460 {
00461     if (result == NULL)
00462         return E_POINTER;
00463         
00464     CComPtr<IUnknown> ptr(*result);
00465     ULONG before = (*result)->AddRef();
00466     ULONG after = (*result)->Release();
00467     if (before - 1 != after)
00468         return E_FAIL;
00469     return nsXPCDispSimple::CreateInstance(result);
00470 }
00471 STDMETHODIMP nsXPCDispTestMethods::InOutsI1(unsigned char * result)
00472 {
00473     if (result == NULL)
00474         return E_POINTER;
00475     ++*result;
00476     return S_OK;
00477 }
00478 STDMETHODIMP nsXPCDispTestMethods::InOutsUI2(USHORT * result)
00479 {
00480     if (result == NULL)
00481         return E_POINTER;
00482     *result += 42;
00483     return S_OK;
00484 }
00485 STDMETHODIMP nsXPCDispTestMethods::InOutsUI4(ULONG * result)
00486 {
00487     if (result == NULL)
00488         return E_POINTER;
00489     *result -= 42;
00490     return S_OK;
00491 }
00492 STDMETHODIMP nsXPCDispTestMethods::OneParameterWithReturn(LONG input, 
00493                                                           LONG * result)
00494 {
00495     if (result == NULL)
00496         return E_POINTER;
00497     *result = input + 42;
00498     return S_OK;
00499 }
00500 STDMETHODIMP nsXPCDispTestMethods::StringInputAndReturn(BSTR str, 
00501                                                         BSTR * result)
00502 {
00503     if (result == NULL)
00504         return E_POINTER;
00505     CComBSTR input(str);
00506     input += L"Appended";
00507     *result = input.Detach();
00508     return S_OK;
00509 }
00510 STDMETHODIMP nsXPCDispTestMethods::IDispatchInputAndReturn(IDispatch * input, IDispatch * * result)
00511 {
00512     if (result == NULL)
00513         return E_POINTER;
00514     HRESULT hResult = VerifynsXPCDispSimple(input);
00515 
00516     hResult = XPCCreateInstance<IDispatch>(CLSID_nsXPCDispSimple, IID_IDispatch, result);
00517     if (FAILED(hResult))
00518         return hResult;
00519     CComVariant variant;
00520     hResult = GetProperty(input, L"Number", variant);
00521     if (FAILED(hResult))
00522         return hResult;
00523     return PutProperty(*result, L"Number", variant.lVal + 5);
00524 }
00525 STDMETHODIMP nsXPCDispTestMethods::TwoParameters(LONG one, LONG two)
00526 {
00527     return one + 1 == two ? S_OK : E_FAIL;
00528 }
00529 STDMETHODIMP nsXPCDispTestMethods::TwelveInParameters(LONG one, LONG two,
00530                                                       LONG three, LONG four,
00531                                                       LONG five, LONG six,
00532                                                       LONG seven, LONG eight,
00533                                                       LONG nine, LONG ten,
00534                                                       LONG eleven, LONG twelve)
00535 {
00536     return one + two + three + four + five + six + seven + eight + nine + 
00537         ten + eleven + twelve == 78 ? S_OK : E_FAIL;
00538 }
00539 STDMETHODIMP nsXPCDispTestMethods::TwelveOutParameters(LONG * one, LONG * two,
00540                                                        LONG * three,
00541                                                        LONG * four,
00542                                                        LONG * five, LONG * six,
00543                                                        LONG * seven,
00544                                                        LONG * eight,
00545                                                        LONG * nine, LONG * ten,
00546                                                        LONG * eleven,
00547                                                        LONG * twelve)
00548 {
00549     if (one == 0 || two == 0 || three == 0 || four == 0 || 
00550         five == 0 || six == 0 || seven == 0 || eight == 0 ||
00551         nine == 0 || ten == 0 || eleven == 0 || twelve == 0)
00552         return E_POINTER;
00553     
00554     *one = 1;
00555     *two = 2;
00556     *three = 3;
00557     *four = 4;
00558     *five = 5;
00559     *six = 6;
00560     *seven = 7;
00561     *eight = 8;
00562     *nine = 9;
00563     *ten = 10;
00564     *eleven = 11;
00565     *twelve = 12;
00566     return S_OK;
00567 }
00568 
00569 inline
00570 boolean Equals(BSTR left, const char * str)
00571 {
00572     return CComBSTR(left) == str;
00573 }
00574 #define TESTPARAM(val) Equals(val, #val)
00575 
00576 STDMETHODIMP nsXPCDispTestMethods::TwelveStrings(BSTR one, BSTR two, BSTR three, BSTR four, BSTR five, BSTR six, BSTR seven, BSTR eight, BSTR nine, BSTR ten, BSTR eleven, BSTR twelve)
00577 {
00578     return TESTPARAM(one) && TESTPARAM(two) && TESTPARAM(three) && 
00579         TESTPARAM(four) && TESTPARAM(five) && TESTPARAM(six) && 
00580         TESTPARAM(seven) && TESTPARAM(eight) && TESTPARAM(nine) && 
00581         TESTPARAM(ten) && TESTPARAM(eleven) && TESTPARAM(twelve) ? 
00582             S_OK : E_FAIL;
00583 }
00584 
00585 #define ASSIGNPARAM(val) \
00586     if (val == 0) \
00587         return E_POINTER; \
00588     *val = CComBSTR(#val).Detach()
00589 STDMETHODIMP nsXPCDispTestMethods::TwelveOutStrings(BSTR * one, BSTR * two, BSTR * three, BSTR * four, BSTR * five, BSTR * six, BSTR * seven, BSTR * eight, BSTR * nine, BSTR * ten, BSTR * eleven, BSTR * twelve)
00590 {
00591     ASSIGNPARAM(one);
00592     ASSIGNPARAM(two);
00593     ASSIGNPARAM(three);
00594     ASSIGNPARAM(four);
00595     ASSIGNPARAM(five);
00596     ASSIGNPARAM(six);
00597     ASSIGNPARAM(seven);
00598     ASSIGNPARAM(eight);
00599     ASSIGNPARAM(nine);
00600     ASSIGNPARAM(ten);
00601     ASSIGNPARAM(eleven);
00602     ASSIGNPARAM(twelve);
00603     return S_OK;
00604 }
00605 #define VERIFYSIMPLE(param) \
00606     hResult = VerifynsXPCDispSimple(param); \
00607     if (FAILED(hResult)) \
00608         return hResult
00609 STDMETHODIMP nsXPCDispTestMethods::TwelveIDispatch(IDispatch * one,
00610                                                    IDispatch * two,
00611                                                    IDispatch * three,
00612                                                    IDispatch * four,
00613                                                    IDispatch * five,
00614                                                    IDispatch * six,
00615                                                    IDispatch * seven,
00616                                                    IDispatch * eight,
00617                                                    IDispatch * nine,
00618                                                    IDispatch * ten,
00619                                                    IDispatch * eleven,
00620                                                    IDispatch * twelve)
00621 {
00622     HRESULT hResult;
00623     VERIFYSIMPLE(one);
00624     VERIFYSIMPLE(two);
00625     VERIFYSIMPLE(three);
00626     VERIFYSIMPLE(four);
00627     VERIFYSIMPLE(five);
00628     VERIFYSIMPLE(six);
00629     VERIFYSIMPLE(seven);
00630     VERIFYSIMPLE(eight);
00631     VERIFYSIMPLE(nine);
00632     VERIFYSIMPLE(ten);
00633     VERIFYSIMPLE(eleven);
00634     VERIFYSIMPLE(twelve);
00635     return S_OK;
00636 }
00637 
00638 #define ASSIGNSIMPLE(param) \
00639     if (param == 0) \
00640         return E_POINTER; \
00641     hResult = nsXPCDispSimple::CreateInstance(param); \
00642     if (FAILED(hResult)) \
00643         return hResult;  \
00644     
00645 STDMETHODIMP nsXPCDispTestMethods::TwelveOutIDispatch(IDispatch * * one,
00646                                                       IDispatch * * two,
00647                                                       IDispatch * * three,
00648                                                       IDispatch * * four,
00649                                                       IDispatch * * five,
00650                                                       IDispatch * * six,
00651                                                       IDispatch * * seven,
00652                                                       IDispatch * * eight,
00653                                                       IDispatch * * nine,
00654                                                       IDispatch * * ten,
00655                                                       IDispatch * * eleven,
00656                                                       IDispatch * * twelve){
00657     HRESULT hResult;
00658     ASSIGNSIMPLE(one);
00659     ASSIGNSIMPLE(two);
00660     ASSIGNSIMPLE(three);
00661     ASSIGNSIMPLE(four);
00662     ASSIGNSIMPLE(five);
00663     ASSIGNSIMPLE(six);
00664     ASSIGNSIMPLE(seven);
00665     ASSIGNSIMPLE(eight);
00666     ASSIGNSIMPLE(nine);
00667     ASSIGNSIMPLE(ten);
00668     ASSIGNSIMPLE(eleven);
00669     ASSIGNSIMPLE(twelve);
00670     return S_OK;
00671 }
00672 STDMETHODIMP nsXPCDispTestMethods::CreateError()
00673 {
00674     CComBSTR someText(L"CreateError Test");
00675     ICreateErrorInfo * pCreateError;
00676     IErrorInfo * pError;
00677     HRESULT result = CreateErrorInfo(&pCreateError);
00678     if (FAILED(result))
00679         return E_NOTIMPL;
00680     result = pCreateError->QueryInterface(&pError);
00681     if (FAILED(result))
00682         return E_NOTIMPL;
00683     result = pCreateError->SetDescription(someText);
00684     if (FAILED(result))
00685         return E_NOTIMPL;
00686     result = pCreateError->SetGUID(IID_nsIXPCDispTestMethods);
00687     if (FAILED(result))
00688         return E_NOTIMPL;
00689     CComBSTR source(L"XPCIDispatchTest.nsXPCDispTestMethods.1");
00690     result = pCreateError->SetSource(source);
00691     if (FAILED(result))
00692         return E_NOTIMPL;
00693     result = SetErrorInfo(0, pError);
00694     if (FAILED(result))
00695         return E_NOTIMPL;
00696     pError->Release();
00697     pCreateError->Release();
00698     return E_FAIL;
00699 }