gov.llnl.babel.backend.matlab

Class Matlab


public class Matlab
extends java.lang.Object

This class defines some of the fundamental mapping rules for translating a symbol in the sidl file into Python. These fundamental mapping rules are used repeatedly in the generation of client and server side bindings, so they are seperated into a class that can be shared by all Python code generators.

Some of the particular features include:

Method Summary

static void
StubHeaderFiles(LanguageWriterForC writer)
Generate an include file for a symbol.
static void
StubNullDefine(LanguageWriterForC writer)
static void
addInclude(LanguageWriterForC writer, String filename, boolean useGuard)
static String
allocateStringSpace(String s_strSize)
Generate a string which allocate space a character array.
static String
argComment(Argument arg)
Create a comment to describe the SIDL type for the C signature.
static String
checkMxClass(Type argType, String mxName, int i, boolean isStatic)
Generate a string which checks if a matrix has the proper class to match the argument type in SIDL specification.
static LanguageWriterForC
createStub(Symbol symbol, String description, Context context)
Generate an IO stream to receive the C stub file for the Matlab clients.
static void
generateCArgumentList(LanguageWriterForC writer, Context context, String self, SymbolID id, Method method, boolean addType, boolean isStatic)
static void
generateMatArgumentList(String self, LanguageWriterForMatlab writer, SymbolID id, Method method)
Generate the argument list for Matlab method function.
static String
generatePlhsMatrix(Type t, int idx, String varName)
Generate a string which creates a Mx matrix for the given Matlab data type.
static String
getClientMatFile(SymbolID id)
Generate the Matlab filename for the client using the specified symbol identifier.
static String
getConstructorStubFile(SymbolID id)
static String
getConstructorStubName(SymbolID id)
static String
getFullMethodName(SymbolID id, Method method)
Generate the full method name associated with the symbol id and the specified method.
static String
getHeaderFile(SymbolID id)
static String
getMethodStubFile(SymbolID id, Method method)
static String
getMxType(String sidlType)
Generate an return string for the Matlab type mapping to the specific SIDL Type.
static String
getObjectName(SymbolID id)
Convert a SIDL symbol name into its object name -- for the purposes of this package that means convert it into its typedef object name.
static String
getReturnType(Method method, Context context)
Generate a return string for the specified IOR type.
static String
getSidlReturnType(Method method)
Generate a return string for the specified SIDL type.
static String
getSymbolName(SymbolID id)
Generate the symbol name using the specified * symbol identifier.
static String
sourceFilename(Symbol symbol, String modifier)
Return a string for the JNI native type corresponding to the specified Java type.
static void
writeMexFunctionSignature(LanguageWriterForC writer)

Method Details

StubHeaderFiles

public static void StubHeaderFiles(LanguageWriterForC writer)
Generate an include file for a symbol.

StubNullDefine

public static void StubNullDefine(LanguageWriterForC writer)

addInclude

public static void addInclude(LanguageWriterForC writer,
                              String filename,
                              boolean useGuard)

allocateStringSpace

public static String allocateStringSpace(String s_strSize)
Generate a string which allocate space a character array.

argComment

public static String argComment(Argument arg)
Create a comment to describe the SIDL type for the C signature.
Parameters:
arg - the argument to make a comment from
Returns:
usually this is just the mode as a string. For arrays and rarrays more information is returned.

checkMxClass

public static String checkMxClass(Type argType,
                                  String mxName,
                                  int i,
                                  boolean isStatic)
Generate a string which checks if a matrix has the proper class to match the argument type in SIDL specification.

createStub

public static LanguageWriterForC createStub(Symbol symbol,
                                            String description,
                                            Context context)
            throws CodeGenerationException
Generate an IO stream to receive the C stub file for the Matlab clients.
Throws:
CodeGenerationException - this is a catch all exception for problems during the code generation phase. Currently: setJavaStylePackageGeneration is set to false, need set to true later and does some work on adding new matpath automatically for each created stub directory named after sidl package name

generateCArgumentList

public static void generateCArgumentList(LanguageWriterForC writer,
                                         Context context,
                                         String self,
                                         SymbolID id,
                                         Method method,
                                         boolean addType,
                                         boolean isStatic)
            throws CodeGenerationException

generateMatArgumentList

public static void generateMatArgumentList(String self,
                                           LanguageWriterForMatlab writer,
                                           SymbolID id,
                                           Method method)
            throws CodeGenerationException
Generate the argument list for Matlab method function.

generatePlhsMatrix

public static String generatePlhsMatrix(Type t,
                                        int idx,
                                        String varName)
Generate a string which creates a Mx matrix for the given Matlab data type.

getClientMatFile

public static String getClientMatFile(SymbolID id)
Generate the Matlab filename for the client using the specified symbol identifier.

getConstructorStubFile

public static String getConstructorStubFile(SymbolID id)

getConstructorStubName

public static String getConstructorStubName(SymbolID id)

getFullMethodName

public static String getFullMethodName(SymbolID id,
                                       Method method)
Generate the full method name associated with the symbol id and the specified method. The returned name prepends the symbol name and only one underbar to the method's name.
Parameters:
id - the SymbolID of the Symbol associated with the method.
method - the Method whose full name is being built.

getHeaderFile

public static String getHeaderFile(SymbolID id)

getMethodStubFile

public static String getMethodStubFile(SymbolID id,
                                       Method method)

getMxType

public static String getMxType(String sidlType)
Generate an return string for the Matlab type mapping to the specific SIDL Type. Currently supported SIDL types: int, long, float, double, bool.

getObjectName

public static String getObjectName(SymbolID id)
Convert a SIDL symbol name into its object name -- for the purposes of this package that means convert it into its typedef object name. The typedef name is the SIDL symbol name with the "." scope separators replaced by underscores.
Parameters:
id - the SymbolID of the Symbol.

getReturnType

public static String getReturnType(Method method,
                                   Context context)
            throws CodeGenerationException
Generate a return string for the specified IOR type.

getSidlReturnType

public static String getSidlReturnType(Method method)
Generate a return string for the specified SIDL type.

getSymbolName

public static String getSymbolName(SymbolID id)
Generate the symbol name using the specified * symbol identifier. Simply replace the "." to "_". name.

sourceFilename

public static String sourceFilename(Symbol symbol,
                                    String modifier)
Return a string for the JNI native type corresponding to the specified Java type. Everything that is not a primitive type like integer or boolean is converted into an JNI object.

writeMexFunctionSignature

public static void writeMexFunctionSignature(LanguageWriterForC writer)