1 /* This file is part of Shapes.
3 * Shapes is free software: you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation, either version 3 of the License, or
8 * Shapes is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with Shapes. If not, see <http://www.gnu.org/licenses/>.
16 * Copyright 2008, 2009 Henrik Tidefelt
21 #include "Shapes_Kernel_decls.h"
23 #include "simplepdfi.h"
24 #include "simplepdfo.h"
27 #include "shapesexceptions.h"
29 #include "multipage.h"
30 #include "continuations.h"
31 #include "charconverters.h"
32 #include "pagecontentstates.h"
33 #include "autoonoff.h"
34 #include "shapesscanner.h"
35 #include "texlabelmanager.h"
51 extern int shapesdebug
;
55 enum SplitMode
{ SPLIT_NO
, SPLIT_FLAT
, SPLIT_DIR
};
57 void argcAssertion( const char * optionSpecifier
, int argc
, int argcMin
);
58 bool strprefixcmp( char * str
, const char * prefix
, const char ** prefixDst
, char ** endp
);
59 bool strtobool( const char * str
, const char * containingString
, const char * trueLabel
= 0, const char * falseLabel
= 0 );
60 std::string
absoluteFilename( const char * filename
);
61 std::string
absoluteDirectory( const char * filename
);
62 void ensureTmpDirectoryExists( const std::string
& dirname
, bool allowCreate
);
63 RefCountPtr
< std::ifstream
> performIterativeStartup( const std::string
& texJobName
);
64 void abortProcedure( int exitCode
);
73 enum XpdfAction
{ XPDF_DEFAULT
, XPDF_RAISE
, XPDF_RELOAD
, XPDF_QUIT
, XPDF_NOSERVER
};
76 XpdfAction xpdfAction
;
77 std::string xpdfServer
;
79 const char * do_open_application
;
82 void preview( const std::string
& filename
, bool splitNoLaunch
= false ) const;
84 void xpdfHelper( const std::string
& filename
) const;
85 void openHelper( const std::string
& filename
) const;
88 class InteractionFormats
95 InteractionFormats( );
96 void setPrompt( const char * format
);
97 void setShow( const char * format
);
98 void setFile( const char * format
);
99 void setBye( const char * format
);
101 void formatPrompt( std::ostream
& os
, size_t inputNo
) const;
102 void formatShow( std::ostream
& os
, size_t inputNo
) const;
103 void formatFile( std::ostream
& os
, size_t inputNo
) const;
104 void formatBye( std::ostream
& os
, size_t inputNo
) const;
107 void writePrompt( std::ostream
& os
, const char * format
, size_t inputNo
) const;
108 void writeEscape( std::ostream
& os
, char c
) const;
115 class InteractionContinuation
;
117 class WarmDebugger
: public Kernel::State
120 Kernel::Environment
* env_
;
121 Kernel::PassedDyn dyn_
;
122 Kernel::ContRef resume_
;
123 Ast::Expression
* breakExpr_
;
124 WarmDebugger( Kernel::Environment
* env
, Kernel::PassedDyn dyn
, Kernel::ContRef resume
, Ast::Expression
* breakExpr
);
125 virtual ~WarmDebugger( );
126 virtual void tackOnImpl( Kernel::EvalState
* evalState
, const RefCountPtr
< const Lang::Value
> & piece
, const Ast::SourceLocation
& callLoc
);
127 virtual void peekImpl( Kernel::EvalState
* evalState
, const Ast::SourceLocation
& callLoc
);
128 virtual void freezeImpl( Kernel::EvalState
* evalState
, const Ast::SourceLocation
& callLoc
);
129 virtual void gcMark( Kernel::GCMarkedSet
& marked
);
136 extern Shapes::Interaction::PreviewOptions previewOptions
;
137 extern Shapes::Interaction::InteractionFormats interactionFormats
;
139 void addDefaultNeedPath( );
140 void addDefaultFontMetricsPath( );
141 void destroyGlobals( );
142 void escapeExtGlobChars( const std::string
& str
, std::ostream
& dst
);
144 void rmSplitFiles( const std::string
& outputName
, const char * sep
);
145 void mkSplitDir( const std::string
& outputName
);
146 void noSplitOpen( std::ofstream
* oFile
, const std::string
& outputName
);
147 std::string
splitOpen( std::ofstream
* oFile
, const std::string outputName
, const char * sep
, size_t physicalPageNo
);
148 void interactiveEvaluation( std::istream
& in
, std::ostream
& out
, const std::string
& outputName
, SplitMode splitMode
,
149 bool evalTrace
, bool evalBackTrace
, bool cleanupMemory
,
150 RefCountPtr
< std::ifstream
> & labelDBFile
, const std::string
& labelDBName
);
151 void nonInteractiveEvaluation( Shapes::Kernel::WarmCatalog::ShipoutList
& documents
, SplitMode splitMode
,
152 bool evalTrace
, bool evalBackTrace
, bool cleanupMemory
,
153 RefCountPtr
< std::ifstream
> & labelDBFile
, const std::string
& labelDBName
);
154 void initCore( RefCountPtr
< std::ifstream
> & labelDBFile
, const std::string
& labelDBName
);