1
/* ====================================================================
2
* Copyright (c) 2007-2008 Open Source Applications Foundation.
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:
11
* The above copyright notice and this permission notice shall be included
12
* in all copies or substantial portions of the Software.
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
* ====================================================================
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
6
* http://www.apache.org/licenses/LICENSE-2.0
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.
44
35
static PyObject *t_fp_repr(t_fp *self);
45
36
static PyObject *t_fp_iter(t_fp *self);
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);
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);
55
PyTypeObject FinalizerClass$$Type = {
48
56
PyObject_HEAD_INIT(NULL)
50
58
"jcc.FinalizerClass", /* tp_name */
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 */
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 */
116
PyTypeObject FinalizerProxy$$Type = {
90
117
PyObject_HEAD_INIT(NULL)
92
119
"jcc.FinalizerProxy", /* tp_name */
185
212
return PyObject_SetAttr(self->object, name, value);
215
static Py_ssize_t t_fp_map_length(t_fp *self)
217
return PyMapping_Size(self->object);
220
static PyObject *t_fp_map_get(t_fp *self, PyObject *key)
222
return PyObject_GetItem(self->object, key);
225
static int t_fp_map_set(t_fp *self, PyObject *key, PyObject *value)
228
return PyObject_DelItem(self->object, key);
230
return PyObject_SetItem(self->object, key, value);
233
static Py_ssize_t t_fp_seq_length(t_fp *self)
235
return PySequence_Length(self->object);
238
static PyObject *t_fp_seq_get(t_fp *self, Py_ssize_t n)
240
return PySequence_GetItem(self->object, n);
243
static int t_fp_seq_contains(t_fp *self, PyObject *value)
245
return PySequence_Contains(self->object, value);
248
static PyObject *t_fp_seq_concat(t_fp *self, PyObject *arg)
250
return PySequence_Concat(self->object, arg);
253
static PyObject *t_fp_seq_repeat(t_fp *self, Py_ssize_t n)
255
return PySequence_Repeat(self->object, n);
258
static PyObject *t_fp_seq_getslice(t_fp *self, Py_ssize_t low, Py_ssize_t high)
260
return PySequence_GetSlice(self->object, low, high);
263
static int t_fp_seq_set(t_fp *self, Py_ssize_t i, PyObject *value)
265
return PySequence_SetItem(self->object, i, value);
268
static int t_fp_seq_setslice(t_fp *self, Py_ssize_t low,
269
Py_ssize_t high, PyObject *arg)
271
return PySequence_SetSlice(self->object, low, high, arg);
274
static PyObject *t_fp_seq_inplace_concat(t_fp *self, PyObject *arg)
276
return PySequence_InPlaceConcat(self->object, arg);
279
static PyObject *t_fp_seq_inplace_repeat(t_fp *self, Py_ssize_t n)
281
return PySequence_InPlaceRepeat(self->object, n);
189
285
/* const variable descriptor */
197
jclass (*initializeClass)(void);
293
getclassfn initializeClass;
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
205
302
static void t_descriptor_dealloc(t_descriptor *self);
206
303
static PyObject *t_descriptor___get__(t_descriptor *self,
256
353
static void t_descriptor_dealloc(t_descriptor *self)
258
355
if (self->flags & DESCRIPTOR_VALUE)
259
357
Py_DECREF(self->access.value);
260
359
self->ob_type->tp_free((PyObject *) self);
263
362
PyObject *make_descriptor(PyTypeObject *value)
265
364
t_descriptor *self = (t_descriptor *)
266
ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
365
ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
275
374
return (PyObject *) self;
278
PyObject *make_descriptor(jclass (*initializeClass)(void))
377
PyObject *make_descriptor(getclassfn initializeClass)
280
379
t_descriptor *self = (t_descriptor *)
281
ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
380
ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
289
388
return (PyObject *) self;
391
PyObject *make_descriptor(getclassfn initializeClass, int generics)
393
t_descriptor *self = (t_descriptor *) make_descriptor(initializeClass);
395
if (self && generics)
396
self->flags |= DESCRIPTOR_GENERIC;
398
return (PyObject *) self;
292
401
PyObject *make_descriptor(PyObject *value)
294
403
t_descriptor *self = (t_descriptor *)
295
ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
404
ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
305
414
return (PyObject *) self;
417
PyObject *make_descriptor(PyObject *(*wrapfn)(const jobject &))
419
return make_descriptor(PyCObject_FromVoidPtr((void *) wrapfn, NULL));
308
422
PyObject *make_descriptor(jboolean b)
310
424
t_descriptor *self = (t_descriptor *)
311
ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
425
ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
323
437
PyObject *make_descriptor(jbyte value)
325
439
t_descriptor *self = (t_descriptor *)
326
ConstVariableDescriptorType.tp_alloc(&ConstVariableDescriptorType, 0);
440
ConstVariableDescriptor$$Type.tp_alloc(&ConstVariableDescriptor$$Type, 0);
330
self->access.value = PyString_FromStringAndSize((char *) &value, 1);
444
self->access.value = PyInt_FromLong(value);
331
445
self->flags = DESCRIPTOR_VALUE;