001: /*
002: * Copyright 1999 Sun Microsystems, Inc. All Rights Reserved.
003: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
004: *
005: * This code is free software; you can redistribute it and/or modify it
006: * under the terms of the GNU General Public License version 2 only, as
007: * published by the Free Software Foundation. Sun designates this
008: * particular file as subject to the "Classpath" exception as provided
009: * by Sun in the LICENSE file that accompanied this code.
010: *
011: * This code is distributed in the hope that it will be useful, but WITHOUT
012: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
013: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
014: * version 2 for more details (a copy is included in the LICENSE file that
015: * accompanied this code).
016: *
017: * You should have received a copy of the GNU General Public License version
018: * 2 along with this work; if not, write to the Free Software Foundation,
019: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
020: *
021: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
022: * CA 95054 USA or visit www.sun.com if you need additional information or
023: * have any questions.
024: */
025: /*
026: * COMPONENT_NAME: idl.toJava
027: *
028: * ORIGINS: 27
029: *
030: * Licensed Materials - Property of IBM
031: * 5639-D57 (C) COPYRIGHT International Business Machines Corp. 1997, 1999
032: * RMI-IIOP v1.0
033: *
034: * @(#)PrimitiveGen.java 1.20 07/05/05
035: */
036:
037: package com.sun.tools.corba.se.idl.toJavaPortable;
038:
039: // NOTES:
040:
041: import java.io.PrintWriter;
042: import java.util.Hashtable;
043:
044: import com.sun.tools.corba.se.idl.PrimitiveEntry;
045: import com.sun.tools.corba.se.idl.SymtabEntry;
046:
047: /**
048: *
049: **/
050: public class PrimitiveGen implements
051: com.sun.tools.corba.se.idl.PrimitiveGen, JavaGenerator {
052: /**
053: * Public zero-argument constructor.
054: **/
055: public PrimitiveGen() {
056: } // ctor
057:
058: /**
059: * This method should never be called; this class exists for
060: * the JavaGenerator interface.
061: **/
062: public void generate(Hashtable symbolTable, PrimitiveEntry e,
063: PrintWriter stream) {
064: } // generate
065:
066: ///////////////
067: // From JavaGenerator
068:
069: public int helperType(int index, String indent,
070: TCOffsets tcoffsets, String name, SymtabEntry entry,
071: PrintWriter stream) {
072: return type(index, indent, tcoffsets, name, entry, stream);
073: } // helperType
074:
075: public int type(int index, String indent, TCOffsets tcoffsets,
076: String name, SymtabEntry entry, PrintWriter stream) {
077: tcoffsets.set(entry);
078: String emit = "tk_null";
079: if (entry.name().equals("null"))
080: emit = "tk_null";
081: else if (entry.name().equals("void"))
082: emit = "tk_void";
083: else if (entry.name().equals("short"))
084: emit = "tk_short";
085: else if (entry.name().equals("long"))
086: emit = "tk_long";
087: else if (entry.name().equals("long long"))
088: emit = "tk_longlong";
089: else if (entry.name().equals("unsigned short"))
090: emit = "tk_ushort";
091: else if (entry.name().equals("unsigned long"))
092: emit = "tk_ulong";
093: else if (entry.name().equals("unsigned long long"))
094: emit = "tk_ulonglong";
095: else if (entry.name().equals("float"))
096: emit = "tk_float";
097: else if (entry.name().equals("double"))
098: emit = "tk_double";
099: else if (entry.name().equals("boolean"))
100: emit = "tk_boolean";
101: else if (entry.name().equals("char"))
102: emit = "tk_char";
103: else if (entry.name().equals("octet"))
104: emit = "tk_octet";
105: else if (entry.name().equals("any"))
106: emit = "tk_any";
107: else if (entry.name().equals("TypeCode"))
108: emit = "tk_TypeCode";
109: else if (entry.name().equals("wchar"))
110: emit = "tk_wchar";
111: else if (entry.name().equals("Principal")) // <d61961>
112: emit = "tk_Principal";
113: else if (entry.name().equals("wchar"))
114: emit = "tk_wchar";
115: stream
116: .println(indent
117: + name
118: + " = org.omg.CORBA.ORB.init ().get_primitive_tc (org.omg.CORBA.TCKind."
119: + emit + ");");
120: return index;
121: } // type
122:
123: public void helperRead(String entryName, SymtabEntry entry,
124: PrintWriter stream) {
125: } // helperRead
126:
127: public void helperWrite(SymtabEntry entry, PrintWriter stream) {
128: } // helperWrite
129:
130: public int read(int index, String indent, String name,
131: SymtabEntry entry, PrintWriter stream) {
132: stream.println(indent + name + " = " + "istream.read_"
133: + Util.collapseName(entry.name()) + " ();");
134: return index;
135: } // read
136:
137: public int write(int index, String indent, String name,
138: SymtabEntry entry, PrintWriter stream) {
139: stream.println(indent + "ostream.write_"
140: + Util.collapseName(entry.name()) + " (" + name + ");");
141: return index;
142: } // write
143:
144: // From JavaGenerator
145: ///////////////
146: } // class PrimitiveGen
|