Back to index

lightning-sunbird  0.9+nobinonly
xpctest_multiple.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
00002  *
00003  * ***** BEGIN LICENSE BLOCK *****
00004  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00005  *
00006  * The contents of this file are subject to the Mozilla Public License Version
00007  * 1.1 (the "License"); you may not use this file except in compliance with
00008  * the License. You may obtain a copy of the License at
00009  * http://www.mozilla.org/MPL/
00010  *
00011  * Software distributed under the License is distributed on an "AS IS" basis,
00012  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00013  * for the specific language governing rights and limitations under the
00014  * License.
00015  *
00016  * The Original Code is Mozilla Communicator client code, released
00017  * March 31, 1998.
00018  *
00019  * The Initial Developer of the Original Code is
00020  * Netscape Communications Corporation.
00021  * Portions created by the Initial Developer are Copyright (C) 1998
00022  * the Initial Developer. All Rights Reserved.
00023  *
00024  * Contributor(s):
00025  *   John Bandhauer <jband@netscape.com>
00026  *
00027  * Alternatively, the contents of this file may be used under the terms of
00028  * either of the GNU General Public License Version 2 or later (the "GPL"),
00029  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00030  * in which case the provisions of the GPL or the LGPL are applicable instead
00031  * of those above. If you wish to allow use of your version of this file only
00032  * under the terms of either the GPL or the LGPL, and not to allow others to
00033  * use your version of this file under the terms of the MPL, indicate your
00034  * decision by deleting the provisions above and replace them with the notice
00035  * and other provisions required by the GPL or the LGPL. If you do not delete
00036  * the provisions above, a recipient may use your version of this file under
00037  * the terms of any one of the MPL, the GPL or the LGPL.
00038  *
00039  * ***** END LICENSE BLOCK ***** */
00040 
00041 #include "xpctest_multiple.h"
00042 #include "nsISupports.h"
00043 #include "xpctest_private.h"
00044 
00045 class xpcTestParentOne : public nsIXPCTestParentOne {
00046 public: 
00047     NS_DECL_ISUPPORTS
00048     NS_DECL_NSIXPCTESTPARENTONE
00049     xpcTestParentOne();
00050 private: 
00051     const char *name;
00052 };
00053 
00054 NS_IMPL_ISUPPORTS1(xpcTestParentOne, nsIXPCTestParentOne)
00055 
00056 xpcTestParentOne :: xpcTestParentOne() 
00057 {
00058     NS_ADDREF_THIS();
00059 }
00060 
00061 NS_IMETHODIMP xpcTestParentOne :: GetParentOneAttribute(char * *_retval) 
00062 {                                                             
00063     char aString[] = "xpcTestParentOne attribute";     
00064     *_retval = (char*) nsMemory::Clone(aString,            
00065                 sizeof(char)*(strlen(aString)+1));            
00066     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00067 }                                                            
00068 
00069 NS_IMETHODIMP xpcTestParentOne :: SetParentOneAttribute(const char * aParentOneAttribute) 
00070 {                                                             
00071     name = aParentOneAttribute;                               
00072     return NS_OK;                                             
00073 }                                                                  
00074 
00075 NS_IMETHODIMP                                                 
00076 xpcTestParentOne :: ParentOneMethod(char * *_retval)                   
00077 {                                                             
00078     char aString[] = "xpcTestParentOne method";  
00079     *_retval = (char*) nsMemory::Clone(aString,            
00080                 sizeof(char)*(strlen(aString)+1));            
00081     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00082 }                                                                   
00083 NS_IMETHODIMP
00084 xpctest::ConstructXPCTestParentOne(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00085 {
00086     nsresult rv;
00087     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00088     xpcTestParentOne *obj = new xpcTestParentOne();
00089 
00090     if(obj)
00091     {
00092         rv = obj->QueryInterface(aIID, aResult);
00093         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00094         NS_RELEASE(obj);
00095     }
00096     else
00097     {
00098         *aResult = nsnull;
00099         rv = NS_ERROR_OUT_OF_MEMORY;
00100     }
00101 
00102     return rv;
00103 }                                                                
00104 
00105 
00106 /*****************************************************************************/
00107 
00108 class xpcTestParentTwo : public nsIXPCTestParentTwo {
00109 public: 
00110   NS_DECL_NSIXPCTESTPARENTTWO
00111   NS_DECL_ISUPPORTS
00112   xpcTestParentTwo();
00113 private:
00114     const char *name;
00115 };
00116 
00117 NS_IMPL_ISUPPORTS1(xpcTestParentTwo, nsIXPCTestParentTwo)
00118 
00119 xpcTestParentTwo :: xpcTestParentTwo()
00120 {
00121     NS_ADDREF_THIS();
00122 }
00123 
00124 NS_IMETHODIMP                                                 
00125 xpcTestParentTwo :: GetParentTwoAttribute(char * *_retval)             
00126 {                                                             
00127     char aString[] = "xpcTestParentTwo attribute";               
00128     *_retval = (char*) nsMemory::Clone(aString,            
00129                 sizeof(char)*(strlen(aString)+1));            
00130     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00131 }                                                        
00132 
00133 NS_IMETHODIMP                                                 
00134 xpcTestParentTwo :: SetParentTwoAttribute(const char * aParentTwoAttribute)  
00135 {                                                             
00136     name = aParentTwoAttribute;                               
00137     return NS_OK;                                             
00138 }                                                                   
00139 
00140 NS_IMETHODIMP                                                 
00141 xpcTestParentTwo :: ParentTwoMethod(char **_retval) 
00142 {                  
00143     char aString[] = "xpcTestParentTwo method";  
00144     *_retval = (char*) nsMemory::Clone(aString,            
00145                 sizeof(char)*(strlen(aString)+1));            
00146     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00147 }
00148   
00149 NS_IMETHODIMP
00150 xpctest::ConstructXPCTestParentTwo(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00151 {
00152     nsresult rv;
00153     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00154     xpcTestParentTwo *obj = new xpcTestParentTwo();
00155 
00156     if(obj)
00157     {
00158         rv = obj->QueryInterface(aIID, aResult);
00159         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00160         NS_RELEASE(obj);
00161     }
00162     else
00163     {
00164         *aResult = nsnull;
00165         rv = NS_ERROR_OUT_OF_MEMORY;
00166     }
00167 
00168     return rv;
00169 }                                                                
00170 /*****************************************************************************/
00171 
00176 class xpcTestChild2 : public nsIXPCTestChild2, public nsIXPCTestParentOne, public nsIXPCTestParentTwo {
00177 public: 
00178   NS_DECL_NSIXPCTESTCHILD2
00179   NS_DECL_NSIXPCTESTPARENTONE
00180   NS_DECL_NSIXPCTESTPARENTTWO
00181   NS_DECL_ISUPPORTS
00182   xpcTestChild2();
00183 private:
00184     const char *name;
00185 };
00186 
00187 NS_IMPL_ISUPPORTS3_CI(xpcTestChild2,nsIXPCTestChild2,nsIXPCTestParentOne,nsIXPCTestParentTwo)
00188 
00189 xpcTestChild2 :: xpcTestChild2() 
00190 {
00191     NS_ADDREF_THIS();
00192 }
00193 
00194 NS_IMETHODIMP 
00195 xpcTestChild2:: GetChildAttribute(char * *_retval) 
00196 {
00197     char aString[] = "xpcTestChild2 attribute";    
00198     *_retval = (char*) nsMemory::Clone(aString,            
00199                 sizeof(char)*(strlen(aString)+1));            
00200     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00201 }
00202 
00203 NS_IMETHODIMP 
00204 xpcTestChild2:: SetChildAttribute(const char * aChildAttribute) 
00205 {
00206     name = aChildAttribute;
00207     return NS_OK;
00208 }
00209 
00210 NS_IMETHODIMP
00211 xpcTestChild2 ::ChildMethod(char **_retval) 
00212 {
00213     char aString[] = "xpcTestChild2 method";  
00214     *_retval = (char*) nsMemory::Clone(aString,            
00215                 sizeof(char)*(strlen(aString)+1));            
00216     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00217 }
00218 
00219 
00220 NS_IMETHODIMP                                                 
00221 xpcTestChild2 :: GetParentOneAttribute(char * *_retval)     
00222 {                                                             
00223     char aString[] = "xpcTestChild2 attribute";     
00224     *_retval = (char*) nsMemory::Clone(aString,            
00225                 sizeof(char)*(strlen(aString)+1));            
00226     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00227 }                                                            
00228 
00229 NS_IMETHODIMP                                                 
00230 xpcTestChild2:: SetParentOneAttribute(const char * aParentOneAttribute) 
00231 {                                                             
00232     name = aParentOneAttribute;                               
00233     return NS_OK;                                             
00234 }                                                                  
00235 
00236 NS_IMETHODIMP                                                 
00237 xpcTestChild2 :: ParentOneMethod(char * *_retval)                   
00238 {                                                             
00239     char aString[] = "xpcTestChild2 method";  
00240     *_retval = (char*) nsMemory::Clone(aString,            
00241                 sizeof(char)*(strlen(aString)+1));            
00242     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00243 }                                  
00244 
00245 NS_IMETHODIMP                                                 
00246 xpcTestChild2 :: GetParentTwoAttribute(char * *_retval)             
00247 {                                                             
00248     char aString[] = "xpcTestChild2 attribute";               
00249     *_retval = (char*) nsMemory::Clone(aString,            
00250                 sizeof(char)*(strlen(aString)+1));            
00251     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00252 }                                                            
00253 
00254 NS_IMETHODIMP                                                 
00255 xpcTestChild2 :: SetParentTwoAttribute(const char * aParentTwoAttribute)  
00256 {                                                             
00257     name = aParentTwoAttribute;                               
00258     return NS_OK;                                             
00259 }                                                                  
00260 
00261 NS_IMETHODIMP                                                 
00262 xpcTestChild2 :: ParentTwoMethod(char **_retval) {                  
00263     char aString[] = "xpcTestChild2 method";  
00264     *_retval = (char*) nsMemory::Clone(aString,            
00265                 sizeof(char)*(strlen(aString)+1));            
00266     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00267 }                                 
00268 
00269 NS_IMETHODIMP
00270 xpctest::ConstructXPCTestChild2(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00271 {
00272     nsresult rv;
00273     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00274     xpcTestChild2 *obj = new xpcTestChild2();
00275 
00276     if(obj)
00277     {
00278         rv = obj->QueryInterface(aIID, aResult);
00279         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00280         NS_RELEASE(obj);
00281     }
00282     else
00283     {
00284         *aResult = nsnull;
00285         rv = NS_ERROR_OUT_OF_MEMORY;
00286     }
00287 
00288     return rv;
00289 }
00290 
00291 /*****************************************************************************/
00292 
00298 class xpcTestChild3 : public nsIXPCTestChild3 {
00299 public: 
00300   NS_DECL_ISUPPORTS
00301   NS_DECL_NSIXPCTESTCHILD3
00302   NS_DECL_NSIXPCTESTPARENTONE
00303   xpcTestChild3();
00304 private:
00305     const char *name;
00306 };
00307 
00308 NS_IMPL_ISUPPORTS2(xpcTestChild3,nsIXPCTestChild3,nsIXPCTestParentOne)
00309 
00310 xpcTestChild3 :: xpcTestChild3() 
00311 {
00312     NS_ADDREF_THIS();
00313 
00314 }
00315 
00316 NS_IMETHODIMP 
00317 xpcTestChild3:: GetChildAttribute(char * *_retval) 
00318 {
00319     char aString[] = "xpcTestChild3 attribute";    
00320     *_retval = (char*) nsMemory::Clone(aString,            
00321                 sizeof(char)*(strlen(aString)+1));            
00322     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00323 }
00324 
00325 NS_IMETHODIMP 
00326 xpcTestChild3 :: SetChildAttribute(const char * aChildAttribute) 
00327 {
00328     name = aChildAttribute;
00329     return NS_OK;
00330 }
00331 
00332 NS_IMETHODIMP
00333 xpcTestChild3 ::ChildMethod(char **_retval) 
00334 {
00335     const char aString[] = "xpcTestChild3 method";
00336     *_retval = (char*) nsMemory::Clone((const char *)aString,
00337                 sizeof(char)*(strlen((const char *)aString)+1));            
00338     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00339 }
00340 
00341 
00342 NS_IMETHODIMP                                                 
00343 xpcTestChild3 :: GetParentOneAttribute(char * *_retval)     
00344 {                                                             
00345     const char aString[] = "xpcTestChild3 attribute";     
00346     *_retval = (char*) nsMemory::Clone(aString,            
00347                 sizeof(char)*(strlen(aString)+1));            
00348     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00349 }                                                            
00350 
00351 NS_IMETHODIMP                                                 
00352 xpcTestChild3:: SetParentOneAttribute(const char * aParentOneAttribute) 
00353 {                                                             
00354     name = aParentOneAttribute;                               
00355     return NS_OK;                                             
00356 }                                                                  
00357 
00358 NS_IMETHODIMP                                                 
00359 xpcTestChild3 :: ParentOneMethod(char * *_retval)                   
00360 {                                                             
00361     char aString[] = "xpcTestChild3 method";  
00362     *_retval = (char*) nsMemory::Clone(aString,            
00363                 sizeof(char)*(strlen(aString)+1));            
00364     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00365 }                                  
00366 
00367 NS_IMETHODIMP
00368 xpctest::ConstructXPCTestChild3(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00369 {
00370     nsresult rv;
00371     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00372     xpcTestChild3 *obj = new xpcTestChild3();
00373 
00374     if(obj)
00375     {
00376         rv = obj->QueryInterface(aIID, aResult);
00377         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00378         NS_RELEASE(obj);
00379     }
00380     else
00381     {
00382         *aResult = nsnull;
00383         rv = NS_ERROR_OUT_OF_MEMORY;
00384     }
00385 
00386     return rv;
00387 }
00388 
00389 /*****************************************************************************/
00390 
00396 class xpcTestChild4 : public nsIXPCTestChild4, public xpcTestParentOne, public xpcTestParentTwo {
00397 public:
00398     NS_DECL_ISUPPORTS
00399     NS_DECL_NSIXPCTESTCHILD4
00400     xpcTestChild4();
00401 private:
00402     const char *name;
00403 };
00404 
00405 NS_IMPL_ISUPPORTS3(xpcTestChild4,nsIXPCTestChild4,nsIXPCTestParentOne,nsIXPCTestParentTwo)
00406 
00407 xpcTestChild4 :: xpcTestChild4() 
00408 {
00409     NS_ADDREF_THIS();
00410 }
00411 
00412 NS_IMETHODIMP 
00413 xpcTestChild4:: GetChildAttribute(char * *_retval) 
00414 {
00415     char aString[] = "xpcTestChild4 attribute";    
00416     *_retval = (char*) nsMemory::Clone(aString,            
00417                 sizeof(char)*(strlen(aString)+1));            
00418     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00419 }
00420 
00421 NS_IMETHODIMP 
00422 xpcTestChild4:: SetChildAttribute(const char * aChildAttribute) 
00423 {
00424     name = aChildAttribute;
00425     return NS_OK;
00426 }
00427 
00428 NS_IMETHODIMP
00429 xpcTestChild4 ::ChildMethod(char **_retval) 
00430 {
00431     char aString[] = "xpcTestChild4 method";  
00432     *_retval = (char*) nsMemory::Clone(aString,            
00433                 sizeof(char)*(strlen(aString)+1));            
00434     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00435 }
00436 
00437 NS_IMETHODIMP
00438 xpctest::ConstructXPCTestChild4(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00439 {
00440     nsresult rv;
00441     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00442     xpcTestChild4 *obj = new xpcTestChild4();
00443 
00444     if(obj)
00445     {
00446         rv = obj->QueryInterface(aIID, aResult);
00447         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00448         NS_RELEASE(obj);
00449     }
00450     else
00451     {
00452         *aResult = nsnull;
00453         rv = NS_ERROR_OUT_OF_MEMORY;
00454     }
00455 
00456     return rv;
00457 }
00458 
00459 /*****************************************************************************/
00465 class xpcTestChild5 : public nsIXPCTestChild5, public xpcTestParentTwo {
00466 public:
00467     NS_DECL_ISUPPORTS
00468     NS_DECL_NSIXPCTESTCHILD5
00469     NS_DECL_NSIXPCTESTPARENTONE
00470     xpcTestChild5();
00471 private:
00472     const char *name;
00473 };
00474 
00475 NS_IMPL_ISUPPORTS3(xpcTestChild5,nsIXPCTestChild5,nsIXPCTestParentOne,nsIXPCTestParentTwo)
00476 
00477 xpcTestChild5 :: xpcTestChild5() 
00478 {
00479     NS_ADDREF_THIS();
00480 }
00481 
00482 NS_IMETHODIMP 
00483 xpcTestChild5:: GetChildAttribute(char * *_retval) 
00484 {
00485     char aString[] = "xpcTestChild5 attribute";    
00486     *_retval = (char*) nsMemory::Clone(aString,            
00487                 sizeof(char)*(strlen(aString)+1));            
00488     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00489 }
00490 
00491 NS_IMETHODIMP 
00492 xpcTestChild5:: SetChildAttribute(const char * aChildAttribute) 
00493 {
00494     name = aChildAttribute;
00495     return NS_OK;
00496 }
00497 
00498 NS_IMETHODIMP
00499 xpcTestChild5 ::ChildMethod(char **_retval) 
00500 {
00501     char aString[] = "xpcTestChild5 method";  
00502     *_retval = (char*) nsMemory::Clone(aString,            
00503                 sizeof(char)*(strlen(aString)+1));            
00504     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00505 }
00506 
00507 
00508 NS_IMETHODIMP                                                 
00509 xpcTestChild5 :: GetParentOneAttribute(char * *_retval)     
00510 {                                                             
00511     char aString[] = "xpcTestChild5 attribute";     
00512     *_retval = (char*) nsMemory::Clone(aString,            
00513                 sizeof(char)*(strlen(aString)+1));            
00514     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00515 }                                                            
00516 
00517 NS_IMETHODIMP                                                 
00518 xpcTestChild5:: SetParentOneAttribute(const char * aParentOneAttribute) 
00519 {                                                             
00520     name = aParentOneAttribute;                               
00521     return NS_OK;                                             
00522 }                                                                  
00523 
00524 NS_IMETHODIMP                                                 
00525 xpcTestChild5 :: ParentOneMethod(char * *_retval)                   
00526 {                                                             
00527     char aString[] = "xpcTestChild5 method";  
00528     *_retval = (char*) nsMemory::Clone(aString,            
00529                 sizeof(char)*(strlen(aString)+1));            
00530     return **_retval ? NS_OK : NS_ERROR_OUT_OF_MEMORY;        
00531 }                                  
00532 
00533 NS_IMETHODIMP
00534 xpctest::ConstructXPCTestChild5(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00535 {
00536     nsresult rv;
00537     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00538     xpcTestChild5 *obj = new xpcTestChild5();
00539 
00540     if(obj)
00541     {
00542         rv = obj->QueryInterface(aIID, aResult);
00543         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00544         NS_RELEASE(obj);
00545     }
00546     else
00547     {
00548         *aResult = nsnull;
00549         rv = NS_ERROR_OUT_OF_MEMORY;
00550     }
00551 
00552     return rv;
00553 }