backing out two changed inadvertantly committed!

This commit is contained in:
jband%netscape.com 2001-02-02 08:52:22 +00:00
parent 1d263ae630
commit 8ccfada88a
2 changed files with 9 additions and 72 deletions

View File

@ -90,7 +90,7 @@ static uint8 xpc_reflectable_flags[XPC_FLAG_COUNT] = {
XPC_MK_FLAG( 1 , 1 , 1 , 0 ), /* T_WCHAR */
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* T_VOID */
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_IID */
XPC_MK_FLAG( 0 , 1 , 0 , 0 ), /* T_DOMSTRING */
XPC_MK_FLAG( 0 , 0 , 0 , 0 ), /* T_DOMSTRING */
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_CHAR_STR */
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_WCHAR_STR */
XPC_MK_FLAG( 0 , 1 , 0 , 1 ), /* T_INTERFACE */
@ -347,35 +347,9 @@ XPCConvert::NativeData2JS(JSContext* cx, jsval* d, const void* s,
}
case nsXPTType::T_DOMSTRING:
{
const nsAReadableString* p = *((const nsAReadableString**)s);
if(!p)
break;
PRUint32 length = p->Length();
jschar* chars = (jschar *)
JS_malloc(cx, (length + 1) * sizeof(jschar));
if(!chars)
return JS_FALSE;
if(length && !CopyUnicodeTo(*p, 0, (PRUnichar*)chars, length))
{
JS_free(cx, chars);
return JS_FALSE;
}
chars[length] = 0;
JSString* str;
if(!(str = JS_NewUCString(cx, chars, length)))
{
JS_free(cx, chars);
return JS_FALSE;
}
*d = STRING_TO_JSVAL(str);
break;
}
// XXX implement DOMSTRING
XPC_LOG_ERROR(("XPCConvert::NativeData2JS : DOMSTRING params not supported"));
return JS_FALSE;
case nsXPTType::T_CHAR_STR:
{
@ -612,42 +586,6 @@ XPCConvert::JSData2Native(JSContext* cx, void* d, jsval s,
}
case nsXPTType::T_DOMSTRING:
{
const PRUnichar* chars = nsnull;
PRUint32 length;
JSString* str;
if(!JSVAL_IS_VOID(s) && !JSVAL_IS_NULL(s) &&
nsnull != (str = JS_ValueToString(cx, s)))
{
chars = (const PRUnichar*) JS_GetStringChars(str);
length = (PRUint32) JS_GetStringLength(str);
}
// XXX We don't yet have a way to represent a null nsAXXXString
// (as opposed to one containing an empty string). This comes later.
const static PRUnichar* emptyString = NS_LITERAL_STRING("");
if(!chars)
{
chars = emptyString;
length = 0;
}
if(useAllocator)
{
nsAReadableString* rs = new nsLiteralString(chars, length);
if(!rs)
return JS_FALSE;
*((nsAReadableString**)d) = rs;
}
else
{
nsAWritableString* ws = *((nsAWritableString**)d);
ws->Assign(chars);
}
return JS_TRUE;
}
// XXX implement DOMSTRING
XPC_LOG_ERROR(("XPCConvert::JSData2Native : DOMSTRING params not supported"));
return JS_FALSE;

View File

@ -274,7 +274,7 @@ XPC_IMPLEMENT_IGNORE_CONSTRUCT(nsJSIID)
XPC_IMPLEMENT_FORWARD_FINALIZE(nsJSIID)
nsJSIID::nsJSIID()
: mObj(nsnull)
: mCacheFilled(JS_FALSE)
{
NS_INIT_ISUPPORTS();
}
@ -479,8 +479,7 @@ nsJSIID::FillCache(JSContext *cx, JSObject *obj,
}
}
// Indicate that we've added the properties to the current object.
mObj = obj;
mCacheFilled = JS_TRUE;
return;
}
@ -503,7 +502,7 @@ nsJSIID::LookupProperty(JSContext *cx, JSObject *obj,
nsIXPCScriptable* arbitrary,
JSBool* retval)
{
if(NeedToFillCache(obj))
if(!mCacheFilled)
FillCache(cx, obj, wrapper, arbitrary);
return arbitrary->LookupProperty(cx, obj, id, objp, propp, wrapper,
nsnull, retval);
@ -516,7 +515,7 @@ nsJSIID::GetProperty(JSContext *cx, JSObject *obj,
nsIXPCScriptable* arbitrary,
JSBool* retval)
{
if(NeedToFillCache(obj))
if(!mCacheFilled)
FillCache(cx, obj, wrapper, arbitrary);
return arbitrary->GetProperty(cx, obj, id, vp, wrapper, nsnull, retval);
}
@ -530,7 +529,7 @@ nsJSIID::Enumerate(JSContext *cx, JSObject *obj,
nsIXPCScriptable *arbitrary,
JSBool *retval)
{
if(enum_op == JSENUMERATE_INIT && NeedToFillCache(obj))
if(enum_op == JSENUMERATE_INIT && !mCacheFilled)
FillCache(cx, obj, wrapper, arbitrary);
return arbitrary->Enumerate(cx, obj, enum_op, statep, idp, wrapper,