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.
18 #include "java/lang/Object.h"
19 #include "java/lang/Class.h"
20 #include "java/util/Iterator.h"
30 Class *Iterator::class$ = NULL;
31 jmethodID *Iterator::mids$ = NULL;
33 jclass Iterator::initializeClass()
37 jclass cls = env->findClass("java/util/Iterator");
39 mids$ = new jmethodID[max_mid];
40 mids$[mid_hasNext] = env->getMethodID(cls, "hasNext",
42 mids$[mid_next] = env->getMethodID(cls, "next",
43 "()Ljava/lang/Object;");
45 class$ = (Class *) new JObject(cls);
48 return (jclass) class$->this$;
51 jboolean Iterator::hasNext() const
53 return env->callBooleanMethod(this$, mids$[mid_hasNext]);
56 Object Iterator::next() const
58 return Object(env->callObjectMethod(this$, mids$[mid_next]));
64 #include "structmember.h"
65 #include "functions.h"
71 static PyObject *t_Iterator_hasNext(t_Iterator *self);
72 static PyObject *t_Iterator_next(t_Iterator *self);
74 static PyMethodDef t_Iterator__methods_[] = {
75 DECLARE_METHOD(t_Iterator, hasNext, METH_NOARGS),
76 DECLARE_METHOD(t_Iterator, next, METH_NOARGS),
77 { NULL, NULL, 0, NULL }
80 DECLARE_TYPE(Iterator, t_Iterator, JObject, java::util::Iterator,
81 abstract_init, 0, 0, 0, 0, 0);
84 PyObject *t_Iterator::wrap_Object(const Iterator& object,
87 PyObject *obj = t_Iterator::wrap_Object(object);
90 t_Iterator *self = (t_Iterator *) obj;
91 self->parameters[0] = T;
96 PyObject *t_Iterator::wrap_jobject(const jobject& object,
99 PyObject *obj = t_Iterator::wrap_jobject(object);
102 t_Iterator *self = (t_Iterator *) obj;
103 self->parameters[0] = T;
108 static PyObject *t_Iterator_hasNext(t_Iterator *self)
112 OBJ_CALL(b = self->object.hasNext());
116 static PyObject *t_Iterator_next(t_Iterator *self)
118 Object next((jobject) NULL);
120 OBJ_CALL(next = self->object.next());
121 return t_Object::wrap_Object(next);