VirtualBox

Changeset 28953 in vbox


Ignore:
Timestamp:
May 2, 2010 7:26:40 AM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
60952
Message:

python bridge: format errors,spaces

Location:
trunk/src/libs/xpcom18a4/python/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/python/src/PyIID.cpp

    r11746 r28953  
    6666                        int size = (*pb->bf_getreadbuffer)(obBuf, 0, &buf);
    6767                        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
    6871                                PyErr_Format(PyExc_ValueError, "A buffer object to be converted to an IID must be exactly %d bytes long", sizeof(nsIID));
     72#endif
    6973                                return NULL;
    7074                        }
     
    194198        Py_nsIID *s_iid = (Py_nsIID *)self;
    195199        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));
    197201        return rc == 0 ? 0 : (rc < 0 ? -1 : 1);
    198202}
  • trunk/src/libs/xpcom18a4/python/src/VariantUtils.cpp

    r11746 r28953  
    190190                case nsXPTType::T_U8:
    191191                case nsXPTType::T_I8:
    192                         ret = sizeof(PRInt8); 
     192                        ret = sizeof(PRInt8);
    193193                        break;
    194194                case nsXPTType::T_I16:
    195195                case nsXPTType::T_U16:
    196                         ret = sizeof(PRInt16); 
     196                        ret = sizeof(PRInt16);
    197197                        break;
    198198                case nsXPTType::T_I32:
    199199                case nsXPTType::T_U32:
    200                         ret = sizeof(PRInt32); 
     200                        ret = sizeof(PRInt32);
    201201                        break;
    202202                case nsXPTType::T_I64:
    203203                case nsXPTType::T_U64:
    204                         ret = sizeof(PRInt64); 
     204                        ret = sizeof(PRInt64);
    205205                        break;
    206206                case nsXPTType::T_FLOAT:
    207                         ret = sizeof(float); 
     207                        ret = sizeof(float);
    208208                        break;
    209209                case nsXPTType::T_DOUBLE:
    210                         ret = sizeof(double); 
     210                        ret = sizeof(double);
    211211                        break;
    212212                case nsXPTType::T_BOOL:
    213                         ret = sizeof(PRBool); 
     213                        ret = sizeof(PRBool);
    214214                        break;
    215215                case nsXPTType::T_CHAR:
    216                         ret = sizeof(char); 
     216                        ret = sizeof(char);
    217217                        break;
    218218                case nsXPTType::T_WCHAR:
    219                         ret = sizeof(PRUnichar); 
     219                        ret = sizeof(PRUnichar);
    220220                        break;
    221221                case nsXPTType::T_IID:
     
    240240}
    241241
    242 static nsresult 
    243 GetArrayElementIID(Py_nsISupports*   self, 
     242static nsresult
     243GetArrayElementIID(Py_nsISupports*   self,
    244244                   nsXPTCVariant*    dispatchParams,
    245245                   PRUint16          methodIndex,
     
    250250        nsCOMPtr<nsIInterfaceInfo> ii;
    251251        nsresult rc;
    252        
     252
    253253        rc = iim->GetInfoForIID(&self->m_iid, getter_AddRefs(ii));
    254254        if (NS_FAILED(rc))
    255255                return rc;
    256256
    257        
     257
    258258        const nsXPTMethodInfo *mi;
    259259        rc = ii->GetMethodInfo(methodIndex, &mi);
    260260        if (NS_FAILED(rc))
    261261                return rc;
    262        
     262
    263263        const nsXPTParamInfo& paramInfo = mi->GetParam(paramIndex);
    264264
     
    272272        if (NS_FAILED(rc))
    273273             return rc;
    274        
     274
    275275        PRUint8 tag = elemType.TagPart();
    276276        if (tag == nsXPTType::T_INTERFACE)
     
    282282          PyXPCOM_LogWarning("Unable to handle T_INTERFACE_IS yet\n");
    283283          return NS_ERROR_NOT_IMPLEMENTED;
    284         } 
    285         else 
     284        }
     285        else
    286286        {
    287287          // this may be valid case, for arrays of other types
     
    289289          rc = NS_ERROR_INVALID_ARG;
    290290        }
    291        
     291
    292292        return rc;
    293293}
     
    353353        // If it is NOT a string, we just fall through and allow the standard
    354354        // sequence unpack code process it (just slower!)
    355         if ( array_type == nsXPTType::T_U8 && 
     355        if ( array_type == nsXPTType::T_U8 &&
    356356                (PyString_Check(sequence_ob) || PyUnicode_Check(sequence_ob))) {
    357357
     
    536536                Py_DECREF(val);
    537537        }
    538         return rc;     
     538        return rc;
    539539}
    540540
     
    653653};
    654654
    655 static PRUint16 BestVariantTypeForPyObject( PyObject *ob, BVFTResult *pdata = NULL) 
     655static PRUint16 BestVariantTypeForPyObject( PyObject *ob, BVFTResult *pdata = NULL)
    656656{
    657657        nsISupports *ps = NULL;
     
    959959        // params share a size_is fields - first time sets it, subsequent
    960960        // time check it.
    961         PRBool have_set_auto; 
     961        PRBool have_set_auto;
    962962};
    963963
     
    10171017        m_pyparams=nsnull;
    10181018        m_num_array = 0;
    1019         m_methodindex = methodindex; 
     1019        m_methodindex = methodindex;
    10201020        // Parent should never die before we do, but let's not take the chance.
    10211021        m_parent = parent;
     
    10831083        // NOTE: The length of the typedescs may be different than the
    10841084        // 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
    10861086        // args never include this.
    10871087        m_num_array = PySequence_Length(typedescs);
     
    11021102                // Pull apart the typedesc tuple back into a structure we can work with.
    11031103                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",
    11051105                                        &ptd.param_flags, &ptd.type_flags, &ptd.argnum, &ptd.argnum2, &ptd.extra);
    11061106                Py_DECREF(desc_object);
     
    11131113        // If not, its really an internal error rather than the user.
    11141114        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
    11151119                PyErr_Format(PyExc_ValueError, "The type descriptions indicate %d args are needed, but %d were provided",
    11161120                        total_params_needed, PySequence_Length(m_pyparams));
     1121#endif
    11171122                goto done;
    11181123        }
     
    11741179{
    11751180        NS_ABORT_IF_FALSE(var_index < m_num_array, "var_index param is invalid");
    1176         PRUint8 argnum = is_arg1 ? 
     1181        PRUint8 argnum = is_arg1 ?
    11771182                m_python_type_desc_array[var_index].argnum :
    11781183                m_python_type_desc_array[var_index].argnum2;
     
    12011206{
    12021207        NS_ABORT_IF_FALSE(var_index < m_num_array, "var_index param is invalid");
    1203         PRUint8 argnum = is_arg1 ? 
     1208        PRUint8 argnum = is_arg1 ?
    12041209                m_python_type_desc_array[var_index].argnum :
    12051210                m_python_type_desc_array[var_index].argnum2;
     
    13421347                        // We created it - flag as such for cleanup.
    13431348                        ns_v.flags |= nsXPTCVariant::VAL_IS_DOMSTR;
    1344                        
     1349
    13451350                        if (!PyObject_AsNSString(val, *s))
    13461351                                BREAK_FALSE;
     
    13691374                                if (!val_use)
    13701375                                        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),
    13721377                                                           PyString_GET_SIZE(val_use));
    13731378                        }
     
    13921397                                break;
    13931398                        }
    1394                            
     1399
    13951400                        if (!PyString_Check(val) && !PyUnicode_Check(val)) {
    13961401                                PyErr_SetString(PyExc_TypeError, "This parameter must be a string or Unicode object");
     
    14351440                                BREAK_FALSE;
    14361441                        if (!Py_nsISupports::InterfaceFromPyObject(
    1437                                                val, 
    1438                                                iid, 
    1439                                                (nsISupports **)&ns_v.val.p, 
     1442                                               val,
     1443                                               iid,
     1444                                               (nsISupports **)&ns_v.val.p,
    14401445                                               PR_TRUE))
    14411446                                BREAK_FALSE;
     
    14631468                                iid = Py_nsIID_NULL;
    14641469                        if (!Py_nsISupports::InterfaceFromPyObject(
    1465                                                val, 
    1466                                                iid, 
    1467                                                (nsISupports **)&ns_v.val.p, 
     1470                                               val,
     1471                                               iid,
     1472                                               (nsISupports **)&ns_v.val.p,
    14681473                                               PR_TRUE))
    14691474                                BREAK_FALSE;
     
    15341539                        int seq_length = PySequence_Length(val);
    15351540                        cb_this_buffer_pointer = seq_length * element_size;
    1536                         if (cb_this_buffer_pointer==0) 
     1541                        if (cb_this_buffer_pointer==0)
    15371542                                // prevent assertions allocing zero bytes.  Can't use NULL.
    1538                                 cb_this_buffer_pointer = 1; 
     1543                                cb_this_buffer_pointer = 1;
    15391544                        MAKE_VALUE_BUFFER(cb_this_buffer_pointer);
    15401545                        memset(this_buffer_pointer, 0, cb_this_buffer_pointer);
     
    17191724                break;
    17201725//        case nsXPTType::T_VOID:
    1721           case nsXPTType::T_IID: 
     1726          case nsXPTType::T_IID:
    17221727                ret = Py_nsIID::PyObjectFromIID( **((nsIID **)ns_v.ptr) );
    17231728                break;
     
    18061811                nsresult res = GetArrayElementIID(m_parent,
    18071812                                                  m_var_array,
    1808                                                   m_methodindex, 
    1809                                                   index, 
     1813                                                  m_methodindex,
     1814                                                  index,
    18101815                                                  &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,
    18131818                                        NS_SUCCEEDED(res) ? &iid : NULL);
    18141819                break;
     
    19191924        // no references added - this class is only alive for
    19201925        // a single gateway invocation
    1921         m_gateway = gw; 
     1926        m_gateway = gw;
    19221927        m_method_index = method_index;
    19231928        m_python_type_desc_array = NULL;
     
    19751980{
    19761981        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 ?
    19781983                m_python_type_desc_array[var_index].argnum :
    19791984                m_python_type_desc_array[var_index].argnum2;
     
    19851990{
    19861991        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 ?
    19881993                m_python_type_desc_array[var_index].argnum :
    19891994                m_python_type_desc_array[var_index].argnum2;
     
    20132018{
    20142019        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 ?
    20162021                m_python_type_desc_array[var_index].argnum :
    20172022                m_python_type_desc_array[var_index].argnum2;
     
    25402545                        }
    25412546                        // 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
    25432548                        // fill in-place!
    25442549                        bBackFill = pi->IsIn();
     
    25962601                        }
    25972602                        // 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
    25992604                        // fill in-place!
    26002605                        bBackFill = pi->IsIn();
     
    26462651                        }
    26472652                        // 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
    26492654                        // fill in-place!
    26502655                        bBackFill = pi->IsIn();
     
    27702775                for (i=0;NS_SUCCEEDED(rc) && i<m_info->GetParamCount();i++) {
    27712776                        // 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)
    27732778                                continue;
    27742779                        nsXPTParamInfo *pi = (nsXPTParamInfo *)m_info->params+i;
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette