зеркало из https://github.com/mozilla/pjs.git
Patch for bug 209699 (convert some consumers over to CopyUTF8toUTF16 / CopyUTF16toUTF8). r=jshin, sr=jst.
This commit is contained in:
Родитель
11eebd3c17
Коммит
79b0f21971
|
@ -2727,7 +2727,7 @@ nsDocument::GetDir(nsAString& aDirection)
|
||||||
context->GetBidi(&options);
|
context->GetBidi(&options);
|
||||||
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
|
for (const DirTable* elt = dirAttributes; elt->mName; elt++) {
|
||||||
if (GET_BIDI_OPTION_DIRECTION(options) == elt->mValue) {
|
if (GET_BIDI_OPTION_DIRECTION(options) == elt->mValue) {
|
||||||
aDirection.Assign(NS_ConvertASCIItoUCS2(elt->mName));
|
CopyASCIItoUTF16(elt->mName, aDirection);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -515,7 +515,7 @@ nsHTMLValue::ToString(nsAString& aResult) const
|
||||||
char buf[10];
|
char buf[10];
|
||||||
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
||||||
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
||||||
aResult.Assign(NS_ConvertASCIItoUCS2(buf));
|
AppendASCIItoUTF16(buf, aResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
case eHTMLUnit_ColorName:
|
case eHTMLUnit_ColorName:
|
||||||
|
|
|
@ -839,7 +839,6 @@ nsPlainTextSerializer::DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag)
|
||||||
if (mHeaderStrategy == 2) { // numbered
|
if (mHeaderStrategy == 2) { // numbered
|
||||||
mIndent += kIndentSizeHeaders;
|
mIndent += kIndentSizeHeaders;
|
||||||
// Caching
|
// Caching
|
||||||
nsCAutoString leadup;
|
|
||||||
PRInt32 level = HeaderLevel(type);
|
PRInt32 level = HeaderLevel(type);
|
||||||
// Increase counter for current level
|
// Increase counter for current level
|
||||||
mHeaderCounter[level]++;
|
mHeaderCounter[level]++;
|
||||||
|
@ -851,12 +850,13 @@ nsPlainTextSerializer::DoOpenContainer(const nsIParserNode* aNode, PRInt32 aTag)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Construct numbers
|
// Construct numbers
|
||||||
|
nsAutoString leadup;
|
||||||
for (i = 1; i <= level; i++) {
|
for (i = 1; i <= level; i++) {
|
||||||
leadup.AppendInt(mHeaderCounter[i]);
|
leadup.AppendInt(mHeaderCounter[i]);
|
||||||
leadup += ".";
|
leadup.Append(PRUnichar('.'));
|
||||||
}
|
}
|
||||||
leadup += " ";
|
leadup.Append(PRUnichar(' '));
|
||||||
Write(NS_ConvertASCIItoUCS2(leadup.get()));
|
Write(leadup);
|
||||||
}
|
}
|
||||||
else if (mHeaderStrategy == 1) { // indent increasingly
|
else if (mHeaderStrategy == 1) { // indent increasingly
|
||||||
mIndent += kIndentSizeHeaders;
|
mIndent += kIndentSizeHeaders;
|
||||||
|
|
|
@ -305,10 +305,10 @@ NS_INTERFACE_MAP_END
|
||||||
// nsIDOMEventInterface
|
// nsIDOMEventInterface
|
||||||
NS_METHOD nsDOMEvent::GetType(nsAString& aType)
|
NS_METHOD nsDOMEvent::GetType(nsAString& aType)
|
||||||
{
|
{
|
||||||
const char* mName = GetEventName(mEvent->message);
|
const char* name = GetEventName(mEvent->message);
|
||||||
|
|
||||||
if (mName) {
|
if (name) {
|
||||||
aType.Assign(NS_ConvertASCIItoUCS2(mName));
|
CopyASCIItoUTF16(name, aType);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -2384,11 +2384,9 @@ nsHTMLInputElement::SubmitNamesValues(nsIFormSubmission* aFormSubmission,
|
||||||
imageControlFrame->GetClickedY(&clickedY);
|
imageControlFrame->GetClickedY(&clickedY);
|
||||||
|
|
||||||
// Convert the values to strings for submission
|
// Convert the values to strings for submission
|
||||||
char buf[20];
|
nsAutoString xVal, yVal;
|
||||||
sprintf(&buf[0], "%d", clickedX);
|
xVal.AppendInt(clickedX);
|
||||||
nsAutoString xVal = NS_ConvertASCIItoUCS2(buf);
|
yVal.AppendInt(clickedY);
|
||||||
sprintf(&buf[0], "%d", clickedY);
|
|
||||||
nsAutoString yVal = NS_ConvertASCIItoUCS2(buf);
|
|
||||||
|
|
||||||
if (!name.IsEmpty()) {
|
if (!name.IsEmpty()) {
|
||||||
aFormSubmission->AddNameValuePair(this,
|
aFormSubmission->AddNameValuePair(this,
|
||||||
|
|
|
@ -1996,15 +1996,15 @@ nsHTMLDocument::SetDomain(const nsAString& aDomain)
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsCAutoString scheme;
|
nsCAutoString newURIString;
|
||||||
if (NS_FAILED(uri->GetScheme(scheme)))
|
if (NS_FAILED(uri->GetScheme(newURIString)))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
nsCAutoString path;
|
nsCAutoString path;
|
||||||
if (NS_FAILED(uri->GetPath(path)))
|
if (NS_FAILED(uri->GetPath(path)))
|
||||||
return NS_ERROR_FAILURE;
|
return NS_ERROR_FAILURE;
|
||||||
NS_ConvertUTF8toUCS2 newURIString(scheme);
|
newURIString.Append(NS_LITERAL_CSTRING("://"));
|
||||||
newURIString.Append(NS_LITERAL_STRING("://") + aDomain +
|
AppendUTF16toUTF8(aDomain, newURIString);
|
||||||
NS_ConvertUTF8toUCS2(path));
|
newURIString.Append(path);
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> newURI;
|
nsCOMPtr<nsIURI> newURI;
|
||||||
if (NS_FAILED(NS_NewURI(getter_AddRefs(newURI), newURIString)))
|
if (NS_FAILED(NS_NewURI(getter_AddRefs(newURI), newURIString)))
|
||||||
|
|
|
@ -182,7 +182,7 @@ nsPluginDocument::CreateSyntheticPluginDocument()
|
||||||
mPluginContent->SetDocument(this, PR_FALSE, PR_TRUE);
|
mPluginContent->SetDocument(this, PR_FALSE, PR_TRUE);
|
||||||
|
|
||||||
// make it a named element
|
// make it a named element
|
||||||
nsHTMLValue name(NS_ConvertUTF8toUCS2("plugin"));
|
nsHTMLValue name(NS_LITERAL_STRING("plugin"));
|
||||||
mPluginContent->SetHTMLAttribute(nsHTMLAtoms::name, name, PR_FALSE);
|
mPluginContent->SetHTMLAttribute(nsHTMLAtoms::name, name, PR_FALSE);
|
||||||
|
|
||||||
// fill viewport and auto-reize
|
// fill viewport and auto-reize
|
||||||
|
|
|
@ -515,7 +515,7 @@ nsHTMLValue::ToString(nsAString& aResult) const
|
||||||
char buf[10];
|
char buf[10];
|
||||||
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
PR_snprintf(buf, sizeof(buf), "#%02x%02x%02x",
|
||||||
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
NS_GET_R(v), NS_GET_G(v), NS_GET_B(v));
|
||||||
aResult.Assign(NS_ConvertASCIItoUCS2(buf));
|
AppendASCIItoUTF16(buf, aResult);
|
||||||
return PR_TRUE;
|
return PR_TRUE;
|
||||||
}
|
}
|
||||||
case eHTMLUnit_ColorName:
|
case eHTMLUnit_ColorName:
|
||||||
|
|
|
@ -232,8 +232,8 @@ nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement,
|
||||||
nsCAutoString eventsC, targetsC, aeventsC, atargetsC;
|
nsCAutoString eventsC, targetsC, aeventsC, atargetsC;
|
||||||
eventsC.AssignWithConversion(updater->mEvents);
|
eventsC.AssignWithConversion(updater->mEvents);
|
||||||
targetsC.AssignWithConversion(updater->mTargets);
|
targetsC.AssignWithConversion(updater->mTargets);
|
||||||
aeventsC.Assign(NS_ConvertUCS2toUTF8(aEvents));
|
CopyUTF16toUTF8(aEvents, aeventsC);
|
||||||
atargetsC.Assign(NS_ConvertUCS2toUTF8(aTargets));
|
CopyUTF16toUTF8(aTargets, atargetsC);
|
||||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||||
("xulcmd[%p] replace %p(events=%s targets=%s) with (events=%s targets=%s)",
|
("xulcmd[%p] replace %p(events=%s targets=%s) with (events=%s targets=%s)",
|
||||||
this, aElement,
|
this, aElement,
|
||||||
|
@ -256,8 +256,8 @@ nsXULCommandDispatcher::AddCommandUpdater(nsIDOMElement* aElement,
|
||||||
}
|
}
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
nsCAutoString aeventsC, atargetsC;
|
nsCAutoString aeventsC, atargetsC;
|
||||||
aeventsC.Assign(NS_ConvertUCS2toUTF8(aEvents));
|
CopyUTF16toUTF8(aEvents, aeventsC);
|
||||||
atargetsC.Assign(NS_ConvertUCS2toUTF8(aTargets));
|
CopyUTF16toUTF8(aTargets, atargetsC);
|
||||||
|
|
||||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||||
("xulcmd[%p] add %p(events=%s targets=%s)",
|
("xulcmd[%p] add %p(events=%s targets=%s)",
|
||||||
|
@ -357,7 +357,7 @@ nsXULCommandDispatcher::UpdateCommands(const nsAString& aEventName)
|
||||||
|
|
||||||
#ifdef NS_DEBUG
|
#ifdef NS_DEBUG
|
||||||
nsCAutoString aeventnameC;
|
nsCAutoString aeventnameC;
|
||||||
aeventnameC.Assign(NS_ConvertUCS2toUTF8(aEventName));
|
CopyUTF16toUTF8(aEventName, aeventnameC);
|
||||||
PR_LOG(gLog, PR_LOG_ALWAYS,
|
PR_LOG(gLog, PR_LOG_ALWAYS,
|
||||||
("xulcmd[%p] update %p event=%s",
|
("xulcmd[%p] update %p event=%s",
|
||||||
this, updater->mElement,
|
this, updater->mElement,
|
||||||
|
|
|
@ -314,7 +314,7 @@ nsXULContentUtils::GetTextForNode(nsIRDFNode* aNode, nsAString& aResult)
|
||||||
const char* p;
|
const char* p;
|
||||||
rv = resource->GetValueConst(&p);
|
rv = resource->GetValueConst(&p);
|
||||||
if (NS_FAILED(rv)) return rv;
|
if (NS_FAILED(rv)) return rv;
|
||||||
aResult.Assign(NS_ConvertASCIItoUCS2(p));
|
CopyASCIItoUTF16(p, aResult);
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4502,7 +4502,7 @@ GlobalWindowImpl::OpenInternal(const nsAString& aUrl,
|
||||||
// Earlier, this code used to call Escape() and would escape characters like
|
// Earlier, this code used to call Escape() and would escape characters like
|
||||||
// '?', '&', and '=' in the url. This caused bug 174628.
|
// '?', '&', and '=' in the url. This caused bug 174628.
|
||||||
if (IsASCII(aUrl)) {
|
if (IsASCII(aUrl)) {
|
||||||
url.Append(NS_ConvertUCS2toUTF8(aUrl));
|
AppendUTF16toUTF8(aUrl, url);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
nsXPIDLCString dest;
|
nsXPIDLCString dest;
|
||||||
|
@ -4510,7 +4510,7 @@ GlobalWindowImpl::OpenInternal(const nsAString& aUrl,
|
||||||
if (NS_SUCCEEDED(rv))
|
if (NS_SUCCEEDED(rv))
|
||||||
NS_EscapeURL(dest, esc_AlwaysCopy | esc_OnlyNonASCII, url);
|
NS_EscapeURL(dest, esc_AlwaysCopy | esc_OnlyNonASCII, url);
|
||||||
else
|
else
|
||||||
url.Append(NS_ConvertUCS2toUTF8(aUrl));
|
AppendUTF16toUTF8(aUrl, url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check whether the URI is allowed, but not for dialogs --
|
/* Check whether the URI is allowed, but not for dialogs --
|
||||||
|
@ -5775,14 +5775,14 @@ NavigatorImpl::GetAppVersion(nsAString& aAppVersion)
|
||||||
if (NS_FAILED(res))
|
if (NS_FAILED(res))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
aAppVersion += NS_ConvertASCIItoUCS2(str);
|
AppendASCIItoUTF16(str, aAppVersion);
|
||||||
|
|
||||||
aAppVersion.Append(NS_LITERAL_STRING("; "));
|
aAppVersion.Append(NS_LITERAL_STRING("; "));
|
||||||
res = service->GetLanguage(str);
|
res = service->GetLanguage(str);
|
||||||
if (NS_FAILED(res))
|
if (NS_FAILED(res))
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
aAppVersion += NS_ConvertASCIItoUCS2(str);
|
AppendASCIItoUTF16(str, aAppVersion);
|
||||||
|
|
||||||
aAppVersion.Append(PRUnichar(')'));
|
aAppVersion.Append(PRUnichar(')'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -118,7 +118,7 @@ HistoryImpl::GetCurrent(nsAString& aCurrent)
|
||||||
curEntry->GetURI(getter_AddRefs(uri));
|
curEntry->GetURI(getter_AddRefs(uri));
|
||||||
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
||||||
uri->GetSpec(curURL);
|
uri->GetSpec(curURL);
|
||||||
aCurrent.Assign(NS_ConvertUTF8toUCS2(curURL));
|
CopyUTF8toUTF16(curURL, aCurrent);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -147,7 +147,7 @@ HistoryImpl::GetPrevious(nsAString& aPrevious)
|
||||||
prevEntry->GetURI(getter_AddRefs(uri));
|
prevEntry->GetURI(getter_AddRefs(uri));
|
||||||
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
||||||
uri->GetSpec(prevURL);
|
uri->GetSpec(prevURL);
|
||||||
aPrevious.Assign(NS_ConvertUTF8toUCS2(prevURL));
|
CopyUTF8toUTF16(prevURL, aPrevious);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -176,7 +176,7 @@ HistoryImpl::GetNext(nsAString& aNext)
|
||||||
nextEntry->GetURI(getter_AddRefs(uri));
|
nextEntry->GetURI(getter_AddRefs(uri));
|
||||||
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
NS_ENSURE_TRUE(uri, NS_ERROR_FAILURE);
|
||||||
uri->GetSpec(nextURL);
|
uri->GetSpec(nextURL);
|
||||||
aNext.Assign(NS_ConvertUTF8toUCS2(nextURL));
|
CopyUTF8toUTF16(nextURL, aNext);
|
||||||
|
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
|
@ -302,7 +302,7 @@ HistoryImpl::Item(PRUint32 aIndex, nsAString& aReturn)
|
||||||
nsCAutoString urlCString;
|
nsCAutoString urlCString;
|
||||||
rv = uri->GetSpec(urlCString);
|
rv = uri->GetSpec(urlCString);
|
||||||
|
|
||||||
aReturn.Assign(NS_ConvertUTF8toUCS2(urlCString));
|
CopyUTF8toUTF16(urlCString, aReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
return rv;
|
return rv;
|
||||||
|
|
|
@ -67,6 +67,7 @@
|
||||||
#include "nsDOMClassInfo.h"
|
#include "nsDOMClassInfo.h"
|
||||||
#include "nsCRT.h"
|
#include "nsCRT.h"
|
||||||
#include "nsIProtocolHandler.h"
|
#include "nsIProtocolHandler.h"
|
||||||
|
#include "nsReadableUtils.h"
|
||||||
|
|
||||||
static nsresult GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
|
static nsresult GetDocumentCharacterSetForURI(const nsAString& aHref, nsACString& aCharset)
|
||||||
{
|
{
|
||||||
|
@ -334,7 +335,8 @@ LocationImpl::GetHash(nsAString& aHash)
|
||||||
NS_UnescapeURL(ref);
|
NS_UnescapeURL(ref);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result) && !ref.IsEmpty()) {
|
if (NS_SUCCEEDED(result) && !ref.IsEmpty()) {
|
||||||
aHash.Assign(NS_LITERAL_STRING("#") + NS_ConvertASCIItoUCS2(ref));
|
aHash.Assign(PRUnichar('#'));
|
||||||
|
AppendASCIItoUTF16(ref, aHash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +374,7 @@ LocationImpl::SetHash(const nsAString& aHash)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LocationImpl::GetHost(nsAString& aHost)
|
LocationImpl::GetHost(nsAString& aHost)
|
||||||
{
|
{
|
||||||
aHost.SetLength(0);
|
aHost.Truncate();
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result;
|
nsresult result;
|
||||||
|
@ -385,7 +387,7 @@ LocationImpl::GetHost(nsAString& aHost)
|
||||||
result = uri->GetHostPort(hostport);
|
result = uri->GetHostPort(hostport);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result)) {
|
if (NS_SUCCEEDED(result)) {
|
||||||
aHost = NS_ConvertUTF8toUCS2(hostport);
|
AppendUTF8toUTF16(hostport, aHost);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -411,7 +413,7 @@ LocationImpl::SetHost(const nsAString& aHost)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LocationImpl::GetHostname(nsAString& aHostname)
|
LocationImpl::GetHostname(nsAString& aHostname)
|
||||||
{
|
{
|
||||||
aHostname.SetLength(0);
|
aHostname.Truncate();
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result;
|
nsresult result;
|
||||||
|
@ -424,7 +426,7 @@ LocationImpl::GetHostname(nsAString& aHostname)
|
||||||
result = uri->GetHost(host);
|
result = uri->GetHost(host);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result)) {
|
if (NS_SUCCEEDED(result)) {
|
||||||
aHostname = NS_ConvertUTF8toUCS2(host);
|
AppendUTF8toUTF16(host, aHostname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -450,7 +452,7 @@ LocationImpl::SetHostname(const nsAString& aHostname)
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LocationImpl::GetHref(nsAString& aHref)
|
LocationImpl::GetHref(nsAString& aHref)
|
||||||
{
|
{
|
||||||
aHref.SetLength(0);
|
aHref.Truncate();
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result;
|
nsresult result;
|
||||||
|
@ -463,7 +465,7 @@ LocationImpl::GetHref(nsAString& aHref)
|
||||||
result = uri->GetSpec(uriString);
|
result = uri->GetSpec(uriString);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result)) {
|
if (NS_SUCCEEDED(result)) {
|
||||||
aHref = NS_ConvertUTF8toUCS2(uriString);
|
AppendUTF8toUTF16(uriString, aHref);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -595,7 +597,7 @@ LocationImpl::SetHrefWithBase(const nsAString& aHref,
|
||||||
NS_IMETHODIMP
|
NS_IMETHODIMP
|
||||||
LocationImpl::GetPathname(nsAString& aPathname)
|
LocationImpl::GetPathname(nsAString& aPathname)
|
||||||
{
|
{
|
||||||
aPathname.SetLength(0);
|
aPathname.Truncate();
|
||||||
|
|
||||||
nsCOMPtr<nsIURI> uri;
|
nsCOMPtr<nsIURI> uri;
|
||||||
nsresult result = NS_OK;
|
nsresult result = NS_OK;
|
||||||
|
@ -609,7 +611,7 @@ LocationImpl::GetPathname(nsAString& aPathname)
|
||||||
result = url->GetFilePath(file);
|
result = url->GetFilePath(file);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result)) {
|
if (NS_SUCCEEDED(result)) {
|
||||||
aPathname = NS_ConvertUTF8toUCS2(file);
|
AppendUTF8toUTF16(file, aPathname);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,7 +704,7 @@ LocationImpl::GetProtocol(nsAString& aProtocol)
|
||||||
result = uri->GetScheme(protocol);
|
result = uri->GetScheme(protocol);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result)) {
|
if (NS_SUCCEEDED(result)) {
|
||||||
aProtocol.Assign(NS_ConvertASCIItoUCS2(protocol));
|
CopyASCIItoUTF16(protocol, aProtocol);
|
||||||
aProtocol.Append(PRUnichar(':'));
|
aProtocol.Append(PRUnichar(':'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -744,7 +746,8 @@ LocationImpl::GetSearch(nsAString& aSearch)
|
||||||
result = url->GetQuery(search);
|
result = url->GetQuery(search);
|
||||||
|
|
||||||
if (NS_SUCCEEDED(result) && !search.IsEmpty()) {
|
if (NS_SUCCEEDED(result) && !search.IsEmpty()) {
|
||||||
aSearch.Assign(NS_LITERAL_STRING("?") + NS_ConvertUTF8toUCS2(search));
|
aSearch.Assign(PRUnichar('?'));
|
||||||
|
AppendUTF8toUTF16(search, aSearch);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -153,11 +153,12 @@ nsScriptNameSpaceManager::~nsScriptNameSpaceManager()
|
||||||
}
|
}
|
||||||
|
|
||||||
nsGlobalNameStruct *
|
nsGlobalNameStruct *
|
||||||
nsScriptNameSpaceManager::AddToHash(const nsAString& aKey)
|
nsScriptNameSpaceManager::AddToHash(const char *aKey)
|
||||||
{
|
{
|
||||||
|
NS_ConvertASCIItoUTF16 key(aKey);
|
||||||
GlobalNameMapEntry *entry =
|
GlobalNameMapEntry *entry =
|
||||||
NS_STATIC_CAST(GlobalNameMapEntry *,
|
NS_STATIC_CAST(GlobalNameMapEntry *,
|
||||||
PL_DHashTableOperate(&mGlobalNames, &aKey, PL_DHASH_ADD));
|
PL_DHashTableOperate(&mGlobalNames, &key, PL_DHASH_ADD));
|
||||||
|
|
||||||
if (!entry) {
|
if (!entry) {
|
||||||
return nsnull;
|
return nsnull;
|
||||||
|
@ -231,22 +232,22 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
|
||||||
categoryEntry.get(),
|
categoryEntry.get(),
|
||||||
getter_Copies(constructorProto));
|
getter_Copies(constructorProto));
|
||||||
if (NS_SUCCEEDED(rv)) {
|
if (NS_SUCCEEDED(rv)) {
|
||||||
NS_ConvertASCIItoUCS2 name(categoryEntry);
|
nsGlobalNameStruct *s = AddToHash(categoryEntry.get());
|
||||||
nsGlobalNameStruct *s = AddToHash(name);
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
||||||
s->mAlias = new nsGlobalNameStruct::ConstructorAlias;
|
s->mAlias = new nsGlobalNameStruct::ConstructorAlias;
|
||||||
if (!s->mAlias) {
|
if (!s->mAlias) {
|
||||||
// Free entry
|
// Free entry
|
||||||
|
NS_ConvertASCIItoUCS2 key(categoryEntry);
|
||||||
PL_DHashTableOperate(&mGlobalNames,
|
PL_DHashTableOperate(&mGlobalNames,
|
||||||
&name,
|
&key,
|
||||||
PL_DHASH_REMOVE);
|
PL_DHASH_REMOVE);
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
return NS_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
s->mType = nsGlobalNameStruct::eTypeExternalConstructorAlias;
|
s->mType = nsGlobalNameStruct::eTypeExternalConstructorAlias;
|
||||||
s->mAlias->mCID = cid;
|
s->mAlias->mCID = cid;
|
||||||
s->mAlias->mProtoName.AssignWithConversion(constructorProto);
|
AppendASCIItoUTF16(constructorProto, s->mAlias->mProtoName);
|
||||||
s->mAlias->mProto = nsnull;
|
s->mAlias->mProto = nsnull;
|
||||||
} else {
|
} else {
|
||||||
NS_WARNING("Global script name not overwritten!");
|
NS_WARNING("Global script name not overwritten!");
|
||||||
|
@ -256,7 +257,7 @@ nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(categoryEntry));
|
nsGlobalNameStruct *s = AddToHash(categoryEntry.get());
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
||||||
|
@ -430,7 +431,7 @@ nsScriptNameSpaceManager::RegisterInterface(const char* aIfName,
|
||||||
{
|
{
|
||||||
*aFoundOld = PR_FALSE;
|
*aFoundOld = PR_FALSE;
|
||||||
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aIfName));
|
nsGlobalNameStruct *s = AddToHash(aIfName);
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
|
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
|
||||||
|
@ -554,7 +555,7 @@ nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
||||||
NS_ERROR("Trying to register a non-ASCII class name");
|
NS_ERROR("Trying to register a non-ASCII class name");
|
||||||
return NS_OK;
|
return NS_OK;
|
||||||
}
|
}
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
nsGlobalNameStruct *s = AddToHash(aClassName);
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
||||||
|
@ -587,7 +588,7 @@ nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
||||||
|
|
||||||
*aFoundOld = PR_FALSE;
|
*aFoundOld = PR_FALSE;
|
||||||
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
nsGlobalNameStruct *s = AddToHash(aClassName);
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
||||||
|
@ -607,7 +608,7 @@ nsresult
|
||||||
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
|
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
|
||||||
nsCID& aCID)
|
nsCID& aCID)
|
||||||
{
|
{
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
nsGlobalNameStruct *s = AddToHash(aClassName);
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
// If an external constructor is already defined with aClassName we
|
// If an external constructor is already defined with aClassName we
|
||||||
|
@ -636,7 +637,7 @@ nsScriptNameSpaceManager::RegisterDOMCIData(const char *aName,
|
||||||
PRBool aHasClassInterface,
|
PRBool aHasClassInterface,
|
||||||
const nsCID *aConstructorCID)
|
const nsCID *aConstructorCID)
|
||||||
{
|
{
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aName));
|
nsGlobalNameStruct *s = AddToHash(aName);
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
||||||
|
|
||||||
// If an external constructor is already defined with aClassName we
|
// If an external constructor is already defined with aClassName we
|
||||||
|
|
|
@ -131,7 +131,7 @@ protected:
|
||||||
// that aKey will be mapped to. If mType in the returned
|
// that aKey will be mapped to. If mType in the returned
|
||||||
// nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
|
// nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
|
||||||
// already existed.
|
// already existed.
|
||||||
nsGlobalNameStruct *AddToHash(const nsAString& aKey);
|
nsGlobalNameStruct *AddToHash(const char *aKey);
|
||||||
|
|
||||||
nsresult FillHash(nsICategoryManager *aCategoryManager,
|
nsresult FillHash(nsICategoryManager *aCategoryManager,
|
||||||
const char *aCategory,
|
const char *aCategory,
|
||||||
|
|
|
@ -1,673 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
||||||
/* ***** BEGIN LICENSE BLOCK *****
|
|
||||||
* Version: NPL 1.1/GPL 2.0/LGPL 2.1
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Netscape Public License
|
|
||||||
* Version 1.1 (the "License"); you may not use this file except in
|
|
||||||
* compliance with the License. You may obtain a copy of the License at
|
|
||||||
* http://www.mozilla.org/NPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
||||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
||||||
* for the specific language governing rights and limitations under the
|
|
||||||
* License.
|
|
||||||
*
|
|
||||||
* The Original Code is Mozilla Communicator client code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is
|
|
||||||
* Netscape Communications Corporation.
|
|
||||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
||||||
* the Initial Developer. All Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* Alternatively, the contents of this file may be used under the terms of
|
|
||||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
||||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
||||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
||||||
* of those above. If you wish to allow use of your version of this file only
|
|
||||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
||||||
* use your version of this file under the terms of the NPL, indicate your
|
|
||||||
* decision by deleting the provisions above and replace them with the notice
|
|
||||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
||||||
* the provisions above, a recipient may use your version of this file under
|
|
||||||
* the terms of any one of the NPL, the GPL or the LGPL.
|
|
||||||
*
|
|
||||||
* ***** END LICENSE BLOCK ***** */
|
|
||||||
|
|
||||||
#include "nsScriptNameSpaceManager.h"
|
|
||||||
#include "nsCOMPtr.h"
|
|
||||||
#include "nsIComponentManager.h"
|
|
||||||
#include "nsICategoryManager.h"
|
|
||||||
#include "nsIServiceManager.h"
|
|
||||||
#include "nsXPCOM.h"
|
|
||||||
#include "nsISupportsPrimitives.h"
|
|
||||||
#include "nsIScriptExternalNameSet.h"
|
|
||||||
#include "nsIScriptNameSpaceManager.h"
|
|
||||||
#include "nsIScriptContext.h"
|
|
||||||
#include "nsIInterfaceInfoManager.h"
|
|
||||||
#include "nsIInterfaceInfo.h"
|
|
||||||
#include "xptinfo.h"
|
|
||||||
#include "nsXPIDLString.h"
|
|
||||||
#include "nsReadableUtils.h"
|
|
||||||
#include "nsDOMClassInfo.h"
|
|
||||||
#include "nsCRT.h"
|
|
||||||
|
|
||||||
#define NS_INTERFACE_PREFIX "nsI"
|
|
||||||
#define NS_DOM_INTERFACE_PREFIX "nsIDOM"
|
|
||||||
|
|
||||||
// Our extended PLDHashEntryHdr
|
|
||||||
class GlobalNameMapEntry : public PLDHashEntryHdr
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
// Our hash table ops don't care about the order of these members
|
|
||||||
nsString mKey;
|
|
||||||
nsGlobalNameStruct mGlobalName;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(const void *)
|
|
||||||
GlobalNameHashGetKey(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|
||||||
{
|
|
||||||
GlobalNameMapEntry *e = NS_STATIC_CAST(GlobalNameMapEntry *, entry);
|
|
||||||
|
|
||||||
return NS_STATIC_CAST(const nsAString *, &e->mKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PLDHashNumber)
|
|
||||||
GlobalNameHashHashKey(PLDHashTable *table, const void *key)
|
|
||||||
{
|
|
||||||
const nsAString *str = NS_STATIC_CAST(const nsAString *, key);
|
|
||||||
|
|
||||||
return HashString(*str);
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PRBool)
|
|
||||||
GlobalNameHashMatchEntry(PLDHashTable *table, const PLDHashEntryHdr *entry,
|
|
||||||
const void *key)
|
|
||||||
{
|
|
||||||
const GlobalNameMapEntry *e =
|
|
||||||
NS_STATIC_CAST(const GlobalNameMapEntry *, entry);
|
|
||||||
const nsAString *str = NS_STATIC_CAST(const nsAString *, key);
|
|
||||||
|
|
||||||
return str->Equals(e->mKey);
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(void)
|
|
||||||
GlobalNameHashClearEntry(PLDHashTable *table, PLDHashEntryHdr *entry)
|
|
||||||
{
|
|
||||||
GlobalNameMapEntry *e = NS_STATIC_CAST(GlobalNameMapEntry *, entry);
|
|
||||||
|
|
||||||
// An entry is being cleared, let the key (nsString) do its own
|
|
||||||
// cleanup.
|
|
||||||
e->mKey.~nsString();
|
|
||||||
if (e->mGlobalName.mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
||||||
nsIClassInfo* ci = GET_CLEAN_CI_PTR(e->mGlobalName.mData->mCachedClassInfo);
|
|
||||||
|
|
||||||
// If we constructed an internal helper, we'll let the helper delete
|
|
||||||
// the nsDOMClassInfoData structure, if not we do it here.
|
|
||||||
if (!ci || e->mGlobalName.mData->u.mExternalConstructorFptr) {
|
|
||||||
delete e->mGlobalName.mData;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Release our pointer to the helper.
|
|
||||||
NS_IF_RELEASE(ci);
|
|
||||||
}
|
|
||||||
else if (e->mGlobalName.mType == nsGlobalNameStruct::eTypeExternalConstructorAlias) {
|
|
||||||
delete e->mGlobalName.mAlias;
|
|
||||||
}
|
|
||||||
|
|
||||||
// This will set e->mGlobalName.mType to
|
|
||||||
// nsGlobalNameStruct::eTypeNotInitialized
|
|
||||||
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PRBool)
|
|
||||||
GlobalNameHashInitEntry(PLDHashTable *table, PLDHashEntryHdr *entry,
|
|
||||||
const void *key)
|
|
||||||
{
|
|
||||||
GlobalNameMapEntry *e = NS_STATIC_CAST(GlobalNameMapEntry *, entry);
|
|
||||||
const nsAString *keyStr = NS_STATIC_CAST(const nsAString *, key);
|
|
||||||
|
|
||||||
// Initialize the key in the entry with placement new
|
|
||||||
new (&e->mKey) nsString(*keyStr);
|
|
||||||
|
|
||||||
// This will set e->mGlobalName.mType to
|
|
||||||
// nsGlobalNameStruct::eTypeNotInitialized
|
|
||||||
memset(&e->mGlobalName, 0, sizeof(nsGlobalNameStruct));
|
|
||||||
return PR_TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsScriptNameSpaceManager::nsScriptNameSpaceManager()
|
|
||||||
: mIsInitialized(PR_FALSE)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
nsScriptNameSpaceManager::~nsScriptNameSpaceManager()
|
|
||||||
{
|
|
||||||
if (mIsInitialized) {
|
|
||||||
// Destroy the hash
|
|
||||||
PL_DHashTableFinish(&mGlobalNames);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGlobalNameStruct *
|
|
||||||
nsScriptNameSpaceManager::AddToHash(const nsAString& aKey)
|
|
||||||
{
|
|
||||||
GlobalNameMapEntry *entry =
|
|
||||||
NS_STATIC_CAST(GlobalNameMapEntry *,
|
|
||||||
PL_DHashTableOperate(&mGlobalNames, &aKey, PL_DHASH_ADD));
|
|
||||||
|
|
||||||
if (!entry) {
|
|
||||||
return nsnull;
|
|
||||||
}
|
|
||||||
|
|
||||||
return &entry->mGlobalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGlobalNameStruct*
|
|
||||||
nsScriptNameSpaceManager::GetConstructorProto(const nsGlobalNameStruct* aStruct)
|
|
||||||
{
|
|
||||||
NS_ASSERTION(aStruct->mType == nsGlobalNameStruct::eTypeExternalConstructorAlias,
|
|
||||||
"This function only works on constructor aliases!");
|
|
||||||
if (!aStruct->mAlias->mProto) {
|
|
||||||
GlobalNameMapEntry *proto =
|
|
||||||
NS_STATIC_CAST(GlobalNameMapEntry *,
|
|
||||||
PL_DHashTableOperate(&mGlobalNames,
|
|
||||||
&aStruct->mAlias->mProtoName,
|
|
||||||
PL_DHASH_LOOKUP));
|
|
||||||
|
|
||||||
if (PL_DHASH_ENTRY_IS_BUSY(proto)) {
|
|
||||||
aStruct->mAlias->mProto = &proto->mGlobalName;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return aStruct->mAlias->mProto;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::FillHash(nsICategoryManager *aCategoryManager,
|
|
||||||
const char *aCategory,
|
|
||||||
nsGlobalNameStruct::nametype aType)
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsISimpleEnumerator> e;
|
|
||||||
nsresult rv = aCategoryManager->EnumerateCategory(aCategory,
|
|
||||||
getter_AddRefs(e));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCAutoString categoryEntry;
|
|
||||||
nsXPIDLCString contractId;
|
|
||||||
nsCOMPtr<nsISupports> entry;
|
|
||||||
|
|
||||||
while (NS_SUCCEEDED(e->GetNext(getter_AddRefs(entry)))) {
|
|
||||||
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
|
|
||||||
|
|
||||||
if (!category) {
|
|
||||||
NS_WARNING("Category entry not an nsISupportsCString!");
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = category->GetData(categoryEntry);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = aCategoryManager->GetCategoryEntry(aCategory, categoryEntry.get(),
|
|
||||||
getter_Copies(contractId));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCID cid;
|
|
||||||
|
|
||||||
rv = nsComponentManager::ContractIDToClassID(contractId, &cid);
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
NS_WARNING("Bad contract id registed with the script namespace manager");
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
|
||||||
nsXPIDLCString constructorProto;
|
|
||||||
rv = aCategoryManager->GetCategoryEntry(JAVASCRIPT_GLOBAL_CONSTRUCTOR_PROTO_ALIAS_CATEGORY,
|
|
||||||
categoryEntry.get(),
|
|
||||||
getter_Copies(constructorProto));
|
|
||||||
if (NS_SUCCEEDED(rv)) {
|
|
||||||
NS_ConvertASCIItoUCS2 name(categoryEntry);
|
|
||||||
nsGlobalNameStruct *s = AddToHash(name);
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
|
||||||
s->mAlias = new nsGlobalNameStruct::ConstructorAlias;
|
|
||||||
if (!s->mAlias) {
|
|
||||||
// Free entry
|
|
||||||
PL_DHashTableOperate(&mGlobalNames,
|
|
||||||
&name,
|
|
||||||
PL_DHASH_REMOVE);
|
|
||||||
return NS_ERROR_OUT_OF_MEMORY;
|
|
||||||
}
|
|
||||||
s->mType = nsGlobalNameStruct::eTypeExternalConstructorAlias;
|
|
||||||
s->mAlias->mCID = cid;
|
|
||||||
s->mAlias->mProtoName.AssignWithConversion(constructorProto);
|
|
||||||
s->mAlias->mProto = nsnull;
|
|
||||||
} else {
|
|
||||||
NS_WARNING("Global script name not overwritten!");
|
|
||||||
}
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(categoryEntry));
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeNotInitialized) {
|
|
||||||
s->mType = aType;
|
|
||||||
s->mCID = cid;
|
|
||||||
} else {
|
|
||||||
NS_WARNING("Global script name not overwritten!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// This method enumerates over all installed interfaces (in .xpt
|
|
||||||
// files) and finds ones that start with "nsIDOM" and has constants
|
|
||||||
// defined in the interface itself (inherited constants doesn't
|
|
||||||
// count), once such an interface is found the "nsIDOM" prefix is cut
|
|
||||||
// off the name and the rest of the name is added into the hash for
|
|
||||||
// global names. This makes things like 'Node.ELEMENT_NODE' work in
|
|
||||||
// JS. See nsWindowSH::GlobalResolve() for detais on how this is used.
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::FillHashWithDOMInterfaces()
|
|
||||||
{
|
|
||||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
|
||||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
|
||||||
NS_ENSURE_TRUE(iim, NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
// First look for all interfaces whose name starts with nsIDOM
|
|
||||||
nsCOMPtr<nsIEnumerator> domInterfaces;
|
|
||||||
nsresult rv =
|
|
||||||
iim->EnumerateInterfacesWhoseNamesStartWith(NS_DOM_INTERFACE_PREFIX,
|
|
||||||
getter_AddRefs(domInterfaces));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsISupports> entry;
|
|
||||||
|
|
||||||
rv = domInterfaces->First();
|
|
||||||
|
|
||||||
if (NS_FAILED(rv)) {
|
|
||||||
// Empty interface list?
|
|
||||||
|
|
||||||
NS_WARNING("What, no nsIDOM interfaces installed?");
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PRBool found_old;
|
|
||||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
|
||||||
nsXPIDLCString if_name;
|
|
||||||
const nsIID *iid;
|
|
||||||
|
|
||||||
for ( ; domInterfaces->IsDone() == NS_ENUMERATOR_FALSE; domInterfaces->Next()) {
|
|
||||||
rv = domInterfaces->CurrentItem(getter_AddRefs(entry));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIInterfaceInfo> if_info(do_QueryInterface(entry));
|
|
||||||
if_info->GetName(getter_Copies(if_name));
|
|
||||||
if_info->GetIIDShared(&iid);
|
|
||||||
rv = RegisterInterface(if_name.get() + sizeof(NS_DOM_INTERFACE_PREFIX) - 1,
|
|
||||||
iid, &found_old);
|
|
||||||
|
|
||||||
#ifdef DEBUG
|
|
||||||
NS_ASSERTION(!found_old,
|
|
||||||
"Whaaa, interface name already in hash!");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
// Next, look for externally registered DOM interfaces
|
|
||||||
rv = RegisterExternalInterfaces(PR_FALSE);
|
|
||||||
|
|
||||||
return rv;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::RegisterExternalInterfaces(PRBool aAsProto)
|
|
||||||
{
|
|
||||||
nsresult rv;
|
|
||||||
nsCOMPtr<nsICategoryManager> cm =
|
|
||||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsIInterfaceInfoManager> iim =
|
|
||||||
dont_AddRef(XPTI_GetInterfaceInfoManager());
|
|
||||||
NS_ENSURE_TRUE(iim, NS_ERROR_NOT_AVAILABLE);
|
|
||||||
|
|
||||||
nsCOMPtr<nsISimpleEnumerator> enumerator;
|
|
||||||
rv = cm->EnumerateCategory(JAVASCRIPT_DOM_INTERFACE,
|
|
||||||
getter_AddRefs(enumerator));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsXPIDLCString IID_string;
|
|
||||||
nsCAutoString category_entry;
|
|
||||||
const char* if_name;
|
|
||||||
nsCOMPtr<nsISupports> entry;
|
|
||||||
nsCOMPtr<nsIInterfaceInfo> if_info;
|
|
||||||
PRBool found_old, dom_prefix;
|
|
||||||
|
|
||||||
while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry)))) {
|
|
||||||
nsCOMPtr<nsISupportsCString> category(do_QueryInterface(entry));
|
|
||||||
|
|
||||||
if (!category) {
|
|
||||||
NS_WARNING("Category entry not an nsISupportsCString!");
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
rv = category->GetData(category_entry);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = cm->GetCategoryEntry(JAVASCRIPT_DOM_INTERFACE, category_entry.get(),
|
|
||||||
getter_Copies(IID_string));
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsIID primary_IID;
|
|
||||||
if (!primary_IID.Parse(IID_string) ||
|
|
||||||
primary_IID.Equals(NS_GET_IID(nsISupports))) {
|
|
||||||
NS_ERROR("Invalid IID registered with the script namespace manager!");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
iim->GetInfoForIID(&primary_IID, getter_AddRefs(if_info));
|
|
||||||
|
|
||||||
while (if_info) {
|
|
||||||
const nsIID *iid;
|
|
||||||
if_info->GetIIDShared(&iid);
|
|
||||||
NS_ENSURE_TRUE(iid, NS_ERROR_UNEXPECTED);
|
|
||||||
|
|
||||||
if (iid->Equals(NS_GET_IID(nsISupports))) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if_info->GetNameShared(&if_name);
|
|
||||||
dom_prefix = (strncmp(if_name, NS_DOM_INTERFACE_PREFIX,
|
|
||||||
sizeof(NS_DOM_INTERFACE_PREFIX) - 1) == 0);
|
|
||||||
|
|
||||||
const char* name;
|
|
||||||
if (dom_prefix) {
|
|
||||||
if (!aAsProto) {
|
|
||||||
// nsIDOM* interfaces have already been registered.
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
name = if_name + sizeof(NS_DOM_INTERFACE_PREFIX) - 1;
|
|
||||||
} else {
|
|
||||||
name = if_name + sizeof(NS_INTERFACE_PREFIX) - 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (aAsProto) {
|
|
||||||
RegisterClassProto(name, iid, &found_old);
|
|
||||||
} else {
|
|
||||||
RegisterInterface(name, iid, &found_old);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (found_old) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsCOMPtr<nsIInterfaceInfo> tmp(if_info);
|
|
||||||
tmp->GetParent(getter_AddRefs(if_info));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::RegisterInterface(const char* aIfName,
|
|
||||||
const nsIID *aIfIID,
|
|
||||||
PRBool* aFoundOld)
|
|
||||||
{
|
|
||||||
*aFoundOld = PR_FALSE;
|
|
||||||
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aIfName));
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized) {
|
|
||||||
*aFoundOld = PR_TRUE;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->mType = nsGlobalNameStruct::eTypeInterface;
|
|
||||||
s->mIID = *aIfIID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::Init()
|
|
||||||
{
|
|
||||||
static PLDHashTableOps hash_table_ops =
|
|
||||||
{
|
|
||||||
PL_DHashAllocTable,
|
|
||||||
PL_DHashFreeTable,
|
|
||||||
GlobalNameHashGetKey,
|
|
||||||
GlobalNameHashHashKey,
|
|
||||||
GlobalNameHashMatchEntry,
|
|
||||||
PL_DHashMoveEntryStub,
|
|
||||||
GlobalNameHashClearEntry,
|
|
||||||
PL_DHashFinalizeStub,
|
|
||||||
GlobalNameHashInitEntry
|
|
||||||
};
|
|
||||||
|
|
||||||
mIsInitialized = PL_DHashTableInit(&mGlobalNames, &hash_table_ops, nsnull,
|
|
||||||
sizeof(GlobalNameMapEntry), 128);
|
|
||||||
NS_ENSURE_TRUE(mIsInitialized, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
|
|
||||||
rv = FillHashWithDOMInterfaces();
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
nsCOMPtr<nsICategoryManager> cm =
|
|
||||||
do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = FillHash(cm, JAVASCRIPT_GLOBAL_CONSTRUCTOR_CATEGORY,
|
|
||||||
nsGlobalNameStruct::eTypeExternalConstructor);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = FillHash(cm, JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
|
|
||||||
nsGlobalNameStruct::eTypeProperty);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = FillHash(cm, JAVASCRIPT_GLOBAL_STATIC_NAMESET_CATEGORY,
|
|
||||||
nsGlobalNameStruct::eTypeStaticNameSet);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
rv = FillHash(cm, JAVASCRIPT_GLOBAL_DYNAMIC_NAMESET_CATEGORY,
|
|
||||||
nsGlobalNameStruct::eTypeDynamicNameSet);
|
|
||||||
NS_ENSURE_SUCCESS(rv, rv);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
PR_STATIC_CALLBACK(PLDHashOperator)
|
|
||||||
NameSetInitCallback(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
|
||||||
PRUint32 number, void *arg)
|
|
||||||
{
|
|
||||||
GlobalNameMapEntry *entry = NS_STATIC_CAST(GlobalNameMapEntry *, hdr);
|
|
||||||
|
|
||||||
if (entry->mGlobalName.mType == nsGlobalNameStruct::eTypeStaticNameSet) {
|
|
||||||
nsresult rv = NS_OK;
|
|
||||||
nsCOMPtr<nsIScriptExternalNameSet> ns =
|
|
||||||
do_CreateInstance(entry->mGlobalName.mCID, &rv);
|
|
||||||
NS_ENSURE_SUCCESS(rv, PL_DHASH_NEXT);
|
|
||||||
|
|
||||||
rv = ns->InitializeNameSet(NS_STATIC_CAST(nsIScriptContext *, arg));
|
|
||||||
NS_WARN_IF_FALSE(NS_SUCCEEDED(rv),
|
|
||||||
"Initing external script classes failed!");
|
|
||||||
}
|
|
||||||
|
|
||||||
return PL_DHASH_NEXT;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::InitForContext(nsIScriptContext *aContext)
|
|
||||||
{
|
|
||||||
PL_DHashTableEnumerate(&mGlobalNames, NameSetInitCallback, aContext);
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::LookupName(const nsAString& aName,
|
|
||||||
const nsGlobalNameStruct **aNameStruct,
|
|
||||||
const PRUnichar **aClassName)
|
|
||||||
{
|
|
||||||
GlobalNameMapEntry *entry =
|
|
||||||
NS_STATIC_CAST(GlobalNameMapEntry *,
|
|
||||||
PL_DHashTableOperate(&mGlobalNames, &aName,
|
|
||||||
PL_DHASH_LOOKUP));
|
|
||||||
|
|
||||||
if (PL_DHASH_ENTRY_IS_BUSY(entry)) {
|
|
||||||
*aNameStruct = &entry->mGlobalName;
|
|
||||||
if (aClassName) {
|
|
||||||
*aClassName = entry->mKey.get();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
*aNameStruct = nsnull;
|
|
||||||
if (aClassName) {
|
|
||||||
*aClassName = nsnull;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::RegisterClassName(const char *aClassName,
|
|
||||||
PRInt32 aDOMClassInfoID)
|
|
||||||
{
|
|
||||||
if (!nsCRT::IsAscii(aClassName)) {
|
|
||||||
NS_ERROR("Trying to register a non-ASCII class name");
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If a external constructor is already defined with aClassName we
|
|
||||||
// won't overwrite it.
|
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
|
||||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
|
||||||
"Whaaa, JS environment name clash!");
|
|
||||||
|
|
||||||
s->mType = nsGlobalNameStruct::eTypeClassConstructor;
|
|
||||||
s->mDOMClassInfoID = aDOMClassInfoID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::RegisterClassProto(const char *aClassName,
|
|
||||||
const nsIID *aConstructorProtoIID,
|
|
||||||
PRBool *aFoundOld)
|
|
||||||
{
|
|
||||||
NS_ENSURE_ARG_POINTER(aConstructorProtoIID);
|
|
||||||
|
|
||||||
*aFoundOld = PR_FALSE;
|
|
||||||
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
if (s->mType != nsGlobalNameStruct::eTypeNotInitialized &&
|
|
||||||
s->mType != nsGlobalNameStruct::eTypeInterface) {
|
|
||||||
*aFoundOld = PR_TRUE;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
s->mType = nsGlobalNameStruct::eTypeClassProto;
|
|
||||||
s->mIID = *aConstructorProtoIID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::RegisterExternalClassName(const char *aClassName,
|
|
||||||
nsCID& aCID)
|
|
||||||
{
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aClassName));
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
// If an external constructor is already defined with aClassName we
|
|
||||||
// won't overwrite it.
|
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeExternalConstructor) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
|
||||||
s->mType == nsGlobalNameStruct::eTypeInterface,
|
|
||||||
"Whaaa, JS environment name clash!");
|
|
||||||
|
|
||||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfoCreator;
|
|
||||||
s->mCID = aCID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsresult
|
|
||||||
nsScriptNameSpaceManager::RegisterDOMCIData(const char *aName,
|
|
||||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
|
||||||
const nsIID *aProtoChainInterface,
|
|
||||||
const nsIID **aInterfaces,
|
|
||||||
PRUint32 aScriptableFlags,
|
|
||||||
PRBool aHasClassInterface,
|
|
||||||
const nsCID *aConstructorCID)
|
|
||||||
{
|
|
||||||
nsGlobalNameStruct *s = AddToHash(NS_ConvertASCIItoUCS2(aName));
|
|
||||||
NS_ENSURE_TRUE(s, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
// If an external constructor is already defined with aClassName we
|
|
||||||
// won't overwrite it.
|
|
||||||
|
|
||||||
if (s->mType == nsGlobalNameStruct::eTypeClassConstructor ||
|
|
||||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfo) {
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
// XXX Should we bail out here?
|
|
||||||
NS_ASSERTION(s->mType == nsGlobalNameStruct::eTypeNotInitialized ||
|
|
||||||
s->mType == nsGlobalNameStruct::eTypeExternalClassInfoCreator,
|
|
||||||
"Someone tries to register classinfo data for a class that isn't new or external!");
|
|
||||||
|
|
||||||
s->mData = new nsExternalDOMClassInfoData;
|
|
||||||
NS_ENSURE_TRUE(s->mData, NS_ERROR_OUT_OF_MEMORY);
|
|
||||||
|
|
||||||
s->mType = nsGlobalNameStruct::eTypeExternalClassInfo;
|
|
||||||
s->mData->mName = aName;
|
|
||||||
if (aConstructorFptr)
|
|
||||||
s->mData->u.mExternalConstructorFptr = aConstructorFptr;
|
|
||||||
else
|
|
||||||
// null constructor will cause us to use nsDOMGenericSH::doCreate
|
|
||||||
s->mData->u.mExternalConstructorFptr = nsnull;
|
|
||||||
s->mData->mCachedClassInfo = nsnull;
|
|
||||||
s->mData->mProtoChainInterface = aProtoChainInterface;
|
|
||||||
s->mData->mInterfaces = aInterfaces;
|
|
||||||
s->mData->mScriptableFlags = aScriptableFlags;
|
|
||||||
s->mData->mHasClassInterface = aHasClassInterface;
|
|
||||||
s->mData->mConstructorCID = aConstructorCID;
|
|
||||||
|
|
||||||
return NS_OK;
|
|
||||||
}
|
|
|
@ -1,151 +0,0 @@
|
||||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
||||||
*
|
|
||||||
* The contents of this file are subject to the Netscape Public
|
|
||||||
* License Version 1.1 (the "License"); you may not use this file
|
|
||||||
* except in compliance with the License. You may obtain a copy of
|
|
||||||
* the License at http://www.mozilla.org/NPL/
|
|
||||||
*
|
|
||||||
* Software distributed under the License is distributed on an "AS
|
|
||||||
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
||||||
* implied. See the License for the specific language governing
|
|
||||||
* rights and limitations under the License.
|
|
||||||
*
|
|
||||||
* The Original Code is Mozilla Communicator client code.
|
|
||||||
*
|
|
||||||
* The Initial Developer of the Original Code is Netscape Communications
|
|
||||||
* Corporation. Portions created by Netscape are
|
|
||||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
||||||
* Rights Reserved.
|
|
||||||
*
|
|
||||||
* Contributor(s):
|
|
||||||
*
|
|
||||||
*
|
|
||||||
* This Original Code has been modified by IBM Corporation.
|
|
||||||
* Modifications made by IBM described herein are
|
|
||||||
* Copyright (c) International Business Machines
|
|
||||||
* Corporation, 2000
|
|
||||||
*
|
|
||||||
* Modifications to Mozilla code or documentation
|
|
||||||
* identified per MPL Section 3.3
|
|
||||||
*
|
|
||||||
* Date Modified by Description of modification
|
|
||||||
* 03/27/2000 IBM Corp. Added PR_CALLBACK for Optlink
|
|
||||||
* use in OS2
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef nsScriptNameSpaceManager_h__
|
|
||||||
#define nsScriptNameSpaceManager_h__
|
|
||||||
|
|
||||||
#include "nsIScriptNameSpaceManager.h"
|
|
||||||
#include "nsString.h"
|
|
||||||
#include "nsID.h"
|
|
||||||
#include "pldhash.h"
|
|
||||||
|
|
||||||
#include "nsDOMClassInfo.h"
|
|
||||||
|
|
||||||
struct nsGlobalNameStruct
|
|
||||||
{
|
|
||||||
struct ConstructorAlias
|
|
||||||
{
|
|
||||||
nsCID mCID;
|
|
||||||
nsString mProtoName;
|
|
||||||
nsGlobalNameStruct* mProto;
|
|
||||||
};
|
|
||||||
|
|
||||||
enum nametype {
|
|
||||||
eTypeNotInitialized,
|
|
||||||
eTypeInterface,
|
|
||||||
eTypeProperty,
|
|
||||||
eTypeExternalConstructor,
|
|
||||||
eTypeStaticNameSet,
|
|
||||||
eTypeDynamicNameSet,
|
|
||||||
eTypeClassConstructor,
|
|
||||||
eTypeClassProto,
|
|
||||||
eTypeExternalClassInfoCreator,
|
|
||||||
eTypeExternalClassInfo,
|
|
||||||
eTypeExternalConstructorAlias
|
|
||||||
} mType;
|
|
||||||
|
|
||||||
union {
|
|
||||||
PRInt32 mDOMClassInfoID; // eTypeClassConstructor
|
|
||||||
nsIID mIID; // eTypeInterface, eTypeClassProto
|
|
||||||
nsExternalDOMClassInfoData* mData; // eTypeExternalClassInfo
|
|
||||||
ConstructorAlias* mAlias; // eTypeExternalConstructorAlias
|
|
||||||
nsCID mCID; // All other types...
|
|
||||||
};
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
// copy constructor
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
class nsIScriptContext;
|
|
||||||
class nsICategoryManager;
|
|
||||||
|
|
||||||
|
|
||||||
class nsScriptNameSpaceManager
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
nsScriptNameSpaceManager();
|
|
||||||
virtual ~nsScriptNameSpaceManager();
|
|
||||||
|
|
||||||
nsresult Init();
|
|
||||||
nsresult InitForContext(nsIScriptContext *aContext);
|
|
||||||
|
|
||||||
// Returns a nsGlobalNameStruct for aName, or null if one is not
|
|
||||||
// found. The returned nsGlobalNameStruct is only guaranteed to be
|
|
||||||
// valid until the next call to any of the methods in this class.
|
|
||||||
// It also returns a pointer to the string buffer of the classname
|
|
||||||
// in the nsGlobalNameStruct.
|
|
||||||
nsresult LookupName(const nsAString& aName,
|
|
||||||
const nsGlobalNameStruct **aNameStruct,
|
|
||||||
const PRUnichar **aClassName = nsnull);
|
|
||||||
|
|
||||||
nsresult RegisterClassName(const char *aClassName,
|
|
||||||
PRInt32 aDOMClassInfoID);
|
|
||||||
|
|
||||||
nsresult RegisterClassProto(const char *aClassName,
|
|
||||||
const nsIID *aConstructorProtoIID,
|
|
||||||
PRBool *aFoundOld);
|
|
||||||
|
|
||||||
nsresult RegisterExternalInterfaces(PRBool aAsProto);
|
|
||||||
|
|
||||||
nsresult RegisterExternalClassName(const char *aClassName,
|
|
||||||
nsCID& aCID);
|
|
||||||
|
|
||||||
// Register the info for an external class. aName must be static
|
|
||||||
// data, it will not be deleted by the DOM code.
|
|
||||||
nsresult RegisterDOMCIData(const char *aName,
|
|
||||||
nsDOMClassInfoExternalConstructorFnc aConstructorFptr,
|
|
||||||
const nsIID *aProtoChainInterface,
|
|
||||||
const nsIID **aInterfaces,
|
|
||||||
PRUint32 aScriptableFlags,
|
|
||||||
PRBool aHasClassInterface,
|
|
||||||
const nsCID *aConstructorCID);
|
|
||||||
|
|
||||||
nsGlobalNameStruct* GetConstructorProto(const nsGlobalNameStruct* aStruct);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
// Adds a new entry to the hash and returns the nsGlobalNameStruct
|
|
||||||
// that aKey will be mapped to. If mType in the returned
|
|
||||||
// nsGlobalNameStruct is != eTypeNotInitialized, an entry for aKey
|
|
||||||
// already existed.
|
|
||||||
nsGlobalNameStruct *AddToHash(const nsAString& aKey);
|
|
||||||
|
|
||||||
nsresult FillHash(nsICategoryManager *aCategoryManager,
|
|
||||||
const char *aCategory,
|
|
||||||
nsGlobalNameStruct::nametype aType);
|
|
||||||
nsresult FillHashWithDOMInterfaces();
|
|
||||||
nsresult RegisterInterface(const char* aIfName,
|
|
||||||
const nsIID *aIfIID,
|
|
||||||
PRBool* aFoundOld);
|
|
||||||
|
|
||||||
// Inline PLDHashTable, init with PL_DHashTableInit() and delete
|
|
||||||
// with PL_DHashTableFinish().
|
|
||||||
PLDHashTable mGlobalNames;
|
|
||||||
|
|
||||||
PRPackedBool mIsInitialized;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* nsScriptNameSpaceManager_h__ */
|
|
Загрузка…
Ссылка в новой задаче