Implemented document.location and better handling of named lookups that fail.

This commit is contained in:
vidur%netscape.com 1998-08-13 19:07:45 +00:00
Родитель 87efb86929
Коммит 34235bee38
5 изменённых файлов: 57 добавлений и 7 удалений

Просмотреть файл

@ -38,8 +38,13 @@ static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
void PR_CALLBACK
NS_ScriptErrorReporter(JSContext *cx, const char *message, JSErrorReport *report)
{
printf("JavaScript error: %s\nURL :%s, LineNo :%u\nLine text: '%s', Error text: '%s'\n", message,
report->filename, report->lineno, report->linebuf, report->tokenptr);
if (nsnull != report) {
printf("JavaScript error: %s\nURL :%s, LineNo :%u\nLine text: '%s', Error text: '%s'\n", message,
report->filename, report->lineno, report->linebuf, report->tokenptr);
}
else {
printf("JavaScript error: %s\n", message);
}
}
nsJSContext::nsJSContext(JSRuntime *aRuntime)

Просмотреть файл

@ -132,6 +132,15 @@ GetHTMLCollectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
*vp = JSVAL_NULL;
}
}
else {
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
else {
return JS_FALSE;

Просмотреть файл

@ -642,6 +642,7 @@ GetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if (NS_OK == b->NamedItem(name, &prop)) {
NS_RELEASE(b);
if (NULL != prop) {
// get the js object
if (prop != nsnull) {
@ -661,7 +662,15 @@ GetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
*vp = JSVAL_NULL;
}
}
NS_RELEASE(b);
else {
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
else {
NS_RELEASE(b);

Просмотреть файл

@ -249,6 +249,7 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
if (NS_OK == a->QueryInterface(kINSHTMLFormElementIID, (void **)&b)) {
if (NS_OK == b->NamedItem(name, &prop)) {
NS_RELEASE(b);
if (NULL != prop) {
// get the js object
if (prop != nsnull) {
@ -268,7 +269,15 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
*vp = JSVAL_NULL;
}
}
NS_RELEASE(b);
else {
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
PRBool rval;
rval = object->GetProperty(cx, id, vp);
NS_RELEASE(object);
return rval;
}
}
}
else {
NS_RELEASE(b);

Просмотреть файл

@ -315,6 +315,15 @@ static const char *kPropFuncNamedItemStr =
" if (NULL != prop) {\n"
"%s"
" }\n"
" else {\n"
" nsIJSScriptObject *object;\n"
" if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {\n"
" PRBool rval;\n"
" rval = object->%sProperty(cx, id, vp);\n"
" NS_RELEASE(object);\n"
" return rval;\n"
" }\n"
" }\n"
" }\n"
" else {\n"
" return JS_FALSE;\n"
@ -337,10 +346,19 @@ static const char *kPropFuncNamedItemNonPrimaryStr =
"\n"
" if (NS_OK == a->QueryInterface(kI%sIID, (void **)&b)) {\n"
" if (NS_OK == b->NamedItem(name, %sprop)) {\n"
" NS_RELEASE(b);\n"
" if (NULL != prop) {\n"
"%s"
" }\n"
" NS_RELEASE(b);\n"
" else {\n"
" nsIJSScriptObject *object;\n"
" if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {\n"
" PRBool rval;\n"
" rval = object->%sProperty(cx, id, vp);\n"
" NS_RELEASE(object);\n"
" return rval;\n"
" }\n"
" }\n"
" }\n"
" else {\n"
" NS_RELEASE(b);\n"
@ -601,13 +619,13 @@ JSStubGen::GeneratePropGetter(ofstream *file,
else if (JSSTUBGEN_NAMED_ITEM == aType) {
sprintf(buf, kPropFuncNamedItemStr, attr_type,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
case_str, "Get");
}
else if (JSSTUBGEN_NAMED_ITEM_NONPRIMARY == aType) {
sprintf(buf, kPropFuncNamedItemNonPrimaryStr, attr_type,
aInterface.GetName(), aInterface.GetName(),
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str, aInterface.GetName());
case_str, "Get", aInterface.GetName());
}
*file << buf;