8e3bd162e179d064897aa27beca75cda08cb1aee
[cacao.git] / src / native / vm / cldc1.1 / java_lang_Object.c
1 /* src/native/vm/cldc1.1/java_lang_Object.c
2
3    Copyright (C) 2006, 2007 R. Grafl, A. Krall, C. Kruegel, C. Oates,
4    R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner,
5    C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger,
6    Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    $Id: java_lang_VMRuntime.c 5900 2006-11-04 17:30:44Z michi $
26
27 */
28
29
30 #include "config.h"
31
32 #include <stdlib.h>
33
34 #include "vm/types.h"
35
36 #include "native/jni.h"
37 #include "native/llni.h"
38 #include "native/native.h"
39
40 #include "native/include/java_lang_String.h"             /* required by j.l.C */
41 #include "native/include/java_lang_Class.h"
42
43 #include "native/include/java_lang_Object.h"
44
45 #include "native/vm/java_lang_Object.h"
46
47
48 /* native methods implemented by this file ************************************/
49  
50 static JNINativeMethod methods[] = {
51         { "getClass",  "()Ljava/lang/Class;",                   (void *) (ptrint) &Java_java_lang_Object_getClass  },
52         { "hashCode",  "()I",                                   (void *) (ptrint) &Java_java_lang_Object_hashCode  },
53         { "notify",    "()V",                                   (void *) (ptrint) &Java_java_lang_Object_notify    },
54         { "notifyAll", "()V",                                   (void *) (ptrint) &Java_java_lang_Object_notifyAll },
55         { "wait",      "(J)V",                                  (void *) (ptrint) &Java_java_lang_Object_wait      },
56 };
57  
58  
59 /* _Jv_java_lang_Object_init ***************************************************
60  
61    Register native functions.
62  
63 *******************************************************************************/
64  
65 void _Jv_java_lang_Object_init(void)
66 {
67         utf *u;
68  
69         u = utf_new_char("java/lang/Object");
70  
71         native_method_register(u, methods, NATIVE_METHODS_COUNT);
72 }
73
74
75 /*
76  * Class:     java/lang/Object
77  * Method:    getClass
78  * Signature: ()Ljava/lang/Class;
79  */
80 JNIEXPORT java_lang_Class* JNICALL Java_java_lang_Object_getClass(JNIEnv *env, java_lang_Object *obj)
81 {
82         java_handle_t *o;
83         classinfo     *c;
84
85         o = (java_handle_t *) obj;
86
87         if (o == NULL)
88                 return NULL;
89
90         c = o->vftbl->class;
91
92         return LLNI_classinfo_wrap(c);
93 }
94
95
96 /*
97  * Class:     java/lang/Object
98  * Method:    hashCode
99  * Signature: ()I
100  */
101 JNIEXPORT s4 JNICALL Java_java_lang_Object_hashCode(JNIEnv *env, java_lang_Object *this)
102 {
103         return (s4) ((ptrint) this);
104 }
105
106
107 /*
108  * Class:     java/lang/Object
109  * Method:    notify
110  * Signature: ()V
111  */
112 JNIEXPORT void JNICALL Java_java_lang_Object_notify(JNIEnv *env, java_lang_Object *this)
113 {
114         _Jv_java_lang_Object_notify(this);
115 }
116
117
118 /*
119  * Class:     java/lang/Object
120  * Method:    notifyAll
121  * Signature: ()V
122  */
123 JNIEXPORT void JNICALL Java_java_lang_Object_notifyAll(JNIEnv *env, java_lang_Object *this)
124 {
125         _Jv_java_lang_Object_notifyAll(this);
126 }
127
128
129 /*
130  * Class:     java/lang/Object
131  * Method:    wait
132  * Signature: (J)V
133  */
134 JNIEXPORT void JNICALL Java_java_lang_Object_wait(JNIEnv *env, java_lang_Object *this, s8 timeout)
135 {
136         _Jv_java_lang_Object_wait(this, timeout, 0);
137 }
138
139
140 /*
141  * These are local overrides for various environment variables in Emacs.
142  * Please do not remove this and leave it at the end of the file, where
143  * Emacs will automagically detect them.
144  * ---------------------------------------------------------------------
145  * Local variables:
146  * mode: c
147  * indent-tabs-mode: t
148  * c-basic-offset: 4
149  * tab-width: 4
150  * End:
151  * vim:noexpandtab:sw=4:ts=4:
152  */