gov.llnl.babel.backend.matlab
Class Matlab

java.lang.Object
  extended by gov.llnl.babel.backend.matlab.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:


Constructor Summary
Matlab()
           
 
Method Summary
static void addInclude(LanguageWriterForC writer, java.lang.String filename, boolean useGuard)
           
static java.lang.String allocateStringSpace(java.lang.String s_strSize)
          Generate a string which allocate space a character array.
static java.lang.String argComment(Argument arg)
          Create a comment to describe the SIDL type for the C signature.
static java.lang.String checkMxClass(Type argType, java.lang.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, java.lang.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, java.lang.String self, SymbolID id, Method method, boolean addType, boolean isStatic)
           
static void generateMatArgumentList(java.lang.String self, LanguageWriterForMatlab writer, SymbolID id, Method method)
          Generate the argument list for Matlab method function.
static java.lang.String generatePlhsMatrix(Type t, int idx, java.lang.String varName)
          Generate a string which creates a Mx matrix for the given Matlab data type.
static java.lang.String getClientMatFile(SymbolID id)
          Generate the Matlab filename for the client using the specified symbol identifier.
static java.lang.String getConstructorStubFile(SymbolID id)
           
static java.lang.String getConstructorStubName(SymbolID id)
           
static java.lang.String getFullMethodName(SymbolID id, Method method)
          Generate the full method name associated with the symbol id and the specified method.
static java.lang.String getHeaderFile(SymbolID id)
           
static java.lang.String getMethodStubFile(SymbolID id, Method method)
           
static java.lang.String getMxType(java.lang.String sidlType)
          Generate an return string for the Matlab type mapping to the specific SIDL Type.
static java.lang.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 java.lang.String getReturnType(Method method, Context context)
          Generate a return string for the specified IOR type.
static java.lang.String getSidlReturnType(Method method)
          Generate a return string for the specified SIDL type.
static java.lang.String getSymbolName(SymbolID id)
          Generate the symbol name using the specified * symbol identifier.
static java.lang.String sourceFilename(Symbol symbol, java.lang.String modifier)
          Return a string for the JNI native type corresponding to the specified Java type.
static void StubHeaderFiles(LanguageWriterForC writer)
          Generate an include file for a symbol.
static void StubNullDefine(LanguageWriterForC writer)
           
static void writeMexFunctionSignature(LanguageWriterForC writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Matlab

public Matlab()
Method Detail

getSymbolName

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


getHeaderFile

public static java.lang.String getHeaderFile(SymbolID id)

getClientMatFile

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


getConstructorStubName

public static java.lang.String getConstructorStubName(SymbolID id)

getConstructorStubFile

public static java.lang.String getConstructorStubFile(SymbolID id)

getFullMethodName

public static java.lang.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.

getMethodStubFile

public static java.lang.String getMethodStubFile(SymbolID id,
                                                 Method method)

writeMexFunctionSignature

public static void writeMexFunctionSignature(LanguageWriterForC writer)

getObjectName

public static java.lang.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.

generateMatArgumentList

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

Throws:
CodeGenerationException

generateCArgumentList

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

argComment

public static java.lang.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.

getReturnType

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

Throws:
CodeGenerationException

getSidlReturnType

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


getMxType

public static java.lang.String getMxType(java.lang.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.


allocateStringSpace

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


checkMxClass

public static java.lang.String checkMxClass(Type argType,
                                            java.lang.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.


generatePlhsMatrix

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


StubHeaderFiles

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


addInclude

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

StubNullDefine

public static void StubNullDefine(LanguageWriterForC writer)

sourceFilename

public static java.lang.String sourceFilename(Symbol symbol,
                                              java.lang.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.


createStub

public static LanguageWriterForC createStub(Symbol symbol,
                                            java.lang.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