public class JavaConfiguration extends Object
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG_IGNORES |
static boolean |
DEBUG_RENAMES |
protected static Logger |
LOG |
static String |
NEWLINE |
Constructor and Description |
---|
JavaConfiguration() |
Modifier and Type | Method and Description |
---|---|
JavaEmitter.MethodAccess |
accessControl(String methodName)
Returns the access control for the emitted Java method.
|
protected void |
addClassJavadoc(String className,
String code) |
protected void |
addCustomJavaCode(String className,
String code) |
protected void |
addJavaPrologueOrEpilogue(String methodName,
String code,
boolean prologue) |
void |
addJavaSymbolRename(String origName,
String newName)
Programmatically adds a rename directive for the given symbol.
|
protected void |
addMethodJavadoc(String methodName,
String code) |
protected void |
addTypeInfo(TypeInfo info) |
void |
addUseNIODirectOnly(String fname) |
void |
addUseNIOOnly(String fname) |
boolean |
allStatic()
Returns true if the emission style is AllStatic.
|
String |
className()
Returns the class name parsed from the configuration file.
|
List<String> |
customCCode()
Returns, as a List of Strings, the custom C code to be emitted
along with the glue code for the main class.
|
List<String> |
customJavaCodeForClass(String className)
Returns a list of Strings containing user-implemented code for
the given Java type name (not fully-qualified, only the class
name); returns either null or an empty list if there is no
custom code for the class.
|
protected void |
dispatch(String cmd,
StringTokenizer tok,
File file,
String filename,
int lineNo) |
protected void |
doInclude(StringTokenizer tok,
File file,
String filename,
int lineNo) |
protected void |
doIncludeAs(StringTokenizer tok,
File file,
String filename,
int lineNo) |
void |
dumpIgnores() |
void |
dumpIgnoresOnce() |
void |
dumpRenames() |
void |
dumpRenamesOnce() |
JavaEmitter.EmissionStyle |
emissionStyle()
Returns the code emission style (constants in JavaEmitter) parsed from the configuration file.
|
boolean |
emitImpl()
Returns true if an implementing class should be emitted during glue code generation.
|
boolean |
emitInterface()
Returns true if an interface should be emitted during glue code generation.
|
List<String> |
extendedInterfaces(String interfaceName)
Returns a List of Strings indicating the interfaces the passed
interface should declare it extends.
|
String |
extendedParentClass(String className)
Returns a List of Strings indicating the interfaces the passed
class should declare it implements.
|
List<String> |
forcedStructs()
Returns, as a List of Strings, the structs for which glue code
emission should be forced.
|
String |
getJavaSymbolRename(String origName)
Returns a replacement name for this function or definition which
should be used as the Java name for the bound method or
constant.
|
Set<String> |
getRenamedJavaSymbols(String aliasedName)
Returns a set of replaced names to the given
aliasedName . |
String |
gluegenRuntimePackage()
Returns the package in which the generated glue code expects to
find its run-time helper classes (Buffers, Platform,
StructAccessor).
|
String |
implClassName()
Returns the implementation class name parsed from the configuration file.
|
List<String> |
implementedInterfaces(String className)
Returns a List of Strings indicating the interfaces the passed
class should declare it implements.
|
String |
implPackageName()
Returns the implementation package name parsed from the configuration file.
|
List<String> |
imports()
Returns the list of imports that should be emitted at the top of each .java file.
|
boolean |
isForceUsingNIOOnly4All() |
boolean |
isUnimplemented(String symbol)
Returns true if this function should be given a body which
throws a run-time exception with an "unimplemented" message
during glue code generation.
|
List<String> |
javadocForClass(String className)
Returns a list of Strings containing Javadoc documentation for
the given Java type name (not fully-qualified, only the class
name); returns either null or an empty list if there is no
Javadoc documentation for the class.
|
List<String> |
javadocForMethod(String methodName) |
List<String> |
javaEpilogueForMethod(MethodBinding binding,
boolean forImplementingMethodCall,
boolean eraseBufferAndArrayTypes)
Returns a list of Strings which should be emitted as an epilogue
to the body for the Java-side glue code for the given method.
|
String |
javaOutputDir()
Returns the Java code output directory parsed from the configuration file.
|
List<String> |
javaPrologueForMethod(MethodBinding binding,
boolean forImplementingMethodCall,
boolean eraseBufferAndArrayTypes)
Returns a list of Strings which should be emitted as a prologue
to the body for the Java-side glue code for the given method.
|
boolean |
manuallyImplement(String functionName)
Returns true if the glue code for the given function will be
manually implemented by the end user.
|
String |
nativeOutputDir()
Returns the native code output directory parsed from the configuration file.
|
boolean |
nativeOutputUsesJavaHierarchy()
Returns whether the native code directory structure mirrors the Java hierarchy.
|
String |
packageForStruct(String structName)
Returns the package into which to place the glue code for
accessing the specified struct.
|
String |
packageName()
Returns the package name parsed from the configuration file.
|
protected static TypeInfo |
parseTypeInfo(String cType,
JavaType javaType) |
void |
read(String filename)
Reads the configuration file.
|
protected void |
read(String filename,
String linePrefix)
Reads the specified file, treating each line as if it started with the
specified string.
|
protected void |
readAccessControl(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readArgumentIsString(StringTokenizer tok,
String filename,
int lineNo)
When const char* arguments in the C function prototypes are encountered,
the emitter will normally convert them to
byte[]
arguments. |
protected Boolean |
readBoolean(String cmd,
StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readClassJavadoc(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readCustomCCode(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readCustomJavaCode(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readExtend(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readExtendedIntfImplSymbols(StringTokenizer tok,
String filename,
int lineNo,
boolean forInterface,
boolean forImplementation,
boolean onlyList) |
protected void |
readIgnore(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readIgnoreField(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readIgnoreNot(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readImplements(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readJavaPrologueOrEpilogue(StringTokenizer tok,
String filename,
int lineNo,
boolean prologue) |
protected void |
readManuallyImplement(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readMethodJavadoc(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readOpaque(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readParentClass(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readRangeCheck(StringTokenizer tok,
String filename,
int lineNo,
boolean inBytes) |
protected void |
readRenameJavaSymbol(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readRenameJavaType(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readReturnedArrayLength(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readReturnsString(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readReturnValueCapacity(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readReturnValueLength(StringTokenizer tok,
String filename,
int lineNo) |
protected String |
readString(String cmd,
StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readStructPackage(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readTemporaryCVariableAssignment(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readTemporaryCVariableDeclaration(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readUnignore(StringTokenizer tok,
String filename,
int lineNo) |
protected void |
readUnimplemented(StringTokenizer tok,
String filename,
int lineNo) |
String |
renameJavaType(String javaTypeName)
Returns a replacement name for this type, which should be the
name of a Java wrapper class for a C struct, or the name
unchanged if no RenameJavaType directive was specified for this
type.
|
String |
returnedArrayLength(String functionName)
Provides a Java MessageFormat expression indicating the number
of elements in the returned array from the specified function
name.
|
boolean |
returnsString(String functionName)
Indicates whether the given function (which returns a
char* in C) should be translated as returning a
java.lang.String . |
String |
returnValueCapacity(String functionName)
Returns a MessageFormat string of the C expression calculating
the capacity of the java.nio.ByteBuffer being returned from a
native method, or null if no expression has been specified.
|
String |
returnValueLength(String functionName)
Returns a MessageFormat string of the C expression calculating
the length of the array being returned from a native method, or
null if no expression has been specified.
|
String |
runtimeExceptionType()
Returns the kind of exception to raise if run-time checks fail in the generated code.
|
void |
setOutputRootDir(String s) |
boolean |
shouldIgnoreInImpl(String symbol) |
boolean |
shouldIgnoreInInterface(String symbol)
Returns true if this #define, function, struct, or field within
a struct should be ignored during glue code generation.
|
protected static boolean |
startsWithDescriptor(String s) |
List<Integer> |
stringArguments(String functionName)
Returns a list of
Integer s which are the indices of const char*
arguments that should be converted to String s. |
protected Class<?> |
stringToPrimitiveType(String type) |
boolean |
structsOnly() |
boolean |
tagNativeBinding()
Returns whether the comment of a native method binding should include a @native tag.
|
List<String> |
temporaryCVariableAssignments(String functionName)
Returns a List of Strings of expressions containing assignments
to temporary C variables in the glue code for the specified
function.
|
List<String> |
temporaryCVariableDeclarations(String functionName)
Returns a List of Strings of expressions declaring temporary C
variables in the glue code for the specified function.
|
TypeInfo |
typeInfo(Type type,
TypeDictionary typedefDictionary)
If this type should be considered opaque, returns the TypeInfo
describing the replacement type.
|
String |
unsupportedExceptionType()
Returns the kind of exception to raise if run-time checks fail in the generated code.
|
boolean |
useNIODirectOnly(String functionName)
Returns true if the given function should only create a java.nio
variant, and no array variants, for
void* and other
C primitive pointers. |
boolean |
useNIOOnly(String functionName)
Returns true if the given function should only create a java.nio
variant, and no array variants, for
void* and other
C primitive pointers. |
public static final boolean DEBUG_IGNORES
public static final boolean DEBUG_RENAMES
protected static final Logger LOG
public static String NEWLINE
public final void read(String filename) throws IOException
filename
- path to file that should be readIOException
protected final void read(String filename, String linePrefix) throws IOException
filename
- path to file that should be readlinePrefix
- if not null, treat each line read as if it were
prefixed with the specified string.IOException
public void setOutputRootDir(String s)
public String packageName()
public String implPackageName()
public String className()
public String implClassName()
public boolean structsOnly()
public String javaOutputDir()
public String nativeOutputDir()
public boolean nativeOutputUsesJavaHierarchy()
public boolean tagNativeBinding()
public JavaEmitter.EmissionStyle emissionStyle()
public JavaEmitter.MethodAccess accessControl(String methodName)
public String gluegenRuntimePackage()
public String runtimeExceptionType()
public String unsupportedExceptionType()
public List<String> imports()
public TypeInfo typeInfo(Type type, TypeDictionary typedefDictionary)
public boolean returnsString(String functionName)
char*
in C) should be translated as returning a
java.lang.String
.public String returnedArrayLength(String functionName)
public List<Integer> stringArguments(String functionName)
Integer
s which are the indices of const char*
arguments that should be converted to String
s. Returns null if there are no
such hints for the given function name.public boolean isForceUsingNIOOnly4All()
public void addUseNIOOnly(String fname)
public boolean useNIOOnly(String functionName)
void*
and other
C primitive pointers. NIO only still allows usage of array backed not direct Buffers.public void addUseNIODirectOnly(String fname)
public boolean useNIODirectOnly(String functionName)
void*
and other
C primitive pointers. NIO direct only does only allow direct Buffers.
Implies useNIOOnly !public boolean manuallyImplement(String functionName)
public List<String> customJavaCodeForClass(String className)
public List<String> javadocForClass(String className)
public String packageForStruct(String structName)
packageName
).public List<String> customCCode()
public List<String> forcedStructs()
public String returnValueCapacity(String functionName)
public String returnValueLength(String functionName)
public List<String> temporaryCVariableDeclarations(String functionName)
public List<String> temporaryCVariableAssignments(String functionName)
public List<String> extendedInterfaces(String interfaceName)
public List<String> implementedInterfaces(String className)
public String extendedParentClass(String className)
public void dumpIgnoresOnce()
public void dumpIgnores()
public void dumpRenamesOnce()
public void dumpRenames()
public boolean shouldIgnoreInInterface(String symbol)
public boolean shouldIgnoreInImpl(String symbol)
public boolean isUnimplemented(String symbol)
public String renameJavaType(String javaTypeName)
public String getJavaSymbolRename(String origName)
public Set<String> getRenamedJavaSymbols(String aliasedName)
aliasedName
.public void addJavaSymbolRename(String origName, String newName)
public boolean allStatic()
public boolean emitInterface()
public boolean emitImpl()
public List<String> javaPrologueForMethod(MethodBinding binding, boolean forImplementingMethodCall, boolean eraseBufferAndArrayTypes)
public List<String> javaEpilogueForMethod(MethodBinding binding, boolean forImplementingMethodCall, boolean eraseBufferAndArrayTypes)
protected void dispatch(String cmd, StringTokenizer tok, File file, String filename, int lineNo) throws IOException
IOException
protected String readString(String cmd, StringTokenizer tok, String filename, int lineNo)
protected Boolean readBoolean(String cmd, StringTokenizer tok, String filename, int lineNo)
protected Class<?> stringToPrimitiveType(String type) throws ClassNotFoundException
ClassNotFoundException
protected void readAccessControl(StringTokenizer tok, String filename, int lineNo)
protected void readOpaque(StringTokenizer tok, String filename, int lineNo)
protected void readReturnsString(StringTokenizer tok, String filename, int lineNo)
protected void readReturnedArrayLength(StringTokenizer tok, String filename, int lineNo)
protected void readExtendedIntfImplSymbols(StringTokenizer tok, String filename, int lineNo, boolean forInterface, boolean forImplementation, boolean onlyList)
protected void readIgnore(StringTokenizer tok, String filename, int lineNo)
protected void readUnignore(StringTokenizer tok, String filename, int lineNo)
protected void readIgnoreNot(StringTokenizer tok, String filename, int lineNo)
protected void readUnimplemented(StringTokenizer tok, String filename, int lineNo)
protected void readIgnoreField(StringTokenizer tok, String filename, int lineNo)
protected void readManuallyImplement(StringTokenizer tok, String filename, int lineNo)
protected void readCustomJavaCode(StringTokenizer tok, String filename, int lineNo)
protected void readCustomCCode(StringTokenizer tok, String filename, int lineNo)
protected void readMethodJavadoc(StringTokenizer tok, String filename, int lineNo)
protected void readClassJavadoc(StringTokenizer tok, String filename, int lineNo)
protected void readArgumentIsString(StringTokenizer tok, String filename, int lineNo)
byte[]
arguments. This directive lets you specify which of those arguments
should be converted to String
arguments instead of
byte[]
. For example, given the C prototype:
void FuncName(const char* ugh, int bar, const char *foo, const char* goop);The emitter will normally emit:
public abstract void FuncName(byte[] ugh, int bar, byte[] foo, byte[] goop);However, if you supplied the following directive:
ArgumentIsString FuncName 0 2The emitter will instead emit:
public abstract void FuncName(String ugh, int bar, String foo, byte[] goop);
protected void readStructPackage(StringTokenizer tok, String filename, int lineNo)
protected void readReturnValueCapacity(StringTokenizer tok, String filename, int lineNo)
protected void readReturnValueLength(StringTokenizer tok, String filename, int lineNo)
protected void readTemporaryCVariableDeclaration(StringTokenizer tok, String filename, int lineNo)
protected void readTemporaryCVariableAssignment(StringTokenizer tok, String filename, int lineNo)
protected void doInclude(StringTokenizer tok, File file, String filename, int lineNo) throws IOException
IOException
protected void doIncludeAs(StringTokenizer tok, File file, String filename, int lineNo) throws IOException
IOException
protected void readExtend(StringTokenizer tok, String filename, int lineNo)
protected void readImplements(StringTokenizer tok, String filename, int lineNo)
protected void readParentClass(StringTokenizer tok, String filename, int lineNo)
protected void readRenameJavaType(StringTokenizer tok, String filename, int lineNo)
protected void readRenameJavaSymbol(StringTokenizer tok, String filename, int lineNo)
protected void readJavaPrologueOrEpilogue(StringTokenizer tok, String filename, int lineNo, boolean prologue)
protected void addJavaPrologueOrEpilogue(String methodName, String code, boolean prologue)
protected void readRangeCheck(StringTokenizer tok, String filename, int lineNo, boolean inBytes)
protected void addTypeInfo(TypeInfo info)
protected static boolean startsWithDescriptor(String s)