Changeset 28953 in vbox
- Timestamp:
- May 2, 2010 7:26:40 AM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 60952
- Location:
- trunk/src/libs/xpcom18a4/python/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/libs/xpcom18a4/python/src/PyIID.cpp
r11746 r28953 66 66 int size = (*pb->bf_getreadbuffer)(obBuf, 0, &buf); 67 67 if (size != sizeof(nsIID) || buf==NULL) { 68 #ifdef VBOX 69 PyErr_Format(PyExc_ValueError, "A buffer object to be converted to an IID must be exactly %u bytes long", sizeof(nsIID)); 70 #else 68 71 PyErr_Format(PyExc_ValueError, "A buffer object to be converted to an IID must be exactly %d bytes long", sizeof(nsIID)); 72 #endif 69 73 return NULL; 70 74 } … … 194 198 Py_nsIID *s_iid = (Py_nsIID *)self; 195 199 Py_nsIID *o_iid = (Py_nsIID *)other; 196 int rc = memcmp(&s_iid->m_iid, &o_iid->m_iid, sizeof(s_iid->m_iid)); 200 int rc = memcmp(&s_iid->m_iid, &o_iid->m_iid, sizeof(s_iid->m_iid)); 197 201 return rc == 0 ? 0 : (rc < 0 ? -1 : 1); 198 202 } -
trunk/src/libs/xpcom18a4/python/src/VariantUtils.cpp
r11746 r28953 190 190 case nsXPTType::T_U8: 191 191 case nsXPTType::T_I8: 192 ret = sizeof(PRInt8); 192 ret = sizeof(PRInt8); 193 193 break; 194 194 case nsXPTType::T_I16: 195 195 case nsXPTType::T_U16: 196 ret = sizeof(PRInt16); 196 ret = sizeof(PRInt16); 197 197 break; 198 198 case nsXPTType::T_I32: 199 199 case nsXPTType::T_U32: 200 ret = sizeof(PRInt32); 200 ret = sizeof(PRInt32); 201 201 break; 202 202 case nsXPTType::T_I64: 203 203 case nsXPTType::T_U64: 204 ret = sizeof(PRInt64); 204 ret = sizeof(PRInt64); 205 205 break; 206 206 case nsXPTType::T_FLOAT: 207 ret = sizeof(float); 207 ret = sizeof(float); 208 208 break; 209 209 case nsXPTType::T_DOUBLE: 210 ret = sizeof(double); 210 ret = sizeof(double); 211 211 break; 212 212 case nsXPTType::T_BOOL: 213 ret = sizeof(PRBool); 213 ret = sizeof(PRBool); 214 214 break; 215 215 case nsXPTType::T_CHAR: 216 ret = sizeof(char); 216 ret = sizeof(char); 217 217 break; 218 218 case nsXPTType::T_WCHAR: 219 ret = sizeof(PRUnichar); 219 ret = sizeof(PRUnichar); 220 220 break; 221 221 case nsXPTType::T_IID: … … 240 240 } 241 241 242 static nsresult 243 GetArrayElementIID(Py_nsISupports* self, 242 static nsresult 243 GetArrayElementIID(Py_nsISupports* self, 244 244 nsXPTCVariant* dispatchParams, 245 245 PRUint16 methodIndex, … … 250 250 nsCOMPtr<nsIInterfaceInfo> ii; 251 251 nsresult rc; 252 252 253 253 rc = iim->GetInfoForIID(&self->m_iid, getter_AddRefs(ii)); 254 254 if (NS_FAILED(rc)) 255 255 return rc; 256 256 257 257 258 258 const nsXPTMethodInfo *mi; 259 259 rc = ii->GetMethodInfo(methodIndex, &mi); 260 260 if (NS_FAILED(rc)) 261 261 return rc; 262 262 263 263 const nsXPTParamInfo& paramInfo = mi->GetParam(paramIndex); 264 264 … … 272 272 if (NS_FAILED(rc)) 273 273 return rc; 274 274 275 275 PRUint8 tag = elemType.TagPart(); 276 276 if (tag == nsXPTType::T_INTERFACE) … … 282 282 PyXPCOM_LogWarning("Unable to handle T_INTERFACE_IS yet\n"); 283 283 return NS_ERROR_NOT_IMPLEMENTED; 284 } 285 else 284 } 285 else 286 286 { 287 287 // this may be valid case, for arrays of other types … … 289 289 rc = NS_ERROR_INVALID_ARG; 290 290 } 291 291 292 292 return rc; 293 293 } … … 353 353 // If it is NOT a string, we just fall through and allow the standard 354 354 // sequence unpack code process it (just slower!) 355 if ( array_type == nsXPTType::T_U8 && 355 if ( array_type == nsXPTType::T_U8 && 356 356 (PyString_Check(sequence_ob) || PyUnicode_Check(sequence_ob))) { 357 357 … … 536 536 Py_DECREF(val); 537 537 } 538 return rc; 538 return rc; 539 539 } 540 540 … … 653 653 }; 654 654 655 static PRUint16 BestVariantTypeForPyObject( PyObject *ob, BVFTResult *pdata = NULL) 655 static PRUint16 BestVariantTypeForPyObject( PyObject *ob, BVFTResult *pdata = NULL) 656 656 { 657 657 nsISupports *ps = NULL; … … 959 959 // params share a size_is fields - first time sets it, subsequent 960 960 // time check it. 961 PRBool have_set_auto; 961 PRBool have_set_auto; 962 962 }; 963 963 … … 1017 1017 m_pyparams=nsnull; 1018 1018 m_num_array = 0; 1019 m_methodindex = methodindex; 1019 m_methodindex = methodindex; 1020 1020 // Parent should never die before we do, but let's not take the chance. 1021 1021 m_parent = parent; … … 1083 1083 // NOTE: The length of the typedescs may be different than the 1084 1084 // args actually passed. The typedescs always include all 1085 // hidden params (such as "size_is"), while the actual 1085 // hidden params (such as "size_is"), while the actual 1086 1086 // args never include this. 1087 1087 m_num_array = PySequence_Length(typedescs); … … 1102 1102 // Pull apart the typedesc tuple back into a structure we can work with. 1103 1103 PythonTypeDescriptor &ptd = m_python_type_desc_array[i]; 1104 PRBool this_ok = PyArg_ParseTuple(desc_object, "bbbbO:type_desc", 1104 PRBool this_ok = PyArg_ParseTuple(desc_object, "bbbbO:type_desc", 1105 1105 &ptd.param_flags, &ptd.type_flags, &ptd.argnum, &ptd.argnum2, &ptd.extra); 1106 1106 Py_DECREF(desc_object); … … 1113 1113 // If not, its really an internal error rather than the user. 1114 1114 if (PySequence_Length(m_pyparams) != total_params_needed) { 1115 #ifdef VBOX 1116 PyErr_Format(PyExc_ValueError, "The type descriptions indicate %d args are needed, but %u were provided", 1117 total_params_needed, PySequence_Length(m_pyparams)); 1118 #else 1115 1119 PyErr_Format(PyExc_ValueError, "The type descriptions indicate %d args are needed, but %d were provided", 1116 1120 total_params_needed, PySequence_Length(m_pyparams)); 1121 #endif 1117 1122 goto done; 1118 1123 } … … 1174 1179 { 1175 1180 NS_ABORT_IF_FALSE(var_index < m_num_array, "var_index param is invalid"); 1176 PRUint8 argnum = is_arg1 ? 1181 PRUint8 argnum = is_arg1 ? 1177 1182 m_python_type_desc_array[var_index].argnum : 1178 1183 m_python_type_desc_array[var_index].argnum2; … … 1201 1206 { 1202 1207 NS_ABORT_IF_FALSE(var_index < m_num_array, "var_index param is invalid"); 1203 PRUint8 argnum = is_arg1 ? 1208 PRUint8 argnum = is_arg1 ? 1204 1209 m_python_type_desc_array[var_index].argnum : 1205 1210 m_python_type_desc_array[var_index].argnum2; … … 1342 1347 // We created it - flag as such for cleanup. 1343 1348 ns_v.flags |= nsXPTCVariant::VAL_IS_DOMSTR; 1344 1349 1345 1350 if (!PyObject_AsNSString(val, *s)) 1346 1351 BREAK_FALSE; … … 1369 1374 if (!val_use) 1370 1375 BREAK_FALSE; 1371 ns_v.val.p = new nsCString(PyString_AS_STRING(val_use), 1376 ns_v.val.p = new nsCString(PyString_AS_STRING(val_use), 1372 1377 PyString_GET_SIZE(val_use)); 1373 1378 } … … 1392 1397 break; 1393 1398 } 1394 1399 1395 1400 if (!PyString_Check(val) && !PyUnicode_Check(val)) { 1396 1401 PyErr_SetString(PyExc_TypeError, "This parameter must be a string or Unicode object"); … … 1435 1440 BREAK_FALSE; 1436 1441 if (!Py_nsISupports::InterfaceFromPyObject( 1437 val, 1438 iid, 1439 (nsISupports **)&ns_v.val.p, 1442 val, 1443 iid, 1444 (nsISupports **)&ns_v.val.p, 1440 1445 PR_TRUE)) 1441 1446 BREAK_FALSE; … … 1463 1468 iid = Py_nsIID_NULL; 1464 1469 if (!Py_nsISupports::InterfaceFromPyObject( 1465 val, 1466 iid, 1467 (nsISupports **)&ns_v.val.p, 1470 val, 1471 iid, 1472 (nsISupports **)&ns_v.val.p, 1468 1473 PR_TRUE)) 1469 1474 BREAK_FALSE; … … 1534 1539 int seq_length = PySequence_Length(val); 1535 1540 cb_this_buffer_pointer = seq_length * element_size; 1536 if (cb_this_buffer_pointer==0) 1541 if (cb_this_buffer_pointer==0) 1537 1542 // prevent assertions allocing zero bytes. Can't use NULL. 1538 cb_this_buffer_pointer = 1; 1543 cb_this_buffer_pointer = 1; 1539 1544 MAKE_VALUE_BUFFER(cb_this_buffer_pointer); 1540 1545 memset(this_buffer_pointer, 0, cb_this_buffer_pointer); … … 1719 1724 break; 1720 1725 // case nsXPTType::T_VOID: 1721 case nsXPTType::T_IID: 1726 case nsXPTType::T_IID: 1722 1727 ret = Py_nsIID::PyObjectFromIID( **((nsIID **)ns_v.ptr) ); 1723 1728 break; … … 1806 1811 nsresult res = GetArrayElementIID(m_parent, 1807 1812 m_var_array, 1808 m_methodindex, 1809 index, 1813 m_methodindex, 1814 index, 1810 1815 &iid); 1811 ret = UnpackSingleArray(m_parent, * ((void **)ns_v.ptr), 1812 seq_size, array_type&XPT_TDP_TAGMASK, 1816 ret = UnpackSingleArray(m_parent, * ((void **)ns_v.ptr), 1817 seq_size, array_type&XPT_TDP_TAGMASK, 1813 1818 NS_SUCCEEDED(res) ? &iid : NULL); 1814 1819 break; … … 1919 1924 // no references added - this class is only alive for 1920 1925 // a single gateway invocation 1921 m_gateway = gw; 1926 m_gateway = gw; 1922 1927 m_method_index = method_index; 1923 1928 m_python_type_desc_array = NULL; … … 1975 1980 { 1976 1981 NS_ABORT_IF_FALSE(var_index < m_num_type_descs, "var_index param is invalid"); 1977 PRUint8 argnum = is_arg1 ? 1982 PRUint8 argnum = is_arg1 ? 1978 1983 m_python_type_desc_array[var_index].argnum : 1979 1984 m_python_type_desc_array[var_index].argnum2; … … 1985 1990 { 1986 1991 NS_ABORT_IF_FALSE(var_index < m_num_type_descs, "var_index param is invalid"); 1987 PRUint8 argnum = is_arg1 ? 1992 PRUint8 argnum = is_arg1 ? 1988 1993 m_python_type_desc_array[var_index].argnum : 1989 1994 m_python_type_desc_array[var_index].argnum2; … … 2013 2018 { 2014 2019 NS_ABORT_IF_FALSE(var_index < m_num_type_descs, "var_index param is invalid"); 2015 PRUint8 argnum = is_arg1 ? 2020 PRUint8 argnum = is_arg1 ? 2016 2021 m_python_type_desc_array[var_index].argnum : 2017 2022 m_python_type_desc_array[var_index].argnum2; … … 2540 2545 } 2541 2546 // It we have an "inout" param, but an "in" count, then 2542 // it is probably a buffer the caller expects us to 2547 // it is probably a buffer the caller expects us to 2543 2548 // fill in-place! 2544 2549 bBackFill = pi->IsIn(); … … 2596 2601 } 2597 2602 // It we have an "inout" param, but an "in" count, then 2598 // it is probably a buffer the caller expects us to 2603 // it is probably a buffer the caller expects us to 2599 2604 // fill in-place! 2600 2605 bBackFill = pi->IsIn(); … … 2646 2651 } 2647 2652 // It we have an "inout" param, but an "in" count, then 2648 // it is probably a buffer the caller expects us to 2653 // it is probably a buffer the caller expects us to 2649 2654 // fill in-place! 2650 2655 bBackFill = pi->IsIn(); … … 2770 2775 for (i=0;NS_SUCCEEDED(rc) && i<m_info->GetParamCount();i++) { 2771 2776 // If weve already done it, or dont need to do it! 2772 if (i==index_retval || m_python_type_desc_array[i].is_auto_out) 2777 if (i==index_retval || m_python_type_desc_array[i].is_auto_out) 2773 2778 continue; 2774 2779 nsXPTParamInfo *pi = (nsXPTParamInfo *)m_info->params+i;
Note:
See TracChangeset
for help on using the changeset viewer.