summaryrefslogtreecommitdiff
path: root/TAO/TAO_IDL/be/be_helper.cpp
diff options
context:
space:
mode:
authorWilliam R. Otte <wotte@dre.vanderbilt.edu>2009-07-14 12:13:54 +0000
committerWilliam R. Otte <wotte@dre.vanderbilt.edu>2009-07-14 12:13:54 +0000
commit00a6d3c7a315423e1e584b3c7a445be1f20ebf41 (patch)
tree06d38b591fa8a01631a2d64ccf9038f12ed5d48b /TAO/TAO_IDL/be/be_helper.cpp
parent618d7a1736bbc5a5f7a07c56cba9a26a5ed8548a (diff)
downloadATCD-00a6d3c7a315423e1e584b3c7a445be1f20ebf41.tar.gz
Tue Jul 14 11:12:09 UTC 2009 William R. Otte <wotte@dre.vanderbilt.edu>
Diffstat (limited to 'TAO/TAO_IDL/be/be_helper.cpp')
-rw-r--r--TAO/TAO_IDL/be/be_helper.cpp175
1 files changed, 175 insertions, 0 deletions
diff --git a/TAO/TAO_IDL/be/be_helper.cpp b/TAO/TAO_IDL/be/be_helper.cpp
index 2a8456aa4bd..7d767d1b369 100644
--- a/TAO/TAO_IDL/be/be_helper.cpp
+++ b/TAO/TAO_IDL/be/be_helper.cpp
@@ -22,8 +22,13 @@
#include "be_helper.h"
#include "be_codegen.h"
#include "be_extern.h"
+#include "ast_expression.h"
#include "idl_defines.h"
+#include "utl_identifier.h"
+#include "utl_idlist.h"
+#include "utl_string.h"
#include "ace/OS_NS_string.h"
+#include "ace/OS_NS_ctype.h"
#include "../../tao/Version.h"
ACE_RCSID (be,
@@ -432,3 +437,173 @@ TAO_OutStream::operator<< (AST_Expression *expr)
{
return this->print (expr);
}
+
+TAO_OutStream &
+TAO_OutStream::print (Identifier *id)
+{
+ ACE_OS::fprintf (this->fp_,
+ id->get_string ());
+
+ return *this;
+}
+
+TAO_OutStream &
+TAO_OutStream::print (UTL_IdList *idl)
+{
+ long first = true;
+ long second = false;
+ Identifier *id = 0;
+
+ for (UTL_IdListActiveIterator i (idl); !i.is_done (); i.next ())
+ {
+ if (!first)
+ {
+ *this << "::";
+ }
+ else if (second)
+ {
+ first = second = false;
+ }
+
+ // Print the identifier.
+ id = i.item ();
+ *this << id;
+
+ if (first)
+ {
+ if (ACE_OS::strcmp (id->get_string (), "") != 0)
+ {
+ // Does not start with a "".
+ first = false;
+ }
+ else
+ {
+ second = true;
+ }
+ }
+ }
+
+ return *this;
+}
+
+TAO_OutStream&
+TAO_OutStream::print (AST_Expression *expr)
+{
+ AST_Expression::AST_ExprValue *ev = expr->ev ();
+
+ if (ev)
+ {
+ switch (ev->et)
+ {
+ case AST_Expression::EV_short:
+ this->TAO_OutStream::print (ACE_INT32_FORMAT_SPECIFIER_ASCII, ev->u.sval);
+ break;
+ case AST_Expression::EV_ushort:
+ this->TAO_OutStream::print (ACE_INT32_FORMAT_SPECIFIER_ASCII "%c", ev->u.usval, 'U');
+ break;
+ case AST_Expression::EV_long:
+ this->TAO_OutStream::print (ACE_INT32_FORMAT_SPECIFIER_ASCII, ev->u.lval);
+ break;
+ case AST_Expression::EV_ulong:
+ this->TAO_OutStream::print (ACE_UINT32_FORMAT_SPECIFIER_ASCII "%c", ev->u.ulval, 'U');
+ break;
+ // The ACE_LACKS_LONGLONG_T guards have been removed around
+ // the next 2 cases since the macros now used should work
+ // whether native 64-bit integers are defined or not.
+ case AST_Expression::EV_longlong:
+ this->TAO_OutStream::print ("ACE_INT64_LITERAL (");
+ this->TAO_OutStream::print (ACE_INT64_FORMAT_SPECIFIER_ASCII,
+ ev->u.llval);
+ this->TAO_OutStream::print (")");
+ break;
+ case AST_Expression::EV_ulonglong:
+ this->TAO_OutStream::print ("ACE_UINT64_LITERAL (");
+ this->TAO_OutStream::print (ACE_UINT64_FORMAT_SPECIFIER_ASCII,
+ ev->u.ullval);
+ this->TAO_OutStream::print (")");
+ break;
+ case AST_Expression::EV_float:
+ this->TAO_OutStream::print ("%f%c", ev->u.fval, 'F');
+ break;
+ case AST_Expression::EV_double:
+ this->TAO_OutStream::print ("%24.16G", ev->u.dval);
+ break;
+ case AST_Expression::EV_longdouble:
+ break;
+ case AST_Expression::EV_char:
+ // isprint() sees \ and ' as printable characters
+ // so we have to test for them first.
+ if (ev->u.cval == '\\')
+ this->TAO_OutStream::print ("'\\\\'");
+ else if (ev->u.cval == '\'')
+ this->TAO_OutStream::print ("'\\''");
+
+ // This handles hex and octal escape sequences
+ // that would print out either as weird characters
+ // or as an unsigned number too large for a char.
+ else if ((unsigned char) ev->u.cval > ACE_CHAR_MAX)
+ this->TAO_OutStream::print ("%hd", ev->u.cval);
+ else if (ACE_OS::ace_isprint (ev->u.cval))
+ this->TAO_OutStream::print ("'%c'", ev->u.cval);
+ else if (ACE_OS::ace_iscntrl (ev->u.cval))
+ switch (ev->u.cval)
+ {
+ case '\n':
+ this->TAO_OutStream::print ("'\\n'");
+ break;
+ case '\t':
+ this->TAO_OutStream::print ("'\\t'");
+ break;
+ case '\r':
+ this->TAO_OutStream::print ("'\\r'");
+ break;
+ case '\v':
+ this->TAO_OutStream::print ("'\\v'");
+ break;
+ case '\f':
+ this->TAO_OutStream::print ("'\\f'");
+ break;
+ case '\b':
+ this->TAO_OutStream::print ("'\\b'");
+ break;
+ case '\a':
+ this->TAO_OutStream::print ("'\\a'");
+ break;
+ case '\?':
+ this->TAO_OutStream::print ("'?'");
+ break;
+ default:
+ this->TAO_OutStream::print ("'\\x%x'", ev->u.cval);
+ }
+ else
+ this->TAO_OutStream::print ("'\\x%x'", ev->u.cval);
+ break;
+ case AST_Expression::EV_wchar:
+ this->TAO_OutStream::print ("L'%lc'", ev->u.wcval);
+ break;
+ case AST_Expression::EV_octet:
+ this->TAO_OutStream::print ("%d", ev->u.oval);
+ break;
+ case AST_Expression::EV_bool:
+ this->TAO_OutStream::print ("%s", ev->u.bval ? "true" : "false");
+ break;
+ case AST_Expression::EV_string:
+ this->TAO_OutStream::print ("\"%s\"", ev->u.strval->get_string ());
+ break;
+ case AST_Expression::EV_wstring:
+ this->TAO_OutStream::print ("L\"%s\"", ev->u.wstrval);
+ break;
+ case AST_Expression::EV_enum:
+ this->print (expr->n ());
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ // XXXASG: need to add code here
+ }
+
+ return *this;
+}