1 20 21 package org.jacorb.idl.javamapping; 22 23 import org.jacorb.idl.*; 24 25 import java.io.*; 26 import java.util.Enumeration ; 27 28 35 36 public class JavaMappingGeneratingVisitor 37 implements IDLTreeVisitor 38 { 39 42 43 public JavaMappingGeneratingVisitor() 44 { 45 } 46 47 52 53 public void visitSpec( Spec spec ) 54 { 55 56 Enumeration e = spec.definitions.elements(); 57 while( e.hasMoreElements() ) 58 { 59 IdlSymbol s = (IdlSymbol)e.nextElement(); 60 s.accept( this ); 61 } 62 63 } 65 66 public void visitDefinitions( Definitions defs ) 67 { 68 Enumeration e = defs.getElements(); 69 while( e.hasMoreElements() ) 70 { 71 IdlSymbol s = (IdlSymbol)e.nextElement(); 72 s.accept( this ); 73 } 74 } 75 76 public void visitDefinition( Definition def ) 77 { 78 def.get_declaration().accept( this ); 79 } 80 81 public void visitDeclaration( Declaration declaration ) 82 { 83 System.out.println("Unimplemented behavior: visitDeclaration"); 86 } 87 88 public void visitModule( Module module ) 89 { 90 module.getDefinitions().accept( this ); 91 } 92 93 public void visitInterface( Interface interfce ) 94 { 95 if( interfce.body == null ) 98 return; 99 100 String [] superInts = interfce.get_ids(); 102 103 for( int i = 1; i < superInts.length; i++ ) 104 { 105 107 } 108 109 if( interfce.body != null ) 110 interfce.body.accept( this ); 111 112 } 113 114 public void visitInterfaceBody( InterfaceBody body ) 115 { 116 Operation[] ops = body.getMethods(); 117 118 119 for( int i = 0; i < ops.length; i++ ) 120 { 121 ops[ i ].accept( this ); 122 } 123 124 125 } 126 127 public void visitMethod( Method m ) 128 { 129 130 if( m.isGetter() ) 131 { 132 ; 133 } 134 else 135 { 136 ; 137 } 138 } 139 140 public void visitOpDecl( OpDecl op ) 141 { 142 144 145 for( Enumeration e = op.paramDecls.elements(); e.hasMoreElements(); ) 147 { 148 ParamDecl param = (ParamDecl)e.nextElement(); 149 param.accept( this ); 150 } 151 152 } 153 154 public void visitParamDecl( ParamDecl param ) 155 { 156 157 String direction = "in"; 158 159 if( param.paramAttribute == ParamDecl.MODE_OUT ) 160 direction = "out"; 161 else if( param.paramAttribute == ParamDecl.MODE_INOUT ) 162 direction = "inout"; 163 164 165 } 166 167 168 public void visitTypeDeclaration( TypeDeclaration typeDecl ) 169 { 170 } 171 172 public void visitConstrTypeSpec( ConstrTypeSpec typeDecl ) 173 { 174 } 176 177 public void visitStruct( StructType struct ) 178 { 179 int length = -1; 180 boolean isSeq = false; 181 boolean isArray = false; 182 183 MemberList members = struct.memberlist; 184 if( members != null ) 185 { 186 187 for( Enumeration e = members.elements(); e.hasMoreElements(); ) 188 { 189 Member m = (Member)e.nextElement(); 190 String memberType = typeSpecDesignator( m.type_spec ); 191 192 193 if( m.type_spec instanceof VectorType ) 194 { 195 memberType = 196 typeSpecDesignator( ((VectorType)m.type_spec).elementTypeSpec() ); 197 length = ((VectorType)m.type_spec).length(); 198 199 if( m.type_spec instanceof SequenceType ) 200 { 201 isSeq = true; 202 } 203 else if( m.type_spec instanceof ArrayTypeSpec ) 204 { 205 isArray = true; 206 } 207 else 208 { 209 throw new RuntimeException ("Internal Error: encountered vector that is neither array nor sequence!"); 210 } 211 } 212 } 213 } 214 } 215 216 219 220 public void visitEnum( EnumType enumType ) 221 { 222 223 for( Enumeration e = enumType.enumlist.elements(); e.hasMoreElements(); ) 224 { 225 } 227 228 } 229 230 public void visitUnion( UnionType union ) 231 { 232 233 } 234 235 public void visitSequence( SequenceType seq ) 236 { 237 } 239 240 public void visitNative( NativeType _native ) 241 { 242 243 } 244 245 public void visitTypeDef( TypeDef typedef ) 246 { 247 } 249 250 251 public void visitAlias( AliasTypeSpec alias ) 252 { 253 boolean isSeq = false; 254 boolean isArray = false; 255 int length = -1; 256 String aliasedType = typeSpecDesignator( alias.originalType() ); 257 258 259 260 if( alias.originalType() instanceof VectorType ) 261 { 262 aliasedType = 263 typeSpecDesignator( ((VectorType)alias.originalType()).elementTypeSpec()); 264 length = ((VectorType)alias.originalType()).length(); 265 266 if( alias.originalType() instanceof SequenceType ) 267 { 268 isSeq = true; 269 } 270 else if( alias.originalType() instanceof ArrayTypeSpec ) 271 { 272 isArray = true; 273 } 274 else 275 { 276 throw new RuntimeException ("Internal Error: encountered vector that is neither array nor sequence!"); 277 } 278 } 279 280 } 281 282 public void visitValue( Value value ) 283 { 284 285 } 286 287 291 292 private String typeSpecDesignator( TypeSpec ts ) 293 { 294 if( ts == null ) 295 new RuntimeException ().printStackTrace(); 296 297 if( ! ts.basic() ) 298 { 299 if( ts.typeSpec() instanceof AnyType ) 300 { 301 return "any"; 302 } 303 else 304 return ts.id(); 305 } 306 else 307 { 308 309 System.out.println("typeSpecDesignator for " + ts.typeSpec().getClass().getName()); 310 311 if( ts.typeSpec() instanceof ObjectTypeSpec ) 312 { 313 return ts.id(); 314 } 315 else if( ts.typeSpec() instanceof ConstrTypeSpec ) 316 { 317 return ((ConstrTypeSpec)ts.typeSpec()).id(); 318 } 319 else if( ts.typeSpec() instanceof ScopedName ) 320 { 321 return typeSpecDesignator ( ((ScopedName)ts.typeSpec()).resolvedTypeSpec() ); 322 } 323 else if( ts.typeSpec() instanceof StringType ) 324 { 325 return "string"; 326 } 327 328 else 329 { 330 return ts.toString(); 334 } 335 } 336 } 337 } 338 | Popular Tags |