nsCRT::memcpy(pthis, PyString_AS_STRING(sequence_ob), sequence_size);
memcpy(pthis, PyString_AS_STRING(sequence_ob), sequence_size);
PRBool FillSingleArray(void *array_ptr, PyObject *sequence_ob, PRUint32 sequence_size, PRUint32 array_element_size, PRUint8 array_type){	PRUint8 *pthis = (PRUint8 *)array_ptr;	NS_ABORT_IF_FALSE(pthis, "Don't have a valid array to fill!");	PRBool rc = PR_TRUE;	// We handle T_U8 specially as a string/Unicode.	// If it is NOT a string, we just fall through and allow the standard	// sequence unpack code process it (just slower!)	if ( (array_type & XPT_TDP_TAGMASK) == nsXPTType::T_U8 &&         (PyString_Check(sequence_ob) || PyUnicode_Check(sequence_ob))) {                    PRBool release_seq;        if (PyUnicode_Check(sequence_ob)) {            release_seq = PR_TRUE;            sequence_ob = PyObject_Str(sequence_ob);        } else            release_seq = PR_FALSE;        if (!sequence_ob) // presumably a memory error, or Unicode encoding error.            return PR_FALSE;		nsCRT::memcpy(pthis, PyString_AS_STRING(sequence_ob), sequence_size);        if (release_seq)            Py_DECREF(sequence_ob);		return PR_TRUE;	}	for (PRUint32 i=0; rc && i<sequence_size; i++,pthis += array_element_size) {		PyObject *val = PySequence_GetItem(sequence_ob, i);		PyObject *val_use = NULL;		if (val==NULL)			return PR_FALSE;		switch(array_type & XPT_TDP_TAGMASK) {			  case nsXPTType::T_I8:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRInt8, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_I16:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRInt16, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_I32:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRInt32, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_I64:				if ((val_use=PyNumber_Long(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRInt64, PyLong_AsLongLong(val_use) );				break;			  case nsXPTType::T_U8:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRUint8, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_U16:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRUint16, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_U32:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRUint32, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_U64:				if ((val_use=PyNumber_Long(val))==NULL) BREAK_FALSE;				FILL_SIMPLE_POINTER( PRUint64, PyLong_AsUnsignedLongLong(val_use) );				break;			  case nsXPTType::T_FLOAT:				if ((val_use=PyNumber_Float(val))==NULL) BREAK_FALSE				FILL_SIMPLE_POINTER( float, PyFloat_AsDouble(val_use) );				break;			  case nsXPTType::T_DOUBLE:				if ((val_use=PyNumber_Float(val))==NULL) BREAK_FALSE				FILL_SIMPLE_POINTER( double, PyFloat_AsDouble(val_use) );				break;			  case nsXPTType::T_BOOL:				if ((val_use=PyNumber_Int(val))==NULL) BREAK_FALSE				FILL_SIMPLE_POINTER( PRBool, PyInt_AsLong(val_use) );				break;			  case nsXPTType::T_CHAR:				if (!PyString_Check(val) && !PyUnicode_Check(val)) {					PyErr_SetString(PyExc_TypeError, "This parameter must be a string or Unicode object");					BREAK_FALSE;				}				if ((val_use = PyObject_Str(val))==NULL)					BREAK_FALSE;				// Sanity check should PyObject_Str() ever loosen its semantics wrt Unicode!				NS_ABORT_IF_FALSE(PyString_Check(val_use), "PyObject_Str didnt return a string object!");				FILL_SIMPLE_POINTER( char, *PyString_AS_STRING(val_use) );				break;			  case nsXPTType::T_WCHAR:				if (!PyString_Check(val) && !PyUnicode_Check(val)) {					PyErr_SetString(PyExc_TypeError, "This parameter must be a string or Unicode object");					BREAK_FALSE;				}				if ((val_use = PyUnicode_FromObject(val))==NULL)					BREAK_FALSE;				NS_ABORT_IF_FALSE(PyUnicode_Check(val_use), "PyUnicode_FromObject didnt return a Unicode object!");				FILL_SIMPLE_POINTER( PRUnichar, *PyUnicode_AS_UNICODE(val_use) );				break;			  case nsXPTType::T_IID: {				nsIID iid;				if (!Py_nsIID::IIDFromPyObject(val, &iid))					BREAK_FALSE;				nsIID **pp = (nsIID **)pthis;				// If there is an existing IID, free it.				if (*pp)					nsAllocator::Free(*pp);				*pp = (nsIID *)nsAllocator::Alloc(sizeof(nsIID));				if (*pp==NULL) {					PyErr_NoMemory();					BREAK_FALSE;				}				nsCRT::memcpy(*pp, &iid, sizeof(iid));				break;				}		//          case nsXPTType::T_BSTR:			  case nsXPTType::T_CHAR_STR: {				// If it is an existing string, free it.				char **pp = (char **)pthis;				if (*pp)					nsAllocator::Free(*pp);				*pp = nsnull;				if (val == Py_None)					break; // Remains NULL.				if (!PyString_Check(val) && !PyUnicode_Check(val)) {					PyErr_SetString(PyExc_TypeError, "This parameter must be a string or Unicode object");					BREAK_FALSE;				}				if ((val_use = PyObject_Str(val))==NULL)					BREAK_FALSE;				// Sanity check should PyObject_Str() ever loosen its semantics wrt Unicode!				NS_ABORT_IF_FALSE(PyString_Check(val_use), "PyObject_Str didnt return a string object!");				const char *sz = PyString_AS_STRING(val_use);				int nch = PyString_GET_SIZE(val_use);				*pp = (char *)nsAllocator::Alloc(nch+1);				if (*pp==NULL) {					PyErr_NoMemory();					BREAK_FALSE;				}				strncpy(*pp, sz, nch+1);				break;				}			  case nsXPTType::T_WCHAR_STR: {				// If it is an existing string, free it.				PRUnichar **pp = (PRUnichar **)pthis;				if (*pp)					nsAllocator::Free(*pp);				*pp = nsnull;				if (val == Py_None)					break; // Remains NULL.				if (!PyString_Check(val) && !PyUnicode_Check(val)) {					PyErr_SetString(PyExc_TypeError, "This parameter must be a string or Unicode object");					BREAK_FALSE;				}				if ((val_use = PyUnicode_FromObject(val))==NULL)					BREAK_FALSE;				NS_ABORT_IF_FALSE(PyUnicode_Check(val_use), "PyUnicode_FromObject didnt return a Unicode object!");				const PRUnichar *sz = PyUnicode_AS_UNICODE(val_use);				int nch = PyUnicode_GET_SIZE(val_use);				*pp = (PRUnichar *)nsAllocator::Alloc(sizeof(PRUnichar) * (nch+1));				if (*pp==NULL) {					PyErr_NoMemory();					BREAK_FALSE;				}				nsCRT::memcpy(*pp, sz, sizeof(PRUnichar) * (nch + 1));				break;				}			  case nsXPTType::T_INTERFACE:  {				// We do allow NULL here, even tho doing so will no-doubt crash some objects.				// (but there will certainly be objects out there that will allow NULL :-(				nsISupports *pnew;				if (!Py_nsISupports::InterfaceFromPyObject(val, NS_GET_IID(nsISupports), &pnew, PR_TRUE))					BREAK_FALSE;				nsISupports **pp = (nsISupports **)pthis;				if (*pp) {					Py_BEGIN_ALLOW_THREADS; // MUST release thread-lock, incase a Python COM object that re-acquires.					(*pp)->Release();					Py_END_ALLOW_THREADS;				}				*pp = pnew; // ref-count added by InterfaceFromPyObject				break;				}			default:				// try and limp along in this case.				// leave rc TRUE				PyXPCOM_LogWarning("Converting Python object for an array element - The object type (0x%x) is unknown - leaving param alone!\n", array_type);				break;		}		Py_XDECREF(val_use);		Py_DECREF(val);	}	return rc;	}