|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectca.weblite.objc.RuntimeUtils
public class RuntimeUtils
A Java class with static methods that interact with the Objective-C runtime. These methods wrap the *very* low level methods provided by the Runtime class to provide a slightly higher level of abstraction.
It is helpful to perform a static import of the methods in this class if you will be using the objc runtime library, as it contains many utility methods to deal with Objective-C primitives. E.g. the cls() method can return the Pointer to a class given its name. The clsName() returns the name of the class specified by a Pointer().
There are also many variants of the msg() method for sendng messages to objects in the Objective-C runtime.
| Field Summary | |
|---|---|
static boolean |
loaded
Flag to indicate whether the jcocoa native library was loaded successfully. |
static Runtime |
rt
Short reference to the runtime instance for interacting with Objective-C |
| Constructor Summary | |
|---|---|
RuntimeUtils()
|
|
| Method Summary | |
|---|---|
static com.sun.jna.Pointer |
addr(Peerable peer)
Returns the pointer to the Native peer for a Peerable object. |
static int |
arraySize(String signature)
Returns the size of an array that is specified in a signature. |
static com.sun.jna.Pointer |
cls(Peerable peer)
Returns a pointer to a class given a Peerable object which wraps the pointer. |
static com.sun.jna.Pointer |
cls(String name)
Returns a pointer to the class for specific class name. |
static String |
clsName(Peerable peer)
A wrapper for the clsName() method given a Peerable object that wraps the class pointer. |
static String |
clsName(com.sun.jna.Pointer cls)
Returns the name of an objective C class specified by the given class pointer. |
static long |
createProxy(Recipient client)
Registers a Java object with the Objective-C runtime so that it can begin to receive messages from it. |
static com.sun.jna.Pointer |
getAsReference(Object val,
String signature)
Wraps the given value in the appropriate ByReference subclass according to the provided signature. |
static com.sun.jna.ptr.ByReference |
getAsReferenceWrapper(Object val,
String signature)
Wraps the given value in the appropriate ByReference subclass according to the provided signature. |
static Recipient |
getJavaPeer(long nsObject)
Returns the Java peer recipient for a native Objective-C object if it exists. |
static void |
init()
Initializes the libjcocoa library. |
static Object |
msg(boolean coerceReturn,
boolean coerceArgs,
com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Sends a message with the option of coercing the inputs and outputs. |
static Object |
msg(Message... messages)
Sends a batch of messages in sequence. |
static long |
msg(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Sends a message to a specified class using the given selector. |
static long |
msg(com.sun.jna.Pointer receiver,
String msg,
Object... args)
Sends a message to a specified class using the given selector. |
static long |
msg(String cls,
com.sun.jna.Pointer msg,
Object... args)
Sends a message to a specified class using the given selector. |
static long |
msg(String cls,
String msg,
Object... args)
Sends a message to a specified class using the given selector. |
static boolean |
msgBoolean(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns a boolean value. |
static boolean |
msgBoolean(com.sun.jna.Pointer receiver,
String selector,
Object... args)
Wrapper around msg() that returns a boolean value. |
static boolean |
msgBoolean(String receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns a boolean value. |
static boolean |
msgBoolean(String receiver,
String selector,
Object... args)
Wrapper around msg() that returns a boolean value. |
static double |
msgDouble(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Sends a message that returns a double value. |
static double |
msgDouble(com.sun.jna.Pointer receiver,
String selector,
Object... args)
Sends a message that returns a double value. |
static double |
msgDouble(String receiver,
com.sun.jna.Pointer selector,
Object... args)
Sends a message that returns a double value. |
static double |
msgDouble(String receiver,
String selector,
Object... args)
Sends a message that returns a double value. |
static int |
msgInt(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns an int. |
static int |
msgInt(com.sun.jna.Pointer receiver,
String selector,
Object... args)
Wrapper around msg() that returns an int. |
static int |
msgInt(String receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns an int. |
static int |
msgInt(String receiver,
String selector,
Object... args)
Wrapper around msg() that returns an int. |
static com.sun.jna.Pointer |
msgPointer(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns a Pointer. |
static com.sun.jna.Pointer |
msgPointer(com.sun.jna.Pointer receiver,
String selector,
Object... args)
Wrapper around msg() that returns a Pointer. |
static com.sun.jna.Pointer |
msgPointer(String receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns a Pointer. |
static com.sun.jna.Pointer |
msgPointer(String receiver,
String selector,
Object... args)
Wrapper around msg() that returns a Pointer. |
static String |
msgString(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns a string value. |
static String |
msgString(com.sun.jna.Pointer receiver,
String selector,
Object... args)
Wrapper around msg() that returns a string value. |
static String |
msgString(String receiver,
com.sun.jna.Pointer selector,
Object... args)
Wrapper around msg() that returns a string value. |
static String |
msgString(String receiver,
String selector,
Object... args)
Wrapper around msg() that returns a string value. |
static com.sun.jna.Pointer |
sel(Peerable peer)
Returns a pointer to the selector that is wrapped by a Peerable object. |
static com.sun.jna.Pointer |
sel(String name)
Returns a pointer to the selector specified by the given selector name. |
static String |
selName(Peerable peer)
Returns the name of a selector. |
static String |
selName(com.sun.jna.Pointer sel)
Returns the name of a selector. |
static String |
str(com.sun.jna.Pointer str)
Converts A native NSString object to a Java string. |
static com.sun.jna.Pointer |
str(String str)
Converts a Java string to an NSString object. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static Runtime rt
public static boolean loaded
| Constructor Detail |
|---|
public RuntimeUtils()
| Method Detail |
|---|
public static com.sun.jna.Pointer cls(String name)
Pointer nsObject = cls("NSObject");
name - The name of the class to retrieve.
public static com.sun.jna.Pointer cls(Peerable peer)
peer - The peer object that is wrapping the Objective-C class
object.
public static String clsName(com.sun.jna.Pointer cls)
cls - The pointer to the class whose name we wish to retrieve.
Runtime.class_getName()public static String clsName(Peerable peer)
peer -
Runtime.class_getName()public static com.sun.jna.Pointer sel(String name)
name -
public static com.sun.jna.Pointer sel(Peerable peer)
peer -
public static String selName(com.sun.jna.Pointer sel)
sel - Pointer to a selector.
public static String selName(Peerable peer)
sel - Peerable that wraps a pointer to a selector.
public static long msg(String cls,
String msg,
Object... args)
cls - The name of the class.msg - The name of the selector.args - The arguments passed to the method. These are passed raw
and will not be coerced.
msgDouble()
public static long msg(String cls,
com.sun.jna.Pointer msg,
Object... args)
cls - The name of the class.msg - The name of the selector.args - The arguments passed to the method. These are passed raw
and will not be coerced.
msgDouble()
public static long msg(com.sun.jna.Pointer receiver,
String msg,
Object... args)
cls - The name of the class.msg - The name of the selector.args - The arguments passed to the method. These are passed raw
and will not be coerced.
msgDouble()
public static long msg(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
cls - The name of the class.msg - The name of the selector.args - The arguments passed to the method. These are passed raw
and will not be coerced.
msgDouble()
public static com.sun.jna.Pointer msgPointer(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static com.sun.jna.Pointer msgPointer(com.sun.jna.Pointer receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static com.sun.jna.Pointer msgPointer(String receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static com.sun.jna.Pointer msgPointer(String receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static int msgInt(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static int msgInt(String receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static int msgInt(String receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static int msgInt(com.sun.jna.Pointer receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static boolean msgBoolean(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static boolean msgBoolean(String receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static boolean msgBoolean(String receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static boolean msgBoolean(com.sun.jna.Pointer receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static String msgString(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static String msgString(String receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static String msgString(String receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static String msgString(com.sun.jna.Pointer receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - Arguments passed to the message.
public static double msgDouble(com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static double msgDouble(String receiver,
com.sun.jna.Pointer selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static double msgDouble(String receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static double msgDouble(com.sun.jna.Pointer receiver,
String selector,
Object... args)
receiver - The target of the message.selector - The selector for the message.args - The arguments passed to the message.
public static Object msg(boolean coerceReturn,
boolean coerceArgs,
com.sun.jna.Pointer receiver,
com.sun.jna.Pointer selector,
Object... args)
Furthermore, this variant is smart about which variable of msg() to call behind the scenes. E.g. if the message signature specifies that this message returns a double, it will automatically use the double variant of msg().
coerceReturn - If true, then the return value will be mapped to an appropriate
Java value using the TypeMapper class.coerceArgs - If true, then the inputs will be mapped from Java to appropriate
C values using the TypeMapper class.receiver - The target of the message.selector - The selector for the message.args - The arguments to be passed in the message.
public static int arraySize(String signature)
signature - The signature for a parameter using Objective-C type encodings.
public static com.sun.jna.Pointer addr(Peerable peer)
peer -
public static Object msg(Message... messages)
messages -
public static com.sun.jna.Pointer str(String str)
str - The Java string to convert.
public static String str(com.sun.jna.Pointer str)
str -
public static com.sun.jna.Pointer getAsReference(Object val,
String signature)
val - The value to be wrapped in a byReference.signature - The signature (using Objective-C type encodings) of the value.
public static com.sun.jna.ptr.ByReference getAsReferenceWrapper(Object val,
String signature)
val - The value to be wrapped in a byReference.signature - The signature (using Objective-C type encodings) of the value.
public static void init()
public static long createProxy(Recipient client)
client -
public static Recipient getJavaPeer(long nsObject)
nsObject -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||