Class CCodegenUtilities
- java.lang.Object
 - 
- ptolemy.cg.kernel.generic.program.procedural.c.CCodegenUtilities
 
 
- 
public class CCodegenUtilities extends java.lang.ObjectA utility class used to simplify creating c templates in EmbeddedCActors.- Since:
 - Ptolemy II 10.0
 - Version:
 - $Id$
 - Author:
 - Teale Fristoe
 - Pt.AcceptedRating:
 - Pt.ProposedRating:
 - red (tbf)
 
 
- 
- 
Constructor Summary
Constructors Constructor Description CCodegenUtilities() 
- 
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static java.lang.StringgetIncludeBlock(java.lang.String file, java.lang.String constant)Return a code block to include a file.static java.lang.StringjniDeleteLocalRef(java.lang.String reference, boolean targetCpp)Return a code block to delete a jni local reference.static java.lang.StringjniFindClass(java.lang.String className, boolean targetCpp)Return a code block to find a jni class.static java.lang.StringjniGetArrayElements(java.lang.String type, java.lang.String arrayName, boolean targetCpp)Return a code block to get the elements of a jni array.static java.lang.StringjniGetMethodID(java.lang.String jniClass, java.lang.String name, java.lang.String signature, boolean targetCpp)Return a code block to get the jni id of a Java method.static java.lang.StringjniGetObjectArrayElement(java.lang.String arrayName, java.lang.String index, boolean targetCpp)Return a code block to get an element from a jni array.static java.lang.StringjniNewArray(java.lang.String type, java.lang.String size, boolean targetCpp)Return a code block to create a new jni array.static java.lang.StringjniNewObject(java.lang.String objectType, java.lang.String methodID, java.lang.String[] arguments, boolean targetCpp)Return a code block to create a new Java object using jni.static java.lang.StringjniNewObjectArray(java.lang.String size, java.lang.String objectType, boolean targetCpp)Return a code block to create a new jni object array.static java.lang.StringjniReleaseArrayElements(java.lang.String type, java.lang.String arrayName, java.lang.String elementsPointer, boolean targetCpp)Return a code block to release elements from a jni array.static java.lang.StringjniSetArrayRegion(java.lang.String type, java.lang.String arrayName, java.lang.String index, java.lang.String length, java.lang.String valuePointer, boolean targetCpp)Return a code block to set elements in a jniarray.static java.lang.StringjniSetObjectArrayElement(java.lang.String arrayName, java.lang.String index, java.lang.String value, boolean targetCpp)Return a code block to set an element in a jni object array. 
 - 
 
- 
- 
Method Detail
- 
getIncludeBlock
public static java.lang.String getIncludeBlock(java.lang.String file, java.lang.String constant)Return a code block to include a file.- Parameters:
 file- The name of the file.constant- The name of the constant to check to see if the file has already been included.- Returns:
 - A block of codegen code to include a file.
 
 
- 
jniDeleteLocalRef
public static java.lang.String jniDeleteLocalRef(java.lang.String reference, boolean targetCpp)Return a code block to delete a jni local reference.- Parameters:
 reference- The reference to delete.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to delete a jni local reference.
 
 
- 
jniFindClass
public static java.lang.String jniFindClass(java.lang.String className, boolean targetCpp)Return a code block to find a jni class.- Parameters:
 className- The name of the class to find.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to find a jni class.
 
 
- 
jniGetArrayElements
public static java.lang.String jniGetArrayElements(java.lang.String type, java.lang.String arrayName, boolean targetCpp)Return a code block to get the elements of a jni array.- Parameters:
 type- The type, with a capital first letter, of the array elements.arrayName- The name of the jni array.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to get elements from a jni array.
 
 
- 
jniGetMethodID
public static java.lang.String jniGetMethodID(java.lang.String jniClass, java.lang.String name, java.lang.String signature, boolean targetCpp)Return a code block to get the jni id of a Java method.- Parameters:
 jniClass- The Java class whose method to find.name- The name of the method to find.signature- The signature of the method to find.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to get the jni id of a Java method.
 
cid = (*env)->GetMethodID(env, stringClass, "<init>", "([C)V"); 
 
- 
jniGetObjectArrayElement
public static java.lang.String jniGetObjectArrayElement(java.lang.String arrayName, java.lang.String index, boolean targetCpp)Return a code block to get an element from a jni array.- Parameters:
 arrayName- The name of the jni array.index- The index in the jni array to find the element.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to get an element from a jni array.
 
 
- 
jniNewArray
public static java.lang.String jniNewArray(java.lang.String type, java.lang.String size, boolean targetCpp)Return a code block to create a new jni array.- Parameters:
 type- The type of the array.size- The number of elements of the array.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to create a new jni element.
 
 
- 
jniNewObject
public static java.lang.String jniNewObject(java.lang.String objectType, java.lang.String methodID, java.lang.String[] arguments, boolean targetCpp)Return a code block to create a new Java object using jni.- Parameters:
 objectType- The type of the object.methodID- The jni id of the object's constructor.arguments- A list of arguments to the constructor.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to create a new Java object.
 
 
- 
jniNewObjectArray
public static java.lang.String jniNewObjectArray(java.lang.String size, java.lang.String objectType, boolean targetCpp)Return a code block to create a new jni object array.- Parameters:
 size- The number of elements of the array.objectType- The type of object in the array.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to create a new jni object array.
 
 
- 
jniReleaseArrayElements
public static java.lang.String jniReleaseArrayElements(java.lang.String type, java.lang.String arrayName, java.lang.String elementsPointer, boolean targetCpp)Return a code block to release elements from a jni array.- Parameters:
 type- The type of object in the array.arrayName- The name of the array.elementsPointer- The pointer to the element to remove.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to release elements from a jni array.
 
 
- 
jniSetArrayRegion
public static java.lang.String jniSetArrayRegion(java.lang.String type, java.lang.String arrayName, java.lang.String index, java.lang.String length, java.lang.String valuePointer, boolean targetCpp)Return a code block to set elements in a jniarray.- Parameters:
 type- The type of the array.arrayName- The name of the array.index- The index of the first element to set.length- The number of elements to set.valuePointer- The value to set the elements.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to set selements in a jni array.
 
 
- 
jniSetObjectArrayElement
public static java.lang.String jniSetObjectArrayElement(java.lang.String arrayName, java.lang.String index, java.lang.String value, boolean targetCpp)Return a code block to set an element in a jni object array.- Parameters:
 arrayName- The name of the object array.index- The index of the element to set.value- The value to set the element.targetCpp- Boolean indicating whether the target language is C or C++.- Returns:
 - A string containing code to set an element in a jni object array.
 
 
 - 
 
 -