Dereference a handle to an Object or Array.
There is no equivalent macro for this operation. Objects
are passed by reference in Toba, not by handles.
Return the length of an array. There is no equivalent macro for this operation. To achieve the same result an Object must be cast to one of the array structure types and the size field examined:
struct carray *ca = (carray *)obj; int length; length = ca->length;
Return the data portion of an array. There is no equivalent macro for this operation. To achieve the same result an Object must be cast to the proper array structure and the data field accessed:
struct carray *ca = (carray *)obj; Char *data; data = ca->data;
Return the class with the given name.
This class is provided by the Java API function
Class.forName(). An upcall into Java
from C should be done to call this method.
Make an array of characters or Java string from a C string.
The function
struct in_java_lang_String *javastring(char *)
performs a similar operation
Allocate an array of the given type and length. The function Object anewarray(Class c, int nelem) performs a similar operation. Class structures for primitives are provided for making arrays of primitive types:
struct carray = anewarray(&cl_char, 3);
Execute methods. There is no equivalent function in Toba. Java methods get translated into C functions and are directly callable (modulo the name-hashing) from C. In order to call a Java method its name should be looked up in the appropriate header file. A static invocation is a direct call to the desired method:
struct in_java_lang_String *str = (struct in_java_lang_String *)arg2; Int hash = hashCode__mK6Su(str);Dynamic invocations are indirect calls through the classes method table:
hash = str->class.M.hash_Code__mK6Su.f(str);
Create a new object.
An object can be constructed using the default constructor
by calling the construct() function. In order to
call another constructor the object should be created
explicitly with new and the appropriate constructor
should be called directly (the name of the constructor can
be found in the generated header file).
Throw an exception.
The function athrow(Object o) raises an exception
of type o. There are many wrapper functions for creating
the object and setting its message type. See
void throwMesg(Class etype, char *mesg)
and the many other throw* functions.
Print a string object.
There is no Toba function with an equivalent operation.
An equivalent operation can be done by translating the
string to a C string and printing it, or by calling
a Java method that will print out the string.
Return the length of a string. There is no Toba function with an equivalent operation. You can get the length of a string by accessing the instances count field:
struct in_java_lang_String *s = (struct in_java_lang_String *)obj; length = s->count;
Create a C string from a Java string.
The function
char *cstring(struct in_java_lang_String *s)
performs the same operation. The returned C string will be
garbage collected
Create an array of unicode characters from a string.
There is no Toba function implementing this function
Create a C string in the buffer provided. There is no Toba function implementing this function. The cstring function performs a similar operation.