public class JavaEmitter extends Object implements GlueEmitter
Modifier and Type | Class and Description |
---|---|
static class |
JavaEmitter.EmissionStyle
Style of code emission.
|
static class |
JavaEmitter.MethodAccess
Access control for emitted Java methods.
|
Modifier and Type | Field and Description |
---|---|
protected JavaConfiguration |
cfg |
protected static Logger |
LOG |
Constructor and Description |
---|
JavaEmitter() |
Modifier and Type | Method and Description |
---|---|
static int |
addStrings2Buffer(StringBuilder buf,
String sep,
String first,
Collection<String> col) |
void |
beginDefines() |
void |
beginEmission(GlueEmitterControls controls)
Begin the emission of glue code.
|
void |
beginFunctions(TypeDictionary typedefDictionary,
TypeDictionary structDictionary,
Map<Type,Type> canonMap) |
void |
beginStructLayout()
Begins the process of computing field offsets and type sizes for
the structs to be emitted.
|
void |
beginStructs(TypeDictionary typedefDictionary,
TypeDictionary structDictionary,
Map<Type,Type> canonMap) |
protected JavaConfiguration |
createConfig()
Create the object that will read and store configuration information for
this JavaEmitter.
|
protected PrintWriter |
cWriter() |
protected void |
emitAllFileFooters()
Write out any footer information for the output files (closing brace of
class definition, etc).
|
protected void |
emitAllFileHeaders()
Write out any header information for the output files (class declaration
and opening brace, import statements, etc).
|
protected void |
emitCHeader(PrintWriter cWriter,
String className) |
protected void |
emitCustomJavaCode(PrintWriter writer,
String className)
Emit all the strings specified in the "CustomJavaCode" parameters of
the configuration file.
|
void |
emitDefine(ConstantDefinition def,
String optionalComment) |
Iterator<FunctionSymbol> |
emitFunctions(List<FunctionSymbol> originalCFunctions)
Emit glue code for the list of FunctionSymbols.
|
void |
emitStruct(CompoundType structType,
String alternateName)
Emit glue code for the given CompoundType.
|
void |
endDefines() |
void |
endEmission()
Finish the emission of glue code.
|
void |
endFunctions() |
void |
endStructLayout()
Finishes the struct layout process.
|
void |
endStructs() |
protected List<MethodBinding> |
expandMethodBinding(MethodBinding binding) |
protected List<? extends FunctionEmitter> |
generateMethodBindingEmitters(Set<MethodBinding> methodBindingSet,
FunctionSymbol sym)
Generate all appropriate Java bindings for the specified C function
symbols.
|
protected void |
generatePrivateEmitters(MethodBinding binding,
List<FunctionEmitter> allEmitters)
Generates the private emitters for this MethodBinding.
|
protected void |
generatePublicEmitters(MethodBinding binding,
List<FunctionEmitter> allEmitters,
boolean signatureOnly)
Generates the public emitters for this MethodBinding which will
produce either simply signatures (for the interface class, if
any) or function definitions with or without a body (depending on
whether or not the implementing function can go directly to
native code because it doesn't need any processing of the
outgoing arguments).
|
protected JavaConfiguration |
getConfig()
Get the configuration information for this JavaEmitter.
|
protected String |
getImplPackageName()
Returns the value that was specified by the configuration directive
"ImplPackage", or the default if none was specified.
|
protected String |
getJavaOutputDir()
Returns the value that was specified by the configuration directive
"JavaOutputDir", or the default if none was specified.
|
protected String |
getJavaPackageName()
Returns the value that was specified by the configuration directive
"Package", or the default if none was specified.
|
protected static int |
getJavaRadix(String name,
String value) |
protected static String |
getJavaType(String name,
Object oval) |
protected static String |
getJavaType(String name,
String value) |
protected static Object |
getJavaValue(String name,
String value) |
protected PrintWriter |
javaImplWriter() |
protected PrintWriter |
javaWriter() |
void |
layoutStruct(CompoundType t)
Lays out one struct which will be emitted later.
|
protected PrintWriter |
openFile(String filename,
String simpleClassName) |
protected void |
prepCEmitter(MethodBinding binding,
CMethodBindingEmitter cEmitter) |
void |
readConfigurationFile(String filename) |
protected JavaConfiguration cfg
protected static final Logger LOG
public void readConfigurationFile(String filename) throws Exception
readConfigurationFile
in interface GlueEmitter
Exception
public void beginEmission(GlueEmitterControls controls) throws IOException
GlueEmitter
beginEmission
in interface GlueEmitter
IOException
public void endEmission()
GlueEmitter
endEmission
in interface GlueEmitter
public void beginDefines() throws Exception
beginDefines
in interface GlueEmitter
Exception
public void emitDefine(ConstantDefinition def, String optionalComment) throws Exception
emitDefine
in interface GlueEmitter
optionalComment
- If optionalComment is non-null, the emitter can
emit that string as a comment providing extra information about the
define.Exception
public void endDefines() throws Exception
endDefines
in interface GlueEmitter
Exception
public void beginFunctions(TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map<Type,Type> canonMap) throws Exception
beginFunctions
in interface GlueEmitter
Exception
public Iterator<FunctionSymbol> emitFunctions(List<FunctionSymbol> originalCFunctions) throws Exception
GlueEmitter
emitFunctions
in interface GlueEmitter
Exception
protected JavaConfiguration createConfig()
protected JavaConfiguration getConfig()
protected void generatePublicEmitters(MethodBinding binding, List<FunctionEmitter> allEmitters, boolean signatureOnly)
protected void generatePrivateEmitters(MethodBinding binding, List<FunctionEmitter> allEmitters)
protected void prepCEmitter(MethodBinding binding, CMethodBindingEmitter cEmitter)
protected List<? extends FunctionEmitter> generateMethodBindingEmitters(Set<MethodBinding> methodBindingSet, FunctionSymbol sym) throws Exception
Exception
public void endFunctions() throws Exception
endFunctions
in interface GlueEmitter
Exception
public void beginStructLayout() throws Exception
GlueEmitter
beginStructLayout
in interface GlueEmitter
Exception
public void layoutStruct(CompoundType t) throws Exception
GlueEmitter
layoutStruct
in interface GlueEmitter
Exception
public void endStructLayout() throws Exception
GlueEmitter
endStructLayout
in interface GlueEmitter
Exception
public void beginStructs(TypeDictionary typedefDictionary, TypeDictionary structDictionary, Map<Type,Type> canonMap) throws Exception
beginStructs
in interface GlueEmitter
Exception
public void emitStruct(CompoundType structType, String alternateName) throws Exception
GlueEmitter
emitStruct
in interface GlueEmitter
Exception
public void endStructs() throws Exception
endStructs
in interface GlueEmitter
Exception
public static int addStrings2Buffer(StringBuilder buf, String sep, String first, Collection<String> col)
protected PrintWriter openFile(String filename, String simpleClassName) throws IOException
filename
- the class's full filename to open w/ write accesssimpleClassName
- the simple class name, i.e. w/o package namePrintWriter
instance to write the class source fileIOException
protected PrintWriter javaWriter()
protected PrintWriter javaImplWriter()
protected PrintWriter cWriter()
protected String getJavaOutputDir()
protected String getJavaPackageName()
protected String getImplPackageName()
protected void emitCustomJavaCode(PrintWriter writer, String className) throws Exception
Exception
protected void emitAllFileHeaders() throws IOException
IOException
protected void emitCHeader(PrintWriter cWriter, String className)
protected void emitAllFileFooters()
protected List<MethodBinding> expandMethodBinding(MethodBinding binding)