Skip to content

Commit 54d49c5

Browse files
committed
JDK6 adjustments: changed primitive types to object types (e.g. long to Long)
1 parent e825d86 commit 54d49c5

File tree

12 files changed

+38
-38
lines changed

12 files changed

+38
-38
lines changed

java/src/ca/weblite/objc/Client.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ public Pointer sendPointer(Pointer receiver, Pointer selector, Object... args){
286286
} else if ( Proxy.class.isInstance(res)){
287287
return ((Proxy)res).getPeer();
288288
} else if ( long.class.isInstance(res) || Long.class.isInstance(res)){
289-
return new Pointer((long)res);
289+
return new Pointer((Long)res);
290290
} else {
291291
return (Pointer)res;
292292
}

java/src/ca/weblite/objc/NSObject.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,13 +297,13 @@ public void forwardInvocationToParent(long linvocation){
297297
Pointer sig = msgPointer(invocation, "methodSignature");
298298
Proxy pSig = new Proxy(rawClient, sig);
299299
Pointer selector = msgPointer(invocation, "selector");
300-
long numArgs = (long)pSig.send("numberOfArguments");
300+
long numArgs = (Long)pSig.send("numberOfArguments");
301301
long respondsToSelector = msg(parent, "respondsToSelector:", selector );
302302
if ( respondsToSelector > 0 ){
303303
long impl = msg(parent, "methodForSelector:", selector);
304304
Pointer pImpl = new Pointer(impl);
305305
Function func = Function.getFunction(pImpl);
306-
long returnType = (long)pSig.send("methodReturnType");
306+
long returnType = (Long)pSig.send("methodReturnType");
307307
String strReturnType = new Pointer(returnType).getString(0);
308308
String prefixes = "rnNoORV";
309309
int offset = 0;
@@ -321,7 +321,7 @@ public void forwardInvocationToParent(long linvocation){
321321
args[0] = peer;
322322
args[1] = parent;
323323
for ( int i=2; i<numArgs; i++){
324-
long argumentSigAddr = (long)pSig.send("getArgumentTypeAtIndex:", i);
324+
long argumentSigAddr = (Long)pSig.send("getArgumentTypeAtIndex:", i);
325325
String argumentSignature = new Pointer(argumentSigAddr).getString(0);
326326
LongByReference ptrRef = new LongByReference();
327327
msg(invocation, "getArgument:atIndex:", ptrRef.getPointer(), i);
@@ -439,7 +439,7 @@ public void forwardInvocation(long linvocation) {
439439
Pointer sig = msgPointer(invocation, "methodSignature");
440440
Proxy pSig = new Proxy(rawClient, sig);
441441
Pointer selector = msgPointer(invocation, "selector");
442-
long numArgs = (long)pSig.send("numberOfArguments");
442+
long numArgs = (Long)pSig.send("numberOfArguments");
443443

444444
Method method = methodForSelector(selName(selector));
445445
if ( method != null){
@@ -452,7 +452,7 @@ public void forwardInvocation(long linvocation) {
452452
Object[] args = new Object[new Long(numArgs).intValue()-2];
453453
for ( int i=2; i<numArgs; i++){
454454

455-
long argumentSigAddr = (long)pSig.send("getArgumentTypeAtIndex:", i);
455+
long argumentSigAddr = (Long)pSig.send("getArgumentTypeAtIndex:", i);
456456
String argumentSignature = new Pointer(argumentSigAddr).getString(0);
457457

458458
if ( "fd".indexOf(argumentSignature.substring(0,1)) != -1 ){
@@ -497,7 +497,7 @@ public void forwardInvocation(long linvocation) {
497497
Proxy.release(args[i]);
498498
}
499499

500-
long returnType = (long)pSig.send("methodReturnType");
500+
long returnType = (Long)pSig.send("methodReturnType");
501501

502502
String strReturnType = new Pointer(returnType).getString(0);
503503

java/src/ca/weblite/objc/Proxy.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,15 +243,15 @@ public String sendString(String selector, Object... args){
243243
public int sendInt(Pointer selector, Object... args){
244244
Object res = send(selector, args);
245245
if ( boolean.class.isInstance(res) || Boolean.class.isInstance(res)){
246-
return ((boolean)res)?1:0;
246+
return ((Boolean)res)?1:0;
247247
} else if ( byte.class.isInstance(res) || Byte.class.isInstance(res)) {
248-
return new Byte((byte)res).intValue();
248+
return new Byte((Byte)res).intValue();
249249
} else if ( int.class.isInstance(res) || Integer.class.isInstance(res)){
250-
return (int)res;
250+
return (Integer)res;
251251
} else if ( long.class.isInstance(res) || Long.class.isInstance(res)){
252-
return new Long((long)res).intValue();
252+
return new Long((Long)res).intValue();
253253
} else {
254-
return (int)res;
254+
return (Integer)res;
255255
}
256256
}
257257

@@ -272,7 +272,7 @@ public int sendInt(String selector, Object... args){
272272
* @return The result of the message call as a double.
273273
*/
274274
public double sendDouble(Pointer selector, Object... args){
275-
return (double)send(selector, args);
275+
return (Double)send(selector, args);
276276
}
277277

278278
/**
@@ -294,18 +294,18 @@ public double sendDouble(String selector, Object... args){
294294
public boolean sendBoolean(Pointer selector, Object... args){
295295
Object res = send(selector, args);
296296
if ( boolean.class.isInstance(res) || Boolean.class.isInstance(res)){
297-
return (boolean)res;
297+
return (Boolean)res;
298298
} else if ( byte.class.isInstance(res) || Byte.class.isInstance(res)) {
299-
byte bres = (byte)res;
299+
byte bres = (Byte)res;
300300
return bres > 0 ? true:false;
301301
} else if ( int.class.isInstance(res) || Integer.class.isInstance(res)){
302-
int ires = (int)res;
302+
int ires = (Integer)res;
303303
return ires > 0 ? true:false;
304304
} else if ( long.class.isInstance(res) || Long.class.isInstance(res)){
305-
long lres = (long)res;
305+
long lres = (Long)res;
306306
return lres > 0L ? true:false;
307307
} else {
308-
return (boolean)res;
308+
return (Boolean)res;
309309
}
310310
}
311311
/**

java/src/ca/weblite/objc/RuntimeUtils.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
800800
throw new RuntimeException("Attempt to pass ineligible value to int: "+val);
801801
}
802802
}
803-
return new IntByReference((int)val);
803+
return new IntByReference((Integer)val);
804804
case 's':
805805
case 'S':
806806
if ( !short.class.isInstance(val) ){
@@ -812,7 +812,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
812812
throw new RuntimeException("Attempt to pass ineligible value to short: "+val);
813813
}
814814
}
815-
return new ShortByReference((short)val);
815+
return new ShortByReference((Short)val);
816816

817817
case 'l':
818818
case 'L':
@@ -827,7 +827,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
827827
throw new RuntimeException("Attempt to pass ineligible value to long: "+val);
828828
}
829829
}
830-
return new LongByReference((long)val);
830+
return new LongByReference((Long)val);
831831

832832
case 'f':
833833
if ( !float.class.isInstance(val) ){
@@ -839,7 +839,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
839839
throw new RuntimeException("Attempt to pass ineligible value to long: "+val);
840840
}
841841
}
842-
return new FloatByReference((float)val);
842+
return new FloatByReference((Float)val);
843843

844844
case 'd':
845845
if ( !double.class.isInstance(val) ){
@@ -851,7 +851,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
851851
throw new RuntimeException("Attempt to pass ineligible value to long: "+val);
852852
}
853853
}
854-
return new DoubleByReference((double)val);
854+
return new DoubleByReference((Double)val);
855855
case 'B':
856856
case 'b':
857857
case 'c':
@@ -863,7 +863,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
863863
} else {
864864
throw new RuntimeException("Attempt to pass ineligible value to byte: "+val);
865865
}
866-
return new ByteByReference((byte)val);
866+
return new ByteByReference((Byte)val);
867867
case 'v':
868868
return null;
869869
case '^':
@@ -880,7 +880,7 @@ public static ByReference getAsReferenceWrapper(Object val, String signature){
880880
if ( Pointer.class.isInstance(val) ){
881881
return new PointerByReference((Pointer)val);
882882
} else if ( Long.class.isInstance(val) || long.class.isInstance(val)){
883-
return new PointerByReference(new Pointer((long)val));
883+
return new PointerByReference(new Pointer((Long)val));
884884
} else {
885885
throw new RuntimeException("Don't know what to do for conversion of value "+val+" and signature "+signature);
886886
}

java/src/ca/weblite/objc/mappers/NSObjectMapping.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ public Object cToJ(Object cVar, String signature, TypeMapping root) {
3131
if ( Pointer.class.isInstance(cVar) ){
3232
cObj = (Pointer)cVar;
3333
} else if (long.class.isInstance(cVar) || Long.class.isInstance(cVar) ){
34-
cObj = new Pointer((long)cVar);
34+
cObj = new Pointer((Long)cVar);
3535
} else {
3636
return cVar;
3737
}
38-
if ( (Pointer.NULL == cObj) || (cVar == 0) || (cObj == null) || (PointerTool.getPeer(cObj) == 0L ) ){
38+
if ( (Pointer.NULL == cObj) || (cVar == null) || (cObj == null) || (PointerTool.getPeer(cObj) == 0L ) ){
3939
//System.out.println("The java value will be null");
4040
return null;
4141
}

java/src/ca/weblite/objc/mappers/PointerMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public PointerMapping(){
3232
@Override
3333
public Object cToJ(Object cVar, String signature, TypeMapping root) {
3434
if ( Pointer.class.isInstance(cVar)) return cVar;
35-
return new Pointer((long)cVar);
35+
return new Pointer((Long)cVar);
3636
}
3737

3838
@Override

java/src/ca/weblite/objc/mappers/ScalarMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public Object cToJ(Object cVar, String signature, TypeMapping root) {
1717
//System.out.println("C to J for signature "+signature);
1818
char firstChar = signature.charAt(0);
1919
if ( Long.class.isInstance(cVar) || long.class.isInstance(cVar)){
20-
long cObj = (long)cVar;
20+
long cObj = (Long)cVar;
2121
switch (firstChar){
2222
case 'i':
2323
case 'I':

java/src/ca/weblite/objc/mappers/StringMapping.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class StringMapping implements TypeMapping{
1616
@Override
1717
public Object cToJ(Object cVar, String signature, TypeMapping root) {
1818
System.out.println("Mapping string from cVar");
19-
return new Pointer((long)cVar).getString(0);
19+
return new Pointer((Long)cVar).getString(0);
2020
}
2121

2222
@Override

java/test/ca/weblite/objc/LoadNibSample.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,14 +72,14 @@ public void startApplication(){
7272

7373

7474

75-
long res = (long)c.send("NSBundle", "loadNibFile:externalNameTable:withZone:", "MainMenu.nib", filesOwner.getPeer(), null);
76-
int numTopLevelObjects = new Long((long)topLevelObjects.send("count")).intValue();
75+
long res = (Long)c.send("NSBundle", "loadNibFile:externalNameTable:withZone:", "MainMenu.nib", filesOwner.getPeer(), null);
76+
int numTopLevelObjects = ((Long)topLevelObjects.send("count")).intValue();
7777

7878
Proxy mainWindow = null;
7979

8080
for ( int i=0; i<numTopLevelObjects; i++){
8181
Proxy obj = (Proxy)topLevelObjects.send("objectAtIndex:", i);
82-
if ( (long)obj.send("isKindOfClass:", cls("NSWindow")) > 0 ){
82+
if ( (Long)obj.send("isKindOfClass:", cls("NSWindow")) > 0 ){
8383
mainWindow = obj;
8484
} else {
8585

java/test/ca/weblite/objc/NSObjectTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public void testNSArray() {
7070

7171

7272
long expectedCount = 0;
73-
long actualCount = (long)o.send("count");
73+
long actualCount = (Long)o.send("count");
7474
assertEquals(expectedCount, actualCount);
7575

7676
// Add a string to the array and check that
@@ -84,7 +84,7 @@ public void testNSArray() {
8484

8585
// There should be one object in the array
8686
expectedCount = 1;
87-
actualCount = (long)o.send("count");
87+
actualCount = (Long)o.send("count");
8888
assertEquals(expectedCount, actualCount);
8989

9090
//Now the string is there

0 commit comments

Comments
 (0)