if (type == nsXPTType::T_I8 || type == nsXPTType::T_I16 || type == nsXPTType::T_I32 || type == nsXPTType::T_U8 || type == nsXPTType::T_U16 || type == nsXPTType::T_U32) { jsval v = INT_TO_JSVAL(c->GetValue()->val.u16);  if (!::JS_DefineProperty(cx, obj, c->GetName(), v, nsnull, nsnull, JSPROP_ENUMERATE)) { return NS_ERROR_UNEXPECTED;
jsval v; switch (type) { case nsXPTType::T_I8: case nsXPTType::T_U8: { v = INT_TO_JSVAL(c->GetValue()->val.u8); break; } case nsXPTType::T_I16: case nsXPTType::T_U16: { v = INT_TO_JSVAL(c->GetValue()->val.u16); break; } case nsXPTType::T_I32: case nsXPTType::T_U32: { v = INT_TO_JSVAL(c->GetValue()->val.u32); break; } default: { #ifdef NS_DEBUG NS_ERROR("Non-numeric constant found in interface."); #endif continue;
DefineInterfaceConstants(JSContext *cx, JSObject *obj, const nsIID *aIID){  nsCOMPtr<nsIInterfaceInfoManager> iim =    dont_AddRef(XPTI_GetInterfaceInfoManager());  NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);  nsCOMPtr<nsIInterfaceInfo> if_info;  nsresult rv = iim->GetInfoForIID(aIID, getter_AddRefs(if_info));  NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && if_info, rv);  PRUint16 constant_count;  if_info->GetConstantCount(&constant_count);  if (!constant_count) {    return NS_OK;  }  nsCOMPtr<nsIInterfaceInfo> parent_if_info;  rv = if_info->GetParent(getter_AddRefs(parent_if_info));  NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && parent_if_info, rv);  PRUint16 parent_constant_count, i;  parent_if_info->GetConstantCount(&parent_constant_count);  for (i = parent_constant_count; i < constant_count; i++) {    const nsXPTConstant *c = nsnull;    rv = if_info->GetConstant(i, &c);    NS_ENSURE_TRUE(NS_SUCCEEDED(rv) && c, rv);    PRUint16 type = c->GetType().TagPart();    if (type == nsXPTType::T_I8 || type == nsXPTType::T_I16 ||        type == nsXPTType::T_I32 || type == nsXPTType::T_U8 ||        type == nsXPTType::T_U16 || type == nsXPTType::T_U32) {      jsval v = INT_TO_JSVAL(c->GetValue()->val.u16);      if (!::JS_DefineProperty(cx, obj, c->GetName(), v, nsnull, nsnull,                               JSPROP_ENUMERATE)) {        return NS_ERROR_UNEXPECTED;      }    }#ifdef NS_DEBUG    else {      NS_ERROR("Non-numeric constant found in interface.");    }#endif  }  return NS_OK;}