Package com.jogamp.gluegen.jcpp
Class Preprocessor
- java.lang.Object
-
- com.jogamp.gluegen.jcpp.Preprocessor
-
- All Implemented Interfaces:
Closeable,AutoCloseable
public class Preprocessor extends Object implements Closeable
-
-
Constructor Summary
Constructors Constructor Description Preprocessor()Preprocessor(Source initial)Preprocessor(File file)Equivalent to 'new Preprocessor(newFileLexerSource(file))'
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFeature(Feature f)Adds a feature to the feature-set of this Preprocessor.voidaddFeatures(Feature... f)Adds features to the feature-set of this Preprocessor.voidaddFeatures(Collection<Feature> f)Adds features to the feature-set of this Preprocessor.voidaddInput(Source source)Adds input for the Preprocessor.voidaddInput(File file)Adds input for the Preprocessor.voidaddMacro(Macro m)Adds a Macro to this Preprocessor.voidaddMacro(String name)Defines the given name as a macro, with the value1.voidaddMacro(String name, String value)Defines the given name as a macro.voidaddWarning(Warning w)Adds a warning to the warning-set of this Preprocessor.voidaddWarnings(Collection<Warning> w)Adds warnings to the warning-set of this Preprocessor.voidclose()protected voiderror(int line, int column, String msg)Handles an error.protected voiderror(Token tok, String msg)Handles an error.booleangetFeature(Feature f)Returns true if the given feature is in the feature-set of this Preprocessor.Set<Feature>getFeatures()Returns the feature-set for this Preprocessor.VirtualFileSystemgetFileSystem()Returns the VirtualFileSystem used by this Preprocessor.List<String>getFrameworksPath()Returns the Objective-C frameworks path used by this Preprocessor.List<? extends VirtualFile>getIncludes()Returns the list ofVirtualFileswhich have been included by this Preprocessor.PreprocessorListenergetListener()Returns the PreprocessorListener which handles events for this Preprocessor.MacrogetMacro(String name)Returns the named macro.Map<String,Macro>getMacros()Returns the Map of Macros parsed during the run of this Preprocessor.List<Macro>getMacros(boolean expand)Returns a list ofMacros.List<String>getQuoteIncludePath()Returns the user include-path of this Preprocessor.SourcegetSource()Returns the top Source on the input stack.List<String>getSystemIncludePath()Returns the system include-path of this Preprocessor.booleangetWarning(Warning w)Returns true if the given warning is in the warning-set of this Preprocessor.Set<Warning>getWarnings()Returns the warning-set for this Preprocessor.protected booleaninclude(VirtualFile file)Attempts to include the given file.protected booleaninclude(Iterable<String> path, String name)Includes a file from an include path, by name.protected voidpop_source()protected Tokenpop_source(boolean linemarker)Pops a Source from the input stack.protected voidpragma(Token name, List<Token> value)protected voidpragma_once(Token name)protected voidpush_source(Source source, boolean autopop)Pushes a Source onto the input stack.voidsetFileSystem(VirtualFileSystem filesystem)Sets the VirtualFileSystem used by this Preprocessor.voidsetFrameworksPath(List<String> path)Sets the Objective-C frameworks path used by this Preprocessor.voidsetListener(PreprocessorListener listener)Sets the PreprocessorListener which handles events for this Preprocessor.voidsetQuoteIncludePath(List<String> path)Sets the user include path used by this Preprocessor.voidsetSystemIncludePath(List<String> path)Sets the system include path used by this Preprocessor.Tokentoken()Returns the next preprocessor token.StringtoString()protected voidwarning(int line, int column, String msg)Handles a warning.protected voidwarning(Token tok, String msg)Handles a warning.
-
-
-
Constructor Detail
-
Preprocessor
public Preprocessor()
-
Preprocessor
public Preprocessor(Source initial)
-
Preprocessor
public Preprocessor(File file) throws IOException
Equivalent to 'new Preprocessor(newFileLexerSource(file))'- Throws:
IOException
-
-
Method Detail
-
setFileSystem
public void setFileSystem(VirtualFileSystem filesystem)
Sets the VirtualFileSystem used by this Preprocessor.
-
getFileSystem
public VirtualFileSystem getFileSystem()
Returns the VirtualFileSystem used by this Preprocessor.
-
setListener
public void setListener(PreprocessorListener listener)
Sets the PreprocessorListener which handles events for this Preprocessor. The listener is notified of warnings, errors and source changes, amongst other things.
-
getListener
public PreprocessorListener getListener()
Returns the PreprocessorListener which handles events for this Preprocessor.
-
getFeatures
public Set<Feature> getFeatures()
Returns the feature-set for this Preprocessor. This set may be freely modified by user code.
-
addFeature
public void addFeature(Feature f)
Adds a feature to the feature-set of this Preprocessor.
-
addFeatures
public void addFeatures(Collection<Feature> f)
Adds features to the feature-set of this Preprocessor.
-
addFeatures
public void addFeatures(Feature... f)
Adds features to the feature-set of this Preprocessor.
-
getFeature
public boolean getFeature(Feature f)
Returns true if the given feature is in the feature-set of this Preprocessor.
-
getWarnings
public Set<Warning> getWarnings()
Returns the warning-set for this Preprocessor. This set may be freely modified by user code.
-
addWarning
public void addWarning(Warning w)
Adds a warning to the warning-set of this Preprocessor.
-
addWarnings
public void addWarnings(Collection<Warning> w)
Adds warnings to the warning-set of this Preprocessor.
-
getWarning
public boolean getWarning(Warning w)
Returns true if the given warning is in the warning-set of this Preprocessor.
-
addInput
public void addInput(Source source)
Adds input for the Preprocessor. Inputs are processed in the order in which they are added.
-
addInput
public void addInput(File file) throws IOException
Adds input for the Preprocessor.- Throws:
IOException- See Also:
addInput(Source)
-
error
protected void error(int line, int column, String msg) throws LexerExceptionHandles an error. If a PreprocessorListener is installed, it receives the error. Otherwise, an exception is thrown.- Throws:
LexerException
-
error
protected void error(Token tok, String msg) throws LexerException
Handles an error. If a PreprocessorListener is installed, it receives the error. Otherwise, an exception is thrown.- Throws:
LexerException- See Also:
error(int, int, String)
-
warning
protected void warning(int line, int column, String msg) throws LexerExceptionHandles a warning. If a PreprocessorListener is installed, it receives the warning. Otherwise, an exception is thrown.- Throws:
LexerException
-
warning
protected void warning(Token tok, String msg) throws LexerException
Handles a warning. If a PreprocessorListener is installed, it receives the warning. Otherwise, an exception is thrown.- Throws:
LexerException- See Also:
warning(int, int, String)
-
addMacro
public void addMacro(Macro m) throws LexerException, IOException
Adds a Macro to this Preprocessor. The givenMacroobject encapsulates both the name and the expansion.- Throws:
IOExceptionLexerException
-
addMacro
public void addMacro(String name, String value) throws LexerException
Defines the given name as a macro. The String value is lexed into a token stream, which is used as the macro expansion.- Throws:
LexerException
-
addMacro
public void addMacro(String name) throws LexerException
Defines the given name as a macro, with the value1. This is a convnience method, and is equivalent toaddMacro(name, "1").- Throws:
LexerException
-
setQuoteIncludePath
public void setQuoteIncludePath(List<String> path)
Sets the user include path used by this Preprocessor.
-
getQuoteIncludePath
public List<String> getQuoteIncludePath()
Returns the user include-path of this Preprocessor. This list may be freely modified by user code.
-
setSystemIncludePath
public void setSystemIncludePath(List<String> path)
Sets the system include path used by this Preprocessor.
-
getSystemIncludePath
public List<String> getSystemIncludePath()
Returns the system include-path of this Preprocessor. This list may be freely modified by user code.
-
setFrameworksPath
public void setFrameworksPath(List<String> path)
Sets the Objective-C frameworks path used by this Preprocessor.
-
getFrameworksPath
public List<String> getFrameworksPath()
Returns the Objective-C frameworks path used by this Preprocessor. This list may be freely modified by user code.
-
getMacros
public Map<String,Macro> getMacros()
Returns the Map of Macros parsed during the run of this Preprocessor.
-
getMacros
public List<Macro> getMacros(boolean expand) throws IOException, LexerException
- Parameters:
expand- iftrueand if macro is notfunction-like, i.e. a constant, the returned macro will be expanded.- Throws:
IOExceptionLexerException
-
getMacro
public Macro getMacro(String name)
Returns the named macro. While you can modify the returned object, unexpected things might happen if you do.
-
getIncludes
public List<? extends VirtualFile> getIncludes()
Returns the list ofVirtualFileswhich have been included by this Preprocessor. This does not include anySourceprovided to the constructor oraddInput(java.io.File)oraddInput(Source).
-
getSource
public Source getSource()
Returns the top Source on the input stack.- See Also:
Source,push_source(Source,boolean),pop_source()
-
push_source
protected void push_source(Source source, boolean autopop)
Pushes a Source onto the input stack.- See Also:
getSource(),pop_source()
-
pop_source
protected Token pop_source(boolean linemarker) throws IOException
Pops a Source from the input stack.- Throws:
IOException- See Also:
getSource(),push_source(Source,boolean)
-
pop_source
protected void pop_source() throws IOException- Throws:
IOException
-
include
protected boolean include(VirtualFile file) throws IOException, LexerException
Attempts to include the given file. User code may override this method to implement a virtual file system.- Throws:
IOExceptionLexerException
-
include
protected boolean include(Iterable<String> path, String name) throws IOException, LexerException
Includes a file from an include path, by name.- Throws:
IOExceptionLexerException
-
pragma_once
protected void pragma_once(Token name) throws IOException, LexerException
- Throws:
IOExceptionLexerException
-
pragma
protected void pragma(Token name, List<Token> value) throws IOException, LexerException
- Throws:
IOExceptionLexerException
-
token
public Token token() throws IOException, LexerException
Returns the next preprocessor token.- Throws:
LexerException- if a preprocessing error occurs.InternalException- if an unexpected error condition arises.IOException- See Also:
Token
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-