--- a/JavaObject.st Wed Jul 30 10:54:27 1997 +0000
+++ b/JavaObject.st Wed Jul 30 14:41:13 1997 +0000
@@ -111,6 +111,224 @@
]
! !
+!JavaObject methodsFor:'interpreter interface'!
+
+invoke:selector interpreter:i sender:aContext
+ "send a message, without args"
+
+ |method cls sel|
+
+ method := self lookupMethod:selector numArgs:0.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') basicNew.
+ stack invoke:#'<init>'.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#isEmpty.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#size.
+ "
+
+ "Modified: 30.7.1997 / 13:27:48 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:argument
+ "send a message, with 1 argument.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ "/
+ "/ hard to do - must find a matching method probably
+ "/
+ (argument isKindOf:JavaObject) ifTrue:[
+ argClass := argument class.
+ ] ifFalse:[
+ "/
+ "/ map to Java:
+ "/ String -> [c
+ "/
+ (argument isMemberOf:String) ifTrue:[
+ jSel := (selector , '([C)V') asSymbolIfInterned.
+ jSel notNil ifTrue:[
+ ^ self
+ invoke:jSel
+ interpreter:i
+ sender:aContext
+ with:argument
+ ]
+ ]
+ ].
+
+ method := self lookupMethod:sel numArgs:1.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:sel
+ with:argument
+ ].
+
+"/ cls := self class.
+"/ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
+"/ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
+"/ aMethod name == sel ifTrue:[
+"/ aMethod numArgs == 1 ifTrue:[
+"/ "/
+"/ "/ this is not completely correct:
+"/ "/ must look for the best type-match,
+"/ "/ (especially: have to look for best match
+"/ "/ over whole superclass chain ...)
+"/ "/ for now take the first with matching number of args
+"/ "/
+"/ ^ self invokeJavaMethod:aMethod with:argument
+"/ ]
+"/ ]
+"/ ].
+"/ cls := cls superclass.
+"/ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#push with:1.
+ "
+ "
+ |stack|
+
+ stack := (Java at:'java/util/Stack') new.
+ stack invoke:#push with:1.
+ stack invoke:#push with:2.
+ stack invoke:#pop.
+ stack invoke:#pop.
+ stack invoke:#pop.
+ "
+
+ "Modified: 30.7.1997 / 13:46:39 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:arg1 with:arg2
+ "send a message, with 2 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:2.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ with:arg1 with:arg2
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:47:05 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3
+ "send a message, with 3 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:3.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ with:arg1 with:arg2 with:arg3
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:47:22 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3 with:arg4
+ "send a message, with 4 arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:4.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ with:arg1 with:arg2 with:arg3 with:arg4
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:47:45 / cg"
+!
+
+invoke:selector interpreter:i sender:aContext withAll:arguments
+ "send a message, with arguments.
+ TEMPORARY: This method needs more work."
+
+ |sel method cls argClass jSel|
+
+ sel := selector asSymbolIfInterned.
+ sel notNil ifTrue:[
+ method := self lookupMethod:sel numArgs:arguments size.
+ method notNil ifTrue:[
+ ^ self
+ invokeJavaMethod:method
+ interpreter:i
+ sender:aContext
+ selector:selector
+ withAll:arguments
+ ].
+ ].
+
+ ^ super doesNotUnderstand:(Message selector:selector)
+
+ "Modified: 30.7.1997 / 13:48:02 / cg"
+! !
+
!JavaObject methodsFor:'message sending'!
doesNotUnderstand:aMessage
@@ -133,91 +351,35 @@
].
^ super doesNotUnderstand:aMessage
- "Modified: 18.3.1997 / 11:47:16 / cg"
-!
-
-invokeJava:selector
- "send javaSelector (name+sig) message, without arguments"
-
- |method|
-
- method := self class lookupMethodFor:selector.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method sender:thisContext
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:11 / cg"
+ "Modified: 30.7.1997 / 13:46:01 / cg"
!
-invokeJava:selector interpreter:i sender:s with:arg1 with:arg2
- "send javaSelector (name+sig) message, with 2 arguments"
-
- |method|
-
- method := self class lookupMethodFor:selector.
- method notNil ifTrue:[
- ^ self
- invokeJavaMethod:method
- interpreter:i
- sender:s
- with:arg1
- with:arg2
- ].
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 18.3.1997 / 11:47:37 / cg"
-!
-
-invokeJava:selector with:arg
- "send javaSelector (name+sig) message, with 1 argument"
-
- |method|
-
- method := self class lookupMethodFor:selector.
- method notNil ifTrue:[
- ^ self
- invokeJavaMethod:method
- with:arg
- ].
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 18.3.1997 / 11:47:46 / cg"
-!
-
-invokeJavaMethod:aJavaMethod
- "invoke java method, without arguments"
-
- ^ self
- invokeJavaMethod:aJavaMethod
- interpreter:JavaInterpreter new
- sender:thisContext sender.
-
- "Modified: 18.3.1997 / 11:46:07 / cg"
-!
-
-invokeJavaMethod:aJavaMethod interpreter:i sender:aContext
- "invoke a java method, without arguments"
+invokeJavaMethod:aJavaMethod interpreter:i sender:s selector:sel
+ "invoke a java method, without arguments."
|val|
aJavaMethod numArgs ~~ 0 ifTrue:[
- self halt:'need arguments'
+ self halt:'argument count'
].
aJavaMethod isStatic ifTrue:[
self halt:'static function'
].
-"/ i := JavaInterpreter new.
+ val := aJavaMethod valueWithReceiver:self arguments:#() selector:sel.
+ val notNil ifTrue:[^ val].
+
i push:self.
- val := i interpret:aJavaMethod sender:aContext.
+ val := i interpret:aJavaMethod sender:s.
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+
+ "Modified: 30.7.1997 / 13:20:29 / cg"
+ "Created: 30.7.1997 / 13:37:25 / cg"
!
-invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1
+invokeJavaMethod:aJavaMethod interpreter:i sender:s selector:sel with:arg1
"invoke a java method, with two arguments.
CAVEAT: these cannot be long or doubles currently."
@@ -230,6 +392,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1) selector:sel.
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
@@ -237,6 +402,36 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:35 / cg"
+ "Created: 30.7.1997 / 13:41:01 / cg"
+!
+
+invokeJavaMethod:aJavaMethod interpreter:i sender:s selector:sel with:arg1 with:arg2
+ "invoke a java method, with two arguments.
+ CAVEAT: these cannot be long or doubles currently."
+
+ |val|
+
+ aJavaMethod numArgs ~~ 2 ifTrue:[
+ self halt:'argument count'
+ ].
+ aJavaMethod isStatic ifTrue:[
+ self halt:'static function'
+ ].
+
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2) selector:sel.
+ val notNil ifTrue:[^ val].
+
+ i push:self.
+ i push:arg1.
+ i push:arg2.
+
+ val := i interpret:aJavaMethod sender:s.
+
+ ^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+
+ "Modified: 30.7.1997 / 13:20:35 / cg"
+ "Created: 30.7.1997 / 13:36:02 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1 with:arg2
@@ -252,6 +447,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2).
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
i push:arg2.
@@ -260,6 +458,7 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:35 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1 with:arg2 with:arg3
@@ -275,6 +474,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2 with:arg3).
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
i push:arg2.
@@ -284,6 +486,7 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:44 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s with:arg1 with:arg2 with:arg3 with:arg4
@@ -299,6 +502,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:(Array with:arg1 with:arg2 with:arg3 with:arg4).
+ val notNil ifTrue:[^ val].
+
i push:self.
i push:arg1.
i push:arg2.
@@ -309,6 +515,7 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
+ "Modified: 30.7.1997 / 13:20:51 / cg"
!
invokeJavaMethod:aJavaMethod interpreter:i sender:s withAll:args
@@ -324,6 +531,9 @@
self halt:'static function'
].
+ val := aJavaMethod valueWithReceiver:self arguments:args.
+ val notNil ifTrue:[^ val].
+
i push:self.
args do:[:arg |
i push:arg.
@@ -333,28 +543,21 @@
^ JavaObject convertJavaObject:val signature:(aJavaMethod retValSignature)
-!
-
-invokeJavaMethod:aJavaMethod sender:aContext
- "invoke a java method, without arguments"
-
- ^ self invokeJavaMethod:aJavaMethod interpreter:JavaInterpreter new sender:aContext
-!
-
-invokeJavaMethod:aJavaMethod with:arg
- "invoke a java method, with one argument.
- CAVEAT: this cannot be a long or doubles currently."
-
- ^ self invokeJavaMethod:aJavaMethod interpreter:JavaInterpreter new sender:thisContext sender with:arg
-
+ "Modified: 30.7.1997 / 13:20:58 / cg"
!
invokeJavaMethod:aJavaMethod with:arg1 with:arg2
"invoke a java method, with two arguments.
CAVEAT: these cannot be long or doubles currently."
- ^ self invokeJavaMethod:aJavaMethod interpreter:JavaInterpreter new sender:thisContext sender with:arg1 with:arg2
+ ^ self
+ invokeJavaMethod:aJavaMethod
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ with:arg1
+ with:arg2
+ "Modified: 30.7.1997 / 13:25:36 / cg"
! !
!JavaObject methodsFor:'printing & storing'!
@@ -402,39 +605,10 @@
invoke:selector
"send a message, without args"
- ^ self invoke:selector interpreter:(JavaInterpreter new) sender:thisContext sender
-
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') basicNew.
- stack invoke:#'<init>'.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#isEmpty.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#size.
- "
-!
-
-invoke:selector interpreter:i sender:aContext
- "send a message, without args"
-
- |method cls sel|
-
- method := self lookupMethod:selector numArgs:0.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
+ ^ self
+ invoke:selector
+ interpreter:(JavaInterpreter new)
+ sender:thisContext sender
"
|stack|
@@ -455,61 +629,29 @@
stack invoke:#size.
"
- "Modified: 1.2.1997 / 21:47:25 / cg"
+ "Modified: 30.7.1997 / 13:44:34 / cg"
!
-invoke:selector interpreter:i sender:aContext with:argument
+invoke:selector sender:aContext
+ "send a message, without args"
+
+ ^ self
+ invoke:selector
+ interpreter:(JavaInterpreter new)
+ sender:aContext
+
+ "Modified: 30.7.1997 / 13:59:18 / cg"
+!
+
+invoke:selector with:arg
"send a message, with 1 argument.
TEMPORARY: This method needs more work."
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- "/
- "/ hard to do - must find a matching method probably
- "/
- (argument isKindOf:JavaObject) ifTrue:[
- argClass := argument class.
- ] ifFalse:[
- "/
- "/ map to Java:
- "/ String -> [c
- "/
- (argument isMemberOf:String) ifTrue:[
- jSel := (selector , '([C)V') asSymbolIfInterned.
- jSel notNil ifTrue:[
- ^ self invokeJava:jSel interpreter:i sender:aContext with:argument
- ]
- ]
- ].
-
- method := self lookupMethod:sel numArgs:1.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext with:argument
- ].
-
-"/ cls := self class.
-"/ [cls notNil and:[cls ~~ JavaObject]] whileTrue:[
-"/ cls methodDictionary keysAndValuesDo:[:sel :aMethod |
-"/ aMethod name == sel ifTrue:[
-"/ aMethod numArgs == 1 ifTrue:[
-"/ "/
-"/ "/ this is not completely correct:
-"/ "/ must look for the best type-match,
-"/ "/ (especially: have to look for best match
-"/ "/ over whole superclass chain ...)
-"/ "/ for now take the first with matching number of args
-"/ "/
-"/ ^ self invokeJavaMethod:aMethod with:argument
-"/ ]
-"/ ]
-"/ ].
-"/ cls := cls superclass.
-"/ ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
+ ^ self
+ invoke:selector
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ with:arg
"
|stack|
@@ -528,148 +670,11 @@
stack invoke:#pop.
"
- "Modified: 22.3.1997 / 00:57:33 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext with:arg1 with:arg2
- "send a message, with 2 arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:2.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- with:arg1 with:arg2
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:31 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3
- "send a message, with 3 arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:3.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- with:arg1 with:arg2 with:arg3
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:33 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext with:arg1 with:arg2 with:arg3 with:arg4
- "send a message, with 4 arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:4.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext
- with:arg1 with:arg2 with:arg3 with:arg4
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:36 / cg"
-!
-
-invoke:selector interpreter:i sender:aContext withAll:arguments
- "send a message, with arguments.
- TEMPORARY: This method needs more work."
-
- |sel method cls argClass jSel|
-
- sel := selector asSymbolIfInterned.
- sel notNil ifTrue:[
- method := self lookupMethod:sel numArgs:arguments size.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:i sender:aContext withAll:arguments
- ].
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "Modified: 1.2.1997 / 21:47:38 / cg"
-!
-
-invoke:selector sender:aContext
- "send a message, without args"
-
- |method cls sel|
-
- method := self lookupMethod:selector numArgs:0.
- method notNil ifTrue:[
- ^ self invokeJavaMethod:method interpreter:(JavaInterpreter new) sender:aContext
- ].
-
- ^ super doesNotUnderstand:(Message selector:selector)
-
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') basicNew.
- stack invoke:#'<init>'.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#isEmpty.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#size.
- "
-
- "Modified: 1.2.1997 / 21:47:40 / cg"
-!
-
-invoke:selector with:arg
- "send a message, with 1 argument.
- TEMPORARY: This method needs more work."
-
- ^ self invoke:selector interpreter:JavaInterpreter new sender:thisContext sender with:arg
-
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- "
- "
- |stack|
-
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- stack invoke:#push with:2.
- stack invoke:#pop.
- stack invoke:#pop.
- stack invoke:#pop.
- "
+ "Modified: 30.7.1997 / 13:44:44 / cg"
!
invoke:selector with:arg1 with:arg2
- "send a message, with 2 arguments.
+ "send a message, with 2 argument.
TEMPORARY: This method needs more work."
^ self
@@ -679,22 +684,37 @@
with:arg1
with:arg2
- "
- |stack|
+ "Modified: 30.7.1997 / 13:44:58 / cg"
+!
+
+invoke:selector with:arg1 with:arg2 with:arg3
+ "send a message, with 3 argument.
+ TEMPORARY: This method needs more work."
+
+ ^ self
+ invoke:selector
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ with:arg1
+ with:arg2
+ with:arg3
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- "
- "
- |stack|
+ "Modified: 30.7.1997 / 13:44:58 / cg"
+ "Created: 30.7.1997 / 13:48:24 / cg"
+!
+
+invoke:selector withAll:args
+ "send a message, with anumber of arguments.
+ TEMPORARY: This method needs more work."
- stack := (Java at:'java/util/Stack') new.
- stack invoke:#push with:1.
- stack invoke:#push with:2.
- stack invoke:#pop.
- stack invoke:#pop.
- stack invoke:#pop.
- "
+ ^ self
+ invoke:selector
+ interpreter:JavaInterpreter new
+ sender:thisContext sender
+ withAll:args
+
+ "Modified: 30.7.1997 / 13:44:58 / cg"
+ "Created: 30.7.1997 / 13:56:33 / cg"
!
lookupMethod:selector numArgs:nargs
@@ -755,5 +775,5 @@
!JavaObject class methodsFor:'documentation'!
version
- ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaObject.st,v 1.27 1997/04/07 17:25:44 cg Exp $'
+ ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaObject.st,v 1.28 1997/07/30 14:41:13 cg Exp $'
! !