if (!nativeThis) return JS_FALSE;
InstallAddSubcomponent(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval){  nsInstall *nativeThis =    (nsInstall*)JS_GetInstancePrivate(cx, obj, &InstallClass, argv);  if (!nativeThis)    return JS_FALSE;  PRInt32 nativeRet;  nsAutoString b0;  nsAutoString b1;  nsAutoString b2;  nsAutoString b3;  nsAutoString b4;  JSObject* jsObj;  nsInstallFolder* folder;  PRInt32 flags = 0;  nsresult rv;  *rval = INT_TO_JSVAL(nsInstall::UNEXPECTED_ERROR);  // If there's no private data, this must be the prototype, so ignore  if (nsnull == nativeThis) {    return JS_TRUE;  }  if(argc >= 6)  {    //  public int AddSubcomponent ( String registryName,    //                               String version,        --OR--     VersionInfo version,    //                               String jarSourcePath,    //                               Object localDirSpec,    //                               String relativeLocalPath,    //                               Int    flags);    ConvertJSValToStr(b0, cx, argv[0]);    ConvertJSvalToVersionString(b1, cx, argv[1]);    ConvertJSValToStr(b2, cx, argv[2]);    ConvertJSValToStr(b4, cx, argv[4]);    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval    {      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);      return JS_TRUE;    }    jsObj = JSVAL_TO_OBJECT(argv[3]);    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))    {      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);      return JS_TRUE;    }    if(JSVAL_IS_INT(argv[5]))      flags = JSVAL_TO_INT(argv[5]);    else      flags = 0;    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);    jsrefcount saveDepth;    saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs    rv= nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, flags, &nativeRet);    JS_ResumeRequest(cx, saveDepth);    if (NS_SUCCEEDED(rv))      *rval = INT_TO_JSVAL(nativeRet);  }  else if(argc >= 5)  {    //  public int AddSubcomponent ( String registryName,    //                               String version,  --OR-- VersionInfo version    //                               String jarSourcePath,    //                               Object localDirSpec,    //                               String relativeLocalPath);    ConvertJSValToStr(b0, cx, argv[0]);    ConvertJSvalToVersionString(b1, cx, argv[1]);    ConvertJSValToStr(b2, cx, argv[2]);    ConvertJSValToStr(b4, cx, argv[4]);    if ((argv[3] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[3])) //argv[3] MUST be a jsval    {      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);      return JS_TRUE;    }    jsObj = JSVAL_TO_OBJECT(argv[3]);    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))    {      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);      return JS_TRUE;    }    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);    jsrefcount saveDepth;    saveDepth = JS_SuspendRequest(cx);//Need to suspend use of thread or deadlock occurs    rv = nativeThis->AddSubcomponent(b0, b1, b2, folder, b4, &nativeRet);    JS_ResumeRequest(cx, saveDepth);    if (NS_SUCCEEDED(rv))      *rval = INT_TO_JSVAL(nativeRet);  }  else if(argc >= 4)  {    //  public int AddSubcomponent ( String registryName,    //                               String jarSourcePath,    //                               Object localDirSpec,    //                               String relativeLocalPath);    ConvertJSValToStr(b0, cx, argv[0]);    ConvertJSValToStr(b1, cx, argv[1]);    ConvertJSValToStr(b3, cx, argv[3]);    if ((argv[2] == JSVAL_NULL) || !JSVAL_IS_OBJECT(argv[2])) //argv[2] MUST be a jsval    {      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);      return JS_TRUE;    }    jsObj = JSVAL_TO_OBJECT(argv[2]);    if (!JS_InstanceOf(cx, jsObj, &FileSpecObjectClass, nsnull))    {      *rval = INT_TO_JSVAL(nsInstall::INVALID_ARGUMENTS);      nativeThis->SaveError(nsInstall::INVALID_ARGUMENTS);      return JS_TRUE;    }    folder = (nsInstallFolder*)JS_GetPrivate(cx, jsObj);    if(NS_OK == nativeThis->AddSubcomponent(b0, b1, folder, b3, &nativeRet))    {      *rval = INT_TO_JSVAL(nativeRet);    }  }  else if(argc >= 1)  {    //  public int AddSubcomponent ( String jarSourcePath);    ConvertJSValToStr(b0, cx, argv[0]);    if(NS_OK == nativeThis->AddSubcomponent(b0, &nativeRet))    {      *rval = INT_TO_JSVAL(nativeRet);    }  }  else  {    JS_ReportError(cx, "Install.addFile parameter error");  }  return JS_TRUE;}