Author: mturk
Date: Wed Jul 1 10:36:50 2009
New Revision: 790103
URL: http://svn.apache.org/viewvc?rev=790103&view=rev
Log:
Add generic Java Object support API
Added:
commons/sandbox/runtime/trunk/src/main/native/include/acr_object.h (with
props)
commons/sandbox/runtime/trunk/src/main/native/shared/object.c (with props)
Modified:
commons/sandbox/runtime/trunk/src/main/native/Makefile.in
commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.in
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.in?rev=790103&r1=790102&r2=790103&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.in Wed Jul 1
10:36:50 2009
@@ -84,6 +84,7 @@
$(SRCDIR)/shared/modules.$(OBJ) \
$(SRCDIR)/shared/native.$(OBJ) \
$(SRCDIR)/shared/pointer.$(OBJ) \
+ $(SRCDIR)/shared/object.$(OBJ) \
$(SRCDIR)/shared/string.$(OBJ) \
$(SRCDIR)/shared/tables.$(OBJ) \
$(SRCDIR)/shared/version.$(OBJ)
Modified: commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in?rev=790103&r1=790102&r2=790103&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in (original)
+++ commons/sandbox/runtime/trunk/src/main/native/Makefile.msc.in Wed Jul 1
10:36:50 2009
@@ -78,6 +78,7 @@
$(SRCDIR)/shared/modules.$(OBJ) \
$(SRCDIR)/shared/native.$(OBJ) \
$(SRCDIR)/shared/pointer.$(OBJ) \
+ $(SRCDIR)/shared/object.$(OBJ) \
$(SRCDIR)/shared/string.$(OBJ) \
$(SRCDIR)/shared/tables.$(OBJ) \
$(SRCDIR)/shared/version.$(OBJ)
Added: commons/sandbox/runtime/trunk/src/main/native/include/acr_object.h
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/include/acr_object.h?rev=790103&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/include/acr_object.h (added)
+++ commons/sandbox/runtime/trunk/src/main/native/include/acr_object.h Wed Jul
1 10:36:50 2009
@@ -0,0 +1,89 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _ACR_OBJECT_H
+#define _ACR_OBJECT_H
+
+#include "acr.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @file acr_object.h
+ * @brief
+ *
+ * ACR Object functions
+ *
+ */
+
+/**
+ * Native version of Java Object.notify() method.
+ * @param env Current JNI environment.
+ * @param o Object to use
+ * @return ACR_SUCCESS or ACR_BUSY on exception.
+ */
+ACR_DECLARE(int) ACR_ObjectNotify(JNIEnv *env, jobject o);
+
+/**
+ * Native version of Java Object.notifyAll() method.
+ * @param env Current JNI environment.
+ * @param o Object to use
+ * @return ACR_SUCCESS or ACR_BUSY on exception.
+ */
+ACR_DECLARE(int) ACR_ObjectNotifyAll(JNIEnv *env, jobject o);
+
+/**
+ * Native version of Java Object.wait() method.
+ * @param env Current JNI environment.
+ * @param o Object to use
+ * @return ACR_SUCCESS or ACR_TIMEUP on exception.
+ */
+ACR_DECLARE(int) ACR_ObjectWait0(JNIEnv *env, jobject o);
+
+/**
+ * Native version of Java Object.wait(long) method.
+ * @param env Current JNI environment.
+ * @param o Object to use
+ * @param ms Number of miliseconds to wait
+ * @return ACR_SUCCESS or ACR_TIMEUP on exception.
+ */
+ACR_DECLARE(int) ACR_ObjectWait1(JNIEnv *env, jobject o, jlong ms);
+
+/**
+ * Native version of Java Object.wait(long, int) method.
+ * @param env Current JNI environment.
+ * @param o Object to use
+ * @param ms Number of miliseconds to wait
+ * @param ns Number of nanoseconds to wait
+ * @return ACR_SUCCESS or ACR_TIMEUP on exception.
+ */
+ACR_DECLARE(int) ACR_ObjectWait2(JNIEnv *env, jobject o, jlong ms, jint ns);
+
+/**
+ * Native version of Java Object.finalize() method.
+ * @param env Current JNI environment.
+ * @param o Object to use
+ */
+ACR_DECLARE(void) ACR_ObjectFinalize(JNIEnv *env, jobject o);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ACR_OBJECT_H */
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/include/acr_object.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c?rev=790103&r1=790102&r2=790103&view=diff
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c (original)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/clazz.c Wed Jul 1
10:36:50 2009
@@ -64,6 +64,7 @@
}
/* Core classes forward declarations */
+ACR_CLASS_LDEF(Object);
ACR_CLASS_LDEF(String);
int ACR_InitCoreClasses(JNIEnv *_E)
@@ -97,6 +98,7 @@
i++;
}
/* Init some core Objects and it's methods */
+ ACR_CLASS_LRUN(Object);
ACR_CLASS_LRUN(String);
return ACR_SUCCESS;
@@ -297,3 +299,4 @@
return i;
}
#endif
+
Added: commons/sandbox/runtime/trunk/src/main/native/shared/object.c
URL:
http://svn.apache.org/viewvc/commons/sandbox/runtime/trunk/src/main/native/shared/object.c?rev=790103&view=auto
==============================================================================
--- commons/sandbox/runtime/trunk/src/main/native/shared/object.c (added)
+++ commons/sandbox/runtime/trunk/src/main/native/shared/object.c Wed Jul 1
10:36:50 2009
@@ -0,0 +1,181 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "acr.h"
+#include "acr_private.h"
+#include "acr_object.h"
+#include "acr_error.h"
+#include "acr_types.h"
+#include "acr_clazz.h"
+#include "acr_vm.h"
+
+J_DECLARE_CLAZZ = {
+ NULL,
+ NULL,
+ "java/lang/Object"
+};
+
+J_DECLARE_M_ID(0000) = {
+ NULL,
+ "<init>",
+ "()V"
+};
+
+J_DECLARE_M_ID(0001) = {
+ NULL,
+ "notify",
+ "()V"
+};
+
+J_DECLARE_M_ID(0002) = {
+ NULL,
+ "notifyAll",
+ "()V"
+};
+
+J_DECLARE_M_ID(0003) = {
+ NULL,
+ "wait",
+ "(J)V"
+};
+
+J_DECLARE_M_ID(0004) = {
+ NULL,
+ "wait",
+ "(JI)V"
+};
+
+J_DECLARE_M_ID(0005) = {
+ NULL,
+ "wait",
+ "()V"
+};
+
+J_DECLARE_M_ID(0006) = {
+ NULL,
+ "finalize",
+ "()V"
+};
+
+ACR_CLASS_LDEF(Object)
+{
+ int rv;
+
+ if ((rv = ACR_LoadClass(_E, &_clazzn, 0)) != ACR_SUCCESS)
+ return rv;
+ J_LOAD_METHOD(0000);
+ J_LOAD_METHOD(0001);
+ J_LOAD_METHOD(0002);
+ J_LOAD_METHOD(0003);
+ J_LOAD_METHOD(0004);
+ J_LOAD_METHOD(0005);
+ J_LOAD_METHOD(0006);
+
+ return ACR_SUCCESS;
+}
+
+ACR_CLASS_UDEF(Object)
+{
+ ACR_UnloadClass(_E, &_clazzn);
+}
+
+ACR_DECLARE(int) ACR_ObjectNotify(ACR_JNISTDARGS)
+{
+ int rc = ACR_ECLASSNOTFOUND;
+
+ if (_clazzn.i && J4MID(0000)) {
+ CALL_METHOD0(Void, 0001, _O);
+ if ((*_E)->ExceptionCheck(_E)) {
+ (*_E)->ExceptionClear(_E);
+ rc = ACR_EBUSY;
+ }
+ else
+ rc = ACR_SUCCESS;
+ }
+ return rc;
+}
+
+ACR_DECLARE(int) ACR_ObjectNotifyAll(ACR_JNISTDARGS)
+{
+ int rc = ACR_ECLASSNOTFOUND;
+
+ if (_clazzn.i && J4MID(0000)) {
+ CALL_METHOD0(Void, 0002, _O);
+ if ((*_E)->ExceptionCheck(_E)) {
+ (*_E)->ExceptionClear(_E);
+ rc = ACR_EBUSY;
+ }
+ else
+ rc = ACR_SUCCESS;
+ }
+ return rc;
+}
+
+ACR_DECLARE(int) ACR_ObjectWait0(ACR_JNISTDARGS)
+{
+ int rc = ACR_ECLASSNOTFOUND;
+
+ if (_clazzn.i && J4MID(0000)) {
+ CALL_METHOD0(Void, 0005, _O);
+ if ((*_E)->ExceptionCheck(_E)) {
+ (*_E)->ExceptionClear(_E);
+ rc = ACR_TIMEUP;
+ }
+ else
+ rc = ACR_SUCCESS;
+ }
+ return rc;
+}
+
+ACR_DECLARE(int) ACR_ObjectWait1(ACR_JNISTDARGS, jlong ms)
+{
+ int rc = ACR_ECLASSNOTFOUND;
+
+ if (_clazzn.i && J4MID(0000)) {
+ CALL_METHOD1(0003, _O, ms);
+ if ((*_E)->ExceptionCheck(_E)) {
+ (*_E)->ExceptionClear(_E);
+ rc = ACR_TIMEUP;
+ }
+ else
+ rc = ACR_SUCCESS;
+ }
+ return rc;
+}
+
+ACR_DECLARE(int) ACR_ObjectWait2(ACR_JNISTDARGS, jlong ms, jint ns)
+{
+ int rc = ACR_ECLASSNOTFOUND;
+
+ if (_clazzn.i && J4MID(0000)) {
+ CALL_METHOD2(0004, _O, ms, ns);
+ if ((*_E)->ExceptionCheck(_E)) {
+ (*_E)->ExceptionClear(_E);
+ rc = ACR_TIMEUP;
+ }
+ else
+ rc = ACR_SUCCESS;
+ }
+ return rc;
+}
+
+ACR_DECLARE(void) ACR_ObjectFinalize(ACR_JNISTDARGS)
+{
+ if (_clazzn.i && J4MID(0000)) {
+ CALL_METHOD0(Void, 0006, _O);
+ }
+}
+
Propchange: commons/sandbox/runtime/trunk/src/main/native/shared/object.c
------------------------------------------------------------------------------
svn:eol-style = native