Back to index

lightning-sunbird  0.9+nobinonly
nsJSInstallVersion.cpp
Go to the documentation of this file.
00001 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
00002 /* ***** BEGIN LICENSE BLOCK *****
00003  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
00004  *
00005  * The contents of this file are subject to the Mozilla Public License Version
00006  * 1.1 (the "License"); you may not use this file except in compliance with
00007  * the License. You may obtain a copy of the License at
00008  * http://www.mozilla.org/MPL/
00009  *
00010  * Software distributed under the License is distributed on an "AS IS" basis,
00011  * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
00012  * for the specific language governing rights and limitations under the
00013  * License.
00014  *
00015  * The Original Code is mozilla.org code.
00016  *
00017  * The Initial Developer of the Original Code is
00018  * Netscape Communications Corporation.
00019  * Portions created by the Initial Developer are Copyright (C) 1998
00020  * the Initial Developer. All Rights Reserved.
00021  *
00022  * Contributor(s):
00023  *
00024  * Alternatively, the contents of this file may be used under the terms of
00025  * either of the GNU General Public License Version 2 or later (the "GPL"),
00026  * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
00027  * in which case the provisions of the GPL or the LGPL are applicable instead
00028  * of those above. If you wish to allow use of your version of this file only
00029  * under the terms of either the GPL or the LGPL, and not to allow others to
00030  * use your version of this file under the terms of the MPL, indicate your
00031  * decision by deleting the provisions above and replace them with the notice
00032  * and other provisions required by the GPL or the LGPL. If you do not delete
00033  * the provisions above, a recipient may use your version of this file under
00034  * the terms of any one of the MPL, the GPL or the LGPL.
00035  *
00036  * ***** END LICENSE BLOCK ***** */
00037 /* AUTO-GENERATED. DO NOT EDIT!!! */
00038 
00039 #include "jsapi.h"
00040 #include "nscore.h"
00041 #include "nsIScriptContext.h"
00042 #include "nsIScriptObjectOwner.h"
00043 #include "nsIScriptGlobalObject.h"
00044 #include "nsString.h"
00045 #include "nsIDOMInstallVersion.h"
00046 #include "nsIScriptNameSpaceManager.h"
00047 #include "nsIComponentManager.h"
00048 #include "nsDOMCID.h"
00049 
00050 #include "nsSoftwareUpdateIIDs.h"
00051 
00052 
00053 PR_STATIC_CALLBACK(JSBool)
00054 GetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
00055 
00056 PR_STATIC_CALLBACK(JSBool)
00057 SetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp);
00058 
00059 PR_STATIC_CALLBACK(JSBool)
00060 EnumerateInstallVersion(JSContext *cx, JSObject *obj);
00061 
00062 PR_STATIC_CALLBACK(JSBool)
00063 ResolveInstallVersion(JSContext *cx, JSObject *obj, jsval id);
00064 
00065 PR_STATIC_CALLBACK(void)
00066 FinalizeInstallVersion(JSContext *cx, JSObject *obj);
00067 
00068 /***********************************************************************/
00069 //
00070 // class for InstallVersion
00071 //
00072 JSClass InstallVersionClass = {
00073   "InstallVersion",
00074   JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
00075   JS_PropertyStub,
00076   JS_PropertyStub,
00077   GetInstallVersionProperty,
00078   SetInstallVersionProperty,
00079   EnumerateInstallVersion,
00080   ResolveInstallVersion,
00081   JS_ConvertStub,
00082   FinalizeInstallVersion
00083 };
00084 
00085 
00086 extern void ConvertJSValToStr(nsString&  aString,
00087                              JSContext* aContext,
00088                              jsval      aValue);
00089 
00090 extern void ConvertStrToJSVal(const nsString& aProp,
00091                              JSContext* aContext,
00092                              jsval* aReturn);
00093 
00094 extern PRBool ConvertJSValToBool(PRBool* aProp,
00095                                 JSContext* aContext,
00096                                 jsval aValue);
00097 
00098 extern PRBool ConvertJSValToObj(nsISupports** aSupports,
00099                                REFNSIID aIID,
00100                                JSClass* aClass,
00101                                JSContext* aContext,
00102                                jsval aValue);
00103 
00104 void ConvertJSvalToVersionString(nsString& versionString, JSContext* cx, jsval* argument);
00105 
00106 
00107 //
00108 // InstallVersion property ids
00109 //
00110 enum InstallVersion_slots {
00111   INSTALLVERSION_MAJOR = -1,
00112   INSTALLVERSION_MINOR = -2,
00113   INSTALLVERSION_RELEASE = -3,
00114   INSTALLVERSION_BUILD = -4
00115 };
00116 
00117 /***********************************************************************/
00118 //
00119 // InstallVersion Properties Getter
00120 //
00121 PR_STATIC_CALLBACK(JSBool)
00122 GetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
00123 {
00124   nsIDOMInstallVersion *a = (nsIDOMInstallVersion*)JS_GetPrivate(cx, obj);
00125 
00126   // If there's no private data, this must be the prototype, so ignore
00127   if (nsnull == a) {
00128     return JS_TRUE;
00129   }
00130 
00131   if (JSVAL_IS_INT(id)) {
00132     switch(JSVAL_TO_INT(id)) {
00133       case INSTALLVERSION_MAJOR:
00134       {
00135         PRInt32 prop;
00136         if (NS_OK == a->GetMajor(&prop)) {
00137           *vp = INT_TO_JSVAL(prop);
00138         }
00139         else {
00140           return JS_FALSE;
00141         }
00142         break;
00143       }
00144       case INSTALLVERSION_MINOR:
00145       {
00146         PRInt32 prop;
00147         if (NS_OK == a->GetMinor(&prop)) {
00148           *vp = INT_TO_JSVAL(prop);
00149         }
00150         else {
00151           return JS_FALSE;
00152         }
00153         break;
00154       }
00155       case INSTALLVERSION_RELEASE:
00156       {
00157         PRInt32 prop;
00158         if (NS_OK == a->GetRelease(&prop)) {
00159           *vp = INT_TO_JSVAL(prop);
00160         }
00161         else {
00162           return JS_FALSE;
00163         }
00164         break;
00165       }
00166       case INSTALLVERSION_BUILD:
00167       {
00168         PRInt32 prop;
00169         if (NS_OK == a->GetBuild(&prop)) {
00170           *vp = INT_TO_JSVAL(prop);
00171         }
00172         else {
00173           return JS_FALSE;
00174         }
00175         break;
00176       }
00177     }
00178   }
00179 
00180   return JS_TRUE;
00181 }
00182 
00183 /***********************************************************************/
00184 //
00185 // InstallVersion Properties Setter
00186 //
00187 PR_STATIC_CALLBACK(JSBool)
00188 SetInstallVersionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
00189 {
00190   nsIDOMInstallVersion *a = (nsIDOMInstallVersion*)JS_GetPrivate(cx, obj);
00191 
00192   // If there's no private data, this must be the prototype, so ignore
00193   if (nsnull == a) {
00194     return JS_TRUE;
00195   }
00196 
00197   if (JSVAL_IS_INT(id)) {
00198     switch(JSVAL_TO_INT(id)) {
00199       case INSTALLVERSION_MAJOR:
00200       {
00201         PRInt32 prop;
00202         int32 temp;
00203         if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
00204           prop = (PRInt32)temp;
00205         }
00206         else {
00207           JS_ReportError(cx, "Parameter must be a number");
00208           return JS_FALSE;
00209         }
00210       
00211         a->SetMajor(prop);
00212         
00213         break;
00214       }
00215       case INSTALLVERSION_MINOR:
00216       {
00217         PRInt32 prop;
00218         int32 temp;
00219         if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
00220           prop = (PRInt32)temp;
00221         }
00222         else {
00223           JS_ReportError(cx, "Parameter must be a number");
00224           return JS_FALSE;
00225         }
00226       
00227         a->SetMinor(prop);
00228         
00229         break;
00230       }
00231       case INSTALLVERSION_RELEASE:
00232       {
00233         PRInt32 prop;
00234         int32 temp;
00235         if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
00236           prop = (PRInt32)temp;
00237         }
00238         else {
00239           JS_ReportError(cx, "Parameter must be a number");
00240           return JS_FALSE;
00241         }
00242       
00243         a->SetRelease(prop);
00244         
00245         break;
00246       }
00247       case INSTALLVERSION_BUILD:
00248       {
00249         PRInt32 prop;
00250         int32 temp;
00251         if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
00252           prop = (PRInt32)temp;
00253         }
00254         else {
00255           JS_ReportError(cx, "Parameter must be a number");
00256           return JS_FALSE;
00257         }
00258       
00259         a->SetBuild(prop);
00260         
00261         break;
00262       }
00263     }
00264   }
00265 
00266   return JS_TRUE;
00267 }
00268 
00269 
00270 //
00271 // InstallVersion finalizer
00272 //
00273 PR_STATIC_CALLBACK(void)
00274 FinalizeInstallVersion(JSContext *cx, JSObject *obj)
00275 {
00276   nsISupports *nativeThis = (nsISupports*)JS_GetPrivate(cx, obj);
00277 
00278   if (nsnull != nativeThis) {
00279     // get the js object
00280     nsIScriptObjectOwner *owner = nsnull;
00281     if (NS_OK == nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner), 
00282                                             (void**)&owner)) {
00283       owner->SetScriptObject(nsnull);
00284       NS_RELEASE(owner);
00285     }
00286     
00287     // The addref was part of JSObject construction
00288     NS_RELEASE(nativeThis);
00289   }
00290 }
00291 
00292 
00293 //
00294 // InstallVersion enumerate
00295 //
00296 PR_STATIC_CALLBACK(JSBool)
00297 EnumerateInstallVersion(JSContext *cx, JSObject *obj)
00298 {
00299   return JS_TRUE;
00300 }
00301 
00302 
00303 //
00304 // InstallVersion resolve
00305 //
00306 PR_STATIC_CALLBACK(JSBool)
00307 ResolveInstallVersion(JSContext *cx, JSObject *obj, jsval id)
00308 {
00309   return JS_TRUE;
00310 }
00311 
00312 
00313 //
00314 // Native method Init
00315 //
00316 PR_STATIC_CALLBACK(JSBool)
00317 InstallVersionInit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
00318 {
00319   nsIDOMInstallVersion *nativeThis =
00320     (nsIDOMInstallVersion*)JS_GetInstancePrivate(cx, obj, &InstallVersionClass,
00321                                                  argv);
00322   if (!nativeThis)
00323     return JS_FALSE;
00324 
00325   nsAutoString b0;
00326 
00327   *rval = JSVAL_NULL;
00328 
00329   // If there's no private data, this must be the prototype, so ignore
00330   if (nsnull == nativeThis) {
00331     return JS_TRUE;
00332   }
00333 
00334   if (argc == 1) 
00335   {
00336     JSString *jsstring;
00337     if ((jsstring = JS_ValueToString(cx, argv[0])) != nsnull) {
00338       b0.Assign(NS_REINTERPRET_CAST(const PRUnichar*,
00339                                     JS_GetStringChars(jsstring)));
00340     }
00341   }
00342   else 
00343   {
00344       b0.AssignLiteral("0.0.0.0");
00345   }
00346     
00347   if (NS_OK != nativeThis->Init(b0)) 
00348         return JS_FALSE;
00349   
00350   *rval = JSVAL_VOID;
00351 
00352   return JS_TRUE;
00353 }
00354 
00355 
00356 //
00357 // Native method ToString
00358 //
00359 PR_STATIC_CALLBACK(JSBool)
00360 InstallVersionToString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
00361 {
00362   nsIDOMInstallVersion *nativeThis =
00363     (nsIDOMInstallVersion*)JS_GetInstancePrivate(cx, obj, &InstallVersionClass,
00364                                                  argv);
00365   if (!nativeThis)
00366     return JS_FALSE;
00367 
00368   nsAutoString nativeRet;
00369 
00370   *rval = JSVAL_NULL;
00371 
00372   // If there's no private data, this must be the prototype, so ignore
00373   if (nsnull == nativeThis) {
00374     return JS_TRUE;
00375   }
00376 
00377   if (NS_OK != nativeThis->ToString(nativeRet)) {
00378     return JS_TRUE;
00379   }
00380 
00381   JSString *jsstring =
00382     JS_NewUCStringCopyN(cx, NS_REINTERPRET_CAST(const jschar*,
00383                                                 nativeRet.get()),
00384                         nativeRet.Length());
00385 
00386   // set the return value
00387   *rval = STRING_TO_JSVAL(jsstring);
00388   return JS_TRUE;
00389 }
00390 
00391 
00392 //
00393 // Native method CompareTo
00394 //
00395 PR_STATIC_CALLBACK(JSBool)
00396 InstallVersionCompareTo(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
00397 {
00398   nsIDOMInstallVersion *nativeThis =
00399     (nsIDOMInstallVersion*)JS_GetInstancePrivate(cx, obj, &InstallVersionClass,
00400                                                  argv);
00401   if (!nativeThis)
00402     return JS_FALSE;
00403 
00404   PRInt32                 nativeRet;
00405   nsString                b0str;
00406   PRInt32                 b0int;
00407   PRInt32                 b1int;
00408   PRInt32                 b2int;
00409   PRInt32                 b3int;
00410 
00411   *rval = JSVAL_NULL;
00412 
00413   // If there's no private data, this must be the prototype, so ignore
00414   if (nsnull == nativeThis) {
00415     return JS_TRUE;
00416   }
00417 
00418   if(argc >= 4)
00419   {
00420     //  public int CompareTo(int    major,
00421     //                       int    minor,
00422     //                       int    release,
00423     //                       int    build);
00424 
00425     if(!JSVAL_IS_INT(argv[0]))
00426     {
00427         JS_ReportError(cx, "1st parameter must be a number");
00428         return JS_FALSE;
00429     }
00430     else if(!JSVAL_IS_INT(argv[1]))
00431     {
00432         JS_ReportError(cx, "2nd parameter must be a number");
00433         return JS_FALSE;
00434     }
00435     else if(!JSVAL_IS_INT(argv[2]))
00436     {
00437         JS_ReportError(cx, "3rd parameter must be a number");
00438         return JS_FALSE;
00439     }
00440     else if(!JSVAL_IS_INT(argv[3]))
00441     {
00442         JS_ReportError(cx, "4th parameter must be a number");
00443         return JS_FALSE;
00444     }
00445 
00446     b0int = JSVAL_TO_INT(argv[0]);
00447     b1int = JSVAL_TO_INT(argv[1]);
00448     b2int = JSVAL_TO_INT(argv[2]);
00449     b3int = JSVAL_TO_INT(argv[3]);
00450 
00451     if(NS_OK != nativeThis->CompareTo(b0int, b1int, b2int, b3int, &nativeRet))
00452     {
00453       return JS_FALSE;
00454     }
00455 
00456     *rval = INT_TO_JSVAL(nativeRet);
00457   }
00458   else if(argc >= 1)
00459   {
00460      //   public int AddDirectory(String version);  --OR--  VersionInfo version
00461 
00462     if(JSVAL_IS_OBJECT(argv[0]))
00463     {
00464         nsCOMPtr<nsIDOMInstallVersion> versionObj;
00465 
00466         if(JS_FALSE == ConvertJSValToObj(getter_AddRefs(versionObj),
00467                                          NS_GET_IID(nsIDOMInstallVersion),
00468                                          &InstallVersionClass,
00469                                          cx,
00470                                          argv[0]))
00471         {
00472           return JS_FALSE;
00473         }
00474 
00475         if (!versionObj)
00476         {
00477           JS_ReportError(cx, "Function compareTo expects a non null object.");
00478           return JS_FALSE;
00479         }
00480 
00481         if(NS_OK != nativeThis->CompareTo(versionObj, &nativeRet))
00482         {
00483           return JS_FALSE;
00484         }
00485     }
00486     else
00487     {
00488         ConvertJSValToStr(b0str, cx, argv[0]);
00489 
00490         if(NS_OK != nativeThis->CompareTo(b0str, &nativeRet))
00491         {
00492           return JS_FALSE;
00493         }
00494     }
00495 
00496     *rval = INT_TO_JSVAL(nativeRet);
00497   }
00498   else
00499   {
00500     JS_ReportError(cx, "Function compareTo requires 4 parameters");
00501     return JS_FALSE;
00502   }
00503 
00504   return JS_TRUE;
00505 }
00506 
00507 
00508 //
00509 // InstallVersion class properties
00510 //
00511 static JSPropertySpec InstallVersionProperties[] =
00512 {
00513   {"major",    INSTALLVERSION_MAJOR,    JSPROP_ENUMERATE},
00514   {"minor",    INSTALLVERSION_MINOR,    JSPROP_ENUMERATE},
00515   {"release",  INSTALLVERSION_RELEASE,  JSPROP_ENUMERATE},
00516   {"build",    INSTALLVERSION_BUILD,    JSPROP_ENUMERATE},
00517   {0}
00518 };
00519 
00520 
00521 //
00522 // InstallVersion class methods
00523 //
00524 static JSFunctionSpec InstallVersionMethods[] = 
00525 {
00526   {"init",          InstallVersionInit,       1},
00527   {"toString",      InstallVersionToString,   0},
00528   {"compareTo",     InstallVersionCompareTo,  1},
00529   {0}
00530 };
00531 
00532 static JSConstDoubleSpec version_constants[] = 
00533 {
00534     { nsIDOMInstallVersion::EQUAL,                  "EQUAL"              },
00535     { nsIDOMInstallVersion::BLD_DIFF,               "BLD_DIFF"           },
00536     { nsIDOMInstallVersion::BLD_DIFF_MINUS,         "BLD_DIFF_MINUS"     },
00537     { nsIDOMInstallVersion::REL_DIFF,               "REL_DIFF"           },
00538     { nsIDOMInstallVersion::REL_DIFF_MINUS,         "REL_DIFF_MINUS"     },
00539     { nsIDOMInstallVersion::MINOR_DIFF,             "MINOR_DIFF"         },
00540     { nsIDOMInstallVersion::MINOR_DIFF_MINUS,       "MINOR_DIFF_MINUS"   },
00541     { nsIDOMInstallVersion::MAJOR_DIFF,             "MAJOR_DIFF"         },
00542     { nsIDOMInstallVersion::MAJOR_DIFF_MINUS,       "MAJOR_DIFF_MINUS"   },
00543     {0}
00544 };
00545 
00546 
00547 
00548 //
00549 // InstallVersion constructor
00550 //
00551 PR_STATIC_CALLBACK(JSBool)
00552 InstallVersion(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
00553 {
00554   nsresult result;
00555   
00556   nsIDOMInstallVersion *nativeThis;
00557   nsIScriptObjectOwner *owner = nsnull;
00558 
00559   static NS_DEFINE_IID(kInstallVersion_CID, NS_SoftwareUpdateInstallVersion_CID);
00560 
00561   result = CallCreateInstance(kInstallVersion_CID, &nativeThis);
00562   if (NS_FAILED(result)) return JS_FALSE;
00563 
00564             
00565   result = nativeThis->QueryInterface(NS_GET_IID(nsIScriptObjectOwner),
00566                                       (void **)&owner);
00567   if (NS_FAILED(result)) {
00568     NS_RELEASE(nativeThis);
00569     return JS_FALSE;
00570   }
00571 
00572   owner->SetScriptObject((void *)obj);
00573   JS_SetPrivate(cx, obj, nativeThis);
00574 
00575   NS_RELEASE(owner);
00576    
00577   jsval ignore;
00578   InstallVersionInit(cx, obj, argc, argv, &ignore);
00579 
00580   return JS_TRUE;
00581 }
00582 
00583 nsresult InitInstallVersionClass(JSContext *jscontext, JSObject *global, void** prototype)
00584 {
00585   JSObject *proto = nsnull;
00586 
00587   if (prototype != nsnull)
00588     *prototype = nsnull;
00589 
00590   proto = JS_InitClass(jscontext,     // context
00591                        global,        // global object
00592                        nsnull,  // parent proto 
00593                        &InstallVersionClass,      // JSClass
00594                        InstallVersion,            // JSNative ctor
00595                        0,             // ctor args
00596                        InstallVersionProperties,  // proto props
00597                        InstallVersionMethods,     // proto funcs
00598                        nsnull,        // ctor props (static)
00599                        nsnull);       // ctor funcs (static)
00600   
00601   if (nsnull == proto)
00602       return NS_ERROR_FAILURE;
00603   
00604   
00605   if ( PR_FALSE == JS_DefineConstDoubles(jscontext, proto, version_constants) )
00606             return NS_ERROR_FAILURE;
00607   
00608   if (prototype != nsnull)
00609       *prototype = proto;
00610   
00611   return NS_OK;
00612 }
00613 
00614 //
00615 // InstallVersion class initialization
00616 //
00617 nsresult NS_InitInstallVersionClass(nsIScriptContext *aContext, void **aPrototype)
00618 {
00619   JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
00620   JSObject *proto = nsnull;
00621   JSObject *constructor = nsnull;
00622   JSObject *global = JS_GetGlobalObject(jscontext);
00623   jsval vp;
00624 
00625   if ((PR_TRUE != JS_LookupProperty(jscontext, global, "InstallVersion", &vp)) ||
00626       !JSVAL_IS_OBJECT(vp) ||
00627       ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) ||
00628       (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || 
00629       !JSVAL_IS_OBJECT(vp)) 
00630   {
00631     nsresult rv = InitInstallVersionClass(jscontext, global, (void**)&proto);
00632     if (NS_FAILED(rv)) return rv;
00633   }
00634   else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) 
00635   {
00636     proto = JSVAL_TO_OBJECT(vp);
00637   }
00638   else 
00639   {
00640     return NS_ERROR_FAILURE;
00641   }
00642 
00643   if (aPrototype) 
00644     *aPrototype = proto;
00645   
00646   return NS_OK;
00647 }
00648 
00649 
00650 //
00651 // Method for creating a new InstallVersion JavaScript object
00652 //
00653 nsresult
00654 NS_NewScriptInstallVersion(nsIScriptContext *aContext, nsISupports *aSupports,
00655                            nsISupports *aParent, void **aReturn)
00656 {
00657   NS_PRECONDITION(nsnull != aContext && nsnull != aSupports &&
00658                   nsnull != aReturn,
00659                   "null argument to NS_NewScriptInstallVersion");
00660 
00661   JSObject *proto;
00662   JSObject *parent;
00663   nsIScriptObjectOwner *owner;
00664   JSContext *jscontext = (JSContext *)aContext->GetNativeContext();
00665   nsresult result = NS_OK;
00666   nsIDOMInstallVersion *installVersion;
00667 
00668   if (nsnull == aParent) {
00669     parent = nsnull;
00670   }
00671   else if (NS_OK == aParent->QueryInterface(NS_GET_IID(nsIScriptObjectOwner),
00672                                             (void**)&owner)) {
00673     if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) {
00674       NS_RELEASE(owner);
00675       return NS_ERROR_FAILURE;
00676     }
00677     NS_RELEASE(owner);
00678   }
00679   else {
00680     return NS_ERROR_FAILURE;
00681   }
00682 
00683   if (NS_OK != NS_InitInstallVersionClass(aContext, (void **)&proto)) {
00684     return NS_ERROR_FAILURE;
00685   }
00686 
00687   result = aSupports->QueryInterface(NS_GET_IID(nsIDOMInstallVersion), (void **)&installVersion);
00688   if (NS_OK != result) {
00689     return result;
00690   }
00691 
00692   // create a js object for this class
00693   *aReturn = JS_NewObject(jscontext, &InstallVersionClass, proto, parent);
00694   if (nsnull != *aReturn) {
00695     // connect the native object to the js object
00696     JS_SetPrivate(jscontext, (JSObject *)*aReturn, installVersion);
00697   }
00698   else {
00699     NS_RELEASE(installVersion);
00700     return NS_ERROR_FAILURE; 
00701   }
00702 
00703   return NS_OK;
00704 }
00705