KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jacorb > idl > NativeType


1 /*
2  * JacORB - a free Java ORB
3  *
4  * Copyright (C) 1997-2004 Gerald Brose.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Library General Public
8  * License as published by the Free Software Foundation; either
9  * version 2 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Library General Public License for more details.
15  *
16  * You should have received a copy of the GNU Library General Public
17  * License along with this library; if not, write to the Free
18  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19  */

20
21 package org.jacorb.idl;
22
23 /**
24  * @author Gerald Brose
25  * @version $Id: NativeType.java,v 1.12 2004/05/06 12:39:58 nicolas Exp $
26  */

27
28 import java.io.PrintWriter JavaDoc;
29
30 public class NativeType
31     extends TypeDeclaration
32 {
33     SimpleDeclarator declarator;
34
35     public NativeType( int num )
36     {
37         super( num );
38         pack_name = "";
39     }
40
41     public Object JavaDoc clone()
42     {
43         NativeType nt = new NativeType( new_num() );
44         nt.declarator = this.declarator;
45         nt.pack_name = this.pack_name;
46         return nt;
47     }
48
49     public void setEnclosingSymbol( IdlSymbol s )
50     {
51         if( enclosing_symbol != null && enclosing_symbol != s )
52             throw new RuntimeException JavaDoc( "Compiler Error: trying to reassign container for " + name );
53         enclosing_symbol = s;
54     }
55
56     public TypeDeclaration declaration()
57     {
58         return this;
59     }
60
61     public String JavaDoc typeName()
62     {
63         if( pack_name.length() > 0 )
64             return ScopedName.unPseudoName( pack_name + "." + name );
65         else
66             return ScopedName.unPseudoName( name );
67     }
68
69
70     public void setPackage( String JavaDoc s )
71     {
72         s = parser.pack_replace( s );
73         if( pack_name.length() > 0 )
74             pack_name = s + "." + pack_name;
75         else
76             pack_name = s;
77     }
78
79     public boolean basic()
80     {
81         return true;
82     }
83
84     public String JavaDoc toString()
85     {
86         return typeName();
87     }
88
89     public void set_included( boolean i )
90     {
91         included = i;
92     }
93
94     public void parse()
95
96     {
97         // don't parse the declarator as that would define its
98
// name which is to be defined as part of this type name
99

100         name = declarator.name();
101         is_pseudo = true;
102
103         ConstrTypeSpec ctspec = new ConstrTypeSpec( new_num() );
104         try
105         {
106             ctspec.c_type_spec = this;
107             NameTable.define( full_name(), "native" );
108             TypeMap.typedef( full_name(), ctspec );
109         }
110         catch( NameAlreadyDefined n )
111         {
112             parser.fatal_error( "Name already defined", token );
113         }
114     }
115
116     public String JavaDoc holderName()
117     {
118         return typeName() + "Holder";
119     }
120
121
122     public String JavaDoc printReadExpression( String JavaDoc Streamname )
123     {
124         return full_name() + "Helper.read(" + Streamname + ")";
125     }
126
127     public String JavaDoc printWriteStatement( String JavaDoc var_name, String JavaDoc Streamname )
128     {
129         return full_name() + "Helper.write(" + Streamname + "," + var_name + ");";
130     }
131
132     public void print( PrintWriter JavaDoc ps )
133     {
134     }
135
136     /**
137      */

138
139     public void accept( IDLTreeVisitor visitor )
140     {
141         visitor.visitNative( this );
142     }
143
144
145 }
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
Popular Tags