[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[cinvoke-svn] r69 - in trunk/cinvoke/bindings/java: . org/cinvoke
From: |
will |
Subject: |
[cinvoke-svn] r69 - in trunk/cinvoke/bindings/java: . org/cinvoke |
Date: |
4 Jul 2006 00:25:12 -0400 |
Author: will
Date: 2006-07-04 00:25:11 -0400 (Tue, 04 Jul 2006)
New Revision: 69
Added:
trunk/cinvoke/bindings/java/org/cinvoke/CInvokeError.java
Removed:
trunk/cinvoke/bindings/java/org/cinvoke/CInvokeException.java
Modified:
trunk/cinvoke/bindings/java/Test.java
trunk/cinvoke/bindings/java/org/cinvoke/CInvProxy.java
trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java
Log:
changed exception to error
Modified: trunk/cinvoke/bindings/java/Test.java
===================================================================
--- trunk/cinvoke/bindings/java/Test.java 2006-07-04 04:17:40 UTC (rev 68)
+++ trunk/cinvoke/bindings/java/Test.java 2006-07-04 04:25:11 UTC (rev 69)
@@ -6,12 +6,8 @@
}
public static void main(String[] args) {
- try {
- libc c = (libc)CInvoke.load("/lib/libc.so.6",
libc.class);
+ libc c = (libc)CInvoke.load("/lib/libc.so.6", libc.class);
- System.out.println("You entered: " + c.getpass("Enter
password: "));
- } catch (CInvokeException ex) {
- System.out.println(ex);
- }
+ System.out.println("You entered: " + c.getpass("Enter password:
"));
}
}
Modified: trunk/cinvoke/bindings/java/org/cinvoke/CInvProxy.java
===================================================================
--- trunk/cinvoke/bindings/java/org/cinvoke/CInvProxy.java 2006-07-04
04:17:40 UTC (rev 68)
+++ trunk/cinvoke/bindings/java/org/cinvoke/CInvProxy.java 2006-07-04
04:25:11 UTC (rev 69)
@@ -10,8 +10,7 @@
private HashMap _functions;
private HashMap _structs;
- public CInvProxy(String libname, int cc, int encoding)
- throws CInvokeException {
+ public CInvProxy(String libname, int cc, int encoding) {
_ctx = Natives.createContext();
if (_ctx == 0) throw new OutOfMemoryError();
_lib = Natives.createLibrary(_ctx, libname);
@@ -49,8 +48,8 @@
}
}
- private void fail() throws CInvokeException {
- throw new CInvokeException(Natives.getError(_ctx));
+ private void fail() {
+ throw new CInvokeError(Natives.getError(_ctx));
}
class NativeStruct {
@@ -133,10 +132,10 @@
}
}
- private int gettypeint(Class cls, boolean thrw) throws CInvokeException
{
+ private int gettypeint(Class cls, boolean thrw) {
if (cls.isArray()) {
if (cls.isInterface())
- throw new CInvokeException("Arrays of callbacks
not supported");
+ throw new CInvokeError("Arrays of callbacks not
supported");
return Natives.T_PTR;
} else {
if (cls.isInterface())
@@ -167,7 +166,7 @@
return Natives.T_PTR;
else {
if (thrw)
- throw new CInvokeException(
+ throw new CInvokeError(
"Passing or returning structures by
value not supported");
else
return -999;
@@ -203,8 +202,7 @@
}
}
- private NativeMethod createNative(Method method)
- throws CInvokeException {
+ private NativeMethod createNative(Method method) {
long ep = Natives.loadEPLibrary(_ctx, _lib, method.getName());
if (ep == 0)
fail();
@@ -215,9 +213,9 @@
Class retcls = method.getReturnType();
if (!retcls.equals(Void.TYPE)) {
if (retcls.isArray())
- throw new CInvokeException("returning arrays
not supported");
+ throw new CInvokeError("returning arrays not
supported");
if (retcls.isInterface())
- throw new CInvokeException("returning callbacks
not supported");
+ throw new CInvokeError("returning callbacks not
supported");
hasret = true;
rettype = gettypeint(retcls, true);
retfmt.append(gettypechar(rettype));
@@ -287,7 +285,7 @@
// XXX
}
- private NativeStruct getNativeStruct(Class cls) throws CInvokeException
{
+ private NativeStruct getNativeStruct(Class cls) {
NativeStruct ret = (NativeStruct)_structs.get(cls);
if (ret == null) {
@@ -299,12 +297,12 @@
Class tcls = fields[i].getType();
if (tcls.isArray()) {
Natives.deleteStruct(_ctx, st);
- throw new CInvokeException(
+ throw new CInvokeError(
"Array structure members not
supported");
}
if (tcls.isInterface()) {
Natives.deleteStruct(_ctx, st);
- throw new CInvokeException(
+ throw new CInvokeError(
"Callback structure members not
supported");
}
int type = gettypeint(tcls, false);
@@ -339,10 +337,9 @@
else
return Natives.ptrToStringUTF8(ptr.longValue());
}
- public Object[] ptrToArray(Ptr ptr, Class type, int num)
- throws CInvokeException {
+ public Object[] ptrToArray(Ptr ptr, Class type, int num) {
if (type.isInterface())
- throw new CInvokeException("Arrays of callbacks not
supported");
+ throw new CInvokeError("Arrays of callbacks not
supported");
Object[] ret = (Object[])Array.newInstance(type, num);
@@ -350,7 +347,7 @@
return ret;
}
- public int sizeof(Class type) throws CInvokeException {
+ public int sizeof(Class type) {
int itype = gettypeint(type, false);
if (itype == -999) {
int ret = Natives.sizeStruct(_ctx,
getNativeStruct(type).st);
@@ -360,11 +357,11 @@
} else
return Natives.sizeofBasic(itype);
}
- public int sizeof(Object obj) throws CInvokeException {
+ public int sizeof(Object obj) {
Class cls = obj.getClass();
if (cls.isArray()) {
if (cls.isInterface())
- throw new CInvokeException("Arrays of callbacks
not supported");
+ throw new CInvokeError("Arrays of callbacks not
supported");
return Array.getLength(obj) *
sizeof(cls.getComponentType());
} else
return sizeof(cls);
Modified: trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java
===================================================================
--- trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java 2006-07-04
04:17:40 UTC (rev 68)
+++ trunk/cinvoke/bindings/java/org/cinvoke/CInvoke.java 2006-07-04
04:25:11 UTC (rev 69)
@@ -13,17 +13,14 @@
public static final int UNICODE = 1;
}
- public static Object load(String libname, Class iface)
- throws CInvokeException {
+ public static Object load(String libname, Class iface) {
return load(libname, iface, CC.DEFAULT);
}
- public static Object load(String libname, Class iface, int callconv)
- throws CInvokeException {
+ public static Object load(String libname, Class iface, int callconv) {
return load(libname, iface, CC.DEFAULT, ENC.UTF8);
}
public static Object load(String libname, Class iface, int callconv,
- int encoding)
- throws CInvokeException {
+ int encoding) {
return Proxy.newProxyInstance(iface.getClassLoader(),
new Class[] { iface }, new CInvProxy(libname, callconv,
encoding));
}
Copied: trunk/cinvoke/bindings/java/org/cinvoke/CInvokeError.java (from rev 68,
trunk/cinvoke/bindings/java/org/cinvoke/CInvokeException.java)
===================================================================
--- trunk/cinvoke/bindings/java/org/cinvoke/CInvokeError.java
(rev 0)
+++ trunk/cinvoke/bindings/java/org/cinvoke/CInvokeError.java 2006-07-04
04:25:11 UTC (rev 69)
@@ -0,0 +1,8 @@
+package org.cinvoke;
+
+public class CInvokeError extends Error {
+ public CInvokeError(String msg) {
+ super(msg);
+ }
+ private static final long serialVersionUID = 1;
+}
Deleted: trunk/cinvoke/bindings/java/org/cinvoke/CInvokeException.java
===================================================================
--- trunk/cinvoke/bindings/java/org/cinvoke/CInvokeException.java
2006-07-04 04:17:40 UTC (rev 68)
+++ trunk/cinvoke/bindings/java/org/cinvoke/CInvokeException.java
2006-07-04 04:25:11 UTC (rev 69)
@@ -1,8 +0,0 @@
-package org.cinvoke;
-
-public class CInvokeException extends Exception {
- public CInvokeException(String msg) {
- super(msg);
- }
- private static final long serialVersionUID = 1;
-}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [cinvoke-svn] r69 - in trunk/cinvoke/bindings/java: . org/cinvoke,
will <=