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