Back to index

lightning-sunbird  0.9+nobinonly
xpctest_out.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_private.h"
00042 #include "xpctest_out.h"
00043 #include "nsISupports.h"
00044 
00045 #define NS_IXPCTESTOUT_IID \
00046   {0x4105ae88, 0x5599, 0x11d3, \
00047     { 0x82, 0xef, 0x00, 0x60, 0xb0, 0xeb, 0x59, 0x6f }}
00048 
00049 class xpcTestOut : public nsIXPCTestOut {
00050 public:
00051 NS_DECL_ISUPPORTS
00052 NS_DECL_NSIXPCTESTOUT
00053 xpcTestOut();
00054 
00055 private:
00056     PRInt32   longProperty;
00057     PRInt16  shortProperty;
00058     char   charProperty;
00059     float  floatProperty;
00060     double doubleProperty;
00061     PRUnichar * stringProperty;
00062     PRBool booleanProperty;
00063     PRUint8 octetProperty;
00064     PRUint16 unsignedShortProperty;
00065     PRUint32 unsignedLongProperty;
00066     PRInt64 longLongProperty;
00067     PRUnichar wcharProperty;
00068 //     PRUnichar *wsStringProperty;
00069 
00070     PRBool PRBoolProperty;
00071     PRInt32 PRInt32Property;
00072     PRInt16 PRInt16Property;
00073     PRInt64 PRInt64Property;
00074     PRUint8 PRUint8Property;
00075     PRUint16 PRUint16Property;
00076     PRUint32 PRUint32Property;
00077     PRUint64 PRUint64Property;
00078 };
00079 
00080 
00081 NS_IMPL_ISUPPORTS1(xpcTestOut, nsIXPCTestOut)
00082 
00083 xpcTestOut :: xpcTestOut() {
00084     NS_ADDREF_THIS();
00085 }
00086 
00087 NS_IMETHODIMP xpcTestOut :: GetLong(PRInt32 *l){
00088     *l = longProperty;
00089     return NS_OK;
00090 }
00091 NS_IMETHODIMP xpcTestOut :: SetLong(PRInt32 l){
00092     longProperty = l;
00093     return NS_OK;
00094 }
00095 NS_IMETHODIMP xpcTestOut :: GetShort(PRInt16 *s){
00096     *s  = shortProperty;
00097     return NS_OK;
00098 }
00099 NS_IMETHODIMP xpcTestOut :: SetShort(PRInt16 s){
00100     shortProperty = s;
00101     return NS_OK;
00102 }
00103 NS_IMETHODIMP xpcTestOut :: SetChar(char c){
00104     charProperty = c;
00105     return NS_OK;
00106 }
00107 NS_IMETHODIMP xpcTestOut :: GetChar(char *c){
00108     *c = charProperty;
00109     return NS_OK;
00110 }
00111 NS_IMETHODIMP xpcTestOut :: GetBoolean(PRBool *b){
00112     *b = booleanProperty;
00113     return NS_OK;
00114 }
00115 NS_IMETHODIMP xpcTestOut :: SetBoolean(PRBool b){
00116     booleanProperty = b;
00117     return NS_OK;
00118 }
00119 NS_IMETHODIMP xpcTestOut :: GetOctet(PRUint8 *o){
00120     *o = octetProperty;
00121     return NS_OK;
00122 }
00123 NS_IMETHODIMP xpcTestOut :: SetOctet(PRUint8 o){
00124     octetProperty = o;
00125     return NS_OK;
00126 }
00127 NS_IMETHODIMP xpcTestOut :: GetLongLong(PRInt64 *ll){
00128     *ll = longLongProperty;
00129     return NS_OK;
00130 }
00131 NS_IMETHODIMP xpcTestOut :: SetLongLong(PRInt64 ll){
00132     longLongProperty = ll;
00133     return NS_OK;
00134 }
00135 NS_IMETHODIMP xpcTestOut :: GetUnsignedShort(PRUint16 *us){
00136     *us = unsignedShortProperty;
00137     return NS_OK;
00138 }
00139 NS_IMETHODIMP xpcTestOut :: SetUnsignedShort(PRUint16 us){
00140     unsignedShortProperty = us;
00141     return NS_OK;
00142 }
00143 NS_IMETHODIMP xpcTestOut :: GetUnsignedLong(PRUint32 *ul){
00144     *ul = unsignedLongProperty;
00145     return NS_OK;
00146 }
00147 NS_IMETHODIMP xpcTestOut :: SetUnsignedLong(PRUint32 ul){
00148     unsignedLongProperty = ul;
00149     return NS_OK;
00150 }
00151 NS_IMETHODIMP xpcTestOut :: GetFloat(float *f){
00152     *f = floatProperty;
00153     return NS_OK;
00154 }
00155 NS_IMETHODIMP xpcTestOut :: SetFloat(float f){
00156     floatProperty = f;
00157     return NS_OK;
00158 }
00159 NS_IMETHODIMP xpcTestOut :: GetDouble(double *d){
00160     *d = doubleProperty;
00161     return NS_OK;
00162 }
00163 NS_IMETHODIMP xpcTestOut :: SetDouble(double d){
00164     doubleProperty = d;
00165     return NS_OK;
00166 }
00167 NS_IMETHODIMP xpcTestOut :: GetWchar(PRUnichar *wc){
00168     *wc = wcharProperty;
00169     return NS_OK;
00170 }
00171 NS_IMETHODIMP xpcTestOut :: SetWchar(PRUnichar wc){
00172     wcharProperty = wc;
00173     return NS_OK;
00174 }
00175 /*
00176 NS_IMETHODIMP xpcTestOut :: GetString(PRUnichar **ws){
00177     **ws = *stringProperty;
00178 
00179     if(!stringProperty)
00180         return NS_ERROR_NULL_POINTER;
00181     *ws = (PRUnichar *) nsMemory::Clone(stringProperty, 
00182                     sizeof(char) *(strlen(stringProperty)+1));
00183     return **ws? NS_OK : NS_ERROR_OUT_OF_MEMORY;
00184 
00185     return NS_OK;
00186 }
00187 NS_IMETHODIMP xpcTestOut :: SetString(const PRUnichar *ws){
00188     //stringProperty = ws;
00189     return NS_OK;
00190 }
00191 */
00192 NS_IMETHODIMP xpcTestOut :: GetPRBool(PRBool *b){
00193     *b = PRBoolProperty;
00194     return NS_OK;
00195 }
00196 NS_IMETHODIMP xpcTestOut :: SetPRBool(PRBool b){
00197     PRBoolProperty = b;
00198     return NS_OK;
00199 }
00200 NS_IMETHODIMP xpcTestOut :: GetPRInt32(PRInt32 *l){
00201     *l = PRInt32Property;
00202     return NS_OK;
00203 }
00204 NS_IMETHODIMP xpcTestOut :: SetPRInt32(PRInt32 l){
00205     PRInt32Property = l;
00206     return NS_OK;
00207 }
00208 NS_IMETHODIMP xpcTestOut :: GetPRInt16(PRInt16 *l){
00209     *l = PRInt16Property;
00210     return NS_OK;
00211 }
00212 NS_IMETHODIMP xpcTestOut :: SetPRInt16(PRInt16 l){
00213     PRInt16Property = l;
00214     return NS_OK;
00215 }
00216 NS_IMETHODIMP xpcTestOut :: GetPRInt64(PRInt64 *i){
00217     *i = PRInt64Property;
00218     return NS_OK;
00219 }
00220 NS_IMETHODIMP xpcTestOut :: SetPRInt64(PRInt64 i){
00221     PRInt64Property = i;
00222     return NS_OK;
00223 }
00224 NS_IMETHODIMP xpcTestOut :: GetPRUint8(PRUint8 *i){
00225     *i = PRUint8Property;
00226     return NS_OK;
00227 }
00228 NS_IMETHODIMP xpcTestOut :: SetPRUint8(PRUint8 i){
00229     PRUint8Property = i;
00230     return NS_OK;
00231 }
00232 NS_IMETHODIMP xpcTestOut :: GetPRUint16(PRUint16 *i){
00233     *i = PRUint16Property;
00234     return NS_OK;
00235 }
00236 NS_IMETHODIMP xpcTestOut :: SetPRUint16(PRUint16 i){
00237     PRUint16Property = i;
00238     return NS_OK;
00239 }
00240 NS_IMETHODIMP xpcTestOut :: GetPRUint32(PRUint32 *i){
00241     *i = PRUint32Property;
00242     return NS_OK;
00243 }
00244 NS_IMETHODIMP xpcTestOut :: SetPRUint32(PRUint32 i){
00245     PRUint32Property = i;
00246     return NS_OK;
00247 }
00248 NS_IMETHODIMP xpcTestOut :: GetPRUint64(PRUint64 *i){
00249     *i = PRUint64Property;
00250     return NS_OK;
00251 }
00252 NS_IMETHODIMP xpcTestOut :: SetPRUint64(PRUint64 i){
00253     PRUint64Property = i;
00254     return NS_OK;
00255 }
00256 /*
00257 NS_IMETHODIMP xpcTestOut :: GetVoidStar(void * *vs){
00258     **vs = voidStarProperty;
00259     return NS_OK;
00260 }
00261 NS_IMETHODIMP xpcTestOut :: SetVoidStar(void * vs){
00262     voidStarProperty = vs;
00263     return NS_OK;
00264 }
00265 NS_IMETHODIMP xpcTestOut :: GetCharStar(char * *cs){
00266     return NS_OK;
00267 }
00268 NS_IMETHODIMP xpcTestOut :: SetCharStar(char * cs){
00269     return NS_OK;
00270 }
00271 
00272 NS_IMETHODIMP xpcTestOut :: GetNsIDRef(nsID & *r){
00273     return NS_OK;
00274 }
00275 NS_IMETHODIMP xpcTestOut :: SetNsIDRef(const nsID & r){
00276     return NS_OK;
00277 }
00278 NS_IMETHODIMP xpcTestOut :: GetNsCIDRef(nsCID & *r){
00279     return NS_OK;
00280 }
00281 NS_IMETHODIMP xpcTestOut :: SetNsCIDRef(const nsCID & r){
00282     return NS_OK;
00283 }
00284 
00285 NS_IMETHODIMP xpcTestOut :: GetNsIDPtr(nsID * *p){
00286     return NS_OK;
00287 }
00288 NS_IMETHODIMP xpcTestOut :: SetNsIDPtr(const nsID * p){
00289     return NS_OK;
00290 }
00291 NS_IMETHODIMP xpcTestOut :: GetNsIIDPtr(nsIID * *p){
00292     return NS_OK;
00293 }
00294 NS_IMETHODIMP xpcTestOut :: SetNsIIDPtr(const nsIID * p){
00295     return NS_OK;
00296 }
00297 NS_IMETHODIMP xpcTestOut :: GetNsCIDPtr(nsCID * *p){
00298     return NS_OK;
00299 }
00300 NS_IMETHODIMP xpcTestOut :: SetNsCIDPtr(const nsCID * p){
00301     return NS_OK;
00302 }
00303 NS_IMETHODIMP xpcTestOut :: GetNsQIResult(void * *r){
00304     return NS_OK;
00305 }
00306 NS_IMETHODIMP xpcTestOut :: SetNsQIResult(void * r){
00307     return NS_OK;
00308 }
00309 NS_IMETHODIMP xpcTestOut :: GetVoid(void){
00310     return NS_OK;
00311 }
00312 NS_IMETHODIMP xpcTestOut :: SetVoid(void){
00313     return NS_OK;
00314 }
00315 */
00316 NS_IMETHODIMP
00317 xpctest::ConstructXPCTestOut(nsISupports *aOuter, REFNSIID aIID, void **aResult)
00318 {
00319     nsresult rv;
00320     NS_ASSERTION(aOuter == nsnull, "no aggregation");
00321     xpcTestOut *obj = new xpcTestOut();
00322 
00323     if(obj)
00324     {
00325         rv = obj->QueryInterface(aIID, aResult);
00326         NS_ASSERTION(NS_SUCCEEDED(rv), "unable to find correct interface");
00327         NS_RELEASE(obj);
00328     }
00329     else
00330     {
00331         *aResult = nsnull;
00332         rv = NS_ERROR_OUT_OF_MEMORY;
00333     }
00334     return rv;
00335 }