PrimitiveGen.java revision 608:7e06bf1dcb09
1/*
2 * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.  Oracle designates this
8 * particular file as subject to the "Classpath" exception as provided
9 * by Oracle in the LICENSE file that accompanied this code.
10 *
11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
14 * version 2 for more details (a copy is included in the LICENSE file that
15 * accompanied this code).
16 *
17 * You should have received a copy of the GNU General Public License version
18 * 2 along with this work; if not, write to the Free Software Foundation,
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 *
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 * or visit www.oracle.com if you need additional information or have any
23 * questions.
24 */
25/*
26 * COMPONENT_NAME: idl.toJava
27 *
28 * ORIGINS: 27
29 *
30 * Licensed Materials - Property of IBM
31 * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
32 * RMI-IIOP v1.0
33 *
34 */
35
36package com.sun.tools.corba.se.idl.toJavaPortable;
37
38// NOTES:
39
40import java.io.PrintWriter;
41import java.util.Hashtable;
42
43import com.sun.tools.corba.se.idl.PrimitiveEntry;
44import com.sun.tools.corba.se.idl.SymtabEntry;
45
46/**
47 *
48 **/
49public class PrimitiveGen implements com.sun.tools.corba.se.idl.PrimitiveGen, JavaGenerator
50{
51  /**
52   * Public zero-argument constructor.
53   **/
54  public PrimitiveGen ()
55  {
56  } // ctor
57
58  /**
59   * This method should never be called; this class exists for
60   * the JavaGenerator interface.
61   **/
62  public void generate (Hashtable symbolTable, PrimitiveEntry e, PrintWriter stream)
63  {
64  } // generate
65
66  ///////////////
67  // From JavaGenerator
68
69  public int helperType (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream)
70  {
71    return type (index, indent, tcoffsets, name, entry, stream);
72  } // helperType
73
74  public int type (int index, String indent, TCOffsets tcoffsets, String name, SymtabEntry entry, PrintWriter stream) {
75    tcoffsets.set (entry);
76    String emit = "tk_null";
77    if (entry.name ().equals ("null"))
78      emit = "tk_null";
79    else if (entry.name ().equals ("void"))
80      emit = "tk_void";
81    else if (entry.name ().equals ("short"))
82      emit = "tk_short";
83    else if (entry.name ().equals ("long"))
84      emit = "tk_long";
85    else if (entry.name ().equals ("long long"))
86      emit = "tk_longlong";
87    else if (entry.name ().equals ("unsigned short"))
88      emit = "tk_ushort";
89    else if (entry.name ().equals ("unsigned long"))
90      emit = "tk_ulong";
91    else if (entry.name ().equals ("unsigned long long"))
92      emit = "tk_ulonglong";
93    else if (entry.name ().equals ("float"))
94      emit = "tk_float";
95    else if (entry.name ().equals ("double"))
96      emit = "tk_double";
97    else if (entry.name ().equals ("boolean"))
98      emit = "tk_boolean";
99    else if (entry.name ().equals ("char"))
100      emit = "tk_char";
101    else if (entry.name ().equals ("octet"))
102      emit = "tk_octet";
103    else if (entry.name ().equals ("any"))
104      emit = "tk_any";
105    else if (entry.name ().equals ("TypeCode"))
106      emit = "tk_TypeCode";
107    else if (entry.name ().equals ("wchar"))
108      emit = "tk_wchar";
109    else if (entry.name ().equals ("Principal")) // <d61961>
110      emit = "tk_Principal";
111    else if (entry.name ().equals ("wchar"))
112      emit = "tk_wchar";
113    stream.println (indent + name + " = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind." + emit + ");");
114    return index;
115  } // type
116
117  public void helperRead (String entryName, SymtabEntry entry, PrintWriter stream)
118  {
119  } // helperRead
120
121  public void helperWrite (SymtabEntry entry, PrintWriter stream)
122  {
123  } // helperWrite
124
125  public int read (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
126  {
127    stream.println (indent + name + " = " + "istream.read_" + Util.collapseName (entry.name ()) + " ();");
128    return index;
129  } // read
130
131  public int write (int index, String indent, String name, SymtabEntry entry, PrintWriter stream)
132  {
133    stream.println (indent + "ostream.write_" + Util.collapseName (entry.name ()) + " (" + name + ");");
134    return index;
135  } // write
136
137  // From JavaGenerator
138  ///////////////
139} // class PrimitiveGen
140