- All Implemented Interfaces:
Peerable,PeerableRecipient,Recipient
The parent object is used as a sort of superclass so that messages that aren't explicitly handled by the Java class can be handled by the superclass.
Simple Example
The following example shows a subclass of NSObject that is used as a delegate for an NSOpenPanel. Notice, that, by using the @Msg annotation, the start() method is effectively called via Objective-C. Similarly, the panelSelectionDidChange() method is called by the NSOpenPanel class to respond to events when the user clicks on a different item in the open dialog.
If you run this application, it will open an NSOpenPanel modal dialog and allow you to select a file. If you run this program and select a single file, the output will look something like:
see NSOpenPanelSample-
Field Summary
FieldsModifier and TypeFieldDescriptioncom.sun.jna.PointerPointer to the parent objective-c object of this object. -
Constructor Summary
ConstructorsConstructorDescriptionNSObject()Creates null proxy (i.e.Creates a null proxy using the specified client as the default client with which to send messages to the objective-c runtime.Creates a proxy for the specified objective-c object.NSObject(com.sun.jna.Pointer peer) Creates an NSObject to wrap (i.e.Constructor for NSObject. -
Method Summary
Modifier and TypeMethodDescriptionchain.chain.chain.dealloc()dealloc.voidforwardInvocation(long linvocation) Handles the invocation of a method on the recipient.voidforwardInvocation(com.sun.jna.Pointer invocation) Handles a method invocation.voidforwardInvocationToParent(long linvocation) Forwards an NSInvocation to the parent object to be handled.voidforwardInvocationToParent(com.sun.jna.Pointer invocation) Forwards an NSInvocation to the parent object to be handled.getMethodMap(Class<?> cls) Returns the method map for a particular class.init(com.sun.jna.Pointer parent) Initializes this object and registers it with the Objective-C runtime.Initializes this object and registers it with the Objective-C runtime.methodForSelector(String selector) Returns the java method that responds to a specific selector for the current object.longmethodSignatureForSelector(long lselector) Returns the method signature for a specified selector.com.sun.jna.PointermethodSignatureForSelector(com.sun.jna.Pointer selector) Returns the NSMethodSignature (Objective-C) object pointer for the specified selector.booleanrespondsToSelector(long lselector) Checks to see if this object responds to the specified selector.booleanrespondsToSelector(com.sun.jna.Pointer selector) Checks whether this object responds to the given selector.Methods inherited from class ca.weblite.objc.Proxy
dispose, drainCache, equals, get, getBoolean, getClient, getDouble, getInt, getPeer, getPointer, getProxy, hashCode, load, release, retain, send, send, send, sendBoolean, sendBoolean, sendDouble, sendDouble, sendInt, sendInt, sendPointer, sendPointer, sendProxy, sendProxy, sendRaw, sendRaw, sendRaw, sendString, sendString, set, setClient, setPeer, toString
-
Field Details
-
parent
public com.sun.jna.Pointer parentPointer to the parent objective-c object of this object.
-
-
Constructor Details
-
NSObject
Constructor for NSObject.
- Parameters:
className- aStringobject.
-
NSObject
public NSObject()Creates null proxy (i.e. a proxy around a null pointer). In order to make this class functional and register it with the objective-c runtime, you still need to call one of the init() method variants. -
NSObject
public NSObject(com.sun.jna.Pointer peer) Creates an NSObject to wrap (i.e. send messages to) the specified Objective-C object. This doesn't actually register an object yet with the Objective-C runtime. You must still call init() to do this.- Parameters:
peer- aPointerobject.
-
NSObject
Creates a null proxy using the specified client as the default client with which to send messages to the objective-c runtime.- Parameters:
c- The client that should be used to send messages in this object.
-
NSObject
Creates a proxy for the specified objective-c object.- Parameters:
c- The client that should be used for sending messages via this proxy.peer- The peer object.
-
-
Method Details
-
getMethodMap
Returns the method map for a particular class. The Map that is returned maps string selectors to Method objects.- Parameters:
cls- The class whose map we wish to obtain- Returns:
- The map that maps string selectors
-
init
Initializes this object and registers it with the Objective-C runtime.- Parameters:
parent- aPointerobject.- Returns:
- Self for chaining.
-
init
Initializes this object and registers it with the Objective-C runtime.- Parameters:
cls- The name of the class to use as the super class for this object.- Returns:
- Self for chaining.
-
methodForSelector
Returns the java method that responds to a specific selector for the current object.- Parameters:
selector- The- Returns:
- The method object that handles the specified selector (or null if none is specified).
- See Also:
-
methodSignatureForSelector
public com.sun.jna.Pointer methodSignatureForSelector(com.sun.jna.Pointer selector) Returns the NSMethodSignature (Objective-C) object pointer for the specified selector. If there is a Java method registered with this selector, then it will return its signature. Otherwise it will return the method signature of the parent object.- Parameters:
selector- aPointerobject.- Returns:
- Pointer to an NSMethodSignature object.
- See Also:
-
methodSignatureForSelector
public long methodSignatureForSelector(long lselector) Returns the method signature for a specified selector. Returns the NSMethodSignature (Objective-C) object pointer for the specified selector. If there is a Java method registered with this selector, then it will return its signature. Otherwise it will return the method signature of the parent object.- Specified by:
methodSignatureForSelectorin interfaceRecipient- Parameters:
lselector- The pointer to the selector to check.- Returns:
- Pointer to the NSMethodSignature object for the specified selector.
- See Also:
-
forwardInvocationToParent
public void forwardInvocationToParent(com.sun.jna.Pointer invocation) Forwards an NSInvocation to the parent object to be handled. The parent will handle the invocation (if it contains an appropriate selector), but the peer will still be treated as the "Self" of the message. I.e. this acts exactly like calling super() in an OO language.- Parameters:
invocation- Pointer to the objective-c NSInvocation object.- See Also:
-
forwardInvocationToParent
public void forwardInvocationToParent(long linvocation) Forwards an NSInvocation to the parent object to be handled. The parent will handle the invocation (if it contains an appropriate selector), but the peer will still be treated as the "Self" of the message. I.e. this acts exactly like calling super() in an OO language.- Parameters:
linvocation- a long.- See Also:
-
forwardInvocation
public void forwardInvocation(com.sun.jna.Pointer invocation) Handles a method invocation. This will first check to see if there is a matching Java method in this class (method requires the @Msg annotation), and call that method if it is available. Otherwise it will obtain the method implementation from the parent class and execute it. The return value is added to the NSInvocation object. This method is used by the Native WLProxy to pipe all messages to this object's peer through Java so that it has a chance to process it.- Parameters:
invocation- NSInvocation Objective-C object that is to be invoked.- See Also:
-
forwardInvocation
public void forwardInvocation(long linvocation) Handles the invocation of a method on the recipient. Typically this should either be handled by a java method, or routed to some parent object that is being proxied. Handles a method invocation. This will first check to see if there is a matching Java method in this class (method requires the @Msg annotation), and call that method if it is available. Otherwise it will obtain the method implementation from the parent class and execute it. The return value is added to the NSInvocation object. This method is used by the Native WLProxy to pipe all messages to this object's peer through Java so that it has a chance to process it.- Specified by:
forwardInvocationin interfaceRecipient- Parameters:
linvocation- The NSInvocation object.- Throws:
NSMessageInvocationException- If an exception occurs while attempting to invoke the method.- See Also:
-
respondsToSelector
public boolean respondsToSelector(com.sun.jna.Pointer selector) Checks whether this object responds to the given selector. This is used by the WLProxy (Objective-C peer object) to route requests for its NSProxy respondsToSelector: message. This will check to see if there is a registered java method in the class that responds to the selector (based on the @Msg annotation). Then it will check the parent object to see if it responds to the selector.- Parameters:
selector- Pointer to the selector to check.- Returns:
- a boolean.
- See Also:
-
respondsToSelector
public boolean respondsToSelector(long lselector) Checks to see if this object responds to the specified selector. Checks whether this object responds to the given selector. This is used by the WLProxy (Objective-C peer object) to route requests for its NSProxy respondsToSelector: message. This will check to see if there is a registered java method in the class that responds to the selector (based on the @Msg annotation). Then it will check the parent object to see if it responds to the selector.- Specified by:
respondsToSelectorin interfaceRecipient- Parameters:
lselector- a long.- Returns:
- True if the object responds to the specified selector.
- See Also:
-
chain
chain.
-
chain
chain.
-
chain
chain.
-
dealloc
dealloc.
- Returns:
- a
NSObjectobject.
-