-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathFFMType.java
More file actions
91 lines (84 loc) · 2.31 KB
/
Copy pathFFMType.java
File metadata and controls
91 lines (84 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package javaforce.ffm;
import java.lang.reflect.*;
import javaforce.*;
/** FFMType.
*
* Typically stored a native handle or enum type.
*
* @author pquiring
*/
public abstract class FFMType {
public static class Uint32 extends FFMType {
public int value;
public String getType() {return "int";}
public int getValue() {return value;}
public void setValue(int value) {this.value = value;}
public void set(Uint32 value) {this.value = value.value;}
public Uint32() {}
public Uint32(int value) {setValue(value);}
public Uint32(Uint32 value) {setValue(value.value);}
public String toString() {return "0x" + java.lang.Integer.toHexString(value);}
}
public static class Uint64 extends FFMType {
public long value;
public String getType() {return "long";}
public long getValue() {return value;}
public void setValue(long value) {this.value = value;}
public void set(Uint64 value) {this.value = value.value;}
public Uint64() {}
public Uint64(long value) {setValue(value);}
public Uint64(Uint64 value) {setValue(value.value);}
public String toString() {return "0x" + java.lang.Long.toHexString(value);}
}
public static boolean isType(Class<?> type) {
try {
return JF.isDerivedFrom(type, FFMType.class);
} catch (Exception e) {
JFLog.log(e);
}
return false;
}
public static boolean isType(Field field) {
try {
Class<?> cls = field.getType();
return isType(cls);
} catch (Exception e) {
JFLog.log(e);
}
return false;
}
public static boolean isTypeInt(Class<?> cls) {
try {
return JF.isDerivedFrom(cls, FFMType.Uint32.class);
} catch (Exception e) {
JFLog.log(e);
}
return false;
}
public static boolean isTypeInt(Field field) {
try {
Class<?> cls = field.getType();
return isTypeInt(cls);
} catch (Exception e) {
JFLog.log(e);
}
return false;
}
public static boolean isTypeLong(Class<?> cls) {
try {
return JF.isDerivedFrom(cls, FFMType.Uint64.class);
} catch (Exception e) {
JFLog.log(e);
}
return false;
}
public static boolean isTypeLong(Field field) {
try {
Class<?> cls = field.getType();
return isTypeLong(cls);
} catch (Exception e) {
JFLog.log(e);
}
return false;
}
}