summaryrefslogtreecommitdiff
path: root/TAO/tests/CDR/tc.cpp
blob: 87d8dec4eb4cf82d597499b0c3b30bcb5aa6db45 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
// $Id$

// ============================================================================
//
// = LIBRARY
//    TAO/tests/CDR
//
// = FILENAME
//    tc.cpp
//
// = DESCRIPTION
//   Verify that the basic typecodes are able to interpret their CDR
//   buffers.
//
// = AUTHORS
//    Carlos O'Ryan
//
// ============================================================================

#include "tao/corba.h"
#include "tao/debug.h"

ACE_RCSID(CDR, tc, "$Id$")

// In this version of TAO typecodes are based on CDR, we have to
// verify that CDR offers the services needed for Typecode...

int
main (int argc, char *argv[])
{
  ACE_TRY_NEW_ENV
    {
      CORBA::ORB_var orb = CORBA::ORB_init (argc,
                                            argv,
                                            0
                                            ACE_ENV_ARG_PARAMETER);
      ACE_TRY_CHECK;

      static const CORBA::TypeCode_ptr tcs[]=
      {
        CORBA::_tc_null,
        CORBA::_tc_void,
        CORBA::_tc_short,
        CORBA::_tc_long,
        CORBA::_tc_ushort,
        CORBA::_tc_ulong,
        CORBA::_tc_float,
        CORBA::_tc_double,
        CORBA::_tc_boolean,
        CORBA::_tc_char,
        CORBA::_tc_octet,
        CORBA::_tc_any,
        CORBA::_tc_TypeCode,
        CORBA::_tc_Principal,
        CORBA::_tc_Object,
        // CORBA::_tc_struct,
        // CORBA::_tc_union,
        // CORBA::_tc_enum,
        CORBA::_tc_string,
        // CORBA::_tc_sequence,
        // CORBA::_tc_array,
        // CORBA::_tc_alias,
        // CORBA::_tc_except,
        CORBA::_tc_longlong,
        CORBA::_tc_ulonglong,
        CORBA::_tc_longdouble,
        CORBA::_tc_wchar,
        CORBA::_tc_wstring,
        CORBA::_tc_UNKNOWN,
        CORBA::_tc_BAD_PARAM,
        CORBA::_tc_NO_MEMORY,
        CORBA::_tc_IMP_LIMIT,
        CORBA::_tc_COMM_FAILURE,
        CORBA::_tc_INV_OBJREF,
        CORBA::_tc_OBJECT_NOT_EXIST,
        CORBA::_tc_NO_PERMISSION,
        CORBA::_tc_INTERNAL,
        CORBA::_tc_MARSHAL,
        CORBA::_tc_INITIALIZE,
        CORBA::_tc_NO_IMPLEMENT,
        CORBA::_tc_BAD_TYPECODE,
        CORBA::_tc_BAD_OPERATION,
        CORBA::_tc_NO_RESOURCES,
        CORBA::_tc_NO_RESPONSE,
        CORBA::_tc_PERSIST_STORE,
        CORBA::_tc_BAD_INV_ORDER,
        CORBA::_tc_TRANSIENT,
        CORBA::_tc_FREE_MEM,
        CORBA::_tc_INV_IDENT,
        CORBA::_tc_INV_FLAG,
        CORBA::_tc_INTF_REPOS,
        CORBA::_tc_BAD_CONTEXT,
        CORBA::_tc_OBJ_ADAPTER,
        CORBA::_tc_DATA_CONVERSION,
        CORBA::TypeCode::_tc_Bounds,
        CORBA::TypeCode::_tc_BadKind
      };

      static int n = sizeof (tcs) / sizeof (tcs[0]);

      for (const CORBA::TypeCode_ptr *i = tcs;
           i != tcs + n;
           ++i)
        {
          CORBA::TypeCode_ptr tc = *i;

          CORBA::TCKind k = tc->kind (ACE_ENV_SINGLE_ARG_PARAMETER);
          ACE_TRY_CHECK;

          switch (k)
            {
            case CORBA::tk_objref:
            case CORBA::tk_struct:
            case CORBA::tk_union:
            case CORBA::tk_enum:
            case CORBA::tk_alias:
            case CORBA::tk_except:
              {
                const char *id = tc->id (ACE_ENV_SINGLE_ARG_PARAMETER);
                ACE_TRY_CHECK;

                const char *name = tc->name (ACE_ENV_SINGLE_ARG_PARAMETER);
                ACE_TRY_CHECK;

                CORBA::ULong length = 0;
                // tc->length (TAO_TRY_ENV);
                // ACE_TRY_CHECK;

                if (TAO_debug_level > 0)
                  {
                    ACE_DEBUG ((LM_DEBUG,
                                "ID = '%s'\n"
                                "%{%{ NAME = %s%$"
                                " KIND = %d%$"
                                " LENGTH = %d"
                                "%}%}\n",
                                (id?id:"empty ID"),
                                (name?name:"empty name"),
                                k,
                                length));
                  }
                break;
              }
            default:
              if (TAO_debug_level > 0)
                {
                  ACE_DEBUG ((LM_DEBUG,
                              "basic type: %d\n",
                              k));
                }
              break;
            }
        }
    }
  ACE_CATCHANY
    {
      ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION, "TC");
      return 1;
    }
  ACE_ENDTRY;

  return 0;
}