mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2025-10-04 02:09:44 +02:00
GP-4376 Add setPackedOutput to Emit
This commit is contained in:
parent
d1dc48547e
commit
49af7f2db5
6 changed files with 36 additions and 10 deletions
|
@ -964,7 +964,9 @@ void IfcPrintCXml::execute(istream &s)
|
|||
|
||||
dcp->conf->print->setOutputStream(status->fileoptr);
|
||||
dcp->conf->print->setMarkup(true);
|
||||
dcp->conf->print->setPackedOutput(false);
|
||||
dcp->conf->print->docFunction(dcp->fd);
|
||||
*status->fileoptr << endl;
|
||||
dcp->conf->print->setMarkup(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -432,7 +432,7 @@ class XmlEncode : public Encoder {
|
|||
tag_stop = 2 ///< No tag is currently being written
|
||||
};
|
||||
static const char spaces[]; ///< Array of ' ' characters for emitting indents
|
||||
static const int4 MAX_SPACES;
|
||||
static const int4 MAX_SPACES; ///< Maximum number of leading spaces when indenting XML
|
||||
ostream &outStream; ///< The stream receiving the encoded data
|
||||
int4 tagStatus; ///< Stage of writing an element tag
|
||||
int4 depth; ///< Depth of open elements
|
||||
|
|
|
@ -329,6 +329,17 @@ void EmitMarkup::setOutputStream(ostream *t)
|
|||
encoder = new PackedEncode(*s);
|
||||
}
|
||||
|
||||
void EmitMarkup::setPackedOutput(bool val)
|
||||
|
||||
{
|
||||
if (encoder == (Encoder *)0) return;
|
||||
delete encoder;
|
||||
if (val)
|
||||
encoder = new PackedEncode(*s);
|
||||
else
|
||||
encoder = new XmlEncode(*s);
|
||||
}
|
||||
|
||||
int4 TokenSplit::countbase = 0;
|
||||
|
||||
/// Emit markup or content corresponding to \b this token on a low-level emitter.
|
||||
|
@ -1199,9 +1210,6 @@ void EmitPrettyPrint::flush(void)
|
|||
lowlevel->flush();
|
||||
}
|
||||
|
||||
/// This method toggles the low-level emitter between EmitMarkup and EmitNoMarkup depending
|
||||
/// on whether markup is desired.
|
||||
/// \param val is \b true if markup is desired
|
||||
void EmitPrettyPrint::setMarkup(bool val)
|
||||
|
||||
{
|
||||
|
|
|
@ -349,6 +349,19 @@ public:
|
|||
virtual void clear(void) { parenlevel = 0; indentlevel=0; pendPrint=(PendPrint *)0; }
|
||||
virtual void setOutputStream(ostream *t)=0; ///< Set the output stream for the emitter
|
||||
virtual ostream *getOutputStream(void) const=0; ///< Get the current output stream
|
||||
|
||||
/// \brief Toggle whether \b this emits mark-up or not
|
||||
|
||||
/// If the emitter supports it, \b true turns on mark-up, \b false turns it off. Otherwise there is no effect.
|
||||
/// \param val is \b true if markup is desired
|
||||
virtual void setMarkup(bool val) {}
|
||||
|
||||
/// \brief Toggle whether \b this emitter produces packed output
|
||||
///
|
||||
/// If the emitter supports it, \b true selects packed output and \b false selects unpacked XML output.
|
||||
/// Otherwise the method has no effect.
|
||||
/// \param val is \b true for packed or \b false for unpacked
|
||||
virtual void setPackedOutput(bool val) {}
|
||||
virtual void spaces(int4 num,int4 bump=0);
|
||||
|
||||
/// \brief Start a new indent level
|
||||
|
@ -522,6 +535,7 @@ public:
|
|||
virtual void closeParen(const string &paren,int4 id);
|
||||
virtual void setOutputStream(ostream *t);
|
||||
virtual ostream *getOutputStream(void) const { return s; }
|
||||
virtual void setPackedOutput(bool val);
|
||||
virtual bool emitsMarkup(void) const { return true; }
|
||||
};
|
||||
|
||||
|
@ -1085,6 +1099,7 @@ public:
|
|||
virtual void clear(void);
|
||||
virtual void setOutputStream(ostream *t) { lowlevel->setOutputStream(t); }
|
||||
virtual ostream *getOutputStream(void) const { return lowlevel->getOutputStream(); }
|
||||
virtual void setPackedOutput(bool val) { lowlevel->setPackedOutput(val); }
|
||||
virtual void spaces(int4 num,int4 bump=0);
|
||||
virtual int4 startIndent(void);
|
||||
virtual void stopIndent(int4 id);
|
||||
|
@ -1096,7 +1111,7 @@ public:
|
|||
virtual void setCommentFill(const string &fill) { commentfill = fill; }
|
||||
virtual bool emitsMarkup(void) const { return lowlevel->emitsMarkup(); }
|
||||
virtual void resetDefaults(void);
|
||||
void setMarkup(bool val); ///< Toggle whether the low-level emitter emits markup or not
|
||||
virtual void setMarkup(bool val);
|
||||
};
|
||||
|
||||
/// \brief Helper class for sending cancelable print commands to an ExitXml
|
||||
|
|
|
@ -648,12 +648,12 @@ void PrintLanguage::emitLineComment(int4 indent,const Comment *comm)
|
|||
comm->setEmitted(true);
|
||||
}
|
||||
|
||||
/// Tell the emitter whether to emit just the raw tokens or if additional mark-up should be provided.
|
||||
/// \param val is \b true for additional mark-up
|
||||
void PrintLanguage::setMarkup(bool val)
|
||||
/// Select packed or unpacked (XML) output, if the emitter supports it.
|
||||
/// \param val is \b true for packed or \b false for unpacked
|
||||
void PrintLanguage::setPackedOutput(bool val)
|
||||
|
||||
{
|
||||
((EmitPrettyPrint *)emit)->setMarkup(val);
|
||||
emit->setPackedOutput(val);
|
||||
}
|
||||
|
||||
/// Emitting formal code structuring can be turned off, causing all control-flow
|
||||
|
|
|
@ -454,7 +454,8 @@ public:
|
|||
uint4 getHeaderComment(void) const { return head_comment_type; } ///< Get the type of comments suitable for a function header
|
||||
void setHeaderComment(uint4 val) { head_comment_type = val; } ///< Set the type of comments suitable for a function header
|
||||
bool emitsMarkup(void) const { return emit->emitsMarkup(); } ///< Does the low-level emitter, emit markup
|
||||
void setMarkup(bool val); ///< Set whether the low-level emitter, emits markup
|
||||
void setMarkup(bool val) { emit->setMarkup(val); } ///< Turn on/off mark-up in emitted output
|
||||
void setPackedOutput(bool val); ///< Turn on/off packed output
|
||||
void setFlat(bool val); ///< Set whether nesting code structure should be emitted
|
||||
|
||||
virtual void initializeFromArchitecture(void)=0; ///< Initialize architecture specific aspects of printer
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue