319 ]. |
319 ]. |
320 ^ failBlock value:('cannot convert argument to ' , type) value:0 |
320 ^ failBlock value:('cannot convert argument to ' , type) value:0 |
321 ]. |
321 ]. |
322 |
322 |
323 (type == #float) ifTrue:[ |
323 (type == #float) ifTrue:[ |
324 arg isReal ifTrue:[ |
324 arg isLimitedPrecisionReal ifTrue:[ |
325 ^ arg asShortFloat |
325 ^ arg asShortFloat |
326 ]. |
326 ]. |
327 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
327 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
328 ]. |
328 ]. |
329 |
329 |
330 (type == 'java.lang.Float') ifTrue:[ |
330 (type = 'java.lang.Float') ifTrue:[ |
331 arg isReal ifTrue:[ |
331 arg isLimitedPrecisionReal ifTrue:[ |
332 f := (Java at:'java.lang.Float') new. |
332 f := (Java at:'java.lang.Float') new. |
333 f perform:#'<init>(F)V' with:(arg asShortFloat). |
333 f perform:#'<init>(F)V' with:(arg asShortFloat). |
334 self halt. |
334 self halt. |
335 ^ f. |
335 ^ f. |
336 ]. |
336 ]. |
337 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
337 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
338 ]. |
338 ]. |
339 (type == 'java.lang.Double') ifTrue:[ |
339 (type = 'java.lang.Double') ifTrue:[ |
340 arg isReal ifTrue:[ |
340 arg isLimitedPrecisionReal ifTrue:[ |
341 f := (Java at:'java.lang.Double') new. |
341 f := (Java at:'java.lang.Double') new. |
342 f perform:#'<init>(D)V' with:(arg asFloat). |
342 f perform:#'<init>(D)V' with:(arg asFloat). |
343 self halt. |
343 self halt. |
344 ^ f. |
344 ^ f. |
345 ]. |
345 ]. |
346 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
346 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
347 ]. |
347 ]. |
348 |
348 |
349 (type == #double) ifTrue:[ |
349 (type == #double) ifTrue:[ |
350 arg isReal ifTrue:[ |
350 arg isLimitedPrecisionReal ifTrue:[ |
351 ^ arg asFloat |
351 ^ arg asFloat |
352 ]. |
352 ]. |
353 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
353 ^ failBlock value:('cannot convert argument to ' , type) value:0.0. |
354 ]. |
354 ]. |
355 |
355 |
420 ]. |
420 ]. |
421 self halt. |
421 self halt. |
422 ^ failBlock value:('cannot convert argument to ' , type) value:failValue |
422 ^ failBlock value:('cannot convert argument to ' , type) value:failValue |
423 |
423 |
424 "Created: / 6.11.1998 / 00:46:19 / cg" |
424 "Created: / 6.11.1998 / 00:46:19 / cg" |
425 "Modified: / 28.1.1999 / 17:55:17 / cg" |
425 "Modified: / 6.11.2001 / 13:28:29 / cg" |
426 ! |
426 ! |
427 |
427 |
428 convertToSmalltalk:jObj type:type |
428 convertToSmalltalk:jObj type:type |
429 "given a java return value, convert to a smalltalk object as appropriate. |
429 "given a java return value, convert to a smalltalk object as appropriate. |
430 Currently, only a few types are converted." |
430 Currently, only a few types are converted." |