} else if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) { native = do_CreateInstance(name_struct->mAlias->mCID, &rv);
StubConstructor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,                jsval *rval){  JSFunction *fun = ::JS_ValueToFunction(cx, argv[-2]);  if (!fun)    return JS_FALSE;  extern nsScriptNameSpaceManager *gNameSpaceManager;  if (!gNameSpaceManager) {    nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_NOT_INITIALIZED);    NS_ERROR("No nsScriptNameSpaceManager!");    return JS_FALSE;  }  const char *name = ::JS_GetFunctionName(fun);  nsAutoString nameStr;  nameStr.AssignWithConversion(name);  const nsGlobalNameStruct *name_struct = nsnull;  nsresult rv = gNameSpaceManager->LookupName(nameStr, &name_struct);  if (NS_FAILED(rv) || !name_struct ||      (name_struct->mType != nsGlobalNameStruct::eTypeExternalConstructor &&       name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfoCreator &&       name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo)) {    return JS_FALSE;  }  if (name_struct->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator) {    nsCOMPtr<nsIDOMCIExtension> creator =      do_CreateInstance(name_struct->mCID, &rv);    if (NS_FAILED(rv)) {      nsDOMClassInfo::ThrowJSException(cx, rv);      NS_ERROR("Couldn't create the DOMCI extender");      return JS_FALSE;    }    nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));    if (sof) {      nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);      NS_ERROR("Couldn't get the DOM script object factory");      return JS_FALSE;    }    rv = creator->RegisterDOMCI(name, sof);    if (NS_FAILED(rv)) {      nsDOMClassInfo::ThrowJSException(cx, rv);      NS_ERROR("Failed to register the DOM ClassInfo data");      return JS_FALSE;    }    rv = gNameSpaceManager->LookupName(nameStr, &name_struct);    if (NS_FAILED(rv) || !name_struct ||        name_struct->mType != nsGlobalNameStruct::eTypeExternalClassInfo) {      nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_FAILURE);      NS_ERROR("Couldn't get the DOM ClassInfo data");      return JS_FALSE;    }  }        nsCOMPtr<nsISupports> native;  if (name_struct->mType == nsGlobalNameStruct::eTypeExternalConstructor) {    native = do_CreateInstance(name_struct->mCID, &rv);  } else {    native = do_CreateInstance(*name_struct->mData->mConstructorCID, &rv);  }  if (NS_FAILED(rv)) {    nsDOMClassInfo::ThrowJSException(cx, rv);    NS_ERROR("Failed to create the object");    return JS_FALSE;  }  nsCOMPtr<nsIJSNativeInitializer> initializer(do_QueryInterface(native));  if (initializer) {    rv = initializer->Initialize(cx, obj, argc, argv);    if (NS_FAILED(rv)) {      nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_NOT_INITIALIZED);      return JS_FALSE;    }  }  nsCOMPtr<nsIScriptObjectOwner> owner(do_QueryInterface(native));  if (owner) {    nsCOMPtr<nsIScriptContext> context;    nsJSUtils::GetStaticScriptContext(cx, obj, getter_AddRefs(context));    if (!context) {      nsDOMClassInfo::ThrowJSException(cx, NS_ERROR_UNEXPECTED);      return JS_FALSE;    }    JSObject* new_obj;    rv = owner->GetScriptObject(context, (void**)&new_obj);    if (NS_SUCCEEDED(rv)) {      *rval = OBJECT_TO_JSVAL(new_obj);    }    return rv;  }  rv = nsDOMGenericSH::WrapNative(cx, ::JS_GetGlobalObject(cx), native,                                  NS_GET_IID(nsISupports), rval);  return NS_SUCCEEDED(rv) ? JS_TRUE : JS_FALSE;}