gov.llnl.babel.backend.python

Class 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, String modifier, String description, Context context)
static LanguageWriterForC
createLaunch(Symbol symbol, String description, Context context)
Generate an IO stream to receive the C skeleton file for the Python implementations.
static LanguageWriterForPython
createPyWriter(Symbol symbol, String file, 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, String description, Context context)
Generate an IO stream to receive the C skeleton file for the Python implementations.
static LanguageWriterForC
createStub(Symbol symbol, 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 String
getAPIVarName(Symbol symbol)
static String
getBorrowArrayFromPython(Type arrayType)
static String
getBorrowArrayFromSIDL(Type arrayType)
static String
getCHeaderPath(Symbol symbol, String modifier)
static String
getCopyArrayFromPython(Type arrayType)
static String
getCopyArrayFromSIDL(Type arrayType)
static String
getDestroyArray(Type arrayType)
static String
getExceptionType(Symbol symbol)
static String
getExtendableAddRef(Symbol symbol)
static String
getExtendableBorrow(Symbol symbol)
static String
getExtendableConnect(Symbol symbol)
static String
getExtendableConverter(Symbol symbol)
static String
getExtendableDeref(Symbol symbol)
static String
getExtendableImport(Symbol symbol)
static String
getExtendableNewRef(Symbol symbol)
static String
getExtendableType(Symbol symbol)
static String
getExtendableWrapper(Symbol symbol)
static String
getImport(String className)
static String
getIncludeGuard(Symbol symbol, String modifier)
Generate an include file for a symbol.
static String
getInternalGuard(Symbol symbol)
static String
getPSkelFCastName(SymbolID sourceid, SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector.
static String
getPSkelFConnectName(SymbolID sourceid, SymbolID targetid)
Convert a SIDL symbol into the name of its associated remote connector.
static 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, 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 String
getPyStructType(Symbol symbol)
static 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 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 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 String
getSkelMethod(SymbolID id, Method m)
Return the name of the function that should be used for the skeleton.
static String
getStructBorrow(Symbol symbol)
static String
getStructCopy(Symbol symbol)
static String
getStructDeserialize(Symbol symbol)
static String
getStructDestroy(Symbol symbol)
static String
getStructInit(Symbol symbol)
static String
getStructSerialize(Symbol symbol)
static String
getStubMethod(SymbolID id, Method m)
Return the name of the function that should be used for the Python stub code.
static String
headerFilename(Symbol symbol, String modifier)
static String
implFilename(Symbol symbol)
static int
maxNameLength(Collection items)
static String
skelFilename(Symbol symbol, String modifier)
static String
sourceFilename(Symbol symbol, String modifier)

Constructor Details

Python

public Python()
Build a Python support object.

Method Details

connectRemoteMethod

public static Method connectRemoteMethod(Extendable ext,
                                         Context context)

createCHeader

public static LanguageWriterForC createCHeader(Symbol symbol,
                                               String modifier,
                                               String description,
                                               Context context)
            throws CodeGenerationException

createLaunch

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

createPyWriter

public static LanguageWriterForPython createPyWriter(Symbol symbol,
                                                     String file,
                                                     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.

createRemoteMethod

public static Method createRemoteMethod(Extendable ext,
                                        Context context)

createSkel

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

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 Python clients.
Throws:
CodeGenerationException - this is a catch all exception for problems during the code generation phase.

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.

getAPIVarName

public static String getAPIVarName(Symbol symbol)

getBorrowArrayFromPython

public static String getBorrowArrayFromPython(Type arrayType)

getBorrowArrayFromSIDL

public static String getBorrowArrayFromSIDL(Type arrayType)

getCHeaderPath

public static String getCHeaderPath(Symbol symbol,
                                    String modifier)

getCopyArrayFromPython

public static String getCopyArrayFromPython(Type arrayType)

getCopyArrayFromSIDL

public static String getCopyArrayFromSIDL(Type arrayType)

getDestroyArray

public static String getDestroyArray(Type arrayType)

getExceptionType

public static String getExceptionType(Symbol symbol)

getExtendableAddRef

public static String getExtendableAddRef(Symbol symbol)

getExtendableBorrow

public static String getExtendableBorrow(Symbol symbol)

getExtendableConnect

public static String getExtendableConnect(Symbol symbol)

getExtendableConverter

public static String getExtendableConverter(Symbol symbol)

getExtendableDeref

public static String getExtendableDeref(Symbol symbol)

getExtendableImport

public static String getExtendableImport(Symbol symbol)

getExtendableNewRef

public static String getExtendableNewRef(Symbol symbol)

getExtendableType

public static String getExtendableType(Symbol symbol)

getExtendableWrapper

public static String getExtendableWrapper(Symbol symbol)

getImport

public static String getImport(String className)

getIncludeGuard

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

getInternalGuard

public static String getInternalGuard(Symbol symbol)

getPSkelFCastName

public static 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)

getPSkelFConnectName

public static 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 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)

getPySplicer

public static CodeSplicer getPySplicer(Symbol symbol,
                                       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

getPyStructType

public static String getPyStructType(Symbol symbol)

getRMIExternName

public static 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".

getSetEPVName

public static 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".

getSetSEPVName

public static 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".

getSkelMethod

public static 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

getStructBorrow

public static String getStructBorrow(Symbol symbol)

getStructCopy

public static String getStructCopy(Symbol symbol)

getStructDeserialize

public static String getStructDeserialize(Symbol symbol)

getStructDestroy

public static String getStructDestroy(Symbol symbol)

getStructInit

public static String getStructInit(Symbol symbol)

getStructSerialize

public static String getStructSerialize(Symbol symbol)

getStubMethod

public static 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

headerFilename

public static String headerFilename(Symbol symbol,
                                    String modifier)

implFilename

public static String implFilename(Symbol symbol)

maxNameLength

public static int maxNameLength(Collection items)

skelFilename

public static String skelFilename(Symbol symbol,
                                  String modifier)

sourceFilename

public static String sourceFilename(Symbol symbol,
                                    String modifier)