JavaNativeMethod.st
author Claus Gittinger <cg@exept.de>
Wed, 10 Dec 2003 11:06:45 +0100
changeset 2114 cbdc4c02a8e2
parent 2107 f4509f6767fa
child 2151 c0b6570c6f9b
permissions -rw-r--r--
ExecutionErrorSignal -> ExecutionError
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
703
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
     1
"{ Package: 'stx:libjava' }"
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
     2
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
     3
JavaMethodWithHandler variableSubclass:#JavaNativeMethod
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
     4
	instanceVariableNames:'nativeImplementation'
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
     5
	classVariableNames:''
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
     6
	poolDictionaries:''
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
     7
	category:'Languages-Java-Classes'
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
     8
!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
     9
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    10
616
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    11
!JavaNativeMethod class methodsFor:'initialization'!
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    12
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    13
initialize
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    14
    self flags:(self flags bitOr:Behavior flagJavaMethod).
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    15
! !
53bf2ec50346 *** empty log message ***
cg
parents: 611
diff changeset
    16
654
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    17
!JavaNativeMethod class methodsFor:'cleanup'!
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    18
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    19
flushAllCachedNativeMethods
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    20
    self allInstancesDo:[:aNativeMethod |
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    21
        aNativeMethod nativeImplementation:nil
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    22
    ].
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    23
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    24
    "
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    25
     self flushAllCachedNativeMethods
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    26
    "
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    27
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    28
    "Created: / 24.12.1999 / 03:10:38 / cg"
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    29
    "Modified: / 24.12.1999 / 03:10:51 / cg"
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    30
! !
da8d060a3150 checkin from browser
cg
parents: 642
diff changeset
    31
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    32
!JavaNativeMethod methodsFor:'accessing'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    33
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    34
nativeImplementation
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    35
    "return the value of the instance variable 'nativeImplementation' (automatically generated)"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    36
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    37
    ^ nativeImplementation
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    38
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    39
    "Created: / 25.9.1999 / 23:08:00 / cg"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    40
!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    41
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    42
nativeImplementation:something
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    43
    "set the value of the instance variable 'nativeImplementation' (automatically generated)"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    44
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    45
    nativeImplementation := something.
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    46
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    47
    "Created: / 25.9.1999 / 23:08:00 / cg"
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    48
! !
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    49
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    50
!JavaNativeMethod methodsFor:'vm support'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    51
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    52
nativeMethodInvokation
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    53
    |nm sel mthd sender|
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    54
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    55
    (mthd := nativeImplementation) isNil ifTrue:[
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    56
        nm := selector copyWithoutLast:signature size.
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    57
        sel := ('_' , javaClass lastName , '_' , nm , ':') asSymbol.
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    58
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    59
        mthd := (JavaVM class compiledMethodAt:sel).
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    60
        (mthd isNil or:[mthd isLazyMethod]) ifTrue:[
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
    61
            sender := thisContext sender.
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
    62
            sender sender selector == #noByteCode ifTrue:[
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
    63
                sender := sender sender.
663
c346b0d28deb checkin from browser
cg
parents: 660
diff changeset
    64
                sender := sender sender.
c346b0d28deb checkin from browser
cg
parents: 660
diff changeset
    65
                sender := sender sender.
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
    66
            ].
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    67
            ^ JavaVM 
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    68
                perform:sel
660
9e916dc2ff18 breakpoint with lazy native method
cg
parents: 654
diff changeset
    69
                with:sender.
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    70
        ].
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    71
        nativeImplementation := mthd.
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    72
    ].
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    73
642
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    74
    ^ mthd
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    75
        valueWithReceiver:JavaVM
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    76
        arguments:(Array with:thisContext sender)
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    77
        selector:selector
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    78
        search:JavaVM class
3f9842e199be checkin from browser
cg
parents: 616
diff changeset
    79
        sender:nil
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    80
703
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    81
"
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    82
JavaNativeMethod flushAllCachedNativeMethods
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    83
"
37d2ddc947ed *** empty log message ***
cg
parents: 663
diff changeset
    84
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    85
    "Modified: / 27.1.2000 / 13:34:53 / cg"
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    86
! !
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    87
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    88
!JavaNativeMethod class methodsFor:'documentation'!
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    89
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    90
version
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
    91
    ^ '$Header: /cvs/stx/stx/libjava/JavaNativeMethod.st,v 1.8 2002-11-22 20:09:13 cg Exp $'
611
490fbaed2257 faster nativeMethod invocation
cg
parents:
diff changeset
    92
! !
2107
f4509f6767fa category change
Claus Gittinger <cg@exept.de>
parents: 2097
diff changeset
    93
2097
f0310d8634d3 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 749
diff changeset
    94
JavaNativeMethod initialize!