~ubuntu-branches/debian/sid/jcc/sid

« back to all changes in this revision

Viewing changes to jcc/sources/functions.cpp

  • Committer: Package Import Robot
  • Author(s): Ludovico Cavedon
  • Date: 2012-06-25 00:27:38 UTC
  • mfrom: (1.1.9)
  • Revision ID: package-import@ubuntu.com-20120625002738-cfontjqhjdgpd53f
Tags: 2.13-1
* Imported Upstream version 2.13
* Update Standrads-Version to 3.9.3.
* Use debhelper compat 9.
* Update copyright file to machine-readable format 1.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1262
1262
 
1263
1263
    for (int i = 0; i < length; i++) {
1264
1264
        PyObject *obj = PySequence_GetItem(sequence, i);
1265
 
        int fromString = 0;
 
1265
        int deleteLocal = 0;
1266
1266
        jobject jobj;
1267
1267
 
1268
1268
        if (!obj)
1272
1272
        else if (PyString_Check(obj) || PyUnicode_Check(obj))
1273
1273
        {
1274
1274
            jobj = env->fromPyString(obj);
1275
 
            fromString = 1;
 
1275
            deleteLocal = 1;
1276
1276
        }
1277
1277
        else if (PyObject_TypeCheck(obj, &PY_TYPE(JObject)))
1278
1278
            jobj = ((t_JObject *) obj)->object.this$;
1279
1279
        else if (PyObject_TypeCheck(obj, &PY_TYPE(FinalizerProxy)))
1280
1280
            jobj = ((t_JObject *) ((t_fp *) obj)->object)->object.this$;
1281
 
        else /* todo: add auto-boxing of primitive types */
 
1281
        else if (obj == Py_True || obj == Py_False)
 
1282
        {
 
1283
            jobj = env->boxBoolean(obj == Py_True);
 
1284
            deleteLocal = 1;
 
1285
        }
 
1286
        else if (PyFloat_Check(obj))
 
1287
        {
 
1288
            jobj = env->boxDouble(PyFloat_AS_DOUBLE(obj));
 
1289
            deleteLocal = 1;
 
1290
        }
 
1291
        else if (PyInt_Check(obj))
 
1292
        {
 
1293
            jobj = env->boxInteger(PyInt_AS_LONG(obj));
 
1294
            deleteLocal = 1;
 
1295
        }
 
1296
        else if (PyLong_Check(obj))
 
1297
        {
 
1298
            jobj = env->boxLong(PyLong_AsLongLong(obj));
 
1299
            deleteLocal = 1;
 
1300
        }
 
1301
        else
1282
1302
        {
1283
1303
            PyErr_SetObject(PyExc_TypeError, obj);
1284
1304
            Py_DECREF(obj);
1285
1305
            return NULL;
1286
1306
        }
1287
1307
 
1288
 
        Py_DECREF(obj);
1289
 
 
1290
1308
        try {
1291
1309
            env->setObjectArrayElement(array, i, jobj);
1292
 
            if (fromString)
 
1310
            if (deleteLocal)
1293
1311
                vm_env->DeleteLocalRef(jobj);
 
1312
            Py_DECREF(obj);
1294
1313
        } catch (int e) {
 
1314
            Py_DECREF(obj);
1295
1315
            switch (e) {
1296
1316
              case _EXC_JAVA:
1297
1317
                PyErr_SetJavaError();