gov.llnl.babel.backend.python
Class Python

java.lang.Object
  extended by gov.llnl.babel.backend.python.Python

public class Python
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
Python()
          Build a Python support object.
 
Method Summary
static Method connectRemoteMethod(Extendable ext, Context context)
           
static LanguageWriterForC createCHeader(Symbol symbol, java.lang.String modifier, java.lang.String description, Context context)
           
static LanguageWriterForC createLaunch(Symbol symbol, java.lang.String description, Context context)
          Generate an IO stream to receive the C skeleton file for the Python implementations.
static LanguageWriterForPython createPyWriter(Symbol symbol, java.lang.String file, java.lang.String description, Context context)
          Create a Python LanguageWriterForPython with a banner comment a documentation string in the FileManager group PYTHON.
static Method createRemoteMethod(Extendable ext, Context context)
           
static LanguageWriterForC createSkel(Symbol symbol, java.lang.String description, Context context)
          Generate an IO stream to receive the C skeleton file for the Python implementations.
static LanguageWriterForC createStub(Symbol symbol, java.lang.String description, Context context)
          Generate an IO stream to receive the C stub file for the Python clients.
static void generateRMIExternStruct(Class cls, LanguageWriterForC lw, Context context)
          This method generates the rmi struct that allows connect and rmicast to be called through the pSkel.
static java.lang.String getAPIVarName(Symbol symbol)
           
static java.lang.String getBorrowArrayFromPython(Type arrayType)
           
static java.lang.String getBorrowArrayFromSIDL(Type arrayType)
           
static java.lang.String getCHeaderPath(Symbol symbol, java.lang.String modifier)
           
static java.lang.String getCopyArrayFromPython(Type arrayType)
           
static java.lang.String getCopyArrayFromSIDL(Type arrayType)
           
static java.lang.String getDestroyArray(Type arrayType)
           
static java.lang.String getExceptionType(Symbol symbol)
           
static java.lang.String getExtendableAddRef(Symbol symbol)
           
static java.lang.String getExtendableBorrow(Symbol symbol)
           
static java.lang.String getExtendableConnect(Symbol symbol)
           
static java.lang.String getExtendableConverter(Symbol symbol)
           
static java.lang.String getExtendableDeref(Symbol symbol)
           
static java.lang.String getExtendableImport(Symbol symbol)
           
static java.lang.String getExtendableNewRef(Symbol symbol)
           
static java.lang.String getExtendableType(Symbol symbol)
           
static java.lang.String getExtendableWrapper(Symbol symbol)
           
static java.lang.String getImport(java.lang.String className)
           
static java.lang.String getIncludeGuard(Symbol symbol, java.lang.String modifier)
          Generate an include file for a symbol.
static java.lang.String getInternalGuard(Symbol symbol)
           
static java.lang.String getPSkelFCastName(SymbolID sourceid, SymbolID targetid)
          Convert a SIDL symbol into the name of its associated remote connector.
static java.lang.String getPSkelFConnectName(SymbolID sourceid, SymbolID targetid)
          Convert a SIDL symbol into the name of its associated remote connector.
static java.lang.String getPSkelSerializeName(SymbolID sourceid, SymbolID targetid, boolean serialize, boolean inLaunch)
          Convert a SIDL symbol into the name of its associated remote (de)serialize method.
static CodeSplicer getPySplicer(Symbol symbol, java.lang.String filename, Context context)
          If filename already exists, extract the code splicer blocks from it and store the contents in the returned code splicer; otherwise, return an empty code splicer.
static java.lang.String getPyStructType(Symbol symbol)
           
static java.lang.String getRMIExternName(SymbolID id)
          Convert a sidl symbol into the name of its associated get RMI Externals method, which is the symbol name appended with "__impl_rmi_externals".
static java.lang.String getSetEPVName(SymbolID id)
          Convert a sidl symbol into the name of its associated set EPV method, which is the symbol name appended with "__set_epv".
static java.lang.String getSetSEPVName(SymbolID id)
          Convert a sidl symbol into the name of its associated set static EPV method, which is the symbol name appended with "__set_sepv".
static java.lang.String getSkelMethod(SymbolID id, Method m)
          Return the name of the function that should be used for the skeleton.
static java.lang.String getStructBorrow(Symbol symbol)
           
static java.lang.String getStructCopy(Symbol symbol)
           
static java.lang.String getStructDeserialize(Symbol symbol)
           
static java.lang.String getStructDestroy(Symbol symbol)
           
static java.lang.String getStructInit(Symbol symbol)
           
static java.lang.String getStructSerialize(Symbol symbol)
           
static java.lang.String getStubMethod(SymbolID id, Method m)
          Return the name of the function that should be used for the Python stub code.
static java.lang.String headerFilename(Symbol symbol, java.lang.String modifier)
           
static java.lang.String implFilename(Symbol symbol)
           
static void leavePython(LanguageWriter lw)
           
static int maxNameLength(java.util.Collection items)
           
static void resumePython(LanguageWriter lw)
           
static java.lang.String skelFilename(Symbol symbol, java.lang.String modifier)
           
static java.lang.String sourceFilename(Symbol symbol, java.lang.String modifier)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Python

public Python()
Build a Python support object.

Method Detail

getIncludeGuard

public static java.lang.String getIncludeGuard(Symbol symbol,
                                               java.lang.String modifier)
Generate an include file for a symbol.


headerFilename

public static java.lang.String headerFilename(Symbol symbol,
                                              java.lang.String modifier)

sourceFilename

public static java.lang.String sourceFilename(Symbol symbol,
                                              java.lang.String modifier)

skelFilename

public static java.lang.String skelFilename(Symbol symbol,
                                            java.lang.String modifier)

implFilename

public static java.lang.String implFilename(Symbol symbol)

getAPIVarName

public static java.lang.String getAPIVarName(Symbol symbol)

getInternalGuard

public static java.lang.String getInternalGuard(Symbol symbol)

getCHeaderPath

public static java.lang.String getCHeaderPath(Symbol symbol,
                                              java.lang.String modifier)

createCHeader

public static LanguageWriterForC createCHeader(Symbol symbol,
                                               java.lang.String modifier,
                                               java.lang.String description,
                                               Context context)
                                        throws CodeGenerationException
Throws:
CodeGenerationException

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 Python clients.

Throws:
CodeGenerationException - this is a catch all exception for problems during the code generation phase.

createSkel

public static LanguageWriterForC createSkel(Symbol symbol,
                                            java.lang.String description,
                                            Context context)
                                     throws CodeGenerationException
Generate an IO stream to receive the C skeleton file for the Python implementations.

Throws:
CodeGenerationException - this is a catch all exception for problems during the code generation phase.

createLaunch

public static LanguageWriterForC createLaunch(Symbol symbol,
                                              java.lang.String description,
                                              Context context)
                                       throws CodeGenerationException
Generate an IO stream to receive the C skeleton file for the Python implementations.

Throws:
CodeGenerationException - this is a catch all exception for problems during the code generation phase.

getSkelMethod

public static java.lang.String getSkelMethod(SymbolID id,
                                             Method m)
Return the name of the function that should be used for the skeleton.

Parameters:
id - the symbol who owns the method.
m - the method

getStubMethod

public static java.lang.String getStubMethod(SymbolID id,
                                             Method m)
Return the name of the function that should be used for the Python stub code.

Parameters:
id - the symbol who owns the method.
m - the method

getPySplicer

public static CodeSplicer getPySplicer(Symbol symbol,
                                       java.lang.String filename,
                                       Context context)
                                throws java.io.IOException
If filename already exists, extract the code splicer blocks from it and store the contents in the returned code splicer; otherwise, return an empty code splicer.

Parameters:
symbol - the symbol whose splicer is to be returned.
filename - the name of the file
Returns:
a valid (though possibly empty) CodeSplicer
Throws:
java.io.IOException - where there is IO, there is the possibility for an IOException.

createPyWriter

public static LanguageWriterForPython createPyWriter(Symbol symbol,
                                                     java.lang.String file,
                                                     java.lang.String description,
                                                     Context context)
                                              throws CodeGenerationException
Create a Python LanguageWriterForPython with a banner comment a documentation string in the FileManager group PYTHON.

Parameters:
symbol - the symbol for which the LanguageWriter is being created.
file - the name of the file to be created. This contains no directory references.
description - a brief statement of the purpose of the file. This string should have no newlines.
Throws:
gov.llnl.backend.CodeGenerationException - something went wrong while trying to create the file.
CodeGenerationException

getSetEPVName

public static java.lang.String getSetEPVName(SymbolID id)
Convert a sidl symbol into the name of its associated set EPV method, which is the symbol name appended with "__set_epv".


getRMIExternName

public static java.lang.String getRMIExternName(SymbolID id)
Convert a sidl symbol into the name of its associated get RMI Externals method, which is the symbol name appended with "__impl_rmi_externals".


getSetSEPVName

public static java.lang.String getSetSEPVName(SymbolID id)
Convert a sidl symbol into the name of its associated set static EPV method, which is the symbol name appended with "__set_sepv".


getImport

public static java.lang.String getImport(java.lang.String className)

getExtendableImport

public static java.lang.String getExtendableImport(Symbol symbol)

getExtendableWrapper

public static java.lang.String getExtendableWrapper(Symbol symbol)

getExtendableBorrow

public static java.lang.String getExtendableBorrow(Symbol symbol)

getExceptionType

public static java.lang.String getExceptionType(Symbol symbol)

maxNameLength

public static int maxNameLength(java.util.Collection items)

getExtendableConverter

public static java.lang.String getExtendableConverter(Symbol symbol)

getExtendableNewRef

public static java.lang.String getExtendableNewRef(Symbol symbol)

getExtendableType

public static java.lang.String getExtendableType(Symbol symbol)

getPyStructType

public static java.lang.String getPyStructType(Symbol symbol)

getStructInit

public static java.lang.String getStructInit(Symbol symbol)

getStructCopy

public static java.lang.String getStructCopy(Symbol symbol)

getStructBorrow

public static java.lang.String getStructBorrow(Symbol symbol)

getStructDestroy

public static java.lang.String getStructDestroy(Symbol symbol)

getStructSerialize

public static java.lang.String getStructSerialize(Symbol symbol)

getStructDeserialize

public static java.lang.String getStructDeserialize(Symbol symbol)

getExtendableAddRef

public static java.lang.String getExtendableAddRef(Symbol symbol)

getExtendableConnect

public static java.lang.String getExtendableConnect(Symbol symbol)

getExtendableDeref

public static java.lang.String getExtendableDeref(Symbol symbol)

getBorrowArrayFromPython

public static java.lang.String getBorrowArrayFromPython(Type arrayType)

getBorrowArrayFromSIDL

public static java.lang.String getBorrowArrayFromSIDL(Type arrayType)

getCopyArrayFromPython

public static java.lang.String getCopyArrayFromPython(Type arrayType)

getCopyArrayFromSIDL

public static java.lang.String getCopyArrayFromSIDL(Type arrayType)

leavePython

public static void leavePython(LanguageWriter lw)

resumePython

public static void resumePython(LanguageWriter lw)

getDestroyArray

public static java.lang.String getDestroyArray(Type arrayType)

getPSkelFConnectName

public static java.lang.String getPSkelFConnectName(SymbolID sourceid,
                                                    SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector. This requires both the SybmolID of the class this is being defined in (sourceid) and the SymbolID of the target class to be connected (targetid)


getPSkelSerializeName

public static java.lang.String getPSkelSerializeName(SymbolID sourceid,
                                                     SymbolID targetid,
                                                     boolean serialize,
                                                     boolean inLaunch)
Convert a SIDL symbol into the name of its associated remote (de)serialize method. This requires both the SybmolID of the class this is being defined in (sourceid) and the SymbolID of the target class to be connected (targetid)


getPSkelFCastName

public static java.lang.String getPSkelFCastName(SymbolID sourceid,
                                                 SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector. This requires both the SybmolID of the class this is being defined in (sourceid) and the SymbolID of the target class to be connected (targetid)


createRemoteMethod

public static Method createRemoteMethod(Extendable ext,
                                        Context context)

connectRemoteMethod

public static Method connectRemoteMethod(Extendable ext,
                                         Context context)

generateRMIExternStruct

public static void generateRMIExternStruct(Class cls,
                                           LanguageWriterForC lw,
                                           Context context)
                                    throws CodeGenerationException
This method generates the rmi struct that allows connect and rmicast to be called through the pSkel.

Throws:
CodeGenerationException