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

« back to all changes in this revision

Viewing changes to jcc/sources/functions.h

  • 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
#ifndef _functions_h
30
21
#include "java/lang/Object.h"
31
22
#include "macros.h"
32
23
 
 
24
#if PY_VERSION_HEX < 0x02050000
 
25
typedef int Py_ssize_t;
 
26
typedef inquiry lenfunc;
 
27
typedef intargfunc ssizeargfunc;
 
28
typedef intintargfunc ssizessizeargfunc;
 
29
typedef intobjargproc ssizeobjargproc;
 
30
typedef intintobjargproc ssizessizeobjargproc;
 
31
#endif
 
32
 
 
33
typedef jclass (*getclassfn)(void);
 
34
typedef PyTypeObject **(*getparametersfn)(void *);
 
35
 
33
36
PyObject *PyErr_SetArgsError(char *name, PyObject *args);
34
37
PyObject *PyErr_SetArgsError(PyObject *self, char *name, PyObject *args);
35
38
PyObject *PyErr_SetArgsError(PyTypeObject *type, char *name, PyObject *args);
67
70
#endif
68
71
 
69
72
int abstract_init(PyObject *self, PyObject *args, PyObject *kwds);
 
73
PyObject *wrapType(PyTypeObject *type, const jobject& obj);
70
74
 
71
75
PyObject *j2p(const java::lang::String& js);
72
76
java::lang::String p2j(PyObject *object);
73
77
 
74
78
PyObject *make_descriptor(PyTypeObject *value);
75
 
PyObject *make_descriptor(jclass (*initializeClass)(void));
 
79
PyObject *make_descriptor(getclassfn initializeClass);
 
80
PyObject *make_descriptor(getclassfn initializeClass, int generics);
76
81
PyObject *make_descriptor(PyObject *value);
 
82
PyObject *make_descriptor(PyObject *(*wrapfn)(const jobject &));
77
83
PyObject *make_descriptor(jboolean value);
78
84
PyObject *make_descriptor(jbyte value);
79
85
PyObject *make_descriptor(jchar value);
90
96
PyObject *callSuper(PyTypeObject *type, PyObject *self,
91
97
                    const char *name, PyObject *args, int cardinality);
92
98
 
93
 
template<class T> PyObject *get_iterator(PyObject *self)
94
 
{
95
 
    java::util::Iterator iterator((jobject) NULL);
96
 
 
97
 
    OBJ_CALL(iterator = (((T *) self)->object.iterator()));
98
 
    return java::util::t_Iterator::wrapObject(iterator);
99
 
}
100
 
 
101
 
template<class U, class V> PyObject *get_iterator_next(PyObject *self)
102
 
{
103
 
    java::util::t_Iterator *iterator = (java::util::t_Iterator *) self;
104
 
    jboolean hasNext;
105
 
 
106
 
    OBJ_CALL(hasNext = iterator->object.hasNext());
107
 
    if (!hasNext)
108
 
    {
109
 
        PyErr_SetNone(PyExc_StopIteration);
110
 
        return NULL;
111
 
    }
112
 
 
113
 
    V next((jobject) NULL);
114
 
    OBJ_CALL(next = iterator->object.next());
115
 
 
116
 
    jclass cls = java::lang::String::initializeClass();
117
 
    if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
118
 
        return env->fromJString((jstring) next.this$);
119
 
 
120
 
    return U::wrapObject(next);
121
 
}
122
 
 
123
 
template<class U, class V> PyObject *get_enumeration_nextElement(PyObject *self)
124
 
{
125
 
    java::util::t_Enumeration *enumeration = (java::util::t_Enumeration *) self;
126
 
    jboolean hasMoreElements;
127
 
 
128
 
    OBJ_CALL(hasMoreElements = enumeration->object.hasMoreElements());
129
 
    if (!hasMoreElements)
130
 
    {
131
 
        PyErr_SetNone(PyExc_StopIteration);
132
 
        return NULL;
133
 
    }
134
 
 
135
 
    V next((jobject) NULL);
136
 
    OBJ_CALL(next = enumeration->object.nextElement());
137
 
 
138
 
    jclass cls = java::lang::String::initializeClass();
139
 
    if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
140
 
        return env->fromJString((jstring) next.this$);
141
 
 
142
 
    return U::wrapObject(next);
143
 
}
144
 
 
145
 
template<class T, class U, class V> PyObject *get_next(PyObject *self)
146
 
{
147
 
    T *iterator = (T *) self;
148
 
    V next((jobject) NULL);
149
 
 
150
 
    OBJ_CALL(next = iterator->object.next());
151
 
    if (!next)
152
 
    {
153
 
        PyErr_SetNone(PyExc_StopIteration);
154
 
        return NULL;
155
 
    }
156
 
        
157
 
    jclass cls = java::lang::String::initializeClass();
158
 
    if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
159
 
        return env->fromJString((jstring) next.this$);
160
 
 
161
 
    return U::wrapObject(next);
162
 
}
 
99
template<class T> PyObject *get_iterator(T *self)
 
100
{
 
101
    java::util::Iterator iterator((jobject) NULL);
 
102
 
 
103
    OBJ_CALL(iterator = self->object.iterator());
 
104
    return java::util::t_Iterator::wrap_Object(iterator);
 
105
}
 
106
 
 
107
#ifdef _java_generics
 
108
template<class T> PyObject *get_generic_iterator(T *self)
 
109
{
 
110
    java::util::Iterator iterator((jobject) NULL);
 
111
    PyTypeObject *param = self->parameters ? self->parameters[0] : NULL;
 
112
 
 
113
    OBJ_CALL(iterator = self->object.iterator());
 
114
    return java::util::t_Iterator::wrap_Object(iterator, param);
 
115
}
 
116
#endif
 
117
 
 
118
template<class T, class U> PyObject *get_iterator_next(T *self)
 
119
{
 
120
    jboolean hasNext;
 
121
    OBJ_CALL(hasNext = self->object.hasNext());
 
122
    if (!hasNext)
 
123
    {
 
124
        PyErr_SetNone(PyExc_StopIteration);
 
125
        return NULL;
 
126
    }
 
127
 
 
128
    jobject next;
 
129
    OBJ_CALL(next = env->iteratorNext(self->object.this$));
 
130
 
 
131
    jclass cls = java::lang::String::initializeClass();
 
132
    if (env->get_vm_env()->IsInstanceOf(next, cls))
 
133
        return env->fromJString((jstring) next, 1);
 
134
 
 
135
    return U::wrap_jobject(next);
 
136
}
 
137
 
 
138
#ifdef _java_generics
 
139
template<class T, class U> PyObject *get_generic_iterator_next(T *self)
 
140
{
 
141
    jboolean hasNext;
 
142
    OBJ_CALL(hasNext = self->object.hasNext());
 
143
    if (!hasNext)
 
144
    {
 
145
        PyErr_SetNone(PyExc_StopIteration);
 
146
        return NULL;
 
147
    }
 
148
 
 
149
    jobject next;
 
150
    OBJ_CALL(next = env->iteratorNext(self->object.this$));
 
151
 
 
152
    jclass cls = java::lang::String::initializeClass();
 
153
    if (env->get_vm_env()->IsInstanceOf(next, cls))
 
154
        return env->fromJString((jstring) next, 1);
 
155
 
 
156
    PyTypeObject *param = self->parameters ? self->parameters[0] : NULL;
 
157
    if (param != NULL)
 
158
        return wrapType(param, next);
 
159
 
 
160
    return U::wrap_jobject(next);
 
161
}
 
162
#endif
 
163
 
 
164
template<class T, class U> PyObject *get_enumeration_next(T *self)
 
165
{
 
166
    jboolean hasMoreElements;
 
167
    OBJ_CALL(hasMoreElements = self->object.hasMoreElements());
 
168
    if (!hasMoreElements)
 
169
    {
 
170
        PyErr_SetNone(PyExc_StopIteration);
 
171
        return NULL;
 
172
    }
 
173
 
 
174
    jobject next;
 
175
    OBJ_CALL(next = env->enumerationNext(self->object.this$));
 
176
 
 
177
    jclass cls = java::lang::String::initializeClass();
 
178
    if (env->get_vm_env()->IsInstanceOf(next, cls))
 
179
        return env->fromJString((jstring) next, 1);
 
180
 
 
181
    return U::wrap_jobject(next);
 
182
}
 
183
 
 
184
#ifdef _java_generics
 
185
template<class T, class U> PyObject *get_generic_enumeration_next(T *self)
 
186
{
 
187
    jboolean hasMoreElements;
 
188
    OBJ_CALL(hasMoreElements = self->object.hasMoreElements());
 
189
    if (!hasMoreElements)
 
190
    {
 
191
        PyErr_SetNone(PyExc_StopIteration);
 
192
        return NULL;
 
193
    }
 
194
 
 
195
    jobject next;
 
196
    OBJ_CALL(next = env->enumerationNext(self->object.this$));
 
197
 
 
198
    jclass cls = java::lang::String::initializeClass();
 
199
    if (env->get_vm_env()->IsInstanceOf(next, cls))
 
200
        return env->fromJString((jstring) next, 1);
 
201
 
 
202
    PyTypeObject *param = self->parameters ? self->parameters[0] : NULL;
 
203
    if (param != NULL)
 
204
        return wrapType(param, next);
 
205
 
 
206
    return U::wrap_jobject(next);
 
207
}
 
208
#endif
 
209
 
 
210
template<class T, class U, class V> PyObject *get_next(T *self)
 
211
{
 
212
    V next((jobject) NULL);
 
213
    OBJ_CALL(next = self->object.next());
 
214
    if (!next)
 
215
    {
 
216
        PyErr_SetNone(PyExc_StopIteration);
 
217
        return NULL;
 
218
    }
 
219
        
 
220
    jclass cls = java::lang::String::initializeClass();
 
221
    if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
 
222
        return env->fromJString((jstring) next.this$, 0);
 
223
 
 
224
    return U::wrap_Object(next);
 
225
}
 
226
 
 
227
#ifdef _java_generics
 
228
template<class T, class U, class V> PyObject *get_generic_next(T *self)
 
229
{
 
230
    V next((jobject) NULL);
 
231
    OBJ_CALL(next = self->object.next());
 
232
    if (!next)
 
233
    {
 
234
        PyErr_SetNone(PyExc_StopIteration);
 
235
        return NULL;
 
236
    }
 
237
        
 
238
    jclass cls = java::lang::String::initializeClass();
 
239
    if (env->get_vm_env()->IsInstanceOf(next.this$, cls))
 
240
        return env->fromJString((jstring) next.this$, 0);
 
241
 
 
242
    PyTypeObject *param = self->parameters ? self->parameters[0] : NULL;
 
243
    if (param != NULL)
 
244
        return wrapType(param, next.this$);
 
245
 
 
246
    return U::wrap_Object(next);
 
247
}
 
248
#endif
163
249
 
164
250
PyObject *get_extension_iterator(PyObject *self);
165
251
PyObject *get_extension_next(PyObject *self);
166
252
PyObject *get_extension_nextElement(PyObject *self);
167
253
 
168
254
jobjectArray fromPySequence(jclass cls, PyObject *sequence);
169
 
PyObject *castCheck(PyObject *obj, jclass cls, int reportError);
170
 
 
171
 
extern PyTypeObject FinalizerClassType;
172
 
extern PyTypeObject FinalizerProxyType;
 
255
PyObject *castCheck(PyObject *obj, getclassfn initializeClass,
 
256
                    int reportError);
 
257
void installType(PyTypeObject *type, PyObject *module, char *name,
 
258
                 int isExtension);
 
259
 
 
260
#ifdef _java_generics
 
261
PyObject *typeParameters(PyTypeObject *types[], size_t size);
 
262
#endif
 
263
 
 
264
extern PyTypeObject FinalizerClass$$Type;
 
265
extern PyTypeObject FinalizerProxy$$Type;
173
266
 
174
267
typedef struct {
175
268
    PyObject_HEAD