JavaNativeMethod.st
author cg
Thu, 27 Jan 2000 12:24:25 +0000
changeset 663 c346b0d28deb
parent 660 9e916dc2ff18
child 703 37d2ddc947ed
permissions -rw-r--r--
checkin from browser

JavaMethodWithHandler variableSubclass:#JavaNativeMethod
	instanceVariableNames:'nativeImplementation'
	classVariableNames:''
	poolDictionaries:''
	category:'Java-Classes'
!


!JavaNativeMethod class methodsFor:'initialization'!

initialize
    self flags:(self flags bitOr:Behavior flagJavaMethod).
! !

!JavaNativeMethod class methodsFor:'cleanup'!

flushAllCachedNativeMethods
    self allInstancesDo:[:aNativeMethod |
        aNativeMethod nativeImplementation:nil
    ].

    "
     self flushAllCachedNativeMethods
    "

    "Created: / 24.12.1999 / 03:10:38 / cg"
    "Modified: / 24.12.1999 / 03:10:51 / cg"
! !

!JavaNativeMethod methodsFor:'accessing'!

nativeImplementation
    "return the value of the instance variable 'nativeImplementation' (automatically generated)"

    ^ nativeImplementation

    "Created: / 25.9.1999 / 23:08:00 / cg"
!

nativeImplementation:something
    "set the value of the instance variable 'nativeImplementation' (automatically generated)"

    nativeImplementation := something.

    "Created: / 25.9.1999 / 23:08:00 / cg"
! !

!JavaNativeMethod methodsFor:'vm support'!

nativeMethodInvokation
    |nm sel mthd sender|

    (mthd := nativeImplementation) isNil ifTrue:[
        nm := selector copyWithoutLast:signature size.
        sel := ('_' , javaClass lastName , '_' , nm , ':') asSymbol.

        mthd := (JavaVM class compiledMethodAt:sel).
        (mthd isNil or:[mthd isLazyMethod]) ifTrue:[
            sender := thisContext sender.
            sender sender selector == #noByteCode ifTrue:[
                sender := sender sender.
                sender := sender sender.
                sender := sender sender.
            ].
            ^ JavaVM 
                perform:sel
                with:sender.
        ].
        nativeImplementation := mthd.
    ].

    ^ mthd
        valueWithReceiver:JavaVM
        arguments:(Array with:thisContext sender)
        selector:selector
        search:JavaVM class
        sender:nil

    "Modified: / 27.1.2000 / 13:34:53 / cg"
! !

!JavaNativeMethod class methodsFor:'documentation'!

version
    ^ '$Header: /home/jv/Projects/SmalltalkX/repositories/cvs/stx/libjava/JavaNativeMethod.st,v 1.6 2000/01/27 12:24:25 cg Exp $'
! !
JavaNativeMethod initialize!