001: /*
002: * JacORB - a free Java ORB
003: *
004: * Copyright (C) 1997-2004 Gerald Brose.
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Library General Public
008: * License as published by the Free Software Foundation; either
009: * version 2 of the License, or (at your option) any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Library General Public License for more details.
015: *
016: * You should have received a copy of the GNU Library General Public
017: * License along with this library; if not, write to the Free
018: * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
019: */
020:
021: package org.jacorb.ir;
022:
023: import org.omg.CORBA.TCKind;
024: import org.omg.CORBA.PrimitiveKind;
025: import org.omg.CORBA.INTF_REPOS;
026:
027: public final class PrimitiveDef extends IRObject implements
028: org.omg.CORBA.PrimitiveDefOperations {
029: protected org.omg.CORBA.PrimitiveKind kind;
030: protected org.omg.CORBA.TypeCode type;
031:
032: public PrimitiveDef(org.omg.CORBA.TypeCode tc) {
033: type = tc;
034: def_kind = org.omg.CORBA.DefinitionKind.dk_Primitive;
035: int _kind = tc.kind().value();
036: switch (_kind) {
037: case TCKind._tk_null: {
038: kind = PrimitiveKind.pk_null;
039: break;
040: }
041: case TCKind._tk_void: {
042: kind = PrimitiveKind.pk_void;
043: break;
044: }
045: case TCKind._tk_short: {
046: kind = PrimitiveKind.pk_short;
047: break;
048: }
049: case TCKind._tk_long: {
050: kind = PrimitiveKind.pk_long;
051: break;
052: }
053: case TCKind._tk_ushort: {
054: kind = PrimitiveKind.pk_ushort;
055: break;
056: }
057: case TCKind._tk_ulong: {
058: kind = PrimitiveKind.pk_ulong;
059: break;
060: }
061: case TCKind._tk_float: {
062: kind = PrimitiveKind.pk_float;
063: break;
064: }
065: case TCKind._tk_double: {
066: kind = PrimitiveKind.pk_double;
067: break;
068: }
069: case TCKind._tk_boolean: {
070: kind = PrimitiveKind.pk_boolean;
071: break;
072: }
073: case TCKind._tk_char: {
074: kind = PrimitiveKind.pk_char;
075: break;
076: }
077: case TCKind._tk_longlong: {
078: kind = PrimitiveKind.pk_longlong;
079: break;
080: }
081: case TCKind._tk_ulonglong: {
082: kind = PrimitiveKind.pk_ulonglong;
083: break;
084: }
085: case TCKind._tk_longdouble: {
086: kind = PrimitiveKind.pk_longdouble;
087: break;
088: }
089: case TCKind._tk_wchar: {
090: kind = PrimitiveKind.pk_wchar;
091: break;
092: }
093: case TCKind._tk_wstring: {
094: kind = PrimitiveKind.pk_wstring;
095: break;
096: }
097: case TCKind._tk_octet: {
098: kind = PrimitiveKind.pk_octet;
099: break;
100: }
101: case TCKind._tk_any: {
102: kind = PrimitiveKind.pk_any;
103: break;
104: }
105: case TCKind._tk_TypeCode: {
106: kind = PrimitiveKind.pk_TypeCode;
107: break;
108: }
109: case TCKind._tk_Principal: {
110: kind = PrimitiveKind.pk_Principal;
111: break;
112: }
113: case TCKind._tk_string: {
114: kind = PrimitiveKind.pk_string;
115: break;
116: }
117: case TCKind._tk_objref: {
118: kind = PrimitiveKind.pk_objref;
119: break;
120: }
121: default: {
122: throw new INTF_REPOS("Unrecognized kind: " + kind);
123: }
124: }
125: }
126:
127: public PrimitiveDef(int _kind) {
128: def_kind = org.omg.CORBA.DefinitionKind.dk_Primitive;
129: kind = PrimitiveKind.from_int(_kind);
130: switch (_kind) {
131: case org.omg.CORBA.PrimitiveKind._pk_null: {
132: type = org.omg.CORBA.ORB.init().get_primitive_tc(
133: org.omg.CORBA.TCKind.tk_null);
134: break;
135: }
136: case org.omg.CORBA.PrimitiveKind._pk_void: {
137: type = org.omg.CORBA.ORB.init().get_primitive_tc(
138: org.omg.CORBA.TCKind.tk_void);
139: break;
140: }
141: case org.omg.CORBA.PrimitiveKind._pk_short: {
142: type = org.omg.CORBA.ORB.init().get_primitive_tc(
143: org.omg.CORBA.TCKind.tk_short);
144: break;
145: }
146: case org.omg.CORBA.PrimitiveKind._pk_long: {
147: type = org.omg.CORBA.ORB.init().get_primitive_tc(
148: org.omg.CORBA.TCKind.tk_long);
149: break;
150: }
151: case org.omg.CORBA.PrimitiveKind._pk_float: {
152: type = org.omg.CORBA.ORB.init().get_primitive_tc(
153: org.omg.CORBA.TCKind.tk_float);
154: break;
155: }
156: case org.omg.CORBA.PrimitiveKind._pk_double: {
157: type = org.omg.CORBA.ORB.init().get_primitive_tc(
158: org.omg.CORBA.TCKind.tk_double);
159: break;
160: }
161: case org.omg.CORBA.PrimitiveKind._pk_boolean: {
162: type = org.omg.CORBA.ORB.init().get_primitive_tc(
163: org.omg.CORBA.TCKind.tk_boolean);
164: break;
165: }
166: case org.omg.CORBA.PrimitiveKind._pk_char: {
167: type = org.omg.CORBA.ORB.init().get_primitive_tc(
168: org.omg.CORBA.TCKind.tk_char);
169: break;
170: }
171: case org.omg.CORBA.PrimitiveKind._pk_octet: {
172: type = org.omg.CORBA.ORB.init().get_primitive_tc(
173: org.omg.CORBA.TCKind.tk_octet);
174: break;
175: }
176: case org.omg.CORBA.PrimitiveKind._pk_any: {
177: type = org.omg.CORBA.ORB.init().get_primitive_tc(
178: org.omg.CORBA.TCKind.tk_any);
179: break;
180: }
181: case org.omg.CORBA.PrimitiveKind._pk_TypeCode: {
182: type = org.omg.CORBA.ORB.init().get_primitive_tc(
183: org.omg.CORBA.TCKind.tk_TypeCode);
184: break;
185: }
186: case org.omg.CORBA.PrimitiveKind._pk_Principal: {
187: type = org.omg.CORBA.ORB.init().get_primitive_tc(
188: org.omg.CORBA.TCKind.tk_Principal);
189: break;
190: }
191: case org.omg.CORBA.PrimitiveKind._pk_string: {
192: type = org.omg.CORBA.ORB.init().get_primitive_tc(
193: org.omg.CORBA.TCKind.tk_string);
194: break;
195: }
196: case org.omg.CORBA.PrimitiveKind._pk_objref: {
197: type = org.omg.CORBA.ORB.init().get_primitive_tc(
198: org.omg.CORBA.TCKind.tk_objref);
199: break;
200: }
201: default: {
202: throw new INTF_REPOS("Unrecognized kind: " + kind);
203: }
204: }
205: }
206:
207: public org.omg.CORBA.TypeCode type() {
208: return type;
209: }
210:
211: public org.omg.CORBA.PrimitiveKind kind() {
212: return kind;
213: }
214:
215: public void destroy() {
216: }
217:
218: void define() {
219: // do nothing
220: }
221: }
|