java.lang.Object
ca.weblite.objc.Client
An object-oriented wrapper around the RuntimeUtils static methods for interacting with the Objective-C runtime.
A client object stores settings about whether to coerce inputs and/or outputs from messages. There are two global instances of this class that are used most often:
getInstance(): The default client with settings to coerce both inputs and outputs. If you need to make a direct call to the Objective-C runtime, this is usually the client that you would use.getRawClient(): Reference to a simple client that is set to not coerce input and output. This is handy if you want to pass in the raw Pointers as parameters, and receive raw pointers as output.
-
Method Summary
Modifier and TypeMethodDescriptionMessage[]buildMessageChain(Object... parameters) Builds a chain of messages that can be executed together at a later time.chain.chain.booleanReturns the coerceInputs flag.booleanReturns the coerceOutputs flag.static ClientRetrieves the global reference to a client that has both input coercion and output coercion enabled.static ClientRetrieves singleton instance to a simple client that has type coercion disabled for both inputs and outputs.newObject(Class<? extends PeerableRecipient> cls) Creates a new peerable and receivable object of the specified class.Sends an array of messages in a chain.Sends a message to an Objective-C object.Sends a message to an Objective-C object.Sends a message to an Objective-C object.Sends a message to an Objective-C object.Sends a message to an Objective-C object.Sends a message to an Objective-C object.com.sun.jna.PointersendPointer(com.sun.jna.Pointer receiver, com.sun.jna.Pointer selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.com.sun.jna.PointersendPointer(com.sun.jna.Pointer receiver, String selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.com.sun.jna.PointersendPointer(String receiver, com.sun.jna.Pointer selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.com.sun.jna.PointersendPointer(String receiver, String selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.A wrapper around send() to ensure that a Proxy object is returned from the message.A wrapper around send() to ensure that a Proxy object is returned from the message.A wrapper around send() to ensure that a Proxy object is returned from the message.A wrapper around send() to ensure that a Proxy object is returned from the message.setCoerceInputs(boolean coerceInputs) Deprecated.setCoerceOutputs(boolean coerceOutputs) Deprecated.UsegetRawClient()to get a client with coercion off.
-
Method Details
-
getInstance
Retrieves the global reference to a client that has both input coercion and output coercion enabled.- Returns:
- Singleton instance.
-
getRawClient
Retrieves singleton instance to a simple client that has type coercion disabled for both inputs and outputs.- Returns:
- a
Clientobject.
-
setCoerceInputs
Deprecated.UsegetRawClient()to get a client with coercion off. UsegetInstance()to get a client with coercion on.Set the coerceInputs flag. Setting this to true will cause all subsequent requests to coerce the input (i.e. convert Java parameters to corresponding C-types).- Parameters:
coerceInputs- Whether to coerce inputs to messages.- Returns:
- Self for chaining.
- See Also:
-
setCoerceOutputs
Deprecated.UsegetRawClient()to get a client with coercion off. UsegetInstance()to get a client with coercion on.Sets the coerceOutputs flag. Setting this to true will cause all subsequent requests to coerce the output (i.e.convert C return values to corresponding Java types.- Parameters:
coerceOutputs- Whether to coerce the outputs of messages.- Returns:
- Self for chaining.
- See Also:
-
getCoerceInputs
public boolean getCoerceInputs()Returns the coerceInputs flag. If this returns true, then it means that the client is currently set to coerce all inputs to messages.- Returns:
- True if input coercion is enabled.
- See Also:
-
getCoerceOutputs
public boolean getCoerceOutputs()Returns the coerceOutputs flag. If this returns true, then it means that the client is currently set to coerce all outputs of messages.- Returns:
- True if output coercion is enabled.
- See Also:
-
send
Sends a message to an Objective-C object.String hello = (String)Client.getInstance() .send(cls("NSString"), sel("stringWithUTF8String:"), "Hello");- Parameters:
receiver- A pointer to the object to which the message is being sent.selector- A pointer to the selector to call on the target.args- Variable arguments of the message.- Returns:
- The return value of the message call.
-
send
Sends a message to an Objective-C object. String selector version.String hello = (String)Client.getInstance() .send(cls("NSString"), "stringWithUTF8String:", "Hello");- Parameters:
receiver- A pointer to the object to which the message is being sent.selector- The string selector. (E.g. "addObject:atIndex:")args- Variable arguments of the message.- Returns:
- The return value of the message call.
-
send
Sends a message to an Objective-C object. String target and Pointer selector version. Typically this variant is used when you need to call a class method (e.g. to instantiate a new object). In this case the receiver is interpreted as a class name.String hello = (String)Client.getInstance() .send("NSString", sel("stringWithUTF8String:"), "Hello");- Parameters:
receiver- The name of a class to send the message to.selector- Pointer to the selector.args- Variable arguments of the message.- Returns:
- The return value of the message call.
-
send
Sends a message to an Objective-C object. String target and String selector version. Typically this variant is used when you need to call a class method (e.g. to instantiate a new object). In this case the receiver is interpreted as a class name.String hello = (String)Client.getInstance() .send("NSString", "stringWithUTF8String:", "Hello");- Parameters:
receiver- The name of a class to send the message to.selector- Pointer to the selector.args- Variable arguments of the message.- Returns:
- The return value of the message call.
-
send
Sends a message to an Objective-C object. Peerable target/Pointer selector variant. This variant is used if you have a Peerable object that is wrapping the Object pointer. E.g. Both the Proxy class and NSObject class implement this interface.Proxy array = Client.getInstance().sendProxy("NSMutableArray", sel("array")); String hello = (String)Client .getInstance().send(array, sel("addObject:atIndex"), "Hello", 2);- Parameters:
selector- Pointer to the selector.args- Variable arguments of the message.proxy- aPeerableobject.- Returns:
- The return value of the message call.
-
send
Sends a message to an Objective-C object. Peerable target/String selector variant. This variant is used if you have a Peerable object that is wrapping the Object pointer. E.g. Both the Proxy class and NSObject class implement this interface.Proxy array = Client.getInstance().sendProxy("NSMutableArray", "array"); String hello = (String)Client .getInstance().send(array, "addObject:atIndex", "Hello", 2);- Parameters:
selector- Pointer to the selector.args- Variable arguments of the message.proxy- aPeerableobject.- Returns:
- The return value of the message call.
-
sendPointer
public com.sun.jna.Pointer sendPointer(com.sun.jna.Pointer receiver, com.sun.jna.Pointer selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A pointer result from the message invocation.
-
sendPointer
public com.sun.jna.Pointer sendPointer(com.sun.jna.Pointer receiver, String selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A pointer result from the message invocation.
-
sendPointer
public com.sun.jna.Pointer sendPointer(String receiver, com.sun.jna.Pointer selector, Object... args) A wrapper around send() to ensure that a pointer is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A pointer result from the message invocation.
-
sendPointer
A wrapper around send() to ensure that a pointer is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A pointer result from the message invocation.
-
sendProxy
A wrapper around send() to ensure that a Proxy object is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A Proxy object wrapper of the result from the message invocation.
-
sendProxy
A wrapper around send() to ensure that a Proxy object is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A Proxy object wrapper of the result from the message invocation.
-
sendProxy
A wrapper around send() to ensure that a Proxy object is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A Proxy object wrapper of the result from the message invocation.
-
sendProxy
A wrapper around send() to ensure that a Proxy object is returned from the message.- Parameters:
receiver- The object to which the message is being sent.selector- The selector to call on the receiver.args- Variable arguments to the message.- Returns:
- A Proxy object wrapper of the result from the message invocation.
-
chain
chain.
-
chain
chain.
-
newObject
Creates a new peerable and receivable object of the specified class. This will create the Objective-C peer and link it to this new class.- Parameters:
cls- The class of the instance that should be created.- Returns:
- A PeerableRecipient object that is connected to an objective-c peer object.
-
send
Sends an array of messages in a chain. -
buildMessageChain
Builds a chain of messages that can be executed together at a later time.
-
getRawClient()to get a client with coercion off.