diff options
Diffstat (limited to 'TAO/CIAO/CCF')
-rw-r--r-- | TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc | 24 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc | 17 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp | 277 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc | 17 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc | 25 | ||||
-rw-r--r-- | TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc | 25 |
6 files changed, 385 insertions, 0 deletions
diff --git a/TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc b/TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc new file mode 100644 index 00000000000..2282230c383 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CIDL/CIDL.mpc @@ -0,0 +1,24 @@ +//$Id$ + +project(CIDL) { + requires += cidl exceptions + sharedname = + staticname = CIDL + includes += $(CIAO_ROOT)/CCF + libout = .. + Source_Files { + . + ./SemanticGraph + ./Traversal + ./SemanticAction + ./SemanticAction/Impl + } + + specific(vc71) { + libs += boost_regex_debug boost_filesystem_debug + } + + verbatim(gnuace, top) { + include ../../Config.rules + } +} diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc new file mode 100644 index 00000000000..23e1e308ebd --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/CodeGenerationKit.mpc @@ -0,0 +1,17 @@ +//$Id$ + +project(CodeGenerationKit) { + requires += cidl exceptions + sharedname = + staticname = CodeGenerationKit + includes += $(CIAO_ROOT)/CCF + libout = .. + + specific(vc71) { + libs += boost_regex_debug boost_filesystem_debug + } + + verbatim(gnuace, top) { + include ../../Config.rules + } +} diff --git a/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp new file mode 100644 index 00000000000..24f9866eac4 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CodeGenerationKit/IndentationIDL.hpp @@ -0,0 +1,277 @@ +// file : CCF/CodeGenerationKit/IndentationIDL.hpp +// author : Boris Kolpackov <boris@dre.vanderbilt.edu> +// cvs-id : $Id$ + +#ifndef CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP +#define CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP + +#include <deque> + +#include "CCF/CodeGenerationKit/IndentationBuffer.hpp" + +namespace Indentation +{ + template <typename C> + class IDL : public Buffer<C> + { + public: + typedef + typename Buffer<C>::traits_type + traits_type; + + typedef + typename Buffer<C>::char_type + char_type; + + typedef + typename Buffer<C>::int_type + int_type; + + typedef + typename Buffer<C>::EndOfStream + EndOfStream; + + public: + IDL (Buffer<C>& out) + : out_ (out), + indentation_ (0), + spaces_ (2), + construct_ (OTHER) + { + } + + virtual + ~IDL () throw () {} + + public: + virtual int_type + put (char_type c) throw (ExH::System::Exception) + { + int_type result = traits_type::to_int_type (c); + + try + { + bool defaulting = false; + switch (c) + { + case '\n': + { + hold_.push_back (c); + break; + } + case '{': + { + ensure_new_line (); + output_indentation (); + result = write (c); + ensure_new_line (); + indentation_++; + break; + } + case '}': + { + if (indentation_ > 0) indentation_--; + + // Reduce multiple newlines to one. + while (hold_.size () > 1) + { + typename Hold::reverse_iterator i = hold_.rbegin (); + if (*i == '\n' && *(i + 1) == '\n') hold_.pop_back (); + else break; + } + + ensure_new_line (); + output_indentation (); + + hold_.push_back (c); + + // result = write (c); + + //ensure_new_line (); + + // Add double newline after '}'. + // + hold_.push_back ('\n'); + hold_.push_back ('\n'); + + + break; + } + case ';': + { + // Handling '};' case. + // + + bool brace (false); + + if (hold_.size () > 1 && hold_.back () == '\n') + { + bool pop_nl (false); + + for (typename Hold::reverse_iterator + i (hold_.rbegin ()), e (hold_.rend ()); i != e; ++i) + { + if (*i != '\n') + { + if (*i == '}') brace = pop_nl = true; + break; + } + } + + if (pop_nl) while (hold_.back () == '\n') hold_.pop_back (); + } + + output_indentation (); + result = write (c); + + if (brace) + { + hold_.push_back ('\n'); + hold_.push_back ('\n'); + } + + if (construct_ != STRING_LITERAL && construct_ != CHAR_LITERAL) + { + ensure_new_line (); + } + break; + } + case '\\': + { + hold_.push_back (c); + break; + } + case '\"': + { + if (hold_.empty () || hold_.back () != '\\') + { + // not escape sequence + if (construct_ == STRING_LITERAL) construct_ = OTHER; + else construct_ = STRING_LITERAL; + } + + defaulting = true; + break; + } + case '\'': + { + if (hold_.empty () || hold_.back () != '\\') + { + // not escape sequence + if (construct_ == CHAR_LITERAL) construct_ = OTHER; + else construct_ = CHAR_LITERAL; + } + + defaulting = true; + break; + } + default: + { + defaulting = true; + break; + } + } + + if (defaulting) + { + output_indentation (); + result = write (c); + } + } + catch (Full const&) + { + result = traits_type::eof (); + } + + return result; + } + + virtual void + unbuffer () throw (EndOfStream, ExH::System::Exception) + { + int_type result; + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + //@@ failed + if (result == traits_type::eof ()) + { + throw EndOfStream ("unable to flush buffer"); + } + + hold_.pop_front (); + } + } + + private: + class Full {}; + + void + ensure_new_line () + { + if (hold_.empty () || hold_.back () != '\n') + { + hold_.push_back ('\n'); + } + } + + + void + output_indentation () throw (Full) + { + if (!hold_.empty () && hold_.back () == '\n') + { + for (unsigned long i = 0; i < indentation_ * spaces_; i++) + { + write (' '); + } + } + } + + int_type + write (char_type c) throw (Full) + { + hold_.push_back (c); + + int_type result (traits_type::eof ()); + + while (!hold_.empty ()) + { + result = out_.put (hold_.front ()); + + if (result == traits_type::eof ()) throw Full (); + + hold_.pop_front (); + } + + return result; + } + + + private: + Buffer<C>& out_; + unsigned long indentation_; + unsigned long spaces_; + + bool suppress_nl_; + + enum Construct + { + OTHER, + STRING_LITERAL, + CHAR_LITERAL + }; + + Construct construct_; + + typedef + std::deque<int_type> + Hold; + + Hold hold_; + }; +} + +#endif // CCF_CODE_GENERATION_KIT_INDENTATION_IDL_HPP diff --git a/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc b/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc new file mode 100644 index 00000000000..037d97e2301 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/CompilerElements/CompilerElements.mpc @@ -0,0 +1,17 @@ +//$Id$ + +project(CompilerElements) { + requires += cidl exceptions + sharedname = + staticname = CompilerElements + includes += $(CIAO_ROOT)/CCF + libout = .. + + specific(vc71) { + libs += boost_regex_debug boost_filesystem_debug + } + + verbatim(gnuace, top) { + include ../../Config.rules + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc b/TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc new file mode 100644 index 00000000000..c56319af393 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL2/IDL2.mpc @@ -0,0 +1,25 @@ +//$Id$ + +project(IDL2) { + requires += cidl exceptions + sharedname = + staticname = IDL2 + includes += $(CIAO_ROOT)/CCF + libout = .. + Source_Files { + . + ./SemanticGraph + ./Traversal + ./SemanticAction + ./SemanticAction/Impl + + } + + specific(vc71) { + libs += boost_regex_debug boost_filesystem_debug + } + + verbatim(gnuace, top) { + include ../../Config.rules + } +} diff --git a/TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc b/TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc new file mode 100644 index 00000000000..d6cd8bfe316 --- /dev/null +++ b/TAO/CIAO/CCF/CCF/IDL3/IDL3.mpc @@ -0,0 +1,25 @@ +//$Id$ + +project(IDL3) { + requires += cidl exceptions + sharedname = + staticname = IDL3 + includes += $(CIAO_ROOT)/CCF + libout = .. + Source_Files { + . + ./SemanticGraph + ./Traversal + ./SemanticAction/Impl + + } + + specific(vc71) { + libs += boost_regex_debug boost_filesystem_debug + } + + verbatim(gnuace, top) { + include ../../Config.rules + } + +} |