2 #include "be_identifier_helper.h"
5 #include "utl_identifier.h"
6 #include "utl_string.h"
7 #include "fe_private.h"
8 #include "global_extern.h"
10 ACE_CString
IdentifierHelper::tmp_retval_
;
13 IdentifierHelper::type_name (be_type
*t
, be_visitor
*visitor
)
15 AST_PredefinedType
*pdt
= 0;
17 switch (t
->node_type ())
19 case AST_Decl::NT_sequence
:
20 case AST_Decl::NT_wstring
:
21 case AST_Decl::NT_string
:
22 (void) t
->accept (visitor
);
24 case AST_Decl::NT_pre_defined
:
25 pdt
= dynamic_cast<AST_PredefinedType
*> (t
);
29 case AST_PredefinedType::PT_pseudo
:
30 return t
->full_name ();
31 case AST_PredefinedType::PT_object
:
33 case AST_PredefinedType::PT_any
:
35 case AST_PredefinedType::PT_long
:
37 case AST_PredefinedType::PT_ulong
:
38 return "unsigned long";
39 case AST_PredefinedType::PT_longlong
:
41 case AST_PredefinedType::PT_ulonglong
:
42 return "unsigned long long";
43 case AST_PredefinedType::PT_short
:
45 case AST_PredefinedType::PT_ushort
:
46 return "unsigned short";
47 case AST_PredefinedType::PT_float
:
49 case AST_PredefinedType::PT_double
:
51 case AST_PredefinedType::PT_longdouble
:
53 case AST_PredefinedType::PT_char
:
55 case AST_PredefinedType::PT_wchar
:
57 case AST_PredefinedType::PT_boolean
:
59 case AST_PredefinedType::PT_octet
:
61 case AST_PredefinedType::PT_void
:
71 IdentifierHelper::tmp_retval_
= "::";
72 IdentifierHelper::tmp_retval_
+=
73 IdentifierHelper::orig_sn (t
->name ()).c_str ();
74 return IdentifierHelper::tmp_retval_
.c_str ();
79 IdentifierHelper::original_local_name (Identifier
* local_name
)
82 const char *lname
= local_name
->get_string ();
86 // 2. it occurs at the beginning of the string and
87 // 3. the rest of the string is a C++ keyword
88 if (ACE_OS::strstr (lname
, "_cxx_") == lname
)
90 TAO_IDL_CPP_Keyword_Table cpp_key_tbl
;
93 static_cast<unsigned int> (ACE_OS::strlen (lname
+ 5));
95 const TAO_IDL_CPP_Keyword_Entry
*entry
=
96 cpp_key_tbl
.lookup (lname
+ 5, len
);
100 // Remove _cxx_ and assign to the Identifier variable.
102 Identifier (lname
+ 5),
109 id
= local_name
->copy ();
116 IdentifierHelper::orig_sn (UTL_IdList
* sn
, bool for_idl
)
123 for (UTL_IdListActiveIterator
i (sn
); !i
.is_done ();)
131 first
= second
= false;
136 ? IdentifierHelper::original_local_name (i
.item ())
137 : i
.item ()->copy ();
141 // Append the identifier.
144 ? IdentifierHelper::try_escape (id
).c_str ()
149 if (ACE_OS::strcmp (id
->get_string (), "") != 0)
151 // Does not start with a "".
169 IdentifierHelper::is_idl_keyword (Identifier
* local_name
)
171 // Convert the identifier string into a
172 // canonical (uppercase) form as a ACE_CString
173 char *tmp
= local_name
->get_string ();
174 ACE_CString
ext_id (tmp
);
175 UTL_String::get_canonical_rep (ext_id
);
177 return !idl_global
->idl_keywords ().find (ext_id
);
181 IdentifierHelper::try_escape (Identifier
* local_name
)
183 ACE_CString
s_local_name (local_name
->get_string ());
185 if (IdentifierHelper::is_idl_keyword (local_name
))
187 return "_" + s_local_name
;