~james-page/ubuntu/oneiric/jcc/fix-library-linking

« back to all changes in this revision

Viewing changes to jcc/sources/types.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Ludovico Cavedon
  • Date: 2010-01-31 18:00:47 UTC
  • mfrom: (3.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100131180047-jryq701kg5wq4943
Tags: 2.5-3
* Merge patch from Ubuntu by Onkar Shinde:
  - When CPU type is i686, use the JRE lib directory corresponding to i386.
    Fixes FTBFS on lpia.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* ====================================================================
2
 
 * Copyright (c) 2007-2008 Open Source Applications Foundation.
3
 
 *
4
 
 * Permission is hereby granted, free of charge, to any person obtaining a
5
 
 * copy of this software and associated documentation files (the "Software"),
6
 
 * to deal in the Software without restriction, including without limitation
7
 
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8
 
 * and/or sell copies of the Software, and to permit persons to whom the
9
 
 * Software is furnished to do so, subject to the following conditions: 
10
 
 *
11
 
 * The above copyright notice and this permission notice shall be included
12
 
 * in all copies or substantial portions of the Software. 
13
 
 *
14
 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15
 
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
 
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
 
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
 
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19
 
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20
 
 * DEALINGS IN THE SOFTWARE.
21
 
 * ====================================================================
 
1
/*
 
2
 *   Licensed under the Apache License, Version 2.0 (the "License");
 
3
 *   you may not use this file except in compliance with the License.
 
4
 *   You may obtain a copy of the License at
 
5
 *
 
6
 *       http://www.apache.org/licenses/LICENSE-2.0
 
7
 *
 
8
 *   Unless required by applicable law or agreed to in writing, software
 
9
 *   distributed under the License is distributed on an "AS IS" BASIS,
 
10
 *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
11
 *   See the License for the specific language governing permissions and
 
12
 *   limitations under the License.
22
13
 */
23
14
 
24
15
#include <jni.h>
44
35
static PyObject *t_fp_repr(t_fp *self);
45
36
static PyObject *t_fp_iter(t_fp *self);
46
37
 
47
 
PyTypeObject FinalizerClassType = {
 
38
static Py_ssize_t t_fp_map_length(t_fp *self);
 
39
static PyObject *t_fp_map_get(t_fp *self, PyObject *key);
 
40
static int t_fp_map_set(t_fp *self, PyObject *key, PyObject *value);
 
41
 
 
42
static Py_ssize_t t_fp_seq_length(t_fp *self);
 
43
static PyObject *t_fp_seq_get(t_fp *self, Py_ssize_t n);
 
44
static int t_fp_seq_contains(t_fp *self, PyObject *value);
 
45
static PyObject *t_fp_seq_concat(t_fp *self, PyObject *arg);
 
46
static PyObject *t_fp_seq_repeat(t_fp *self, Py_ssize_t n);
 
47
static PyObject *t_fp_seq_getslice(t_fp *self, Py_ssize_t low, Py_ssize_t high);
 
48
static int t_fp_seq_set(t_fp *self, Py_ssize_t i, PyObject *value);
 
49
static int t_fp_seq_setslice(t_fp *self, Py_ssize_t low,
 
50
                             Py_ssize_t high, PyObject *arg);
 
51
static PyObject *t_fp_seq_inplace_concat(t_fp *self, PyObject *arg);
 
52
static PyObject *t_fp_seq_inplace_repeat(t_fp *self, Py_ssize_t n);
 
53
 
 
54
 
 
55
PyTypeObject FinalizerClass$$Type = {
48
56
    PyObject_HEAD_INIT(NULL)
49
57
    0,                                   /* ob_size */
50
58
    "jcc.FinalizerClass",                /* tp_name */
86
94
    0,                                   /* tp_new */
87
95
};
88
96
 
89
 
PyTypeObject FinalizerProxyType = {
 
97
static PyMappingMethods t_fp_as_mapping = {
 
98
    (lenfunc)t_fp_map_length,            /* mp_length          */
 
99
    (binaryfunc)t_fp_map_get,            /* mp_subscript       */
 
100
    (objobjargproc)t_fp_map_set,         /* mp_ass_subscript   */
 
101
};
 
102
 
 
103
static PySequenceMethods t_fp_as_sequence = {
 
104
    (lenfunc)t_fp_seq_length,                 /* sq_length */
 
105
    (binaryfunc)t_fp_seq_concat,              /* sq_concat */
 
106
    (ssizeargfunc)t_fp_seq_repeat,            /* sq_repeat */
 
107
    (ssizeargfunc)t_fp_seq_get,               /* sq_item */
 
108
    (ssizessizeargfunc)t_fp_seq_getslice,     /* sq_slice */
 
109
    (ssizeobjargproc)t_fp_seq_set,            /* sq_ass_item */
 
110
    (ssizessizeobjargproc)t_fp_seq_setslice,  /* sq_ass_slice */
 
111
    (objobjproc)t_fp_seq_contains,            /* sq_contains */
 
112
    (binaryfunc)t_fp_seq_inplace_concat,      /* sq_inplace_concat */
 
113
    (ssizeargfunc)t_fp_seq_inplace_repeat,    /* sq_inplace_repeat */
 
114
};
 
115
 
 
116
PyTypeObject FinalizerProxy$$Type = {
90
117
    PyObject_HEAD_INIT(NULL)
91
118
    0,                                   /* ob_size */
92
119
    "jcc.FinalizerProxy",                /* tp_name */
99
126
    0,                                   /* tp_compare */
100
127
    (reprfunc)t_fp_repr,                 /* tp_repr */
101
128
    0,                                   /* tp_as_number */
102
 
    0,                                   /* tp_as_sequence */
103
 
    0,                                   /* tp_as_mapping */
 
129
    &t_fp_as_sequence,                   /* tp_as_sequence */
 
130
    &t_fp_as_mapping,                    /* tp_as_mapping */
104
131
    0,                                   /* tp_hash  */
105
132
    0,                                   /* tp_call */
106
133
    0,                                   /* tp_str */
135
162
 
136
163
    if (obj)
137
164
    {
138
 
        t_fp *fp = (t_fp *) FinalizerProxyType.tp_alloc(&FinalizerProxyType, 0);
 
165
        t_fp *fp = (t_fp *) FinalizerProxy$$Type.tp_alloc(&FinalizerProxy$$Type, 0);
139
166
 
140
167
        fp->object = obj;
141
168
        obj = (PyObject *) fp;
185
212
    return PyObject_SetAttr(self->object, name, value);
186
213
}
187
214
 
 
215
static Py_ssize_t t_fp_map_length(t_fp *self)
 
216
{
 
217
    return PyMapping_Size(self->object);
 
218
}
 
219
 
 
220
static PyObject *t_fp_map_get(t_fp *self, PyObject *key)
 
221
{
 
222
    return PyObject_GetItem(self->object, key);
 
223
}
 
224
 
 
225
static int t_fp_map_set(t_fp *self, PyObject *key, PyObject *value)
 
226
{
 
227
    if (value == NULL)
 
228
        return PyObject_DelItem(self->object, key);
 
229
 
 
230
    return PyObject_SetItem(self->object, key, value);
 
231
}
 
232
 
 
233
static Py_ssize_t t_fp_seq_length(t_fp *self)
 
234
{
 
235
    return PySequence_Length(self->object);
 
236
}
 
237
 
 
238
static PyObject *t_fp_seq_get(t_fp *self, Py_ssize_t n)
 
239
{
 
240
    return PySequence_GetItem(self->object, n);
 
241
}
 
242
 
 
243
static int t_fp_seq_contains(t_fp *self, PyObject *value)
 
244
{
 
245
    return PySequence_Contains(self->object, value);
 
246
}
 
247
 
 
248
static PyObject *t_fp_seq_concat(t_fp *self, PyObject *arg)
 
249
{
 
250
    return PySequence_Concat(self->object, arg);
 
251
}
 
252
 
 
253
static PyObject *t_fp_seq_repeat(t_fp *self, Py_ssize_t n)
 
254
{
 
255
    return PySequence_Repeat(self->object, n);
 
256
}
 
257
 
 
258
static PyObject *t_fp_seq_getslice(t_fp *self, Py_ssize_t low, Py_ssize_t high)
 
259
{
 
260
    return PySequence_GetSlice(self->object, low, high);
 
261
}
 
262
 
 
263
static int t_fp_seq_set(t_fp *self, Py_ssize_t i, PyObject *value)
 
264
{
 
265
    return PySequence_SetItem(self->object, i, value);
 
266
}
 
267
 
 
268
static int t_fp_seq_setslice(t_fp *self, Py_ssize_t low,
 
269
                             Py_ssize_t high, PyObject *arg)
 
270
{
 
271
    return PySequence_SetSlice(self->object, low, high, arg);
 
272
}
 
273
 
 
274
static PyObject *t_fp_seq_inplace_concat(t_fp *self, PyObject *arg)
 
275
{
 
276
    return PySequence_InPlaceConcat(self->object, arg);
 
277
}
 
278
 
 
279
static PyObject *t_fp_seq_inplace_repeat(t_fp *self, Py_ssize_t n)
 
280
{
 
281
    return PySequence_InPlaceRepeat(self->object, n);
 
282
}
 
283
 
188
284
 
189
285
/* const variable descriptor */
190
286
 
194
290
    int flags;
195
291
    union {
196
292
        PyObject *value;
197
 
        jclass (*initializeClass)(void);
 
293
        getclassfn initializeClass;
198
294
    } access;
199
295
};
200
296
    
201
 
#define DESCRIPTOR_VALUE 0x1
202
 
#define DESCRIPTOR_CLASS 0x2
203
 
#define DESCRIPTOR_GETFN 0x4
 
297
#define DESCRIPTOR_VALUE   0x0001
 
298
#define DESCRIPTOR_CLASS   0x0002
 
299
#define DESCRIPTOR_GETFN   0x0004
 
300
#define DESCRIPTOR_GENERIC 0x0008
204
301
 
205
302
static void t_descriptor_dealloc(t_descriptor *self);
206
303
static PyObject *t_descriptor___get__(t_descriptor *self,
211
308
};
212
309
 
213
310
 
214
 
PyTypeObject ConstVariableDescriptorType = {
 
311
PyTypeObject ConstVariableDescriptor$$Type = {
215
312
    PyObject_HEAD_INIT(NULL)
216
313
    0,                                   /* ob_size */
217
314
    "jcc.ConstVariableDescriptor",       /* tp_name */
256
353
static void t_descriptor_dealloc(t_descriptor *self)
257
354
{
258
355
    if (self->flags & DESCRIPTOR_VALUE)
 
356
    {
259
357
        Py_DECREF(self->access.value);
 
358
    }
260
359
    self->ob_type->tp_free((PyObject *) self);
261
360
}
262
361
 
263
362
PyObject *make_descriptor(PyTypeObject *value)
264
363
{
265
364
    t_descriptor *self = (t_descriptor *)
266
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
365
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
267
366
 
268
367
    if (self)
269
368
    {
275
374
    return (PyObject *) self;
276
375
}
277
376
 
278
 
PyObject *make_descriptor(jclass (*initializeClass)(void))
 
377
PyObject *make_descriptor(getclassfn initializeClass)
279
378
{
280
379
    t_descriptor *self = (t_descriptor *)
281
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
380
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
282
381
 
283
382
    if (self)
284
383
    {
289
388
    return (PyObject *) self;
290
389
}
291
390
 
 
391
PyObject *make_descriptor(getclassfn initializeClass, int generics)
 
392
{
 
393
    t_descriptor *self = (t_descriptor *) make_descriptor(initializeClass);
 
394
 
 
395
    if (self && generics)
 
396
        self->flags |= DESCRIPTOR_GENERIC;
 
397
 
 
398
    return (PyObject *) self;
 
399
}
 
400
 
292
401
PyObject *make_descriptor(PyObject *value)
293
402
{
294
403
    t_descriptor *self = (t_descriptor *)
295
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
404
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
296
405
 
297
406
    if (self)
298
407
    {
305
414
    return (PyObject *) self;
306
415
}
307
416
 
 
417
PyObject *make_descriptor(PyObject *(*wrapfn)(const jobject &))
 
418
{
 
419
    return make_descriptor(PyCObject_FromVoidPtr((void *) wrapfn, NULL));
 
420
}
 
421
 
308
422
PyObject *make_descriptor(jboolean b)
309
423
{
310
424
    t_descriptor *self = (t_descriptor *)
311
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
425
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
312
426
 
313
427
    if (self)
314
428
    {
323
437
PyObject *make_descriptor(jbyte value)
324
438
{
325
439
    t_descriptor *self = (t_descriptor *)
326
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
440
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
327
441
 
328
442
    if (self)
329
443
    {
330
 
        self->access.value = PyString_FromStringAndSize((char *) &value, 1);
 
444
        self->access.value = PyInt_FromLong(value);
331
445
        self->flags = DESCRIPTOR_VALUE;
332
446
    }
333
447
 
337
451
PyObject *make_descriptor(jchar value)
338
452
{
339
453
    t_descriptor *self = (t_descriptor *)
340
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
454
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
341
455
 
342
456
    if (self)
343
457
    {
353
467
PyObject *make_descriptor(jdouble value)
354
468
{
355
469
    t_descriptor *self = (t_descriptor *)
356
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
470
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
357
471
 
358
472
    if (self)
359
473
    {
367
481
PyObject *make_descriptor(jfloat value)
368
482
{
369
483
    t_descriptor *self = (t_descriptor *)
370
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
484
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
371
485
 
372
486
    if (self)
373
487
    {
381
495
PyObject *make_descriptor(jint value)
382
496
{
383
497
    t_descriptor *self = (t_descriptor *)
384
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
498
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
385
499
 
386
500
    if (self)
387
501
    {
395
509
PyObject *make_descriptor(jlong value)
396
510
{
397
511
    t_descriptor *self = (t_descriptor *)
398
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
512
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
399
513
 
400
514
    if (self)
401
515
    {
409
523
PyObject *make_descriptor(jshort value)
410
524
{
411
525
    t_descriptor *self = (t_descriptor *)
412
 
        ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
 
526
        ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
413
527
 
414
528
    if (self)
415
529
    {
430
544
    }
431
545
 
432
546
    if (self->flags & DESCRIPTOR_CLASS)
433
 
        return t_Class::wrapObject(Class((*self->access.initializeClass)()));
 
547
    {
 
548
#ifdef _java_generics
 
549
        if (self->flags & DESCRIPTOR_GENERIC)
 
550
            return t_Class::wrap_Object(Class((*self->access.initializeClass)()), (PyTypeObject *) type);
 
551
        else
 
552
#endif
 
553
            return t_Class::wrap_Object(Class((*self->access.initializeClass)()));
 
554
    }
434
555
 
435
556
    Py_RETURN_NONE;
436
557
}